Csound Csound-dev Csound-tekno Search About

[Csnd-dev] MIDI port mapping mechanism

Date2019-12-24 13:32
FromVictor Lazzarini
Subject[Csnd-dev] MIDI port mapping mechanism
For the API users out there and other interested developers, I’d like to outline the simple input port mapping
mechanism I introduced.

The basic idea is that if multiple ports needed to be mapped to higher-order channels, then you can
just insert a 1xxx xxxx byte after the status byte with a 7-bit number xxx xxxx holding the port 
number (zero-based). Csound will detect that there is an extra ’status’ byte and use the port number
for mapping the received channel msgs.

So the channel message placed in the Csound MIDI buffer will be

1xxx xxxx  1xxx xxxx  0xxx xxxx [0xxx xxxx]

and in your code you should do this

byte[0] = status;  // as coming from the midi device
byte[1] = 0x80 | port;  // the port number from 0 upwards (64 devices)
byte[2] = databyte1; // as coming from the midi device
byte[3] = databyte2; // as coming from the midi device, if the msg uses it.

Once this is done, Csound will automatically map the channel to channel + 16*port

I have implemented this in pmidi.c, so you can look at it for reference.

Note that this is input only.
========================
Prof. Victor Lazzar