7

I've got a project that uses NAudio to convert from mp3 to wav. (using the WaveFormatConversionStream.CreatePcmStream() method)

It worked fine on my development machine but now I'm trying it on a fresh new server and its throwing this error:

NAudio.MmException: NoDriver calling acmFormatSuggest
at NAudio.MmException.Try(MmResult result, String function)
at NAudio.Wave.Compression.AcmStream.SuggestPcmFormat(WaveFormat compressedFormat)
at NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(WaveStream sourceStream)

I assume there is some dependency that NAudio needs here that isn't on the new server. What is it and where should I install it from?

Server is a freshly-hatched Amazon EC2 Windows 2008 32-bit instance with 'web server' and 'app server' roles installed.

codeulike
  • 22,514
  • 29
  • 120
  • 167

3 Answers3

7

Running Windows 2008 R2, using Naudio to detect the length of Wav and Mp3 files, i ran into the same problem.

I solved this by following this: https://technet.microsoft.com/en-us/library/cc772567.aspx

Essentially, install the "Desktop Experience" feature.

The above will require a restart of the server.

Once the above was installed, i needed to enable nothing further, the problem was resolved.

Wendell Urth
  • 86
  • 1
  • 5
  • Thinking back, that might be how I eventually solved this too. – codeulike Feb 26 '16 at 11:07
  • This solution is great when you own the server, when you don't (as is the case for Azure Websites), you can't install this. Try using NLayer https://nlayer.codeplex.com/ – Shiroy Sep 08 '16 at 19:23
  • Works on Windows Server 2012 as well. The "Desktop Experience" feature is a litle bit more hidden there, use this to find it: https://yellowduckguy.wordpress.com/2012/12/21/windows-server-2012-how-to-add-desktop-experience-feature/ – Jan Šotola Aug 04 '17 at 09:22
2

WaveFormatConversionStream makes use of the ACM codecs installed on your machine. It starts by asking if there is any ACM codec installed that can convert from the source to the target format. It would seem that you are missing an MP3 codec on the target machine.

NAudio does offer a different way to decode MP3s, using the DMO MP3 Decoder (DirectX Media Object), which may also be on your target machine. To use this you need to get the latest NAudio source from Codeplex and in the MP3FileReader (which now does the conversion to PCM for you), you take the following line:

decompressor = new AcmMp3FrameDecompressor(this.Mp3WaveFormat); 

and replace it with

decompressor = new DmoMp3FrameDecompressor(this.Mp3WaveFormat); 
Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • This didn't work for me. That code apparently tries to load a DMO that is ALSO not installed on Windows 2008 Server. Allegedly this DMO is in the Windows SDK, but I installed that and it's still not there. – Lavamantis Jun 19 '12 at 05:07
  • I am also still not get the .wav file. I am just convert my mp3 to wav file. – Illaya Mar 31 '14 at 17:34
  • 1
    you need to install the desktop experience component of Windows Server. – Mark Heath Apr 01 '14 at 08:51
  • You can't install the Desktop Experience Pack on Windows Azure Websites. I tried NLayer as well, but it converts the WAV file to a 32bit float file, which makes it harder to read. – Shiroy Sep 08 '16 at 17:35
  • @Shiroy You can go back to 16 bit with `WaveFloatTo16Provider` – Mark Heath Sep 08 '16 at 17:55
  • Can you please help with the code? See my related question at: http://stackoverflow.com/questions/39398668/nlayer-reading-16bit-pcm-from-32bit-float – Shiroy Sep 08 '16 at 19:20
0

Thanks to @Shiroy, I found the amazing NLayer (https://github.com/naudio/NLayer) library By @MarkHeath. If you install it with NLayer.NAudioSupport, you can compress with one additional line of code (and no installed codecs required).

ulu
  • 5,872
  • 4
  • 42
  • 51