我在 OS X 上,我必须在说话时连续读取输入音量(例如 Siri,它会在高或低的紫色条上显示强大的声音或微弱的声音)。我试过这段代码,但它返回“参数 ID 无效”:
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);
}
我能怎么做?谢谢。