Music Device and channel handshake
Music Device and channel handshake
- Subject: Music Device and channel handshake
- From: Makira <email@hidden>
- Date: Fri, 28 Jan 2005 14:39:04 -0500
Hi!
I'm trying to make a 0 to n music device: 0 to 1 works nicely, I'd like to
do 0 to n (GarageBand doesn't seem to want to load 0 to 1), but I can't get
even 0 to 2 to work..
Here's is the revelent code I use, anyone can help ? Even though Plogue will
load it, it'll show as a 1 output music device.
The auval tests pass successfully, showing the 0-2 format.
Thank you!
Antoine
Plogue Bidule Log:
Object create
GetParameterInfo
GetParameterInfo
GetParameterInfo
GetParameterInfo
GetParameterInfo
GetParameterInfo
PostConstructor
ValidFormat 1 // returned false
Initialize
auNumOutputs: 2, outChannels: 2
[more getParam]
//--------------------------------------------------------------------------
----------------
SonicBirthRuntimeMusicDevice::SonicBirthRuntimeMusicDevice(AudioUnit
component)
: MusicDeviceBase(component, 0, 1, 0)
{
LOG("Object create\n")
[...]
mChannelInfo.inChannels = 0;
mChannelInfo.outChannels = 2;
[...]
}
//--------------------------------------------------------------------------
----------------
UInt32 SonicBirthRuntimeMusicDevice::SupportedNumChannels(const
AUChannelInfo ** outInfo)
{
LOG("SupportedNumChannels\n")
if (outInfo != NULL)
*outInfo = &mChannelInfo;
return 1;
}
//--------------------------------------------------------------------------
----------------
ComponentResult SonicBirthRuntimeMusicDevice::Initialize()
{
LOG("Initialize\n")
int auNumOutputs = GetStreamFormat(kAudioUnitScope_Output,
(AudioUnitElement)0).mChannelsPerFrame;
LOG("\tauNumOutputs: %i, outChannels: %i\n", auNumOutputs,
mChannelInfo.outChannels)
if (mChannelInfo.outChannels != -1 && auNumOutputs !=
mChannelInfo.outChannels)
return kAudioUnitErr_FormatNotSupported;
[...]
}
//--------------------------------------------------------------------------
----------------
void SonicBirthRuntimeMusicDevice::PostConstructor()
{
LOG("PostConstructor\n")
MusicDeviceBase::PostConstructor();
if ( Inputs().GetNumberOfElements() > 0 )
{
const CAStreamBasicDescription curInStreamFormat =
GetStreamFormat(kAudioUnitScope_Input, (AudioUnitElement)0);
if ( ((UInt32)(mChannelInfo.inChannels) !=
curInStreamFormat.mChannelsPerFrame) && (mChannelInfo.inChannels >= 0) )
{
CAStreamBasicDescription newStreamFormat(curInStreamFormat);
newStreamFormat.mChannelsPerFrame = (UInt32)
(mChannelInfo.inChannels);
AUBase::ChangeStreamFormat(kAudioUnitScope_Input,
(AudioUnitElement)0, curInStreamFormat, newStreamFormat);
LOG("\tChanged input to %i\n", mChannelInfo.inChannels)
}
}
const CAStreamBasicDescription curOutStreamFormat =
GetStreamFormat(kAudioUnitScope_Output, (AudioUnitElement)0);
if ( ((UInt32)(mChannelInfo.outChannels) !=
curOutStreamFormat.mChannelsPerFrame) && (mChannelInfo.outChannels >= 0) )
{
CAStreamBasicDescription newStreamFormat =
CAStreamBasicDescription(curOutStreamFormat);
newStreamFormat.mChannelsPerFrame = (UInt32)
(mChannelInfo.outChannels);
AUBase::ChangeStreamFormat(kAudioUnitScope_Output,
(AudioUnitElement)0, curOutStreamFormat, newStreamFormat);
LOG("\tChanged output to %i\n", mChannelInfo.outChannels)
}
}
//--------------------------------------------------------------------------
----------------
bool SonicBirthRuntimeMusicDevice::ValidFormat(AudioUnitScope inScope,
AudioUnitElement inElement,
const CAStreamBasicDescription &inNewFormat)
{
LOG("ValidFormat %i\n", inNewFormat.mChannelsPerFrame)
if (!AUBase::ValidFormat(inScope, inElement, inNewFormat)) return false;
if (mChannelInfo.outChannels != -1 && (int)inNewFormat.mChannelsPerFrame
!= mChannelInfo.outChannels)
return false;
LOG("\tyes\n")
return true;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden