• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting A MusicDevice's Instrument Timbre
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Changing tempo of MusicSequence on fly in Panther
  • Next by Date: Re: Wrapping VSTGUI for Dummies
  • Previous by thread: Re: Changing tempo of MusicSequence on fly in Panther
  • Next by thread: Re: Wrapping VSTGUI for Dummies
  • Index(es):
    • Date
    • Thread