Re: Simple 3D mixer confusion
Re: Simple 3D mixer confusion
- Subject: Re: Simple 3D mixer confusion
- From: John Stiles <email@hidden>
- Date: Wed, 5 May 2004 16:02:13 -0700
OK, the conversation has taken an interesting path of "what hardware to
buy," but I'm still curious about the validity of this code.
Why does the "Unable to set the speaker mode" case happen? Should I be
worried about this?
Do I want AudioUnit_5_0 or AudioUnit_5_1? The AGK code used 5_0, but it
seems to me that we probably want regular subwoofer output.
On May 5, 2004, at 11:19 AM, John Stiles wrote:
// CODE SNIPPET!
err = AudioUnitGetProperty( m_outputUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &format,
&dataSize );
ASSERTN( err == noErr, err );
format.mChannelsPerFrame = (m_speakerMode == SPEAKERMODE_SURROUND)?
5: 2;
format.mBytesPerPacket = sizeof(float);
format.mBytesPerFrame = sizeof(float);
format.mFormatFlags |= kAudioFormatFlagIsNonInterleaved;
err = AudioUnitSetProperty( m_outputUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &format,
sizeof(format) );
if( err != noErr )
{
if( m_speakerMode == SPEAKERMODE_SURROUND )
{
// THIS HAPPENS ON MY SONICA THEATER USB BOX
printf( "FAILED! Surround sound is not supported on this
hardware.\n" );
m_speakerMode = SPEAKERMODE_STEREO;
return err;
}
// THIS HAPPENS TO THE TESTERS, BUT NO PROBLEMS FOR ME AND MY
SOUNDSTICKS OR INTERNAL OUT
printf( "FAILED! Unable to set the speaker mode (output unit: stream
input format). (%d)\n", err );
m_speakerMode = SPEAKERMODE_STEREO;
return err;
}
err = AudioUnitSetProperty( m_mixerUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &format,
sizeof(format) );
if( err != noErr )
{
// THIS HASN'T HAPPENED TO ANYONE YET, JUST BEING PARANOID
printf( "Unable to set the speaker mode (mixer unit: stream output
format). (%d)\n", err );
m_speakerMode = SPEAKERMODE_STEREO;
return err;
}
AudioChannelLayout layout = {};
layout.mChannelLayoutTag = (m_speakerMode == SPEAKERMODE_SURROUND)?
kAudioChannelLayoutTag_AudioUnit_5_0: kAudioChannelLayoutTag_Stereo;
// is 5_0 correct? or do I want 5_1??
err = AudioUnitSetProperty( m_outputUnit,
kAudioUnitProperty_AudioChannelLayout, kAudioUnitScope_Input, 0,
&layout, sizeof(layout) );
ASSERTN( err == noErr, err );
err = AudioUnitSetProperty( m_mixerUnit,
kAudioUnitProperty_AudioChannelLayout, kAudioUnitScope_Output, 0,
&layout, sizeof(layout) );
ASSERTN( err == noErr, err );
UInt32 spatialization = kSpatializationAlgorithm_EqualPowerPanning;
switch( m_speakerMode )
{
case SPEAKERMODE_HEADPHONES: spatialization =
kSpatializationAlgorithm_HRTF; break;
case SPEAKERMODE_SURROUND: spatialization =
kSpatializationAlgorithm_SoundField; break;
}
for( int channel=0; channel<64; channel++ )
{
err = AudioUnitSetProperty( m_mixerUnit,
kAudioUnitProperty_SpatializationAlgorithm,
kAudioUnitScope_Input,
channel,
&spatialization,
sizeof(spatialization) );
ASSERTN( err == noErr, err );
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.