Blog
Logic Pro X bounce time
Date: 27/4/2016
Tags: logic audio
I was doing some mixing today and the bounce time in Logic Pro X seemed very long. Much slower than I was expecting. (Bouncing is basically "rendering" all the audio down to a stereo track for those wondering).

I opened up the Activity Monitor and Logic was reading 10mb/s off a disk capable of 100mb/s. CPU was about 30%, i.e. it's using one core (of my 4 core i5 machine). In true programmer fashion I started to google the problem and it appears that people are having trouble with various plugins being slow. I didn't have anything much loaded, just lots of audio tracks. But I tried disabling the reverb to see if it made any difference. None whatsoever.

I began wondering about the disk speed. Maybe it's causing problems? So I copied the project (all 50GiB) onto a fast USB3 flash drive and run my test again. The export of 2 songs went from 2 minutes to 20 seconds. Uh, ok, wow that's pretty different.

Then I started to wonder about why that is so. The USB3 flash drive is capable of 190MiB / second, and the original hard drive can do 110MiB / second. It's in the same ball park really... so why the order of magnitude performance difference? I think it comes down to the read strategy of Logic. Now I'm just guessing here, but I think it reads small blocks (KiB) of audio from the files to keep the in memory buffer of audio small. This means in large projects with many audio tracks seeking from one file to the next constantly trying to get the next little bit of the audio. This is kinda worst case for a mechanical drive that has to move the head to a new location between each file. Seeking is expensive. On the USB key, seeking is almost free... so it runs fast.

Now the authors of Logic could have bumped the buffer size up considerably so that when trying to access lots of audio tracks there would be more reading and less seeking between files. In my case with 16GiB of RAM to burn that would be fine, but might be an issue with smaller RAM sizes. You certainly can't afford any paging during audio work. Still Logic should be able to see how much RAM is available and size it's internal buffers accordingly.

Obviously for anything to do with "live" audio the buffer size has to be tiny, so that the latency is short. But for pre-recorded material buffering up a few MiB's of audio shouldn't be an issue.
(0) Comments | Add Comment

Converting audio samples to dB and back
Date: 26/4/2012
Tags: audio
I've been writing a tool to normalize lots of audio files at once, as well as convert between various loss-less formats (particularly FLAC and WAV). In doing that I needed a way of converting between the raw audio sample maximum and dB. So I present to you my C functions for doing so:
double LinearToDb(int32 linear, int bitDepth)
{
    uint32 MaxLinear = (1 << (bitDepth - 1)) - 1;
    uint32 ab = linear >= 0 ? linear : -linear;
    return log10((double)ab / MaxLinear) * 20.0;
}

int32 DbToLinear(double dB, int bitDepth)
{
    uint32 MaxLinear = (1 << (bitDepth - 1)) - 1;
    double d = pow(10, dB / 20);
    return d * MaxLinear;
}
Another code snippit for Google to index.
(0) Comments | Add Comment