3

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Leonid
  • 1,071
  • 2
  • 15
  • 27

3 Answers3

2

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.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
0

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

acheo
  • 3,106
  • 2
  • 32
  • 57
  • The reason I mention the key paths is because there are various sites showing how to install ACM codec using reg files but those reg files tend to be aimed at x86 – acheo Apr 07 '12 at 05:32
-1

This thread contains some solutions which might help you: Play audio from a stream using C#

Community
  • 1
  • 1
  • You sure the mp3 is being read right? Have you tried to dump the contents of the mp3Reader? Is there a way to check for the ID3 tag to see if it is being read correctly as an mp3? – Please treat your mods well. Mar 25 '11 at 14:07
  • It's not my code. It's code from NAudio examples, it have to be right but... Maybe **Hans Passant** is right, and I should write custom buffer stream... Thanks! – Leonid Mar 25 '11 at 14:25