I need a quick method to store all samples of a wav file in an array. I am currently working on this issue by playing music and storing values ββfrom the Example Provider, but this is not very elegant.
From the NAudio demo, I have an Audioplayer class using this method:
private ISampleProvider CreateInputStream(string fileName) { if (fileName.EndsWith(".wav")) { fileStream = OpenWavStream(fileName); } throw new InvalidOperationException("Unsupported extension"); } var inputStream = new SampleChannel(fileStream, true); var sampleStream = new NotifyingSampleProvider(inputStream); SampleRate = sampleStream.WaveFormat.SampleRate; sampleStream.Sample += (s, e) => { aggregator.Add(e.Left); };
I want to skip this move of getting sample values ββduring file playback, instead I want the values ββto be immediately, without waiting for the end of the file. Basically, like the wavread command in matlab.
source share