Q: When recording sound using the Sequence Grabber, how can my application duplicate the sound source "Speaker" play through settings as seen when SGSettingsDialog is used to configure a Sound Channel? What API is used to turn play through on and off? A: To change the sound channel play through state, use the Sequence Grabber SGGetChannelUsage and SGSetChannelUsage API pair.
Listing 1 demonstrates how you can set the play through state to one of the following:
Off
On during record and preview
Off during record but On during preview
Listing 1. SetSoundChannelPlayThruState.
|
// SetSoundChannelPlayThruState
// Duplicates the functionality of the menu popup control
// in the Source tab of the Sequence Grabber Sound Settings dialog
// inSoundChannel - a sequence grabber sound channel
// inControl - a three entry pop-up menu control
//
ComponentResult SetSoundChannelPlayThruState(const SGChannel inSoundChannel,
const ControlRef inControl)
{
SInt32 value, usage;
ComonentResult err;
value = GetControl32BitValue(inControl);
switch (value) {
// always off
case 1:
value = 0;
break;
// on during preview and record
case 2:
value = seqGrabPreview | seqGrabPlayDuringRecord;
break;
// on during preview only
case 3:
value = seqGrabPreview;
break;
}
err = SGGetChannelUsage(inSoundChannel, &usage);
if (noErr == err) {
usage &= ~(seqGrabPreview | seqGrabPlayDuringRecord);
usage |= value;
err = SGSetChannelUsage(inSoundChannel, usage);
}
return err;
}
|
References:
[Sep 23, 2003]
|