2
votes

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.

1
Which sort of raw data are you after? MP3 frames?Corey

1 Answers

3
votes

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.