Unable to add reference to libmp3lame.dll
Closed this issue · 5 comments
I cannot add the ibmp3lame.dll reference in my project. Neither the 32bit or 64bit.
Visual studio says make sure the file is accessible, and that it is a valid assembly or COM component.
Any ideas?
it's not a managed DLL, so you don't add it as a reference. You just make sure it gets copied into the bin folder when you build. (Could do this by adding as a resource and setting it to Copy, or by using a post-build step)
Okay thanks. I've done that and copied the example code.
The MP3ToWave method runs without errors and saves an MP3 but it has zero bytes.
Is there anything else i could be missing?
From the original issue with libmp3lame.dll I assume you've downloaded the github main fork and are working from that. There is a nuget package - built from the code in the Experimental fork - that simplifies the process from the user perspective, but is a bit more complicated in places and harder to debug.
Normally the only way to get a zero-length MP3 file is if there is no audio data to encode.
The first thing I would do is check that you are actually getting data into the encoder by putting a breakpoint in the LameMP3FileWriter.Encode
method. This is where the audio data is forwarded to the LAME library for encoding, and is called whenever there are enough samples to process and when you close the stream. This will tell you whether data is getting through to the encoder and if anything is coming back.
One other thing that might cause this is if the wave format you are using is unsupported by the LAME library. I've put a stack of tests in to make sure that the basics are right - sample format and number of channels - but there are some sample rates that LAME refuses to work with. Sadly, I omitted a check for that in the call to InitParams
here and here in the code. Put a breakpoint in the LibMp3Lame.InitParams
method and check the return value from LAME to make sure it's not complaining about something.
If neither of these helps, or if you're using the nuget package and can't get at the code to add breakpoints, let me know where I can find your source wave file and I'll see if I can figure out what is going wrong with it.
Thanks for your help, after I uninstalled and re-installed lame, it started working.
Glad you have it working.