Re: kMusicDeviceProperty_InstrumentCount
Re: kMusicDeviceProperty_InstrumentCount
- Subject: Re: kMusicDeviceProperty_InstrumentCount
- From: Christopher Corbell <email@hidden>
- Date: Thu, 30 Oct 2003 11:47:28 -0800
Marc is right, use sizeof(UInt32) for initial value of your
size value and element should be 0.
Also, the scope param should be kAudioUnitScope_Global (not
_Output).
Here's my code which works with the Apple DLS synth - it's
an objective-C method but it just wraps the same params
to AudioUnitGetProperty():
UInt32 nSize = 0;
UInt32 nCount = 0;
nSize = sizeof(UInt32);
OSStatus status = [self getProperty:kMusicDeviceProperty_InstrumentCount
forScope:kAudioUnitScope_Global
forElement:0
out
Data:&nCount
ioDataSize:&nSize];
On Thursday, October 30, 2003, at 08:17 AM, Marc Poirier wrote:
I am using this code to get the instrument count with a -50.
-(NSArray *)instrumentArray
{
AUNode synthNode;
AudioUnit theSynth;
UInt32 count =0;
UInt32 size = 0;
OSStatus err;
AUGraphGetIndNode(graph, 0, &synthNode);
err = AUGraphGetNodeInfo(graph, synthNode, NULL, NULL, NULL,
&theSynth);
err = AudioUnitGetProperty(theSynth,
kMusicDeviceProperty_InstrumentCount, kAudioUnitScope_Output, 2,
&count, &size);
NSLog(@"%d", err);
return blahblah...
}
I see 1 definite mistake. You should have
UInt32 size = sizeof(count);
not:
UInt32 size = 0;
The ioDataSize argument of AudioUnitGetProperty is an input/output
argument. On entry, it lets you say how large the the data buffer you
are
passing is. On return, the value may be changed to the size of the
data
actually gotten, if that differs from the entry value. So what you are
saying is, "Here's a data buffer that has space for 0 bytes of data.
Please put the data in there," which won't work.
The other possible problem is specifying 2 as the element in
AudioUnitGetProperty. The DLS MD doesn't have 3 elements, does it? I
think that you want to pass 0 for element 1, since instrument count is
element-global, isn't it? Anyway, this point I'm not so sure about,
but
the size thing I know will not work and needs to change.
Marc
_______________________________________________
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.