I have an mp3 file into one large array of audio samples. I want the audio samples to be floats.
NAudio.Wave.WaveStream pcm=NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(OFD.FileName));
so far I get the pcm stream and can play that back fine but I don't know how to read the raw data out of the stream.
Use AudioFileReader
. This implements ISampleProvider
so the Read
method allows you to read directly into a float array of samples.
Alternatively use the ToSampleProvider
method after your Mp3FileReader
. You don't need to use WaveFormatConversionStream
, since Mp3FileReader
(and AudioFileReader
) already decompress the MP3 frames.