Пример #1
0
        public static GuitarTune GetDefaultGuitarTune()
        {
            var notes = StaticUsefulStuff.GetNotes();
            int _1    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 329.63));
            int _2    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 246.94));
            int _3    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 196.00));
            int _4    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 146.83));
            int _5    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 110.00));
            int _6    = notes.FindIndex(a => StaticUsefulStuff.floatingPointEqual(a, 82.41));

            return(new GuitarTune(new [] { _1, _2, _3, _4, _5, _6 }));
        }
Пример #2
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();
            }
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         var guitarTune = new GuitarTune(textBox1.Text.Split(' ')
                                         .Select <string, int>(noteName => StaticUsefulStuff.ConvertToNoteIndex(noteName))
                                         .ToArray());
         var notes = StaticUsefulStuff.GetNotes();
         foreach (var desiredNoteIndex in guitarTune.StringTunes)
         {
             if (desiredNoteIndex < 0 || desiredNoteIndex >= notes.Count)
             {
                 throw new Exception();
             }
         }
         tablatureProcessor.ChangeTune(guitarTune);
     }
     catch
     {
         MessageBox.Show("Wrong syntax of desired tune, thus tune was not updated", "Error!");
     }
 }