-
Notifications
You must be signed in to change notification settings - Fork 11
About Multi Port
The standard MIDI protocol limits the number of channels to 16 per MIDI port, which can restrict the versatility of MIDI files. To overcome this limitation, MIDI supports meta messages to specify the MIDI port for each track.
Meta Status: 0x21
Data: pp
(Port Number)
Note
Description adapted from Mixage Software
This optional meta event typically appears at the beginning of a track, before any MIDI events. It specifies which MIDI port (or bus) the track's events will use. The data byte pp
indicates the port number, where 0
corresponds to the first MIDI port in the system.
While the MIDI spec limits each MIDI port to 16 channels (0-15), multiple ports can be used to extend the number of channels available. This meta event allows for distinguishing events on different ports, effectively enabling more channels at once.
Important
Multiple Port events in a track are acceptable if the track needs to switch ports mid-way.
Here’s how SpessaSynth handles multi-port MIDI files. This approach is designed to work with various multi-port files and might be helpful for others implementing similar functionality.
Note
This is specific to SpessaSynth’s implementation and may vary from other MIDI tools.
-
Port Assignment: During MIDI file parsing, assign the detected MIDI ports to each track. If no port is found, use the next track's port. If no ports are specified, default to port
0
. -
Port Offsets: When playback starts, assign each port a unique offset, incremented by 16 for each port. For example, if the first detected port is
1
, it gets an offset of0
. The next port gets an offset of16
, and so on. -
Channel Mapping: When assigning offsets to ports, ensure each port has an additional 16 channels. This provides a unique range of channels for each port.
-
Port Prefix Handling: On encountering a Port Prefix meta message, update the track’s port to the specified value. Assign an offset to this port as described in step 2 if it does not already have one.
-
Final Channel Calculation: For voice and system exclusive messages, add the port offset to the channel number to determine the final channel used.
-
FF 21 01 00
(Port0
) - The first track will use channels0-15
. -
FF 21 01 01
(Port1
) - The second track will use channels16-31
.
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!