My application uses the power applied the microphone to adjust the volume of playback, similar to Ocarina.
I have tried two solutions, both of which work to some degree, but each with a different problem.
In solution A, I use the remote i/o unit. A render callback reads data from an audio file. At the same time, I have an audio queue set up as a recorder. From this I periodically read the audio levels, which vary as expected as I blow into the microphone, and use this value to set the kHALOutputParam_Volume. However, full volume is always produced, regardless of the parameter setting.
In solution B, I adopted a strategy I found on-line. I make a small audio graph consisting of the remote i/o unit and a multi-channel mixer. I feed the mixer from a callback, and vary its volume using kMultiChannelMixerParam_Volume. This also works, except the volume produced, which does vary, is very soft, even with the parameter set to 1.0, equivalent to the master volume control being set to a tenth or so of its full value.
In both cases, I use ExtAudioFileRead to convert from the wav file's audio format to the format required by the audio graph.
I am inclined to conclude that kHALOutputParam_Volume simply does nothing, and that the fix here is to change the volume myself in the callback with a loop that scales the values read from the file.
But I can't understand why the audio graph solution doesn't produce full volume. Could this be due to some failure of the audio format conversion? I've been assuming that the conversion is correct because the output is correct in all respects, except for the volume. But perhaps the conversion is reading the bytes incorrectly and getting the wrong magnitudes.
On a distinct but related topic, is there any documentation available on using AudioUnitScheduleParameters? I have not been able to find anything at Apple, and only a brief mention of the service in Google.
-- Timothy Larkin Abstract Tools Caroline, NY
|