user1849514
user1849514

Reputation:

AudioQueue read input volume

I'm on OS X, and i've to read continuously input volume while i speak (like Siri that shows purple bar high or low for powerful voice or weak voice). I've tried this code but it returns me "parameter ID invalid":

    UInt32 size = sizeof(AudioQueueLevelMeterState) * record_state.data_format.mChannelsPerFrame;
    AudioQueueLevelMeterState *outValue = malloc(size);
OSStatus errorMsg = AudioQueueGetProperty (record_state.queue, kAudioQueueProperty_CurrentLevelMeter,  &outValue, &size     );

    if (!errorMsg) {
        printf("Volume: %f", outValue[0].mPeakPower);
    }
    else
    {
        printf("Er: %i", errorMsg);
    }

How can i do? Thanks.

Upvotes: 0

Views: 315

Answers (1)

Rad'Val
Rad'Val

Reputation: 9251

Did you enable the metering by setting kAudioQueueProperty_EnableLevelMetering property? If not, that could be the cause.

Upvotes: 1

Related Questions