NAudio
NAudio copied to clipboard
DllNotFoundException: Msacm32.dll when I use NAudio in Unity of Mac OS
Hi,
when I want to use NAudio to convert mp3 into wav, the error message jumped out on my Unity log window. The message is in the following lines.
DllNotFoundException: Msacm32.dll
NAudio.Wave.Compression.AcmStream.SuggestPcmFormat (NAudio.Wave.WaveFormat compressedFormat)
NAudio.Wave.AcmMp3FrameDecompressor..ctor (NAudio.Wave.WaveFormat sourceFormat)
NAudio.Wave.Mp3FileReader.CreateAcmFrameDecompressor (NAudio.Wave.WaveFormat mp3Format)
NAudio.Wave.Mp3FileReader..ctor (System.IO.Stream inputStream, NAudio.Wave.FrameDecompressorBuilder
I found someone had the same problem as mine.
https://answers.unity.com/questions/1224167/dllnotfoundexception-msacm32dll.html
hi, NAudio contains many wrappers for Windows APIs, and the ACM APIs which are found in msacm32.dll are part of that. It means you can't use them from non-Windows operating systems.
By default the Mp3FileReader tries to use ACM, but you can plug in a fully managed MP3 decoder if you prefer. See my article here
I can confirm that the linked work-around works (although the article is from 2017, which does not inspire me with confidence). As of writing, the sample code works with NLayer.NAudioSpport 1.13.0, and looks similar to the article code:
var fileName = @"C:\Users\markh\Desktop\input.mp3";
var builder = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
using (var reader = new Mp3FileReader(fileName, builder))
{
WaveFileWriter.CreateWaveFile(@"C:\Users\markh\Desktop\output.wav",reader);
}
From the comments above and no mention on the prerequisites page the library is not supported on Mac OSX?
Any news to be supported on Mac OSX?
Afraid I have no plans to support Mac OSX. I do not own a Mac computer. Someone else could always make an NAudio extension that implements interfaces like IWavePlayer and make the Mac equivalents of things like MediaFoundationReader.
I am also interested in using NAudio in a Mac computer. Can you detail exactly which interfaces should be implemented to get a full mp3/wav decoding and audio playback specific to a target OS? I need to know up to which point NAudio is generic and where we need to create concrete stuff for the target OS.
I imagine we need a replacement of WaveOutEvent (IWavePlayer) and Mp3FileReader (I tried with NLayer Mp3FrameDecompressor solution you proposed in 2019, but it doesn't work anymore with the Mp3FileReader current constructors).
Thank you very much for the great job you did for Audio support in .NET core :) your library is simply amazing
You can read WAV files no problem cross platform as they almost always contain raw PCM.
NLayer can still be used for MP3 file reading - just use Mp3FileReaderBase instead as in this example
For more comprehensive Mac support I'd implement the equivalent of MediaFoundationReader that uses whatever Mac APIs support reading files of various types
I did all the above, also changed to Mp3FileReaderBase but the error still persists. Any idea why? I'm using it in a .NET Core project. The error was "Unable to load shared library 'Msacm32.dll' or one of its dependencies".
Are you using WaveFormatConversionStream as well? If so, you don't need to use that