using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
- Subject: using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
- From: "Brian Sheehan" <email@hidden>
- Date: Fri, 28 Apr 2006 17:01:37 +0100
Hi,
This question has been addressed on the list before, and I've tried
using the approach outlined, but I'm having a couple of problems.
I want to allow a user to toggle the playback of a MusicSequence
between the built-in apple dls synth and an external hardware synth.
The code to handle this is in an objective-c wrapper for a
MusicSequence. In the init method, the default AUGraph used by the
sequence is saved to an instance variable using:
MusicSequenceGetAUGraph(sequence, &augraph);
Pointing the sequence at a MIDI endpoint with the
useMIDIEndpoint:(SInt32) uid method below works okay (although the
sequence has to be stopped, and returned to the beginning before it
takes effect!).
However, calls to useBuiltinSynth don't work, and an error of -50
(paramErr from MacErrors.h) is returned from the call to
MusicPlayerPreroll(player). Subsequent calls to useMDIEndpoint: work
fine.
any ideas?
thanks,
Brian
//This is called to tell the sequence to use the built-in synth
- (id) useBuiltinSynth
{
if (midiEndpoint) //and instance variable
{
Boolean wasPlaying;
if (wasPlaying = [self isPlaying])
{
[self stop];
}
OSStatus err = MusicSequenceSetMIDIEndpoint(sequence, nil);
err = MusicSequenceSetAUGraph(sequence, augraph);
err = MusicPlayerPreroll(player); //this call returns -50
midiEndpoint = nil;
if (wasPlaying)
{
[self play];
}
}
return self;
}
//This is called to tell the sequence to use the endpoint with unique ID uid
//and seems to work ok.
- (id) useMIDIEndpoint:(SInt32) uid
{
if (!midiEndpoint)
{
MIDIObjectRef endpoint;
MIDIObjectType type;
OSStatus err = MIDIObjectFindByUniqueID(uid, &endpoint, &type);
if (!err && (type == kMIDIObjectType_ExternalDestination || type ==
kMIDIObjectType_Destination))
{
midiEndpoint = (MIDIEndpointRef) endpoint;
Boolean wasPlaying;
if (wasPlaying = [self isPlaying])
{
[self stop];
}
err = MusicSequenceSetMIDIEndpoint(sequence, midiEndpoint);
err = MusicPlayerPreroll(player);
if (wasPlaying)
{
[self play];
}
}
}
return self;
}
_______________________________________________
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