Beispiel #1
0
 public void Init()
 {
     try
     {
         ISampleProvider[] sources = new ISampleProvider[Syllables.Length];
         for (int i = 0; i < Syllables.Length; i++)
         {
             if (File.Exists(Syllables[i].TWavPath))
             {
                 var wavSource = new AudioFileReader(Syllables[i].TWavPath);
                 sources[i] = wavSource.Take(new TimeSpan(0, 0, 0, 0, (int)(wavSource.TotalTime.Milliseconds * 0.9))).Skip(new TimeSpan(0, 0, 0, 0, (int)(wavSource.TotalTime.Milliseconds * 0.15)));
             }
             else
             {
                 sources[i] = null;
                 return;
             }
         }
         Wav = new ConcatenatingSampleProvider(sources);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #2
0
        private void TestFile()
        {
            using (var audioFile = new AudioFileReader("C:/Users/alber/Documents/Synth/wav/sine_440.wav"))
            {
                var stream = audioFile.Take(new TimeSpan(0, 0, 3));

                var     bufferLength = 2000;
                float[] buffer       = new float[bufferLength];
                Console.WriteLine(buffer[100]);
                stream.Read(buffer, 0, bufferLength);
                rfa.NewSamples(buffer);

                ResultFrequency.Text = "" + rfa.Fundamental() * 44100;
            }
        }