yes, you are getting there. Let me show that on a few drawings. Imagine you have received a sysex message that consists of number of bytes:
4, 5, 6 are the positions of each byte in the message.
say that these three bytes consist of data that form the values of two parameters. One 7-bit CC 60 and one 14-bit NRPN 81.
The transformation is done with the parsing rules defined in the patch response
object.
Each parsing rule has two sets of elements:
- elements to locate the bits in the sysex bytes
- elements to specify where the bits located with above elements should be placed within the parameter value, thus to compose the parameter value
The Rule elements to locate the bits
"byte":
"byteBitPosition"
"bitWidth"
byte
says which sysex bytes will be parsed
byteBitPosition
tells the start position of the bits to be parsed out (counted from the right, ie. LSB)
bitWidth
number of bits to be parsed out (counted towards the MSB).
The above elements are used to identify and parse out a group of bits out of the sysex data.
a few examples:
say you will want to parse the bits marked with the thick outline, then you would use
"byte": 4,
"byteBitPosition": 0,
"bitWidth": 7
"byte": 5,
"byteBitPosition": 0,
"bitWidth": 4
"byte": 6,
"byteBitPosition": 4,
"bitWidth": 1
so to sum it up:
is translated to
"byte": 8,
"byteBitPosition": 2,
"bitWidth": 4
The Rule elements to compose Parameter value
"type":"nrpn",
"parameterNumber":4,
"parameterBitPosition":7,
"bitWidth":1
type
is the type of the parameter that is being composed
parameterNumber
is the number (identifier) of the parameter
parameterBitPosition
position where the parsed bits should be placed (counted from the right, ie. LSB)
bitWidth
number of bits to be parsed out (counted towards the MSB).
These elements instruct Electra where the parsed bits (see above) should be placed within given parameter.
examples:
say, that the 4 lower bits sysex byte 5 consist of value of the 7bit CC parameter.
{
"type":"cc7",
"parameterNumber":60,
"parameterBitPosition":0,
"byte":5,
"byteBitPosition":0,
"bitWidth":4
}
And now the 14-bit nrpn parameter that has its value distributed between sysex bytes 4 and 6 (quite similar to MS packed format).
byte 4 consists of lower (LSB) 7 bits of the parameter value, byte 6 consists of 1 bit of MSB part of the parameter value.
{
"type":"nrpn",
"parameterNumber":81,
"parameterBitPosition":0,
"byte":4,
"byteBitPosition":0,
"bitWidth":7
},
{
"type":"nrpn",
"parameterNumber":81,
"parameterBitPosition":7,
"byte":6,
"byteBitPosition":4,
"bitWidth":1
}
because the parameter value is composed of two separate parts (7bit and 1bit), two rules are needed. These two rules, however, refer to the same parameter (nrpn 81). Electra will interpret this by putting the two parts together (logical OR operation).
And now the homework part. The Mopho user guide says:
so getting the 8bit value of C is:
{
"type":"nrpn",
"parameterNumber":3,
"parameterBitPosition":0,
"byte":4,
"byteBitPosition":0,
"bitWidth":7
},
{
"type":"nrpn",
"parameterNumber":3,
"parameterBitPosition":7,
"byte":1,
"byteBitPosition":2,
"bitWidth":1
}
by doing this, nprn parameter 3 will be set to 8bit value. if it is just a simple value 0 …255. You are done. If it was for example a number with range -128 … 127. you will need to tackle the signedness, but that is done outside the parsing rules.