0

I am using apples AudioUnit to create sound. I was wondering if it is possible to control the volume of only my audio output and not the whole system audio with MPVolumeView.

If anyone could provide an answer, or a hint where to look i would very much appreciate it.

Torbilicious
  • 467
  • 1
  • 4
  • 17

1 Answers1

2

Yes - it is possible. You do it by adding a mixer module to your AUGraph. You can address it in code to regulate volume. There are other methods as well, but this would be the most common one. Typing on a phone, but this is approximately how you would implement an on/off switch in obj-c:

float volume = (localAudio) ? 0.95 : 0.0;
AudioUnitSetParameter(_mixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Output, 0, volume, 0);
caxix
  • 1,085
  • 1
  • 13
  • 25