Ejemplo n.º 1
0
 public void CanReadABlockFromResamplerStream()
 {
     //using (WaveFileReader reader = new WaveFileReader("C:\\Users\\Mark\\Recording\\REAPER\\ideas-2008-05-17.wav"))
     WaveFormat inputFormat = new WaveFormat(44100, 16, 1);
     using (WaveStream reader = new NullWaveStream(inputFormat, inputFormat.AverageBytesPerSecond * 20))
     {
         using (ResamplerDmoStream resampler = new ResamplerDmoStream(reader, WaveFormat.CreateIeeeFloatWaveFormat(48000, 2)))
         {
             // try to read 10 ms;
             int bytesToRead = resampler.WaveFormat.AverageBytesPerSecond / 100;
             byte[] buffer = new byte[bytesToRead];
             int count = resampler.Read(buffer, 0, bytesToRead);
             Assert.That(count > 0, "Bytes Read");
         }
     }
 }
Ejemplo n.º 2
0
 private void ResampleAWholeStream(WaveFormat inputFormat, WaveFormat outputFormat)
 {
     using (WaveStream reader = new NullWaveStream(inputFormat, inputFormat.AverageBytesPerSecond * 20))
     {
         using (ResamplerDmoStream resampler = new ResamplerDmoStream(reader, outputFormat))
         {
             // try to read 10 ms;
             int bytesToRead = resampler.WaveFormat.AverageBytesPerSecond / 100;
             byte[] buffer = new byte[bytesToRead];
             int count;
             int total = 0;
             do
             {
                 count = resampler.Read(buffer, 0, bytesToRead);
                 total += count;
                 //Assert.AreEqual(count, bytesToRead, "Bytes Read");
             } while (count > 0);
             //Debug.WriteLine(String.Format("Converted input length {0} to {1}", reader.Length, total));
         }
     }
 }