Mp3FileReader not in NAudio.Wave namespace


I'm trying to process an mp3 stream (from the microphone) in memory, without disk I/O, in a Windows Store app. I installed the NuGet package NAudio v1.8.0 but the Mp3FileReader class is not in the namespace NAudio.Wave. Should I be using some other function in this environment?


markheath wrote Jan 30 at 12:57 PM

Mp3FileReader is not available in Windows Store apps as it calls into APIs that are not permitted in that context.

Yowza wrote Jan 30 at 9:35 PM

Thanks, Mark.

I have encountered the same problem with speech recognition. Microsoft's quest to make every platform look the same to the user has had the opposite effect on the developer.

I guess I'll have to roll my own if I want it that badly.

markheath wrote Jan 30 at 10:04 PM

try MediaFoundationReader instead. That should work

Yowza wrote Feb 2 at 8:11 PM

Still stuck. There seems to be no overload of MediaFoundationReader that will take as stream as an argument. (I can't afford the latency of writing to a file and then reading back again.)

Here is what I tried:
encodingProfile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.Low);  
audioStream = new InMemoryRandomAccessStream();
await mediaCapture.StartRecordToStreamAsync(encodingProfile, audioStream);
using (var audioStreamTest = audioStream.CloneStream())
    using (StreamReader reader = new StreamReader(audioStreamTest.AsStreamForRead()))
            string textStream = await reader.ReadToEndAsync();
            MediaFoundationReader mfreader = new MediaFoundationReader(textStream);
It fails, of course, because MediaFoundationReader wants to open a file with path = textStream.

Would I be able to overload MediaFoundationReader to take a text stream instead of a file?

markheath wrote Feb 3 at 1:21 PM

Someone has recently contributed a StreamMediaFoundationReader class which you can try out if you get latest coed. Haven't tried it out myself yet, so can't say how reliable it is