public void CanCreateResamplerStream() { //using (WaveFileReader reader = new WaveFileReader("C:\\Users\\Mark\\Recording\\REAPER\\ideas-2008-05-17.wav")) using (WaveStream reader = new NullWaveStream(new WaveFormat(44100, 16, 1), 1000)) { using (ResamplerDmoStream resampler = new ResamplerDmoStream(reader, WaveFormat.CreateIeeeFloatWaveFormat(48000, 2))) { Assert.Greater(resampler.Length, reader.Length, "Length"); Assert.AreEqual(0, reader.Position, "Position"); Assert.AreEqual(0, resampler.Position, "Position"); } } }
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"); } } }
public void CanReadABlockFromDmoEffectWaveProvider() { //using (var reader = new Mp3FileReader("C:\\Users\\Wind\\Source\\Repos\\source.mp3")) WaveFormat inputFormat = new WaveFormat(44100, 16, 1); using (WaveStream reader = new NullWaveStream(inputFormat, inputFormat.AverageBytesPerSecond * 20)) { using (var effector = new DmoEffectWaveProvider <DmoFlanger, DmoFlanger.Params>(reader)) { // try to read 10 ms; int bytesToRead = effector.WaveFormat.AverageBytesPerSecond / 100; byte[] buffer = new byte[bytesToRead]; int count = effector.Read(buffer, 0, bytesToRead); Assert.That(count > 0, "Bytes Read"); } } }
public void CanCreateDmoEffectWaveProvider() { try { //using (var reader = new Mp3FileReader("C:\\Users\\Wind\\Source\\Repos\\source.mp3")) using (WaveStream reader = new NullWaveStream(new WaveFormat(44100, 16, 1), 1000)) { using (var effector = new DmoEffectWaveProvider <DmoFlanger, DmoFlanger.Params>(reader)) { Assert.IsNotNull((object)effector.EffectParams); } } } catch (NotSupportedException) { Debug.WriteLine("No support Dmo Effect type"); } }
private void CanCreateConversionStream(WaveFormat inputFormat, WaveFormat outputFormat) { var inputStream = new NullWaveStream(inputFormat, 10000); using (var stream = new WaveFormatConversionStream( outputFormat, inputStream)) { byte[] buffer = new byte[stream.WaveFormat.AverageBytesPerSecond]; int totalRead = 0; int bytesRead; do { bytesRead = stream.Read(buffer, 0, buffer.Length); totalRead += bytesRead; } while (bytesRead > 0); Debug.WriteLine(String.Format("Converted {0}", totalRead)); Assert.AreEqual(inputStream.Length, inputStream.Position); } }
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)); } } }