ioscore-audioaccelerate-frameworkvdspthe-amazing-audio-engine

Convert decibels to volume using Accelerate Framework


I am building some kind of an audio fader effect.

I am using vDSP_vdbcon to turn a buffer of volumes into decibels, applying some modifications in db-space and would like to convert the decibel buffer into volume using the accelerate framework.

Thanks!


Solution

  • Here is what I use for each element for decibel values between -40 and 0. It gives pretty good results.

    float decibelsToMag(float decibels){
        return pow (10, (0.05 * decibels));
    }
    

    I don't know the Accelerate vector equivalent for the pow function. But here's a half vectorized version.

    void decibelsToMags(float *decibels, float *mag, int count){
        float mul = 0.05;
        vDSP_vsmul(decibels, 1, &mul, mag, 1, count);
        for (int i = 0; i < count; i++) {
            mag[i] = pow(10,mag[i]);
        }
    }
    

    Post back if you can figure out the vDSP version of the loop.