Skip to content

MIDI Customizations

Tom M edited this page Apr 18, 2020 · 12 revisions

Unfortunaltely, MIDI is very old and limited, esp. when wanting to use it to recreate soundtracks from videogames:

  1. MIDI doesnt support loop markers
  2. Allow overlapping notes
  3. MIDI is limited to 16 channels
  4. Supporting a custom low-pass IIR filter

To handle those issues, ANMP tweaks the MIDI standard in a special way described below.

1. Supporting loop markers

ANMP supports making use of individually looped midi tracks. This can be achieved by inserting midi controllers 102 (loop start) and 103 (loop end) into a track. In-between these two CCs, all events in the corresponding midi track get looped.

How these controllers have to be inserted, is described in detail in the Nintendo 64 SDK section 20.5.1 Loops in the Sequence. ANMP supports CC 104 (i.e. loop count) since version 7. Support for CC 105 not planned.

Note: The longest loop found inside a MIDI will be used as master loop, i.e. for looping back the playhead (Works very well for David Wise's N64 soundtracks like DKR and Dinosaur Planet, but doesn't work well for Grant Kirkhopes N64 themes). In cases where it does not work well on may chose to unroll all MIDI track loops, which can be achieved by setting the "Overriding Loop Count" option from the settings dialog to the desired value.

2. Allow overlapping notes

ANMP uses fluidsynth for MIDI synthesization. Using fluidsynth's API in a naive manner would kill notes that are playing on the same key and channel (i.e. overlapping).

ANMP handles notes in a FIFO way, i.e. it makes sure, that the first noteon is killed by the first noteoff.

3. Supporting more than 16 channels

NOT YET IMPLEMENTED!

Idea: Let each midi track play on its own channel. Therefore MIDI CCs dont update on midi channel but only on the track they are in. NoteOns dont trigger on their channel, but for their track. (TODO: verify that this works for BanjoTooie). To remain backward compatibility to usual midi files, name those specially treated midi files .mid64 or .midi64 (because this method will initially be used for midi files that were taken from the N64)

4. Supporting a custom low-pass IIR filter

ANMP uses fluidsynth's API to manipulate default modulators for providing a custom low-pass filter that is compatible to the filter found in a few of Rareware's N64 games. The filter's cutoff frequency is controlled by MIDI CC 34, while the filters Q is set by CC 33.

Note: In order to use this feature you must compile against fluidsynth >= 2.0!