2

So I can't find anything online that says I can't do this, but whenever I try to do it on the iPhone, errors are returned from AudioQueueSetParameter. Specifically, if I try this code:

AudioQueueParameterValue val = f;
XThrowIfError(AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, val), "set queue volume");

Then I get the following error: kAudioQueueErr_InvalidParameter. Which Apple's documentation says it means: "The specified parameter ID is invalid".

But if I try the same exact code on an output queue, it works just fine. Does anyone have any idea why I can change the volume on output, but not input?

Thanks

Robbie
  • 831
  • 2
  • 14
  • 22

2 Answers2

2

According to Apple's Audio Queue Services Reference AudioQueue Parameters apply only to playback audio queues.

To retrieve information about your input stream try to use AudioQueue Properties.

// streamDescription here means your AudioStreamBasicDescription
UInt32 levelSize = sizeof(AudioQueueLevelMeterState) * streamDescription.mChannelsPerFrame;
AudioQueueLevelMeterState *level = (AudioQueueLevelMeterState*)malloc(levelSize);
if (AudioQueueGetProperty(inQueue,
                          kAudioQueueProperty_CurrentLevelMeter,
                          &levelSize,
                          &level) == noErr) {
    printf("Current peak: %f", level[0].mPeakPower);
}
XcodeJunkie
  • 424
  • 4
  • 10
0

I presume you could just multiply the PCM values of the AudioQueueBuffers by some volume factor yourself to produce a volume adjustment.