I get the exception "NoDriver calling acmFormatSuggest" when executing this function:
private static WaveChannel32 OpenMp3Stream(string fileName)
{
WaveChannel32 inputStream;
WaveStream mp3Reader = new Mp3FileReader(fileName);
WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(mp3Reader);
WaveStream blockAlignedStream = new BlockAlignReductionStream(pcmStream);
inputStream = new WaveChannel32(blockAlignedStream);
return inputStream;
}
On this line:
WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(mp3Reader);
I've tried to change the platform of NAudio.dll (from x86 to x64 and vice-versa), but that didn't help.
Is there another way to play an MP3 file from MemoryStream or how do I fix this error?
This code relies on an ACM codec that can decode MP3 being present on your system. What OS are you using? Also ACM codecs are typically 32 bit, so running in x64 would mean there are no codecs available.
NAudio does also offer the possibility of using the DMO MP3 decoder as an alternative, which isn't available in XP, but seems to be present on most newer versions of Windows.
Finally, I would recommend using the very latest NAudio source code, in which the MP3FileReader has the PCM conversion built in, meaning you can just call Read and get PCM out.
Compile the NAudioDemo for x86 and see the list of ACM codecs available. As far as I know NAudio uses the Fraunhofer professional ACM codec if you can't see it in the list, i tried installing the LAME ACM before but that didn't help, it needed the fraunhofer codec.
also something else to watch out for is that on x64 versions of windows the ACM registry keys are in
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]
rather than
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]
you can use Mark's excellent NAudioDemo tool to check the ACMs are correctly registered on your system
This thread contains some solutions which might help you: Play audio from a stream using C#