play multi-instrument MIDI file
-
03-07-2021 - |
Frage
I have been working with the MusicPlayer
and MusicSequence
classes to play MIDI files. However, I am wondering how to specify instruments for different channels. What is the MusicPlayer
's default response to program change events? Can I tell the MusicPlayer
to use certain samplers for certain channels? Or is the only way to set my own function as a MIDI Endpoint, and then handle the playing of notes myself using MusicDeviceMIDIEvent()
to specify the sampler?
Lösung
You can specify different instruments for different tracks in a MusicSequence. (MusicTrack API) I don't think MusicPlayer does anything with channels per se. You can specify that channels be converted to tracks when loading a MIDI file.
Music Sequence Load Flags
Flags used to configure the behavior of the MusicSequenceFileLoad and MusicSequenceFileLoadData functions.
enum { kMusicSequenceLoadSMF_ChannelsToTracks = (1 << 0) }; typedef UInt32 MusicSequenceLoadFlags;
Constants
kMusicSequenceLoadSMF_ChannelsToTracks
If this flag is set the resultant Sequence will contain a tempo track, 1 track for each MIDI Channel that is found in the SMF, 1 track
for SysEx or MetaEvents - and this will be the last track in the sequence after the LoadSMFWithFlags calls.
Available in OS X v10.3 and later. Declared in MusicPlayer.h.