Re: using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
Re: using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
- Subject: Re: using MusicSequenceSetMIDIEndpoint() & MusicSequenceSetAUGraph()
- From: William Stewart <email@hidden>
- Date: Mon, 1 May 2006 11:17:33 -0700
On 28/04/2006, at 9:01 AM, Brian Sheehan wrote:
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);
This overides the previous call - which do you want - the sequence or
the MIDI endpoint? You should NOT be setting null here = this should
be returning a param err (and you might want to actually check it)!!!
err = MusicPlayerPreroll(player); //this call returns -50
Just a general comment:
If you are doing the kind of manipulation you are, you should make
and manage your own graph - the "default" graph is really only
provided as a convenience for very simple and straight forward uses
of the sequence.
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
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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