LAME executable on Mac

Hi all,

Our app is using LAMEEncoderAudioFormat to export projects to an MP3 file. I’ve got this working on Windows, but I won’t work on Mac - it just produces a zero byte file.

I’m thinking the problem is with the LAME executable I’m using on Mac - I can’t seem to find a good one. I’ve tried ones from RareWare (recommended binaries by LAME), this site recommended by Audacity, and even compiling my own using a GitHub project intended for iOS. All of them output an empty file. By the way I’m using a MacBook 2019 (not a M1 one!) and running macOS 11.1.

Here’s the LAMEEncoderAudioFormat constructor we’re using:
std::unique_ptr<LAMEEncoderAudioFormat> mp3AudioFormat = std::make_unique<LAMEEncoderAudioFormat>(File("<executable location>"));

And the code used to export the project (uses Tracktion Engine):

tracktion_engine::Renderer::Parameters params (edit);
params.edit = &edit;
params.destFile = file;
params.audioFormat = mp3AudioFormat.get();
params.time = { edit.getFirstClipTime(), edit.getLength() };
int numTracks = getAllTracks(edit).size();
BigInteger tracksToDo;
tracksToDo.setRange(0, numTracks, 1);
params.tracksToDo = tracksToDo;
params.usePlugins = false;
params.bitDepth = 24;
params.sampleRateForAudio = engine.getDeviceManager().getSampleRate();
params.blockSizeForAudio = engine.getDeviceManager().getBlockSize();
params.addAntiDenormalisationNoise = te::EditPlaybackContext::shouldAddAntiDenormalisationNoise(engine);
te::Renderer::renderToFile("Render", params);

Have you tried running lame rom the command line? Maybe it won’t run because of invalid signature or similar. I think for Waveform we bundle lame inside the package. You might be able to just pull our version out of the package.

When I run the one generated by the GitHub project I get the following error:
zsh: exec format error: ./lame

Here’s the result of running file ./lame:

./lame: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive random library] [arm_v7s:current ar archive random library] [x86_64] [arm64]
./lame (for architecture armv7): current ar archive random library
./lame (for architecture armv7s): current ar archive random library
./lame (for architecture x86_64): current ar archive random library
./lame (for architecture arm64): current ar archive random library

And the result of uname -a:
Darwin <computer-name> 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

I’ll look into pulling the one inside Waveform.

Using the Waveform LAME executable worked. Strange that none of the executable I found worked!

For anyone wondering, I installed Waveform, and copied Applications/Waveform (Show Package Contents)/Contents/Resources/lame to my project directory.

I used the homebrew LAME using brew install lame which placed the executable at /usr/local/bin/lame which then worked fine, I give instructions to macOS users on how to do this should they require MP3 encoding on macOS using my software.

Yep, I just tried using the brew version of LAME and it worked. Wish I had heard about this earlier from somewhere else.