Ejemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            richTextBox1.Font = new Font(FontFamily.GenericMonospace, richTextBox1.Font.Size);
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
            Notes = StaticUsefulStuff.GetNotes();
            tablatureProcessor                    = new TablatureProcessor();
            tablatureProcessor.OnTabLoaded       += TablatureProcessor_OnTabLoaded;
            tablatureProcessor.OnPositionUpdated += TablatureProcessorOnOnPositionUpdated;

            int deviceCount = WaveIn.DeviceCount;

            if (deviceCount == 0)
            {
                MessageBox.Show(
                    "No sound input devices found. Having at least one of them is essential, thus application is closing now",
                    "General error!");
                this.Close();
            }
            else
            {
                if (deviceCount != 1)
                {
                    this.Hide();
                    new SelectInputDeviceForm(this).ShowDialog();
                    this.Show();
                }
                else
                {
                    SelectedInputDeviceIndex = 0;
                }
                waveIn = new WaveIn {
                    DeviceNumber = SelectedInputDeviceIndex
                };
                sampleAggregator = new SampleAggregator(fftlength, timeScaleFactor);
                sampleAggregator.FftCalculated += sampleAggregator_FftCalculated;
                waveIn.DataAvailable           += waveIn_DataAvailable;
                binSize = sampleRate / fftlength;
                int channels   = 1; // mono
                var waveFormat = new WaveFormat(sampleRate, channels);
                waveIn.WaveFormat    = waveFormat;
                bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
                waveIn.StartRecording();
                //var waveOut = new DirectSoundOut(50);
                WaveOut waveOut = new WaveOut();
                waveOut.Init(bufferedWaveProvider);
                waveOut.Volume = 0;
                waveOut.Play();
            }
        }
Ejemplo n.º 2
0
        public ChangeSettingsForm(TablatureProcessor tablatureProcessor)
        {
            InitializeComponent();
            this.MaximumSize        = this.Size;
            this.MinimumSize        = this.Size;
            this.tablatureProcessor = tablatureProcessor;

            UpdateText();

            int    maximumPositionSkip;
            double missingNotesFraction;
            int    maximumWrongNotes;
            int    minimumDelay;

            (maximumPositionSkip, missingNotesFraction, maximumWrongNotes, minimumDelay) = tablatureProcessor.GetOtherSettings();
            this.numericUpDown1.Value = maximumPositionSkip;
            this.numericUpDown2.Value = (decimal)missingNotesFraction;
            this.numericUpDown3.Value = maximumWrongNotes;
            this.numericUpDown4.Value = minimumDelay;
        }