Explaining the formulation of Voltage Combined in KDL's Midi2volts for synthedit
After working with KDL's Midi2Volts module, I needed to know how Voltage Combined was calculated, so that I could use it with my synthedit creation called Music Computer.
Let me first explain the other fields:
Status is simple, 128 for note off, 144 for note on. It is formulated like this... 1SSS0000, where SSS is the status. That means note off is 000 and note on is 001. To go to the voltage value, it is straight-forward binary to decimal stuff.
Channel is also simple. It's the numbers from 1 to 16. Notice how it is not 0 to 15, like it is in binary. The channel forms the last 4 bits of the status byte. To get the binary value, take the Channel voltage, subtract 1 and convert to binary. For example, channel 5 would be 0100.
Data 1 is used normally for Note Number. the first bit is zero, so you only have 7 bits to work with.
Data 2 is normally used for Velocity. the first bit is zero, 7 bits to work with.
NOW FOR THE HARD PART:
It took me some time to figure out how one gets the "Voltage combined". Perhaps I was unlucky or stupid.
But here it is:
VOLTAGE Combined = Status + (Channel-1) + 256 * Data1+ 256^2 * Data2
My hope is that this will save you some effort.
Another way to look at it, bit wise:
0DDD DDDD | 0ddd dddd | 1SSS CCCC |
data 2 data 1 status-chan = Voltage Combined