USB MIDI Support Part 1: The Basics
In preparation for the b2 prototyping (which will feature two front-facing USB OTG connectors), I'm furiously adding support for a few new USB devices. In this case, we'll specifically talk about USB MIDI controllers. While the USB MIDI standard is fairly cut and dry and there are a few USB MIDI hosts out there for eurorack already, the 'b and it's successors have quite a few outputs to play with, so we can be a bit more liberal with the outputs... which should result in a more expressive experience.
## Monophonic Controllers
To start with, we've got the basics... Each voice on the 'b has the possibility of 6 different note-specific signals plus any number of channel signals.
As such, the monophonic voice has separate outputs for each of the following:
- Pitch CV (note + pitchbend)
- Velocity CV
- Gate
- Pressure CV (note pressure)
- Note ON trigger
- Note OFF trigger
And of course, there is a common channel aftertouch CV.
Here's what it looks like in JSON:
{
"program" :
{
"name" : "USB Monophonic Midi",
"clock" :
{
"type" : "FixedClock",
"tempo" : 120,
"beats" : 16
},
"devices" : [
{
"type" : "USBMonophoncMidiController",
"gate" : 2,
"pitch" : 1,
"velocity" : 3,
"pressure" : 5,
"aftertouch" : 4,
"triggerOn" : 3,
"triggerOff" : 4
}
]
}
}
That's fine and dandy, but what about splits? Yeah, that works too. Two separate monophonic voices split across the keyboard:
{
"program" :
{
"name" : "USB Split Monophonic Midi Controller",
"clock" :
{
"type" : "FixedClock",
"tempo" : 120,
"beats" : 16
},
"devices" : [
{
"type" : "USBSplitMonoMidiController",
"gate1" : 2,
"pitch1" : 1,
"velocity1" : 3,
"pressure1" : 4,
"triggerOn1" : 3,
"triggerOff1" : 4,
"gate2" : 5,
"pitch2" : 5,
"velocity2" : 6,
"pressure2" : 7,
"triggerOn2" : 6,
"triggerOff2" : 7,
"aftertouch" : 10,
"splitNote" : 48
}
]
}
}
## The Note Stack
A key feature of a monophonic voice is how the key presses stack up and release. The monophonic voice follows a standard pattern of most-recent-key wins. An example of how this works on a few key presses is as follows:
1. The user presses C2.
2. The pitch, velocity, and pressure for the C2 note is routed to the respective analog outputs.
3. The gate output is opened, and the note-on trigger is fired.
4. The user then presses G2.
5. The pitch, velocity, and pressure for the G2 note is routed to the respective analog outputs.
6. The gate remains open (unchanged), and the note-on trigger is fired again.
7. The user presses C3.
8. The pitch, velocity, and pressure for the C3 note is routed to the respective analog outputs.
9. The gate remains open (unchanged), and the note-on trigger is fired again.
10. The user releases G2.
11. No changes are made to any of the outputs since G2 is not currently the active note.
12. The user releases C3.
13. The pitch, velocity, and pressure for the C2 note is routed to the respective analog outputs.
14. The gate remains open (unchanged), and the note-off trigger is fired.
15. The user release C2.
16. The pitch output remains at C2. The velocity and pressure outputs are changed to 0.
17. The gate is closed. The note-off trigger is fired.
Up to 16 key presses are stored per monophonic voice. When the split controller is used, each voice gets its own complete voice stack.
That's a brief overview of the first two MIDI-based devices. Next time we'll look at continuous controllers and the arpeggiator.