This project has moved. For the latest updates, please go here.
1
Vote

Mp3FileReader not in NAudio.Wave namespace

description

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?

comments

markheath wrote Jan 30 at 1: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 10: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 11:04 PM

try MediaFoundationReader instead. That should work

Yowza wrote Feb 2 at 9: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 2: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