Re: Setting A MusicDevice's Instrument Timbre
Re: Setting A MusicDevice's Instrument Timbre
- Subject: Re: Setting A MusicDevice's Instrument Timbre
- From: Craig Bakalian <email@hidden>
- Date: Sat, 1 Nov 2003 15:14:59 -0500
Hi,
I figured out how to set the instrument of Apple's Synth. Yet, the
instrument number doesn't correlate to timbre that is set. I guess I
will need to write an array of Midi timbre names from 0-127 and use
that to set the timbre, or is there a better way to correlate.
-(void)setInstrumentNumber: (id)sender ForTrackNumber: (UInt32)num
{
UInt32 instrumentNumber = (UInt32)[sender indexOfSelectedItem];
AUNode synthNode;
AudioUnit theSynth;
AUGraph track = [[self document]getGraphForTrackNumber: num];
AUGraphGetIndNode(track, 0, &synthNode);
AUGraphGetNodeInfo(track, synthNode, NULL, NULL, NULL, &theSynth);
ComponentResult a;
a = MusicDeviceMIDIEvent(theSynth, 192, instrumentNumber,0,0);
//need to set a MusicTrackMIDIEvent here to assure the track is
saved with the same data.
}
-(NSArray *)getInstrumentArrayForTrackNumber: (UInt32)num
{
NSMutableArray *instr = [NSMutableArray array];
AUNode synthNode;
AudioUnit theSynth;
AUGraph track = [[self document]getGraphForTrackNumber: num];
AUGraphGetIndNode(track, 0, &synthNode);
AUGraphGetNodeInfo(track, synthNode, NULL, NULL, NULL, &theSynth);
UInt32 count =0;
UInt32 size = sizeof(count);
OSStatus err;
err = AudioUnitGetProperty(theSynth,
kMusicDeviceProperty_InstrumentCount, kAudioUnitScope_Global, 0,
&count, &size);
int i;
for(i=0;i<count ;i++)
{
MusicDeviceInstrumentID musicID;
size = sizeof(musicID);
err = AudioUnitGetProperty(theSynth,
kMusicDeviceProperty_InstrumentNumber, kAudioUnitScope_Global, i,
&musicID, &size);
char name[24];
size = sizeof(name);
err = AudioUnitGetProperty(theSynth,
kMusicDeviceProperty_InstrumentName, kAudioUnitScope_Global, musicID,
&name , &size);
NSString *n = [NSString stringWithCString: name];
[instr addObject: n];
}
return instr;
}
Craig Bakalian
www.eThinkingCap.com
_______________________________________________
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.