1

Right now, I successfully created a MIKMIDISequence sequence. However, I couldn't find out how to tie a sound font to that sequence. My question is, how can I assign a MIKMIDISequence a soundfont?

Andrew Madsen
  • 21,309
  • 5
  • 56
  • 97
Thomas
  • 61
  • 4

1 Answers1

1

Rather than setting a soundfont on the sequence, you should use the -loadSoundfontFromFileAtURL:error: of MIKMIDISynthesizer to do so.

Assuming you're using MIKMIDISequencer to play back your sequence, you can get the synthesizer for each track using -builtinSynthesizerForTrack: on MIKMIDISequencer. Note that there is a synthesizer for each track in the sequence, so if your sequence has multiple tracks you'll can/should load a soundfont for each one.

Something like:

for (MIKMIDITrack *track in sequence.tracks) {
    MIKMIDISynthesizer *synth = [sequencer builtInSynthesizerForTrack:track]
    NSError *error = nil;
    if (![synth loadSoundfontFromFileAtURL:soundfontURL error:&error]) {
        NSLog(@"Error loading soundfont (%@) into synthesizer for track (%@): %@", sondfontURL, track, synthesizer);
    }
}
Andrew Madsen
  • 21,309
  • 5
  • 56
  • 97