MIDI and NRPN Noob - Help Me Decode Page 13 of MIDI Doc?

  • The Profiler Model referred to in this thread is ...
    ☑️ Profiler Stage

    I’m a MIDI and NRPN noob, and trying to educate myself in this area. I’ve read heaps of threads and posts on the subject, some of which have been very helpful. This post by Torsten ToH2002 was awesome, as have been many posts by Burkhard , and clarified a lot. But I’m still struggling with page 13 (and associated pages 11 and12) of MIDI Parameter Documentation 8.6.


    The example on page 13 references ““Reverb Mix” in module REV is at NRPN #6169”. I can see from page 23 of the MIDI document, the Effect Module REV is at Address Page 61, so I presume 61 becomes the MSB. And from a Decimal to Hex converter, 61 Dec = 3D Hex (written$3D?). And then on page 20, I can see that “Mix 3 (delay and reverb effects)” is 69, which equals Hex 45. So I can see where the first couple of numbers in the example are from.


    But I can’t understand the next paragraph, starting with “So, why $40 and $00?”. I can see the conversion of 8192 into Hex 2000. $2000 when converted to binary becomes 10000000000000. The SHR 7 is (I think) a Shift Right by 7 bits (= 1000000) to get the MSB. Converting Binary 1000000 to Hex = $40. The remaining binary bits are 0000000. And unsurprisingly, Binary 0000000 = Hex $00. So I can see where those two numbers come from.


    So why is the “AND $7F” function used?


    Trying to remember back to my university days, which preceded the existence of desktop PC’s, phones, internet, you name it, the AND function compares the same bits from two numbers, and returns a 1 where the two bits are both 1, and returns a 0 otherwise.


    Hex $7F = Dec 127 = Binary 1111111.


    So if the MSB is 1000000, and you AND 1000000 with 1111111, the answer will be 1000000. Which per the above converts to Hex $40, so all good.


    But why do you do that?


    Similarly, if the LSB is 0000000, and you AND 0000000 with 1111111, the answer will be 0000000. Which per the above converts to Hex $00, again all good.


    But again, why do you do the AND function/calculation?


    And why use the number $7F, (or127), apart from the fact this gives you seven bits of one’s?


    Or asking these questions the other way round, what happens (or what is the risk/issue) if I just used the numbers I got from the MIDI parameter lists, and didn’t do the “AND” calculation?


    And lastly, assuming I can get on-board with all the maths and numbers above, I’m guessing that, if I was sending a SysEx command, I would be using the Hex numbers, and if I was using NRPN, the numbers would all be decimal?


    Thanks for anyone who has read this far, and even more thanks for anyone who responds!!

  • Okay, I'll take a shot:

    Output from code:

    0111101

    1000101

    1000000

    0000000

    8192

    As you can see above, sending 8192 by two pairs of seven bits means sending 1 value of 0b1000000and a second value of 0b0000000.
    Join them together and it makes 0b10000000000000 (8192)

    Does that help? Maybe I misread something, there is a lot of text here.

  • Thanks for this response, and the comments. I don't know C or its derivatives at all, but I think I can work out what the code is doing/saying.


    Yes, there is a lot of text in my post, sorry for that.


    But I was trying to explain my reasoning and deductions in working through the MIDI doc and the example on page 13, and the conversions of dec --> hex --> binary, etc. If I am wrong in my reasoning, hopefully someone can correct me, and I'll be the better for it.


    I was able to work out how to convert 8192 into 7-bit binary, but thanks for your comments.


    My real question is why the example includes the "AND $7F" operation, and what it means if this is not done. {Edit: It seems to me if you "AND" any 7-bit number with $7F, you will get the original number as the answer, so why do it?}


    If I'm looking for parameters and values for some other operation controlled by MIDI (changing delay settings or gain settings, etc), and I don't apply an "AND $7F" to whatever parameters and values I read from the Kemper MIDI doc, will that matter?


    I'll do some googling on "AND" and "$7F" and binary and MIDI, and see if I can work it out.

    Edited once, last by DunnyDaw ().

  • You're AND'ing the value to mask out 127.
    The simplest way I can explain this is as follows: With an arbitrary value (say, 243).
    If I mask with 127 (7 bits) I'm asking:
    Out of 243, how many of these bottom 7 bits are on?


    Output:


    11110011 [value]

    & 01111111 [mask]

    = 01110011

    ...1110011 is the "status" of the last 7 bits.


    Quote

    If I'm looking for parameters and values for some other operation controlled by MIDI (changing delay settings or gain settings, etc), and I don't apply an "AND $7F" to whatever parameters and values I read from the Kemper MIDI doc, will that matter?

    Yes it will. Depending on how your serial connection is made through midi you might be sending additional bits that the receiver end might not be expecting.
    It's not going to fry anything but I imagine the receiving end is just going to think of it as garbage. You could try it out though.

    In serial you're essentially creating a hose of bits and firing off groups of bits and if one number you're trying to send is larger than the group of bits I imagine that you'd be sending a lot of data that receiver probably won't respond to correctly.

    You could try connecting an oscilloscope with UART a decoding function to see what exactly the serial connection is sending.

    If you want to see how it's being decoded you probably would need to set up an UART receiver yourself (software & hardware wise)

    Edited once, last by 0K1900 ().

  • Thanks so much for this response, it has clarified a lot for me.


    There is a further complication for me though.


    In Kemper's "MIDI Parameter Documentation 8.6" document, page 13, they seem to be splitting a 14-bit number into two sections of 7 bits:-



    The "SHR 7" (Shift Right by 7 bits?) seems to me to be selecting the first 7 bits, if so, do they then need to do an "AND $7f" action on what is now a 7-bit number? In your discussion, the number was more than 7-bits, so I can see the purpose. It seems to me that, by Kemper splitting it into the 7-bits, the "AND $7f" action becomes superfluous.



    What are you using to do all this midi communication? ie, an arduino, rapsberry pi, PC, mac.

    What is the end device going to be? a bit of hardware or just software?


    I believe it is Wheresthedug has the droll comment in his sig "Way more gear than talent". That applies massively to me. I will be using a MIDI foot controller for sending the MIDI messages, an XSonic Airstep or maybe a PaintAudio MIDI Captain. I have a couple of other old devices I have accumulated over time that I might dust off also. The Airstep can send PC, CC, and SysEx, I believe the MIDI Captain will be soon able to send SysEx also. The end device is hardware, a Kemper Player or maybe a Stage. I am slowly piecing together all the info I have found on MIDI as related to Kemper, and can do basic stuff likely changing rigs, etc. But I want to understand the Kemper doc fully, so I can start going the next step of changing Kemper effects to intermediate levels, etc.

  • I believe it is Wheresthedug has the droll comment in his sig "Way more gear than talent". That applies massively to me. I will be using a MIDI foot controller for sending the MIDI messages, an XSonic Airstep or maybe a PaintAudio MIDI Captain. I have a couple of other old devices I have accumulated over time that I might dust off also. The Airstep can send PC, CC, and SysEx, I believe the MIDI Captain will be soon able to send SysEx also. The end device is hardware, a Kemper Player or maybe a Stage. I am slowly piecing together all the info I have found on MIDI as related to Kemper, and can do basic stuff likely changing rigs, etc. But I want to understand the Kemper doc fully, so I can start going the next step of changing Kemper effects to intermediate levels, etc.

    Sorry if i misunderstand, but would it not just be simpler to buy a piece of hardware that already exists?

    i understand your situation though because i have, numerous times, built my own midi controllers but ended up using an "off-the-shelf" bit of kit that does all i need for live use. I do enjoy the tec-side and making things so will probably continue to do so but if (and this might not apply to yourself) you struggle with understanding midi, programming and the hardware you can save much time and frustration letting someone else do the work, ie buying a ready-made device.

  • I've certainly never needed to do any midi-maths, other than calculate a sysex-checksum (not for Kemper) or bit-shift operations so your stuff seems overly complicated, but again, maybe i dont fully understand your mission

  • The "SHR 7" (Shift Right by 7 bits?) seems to me to be selecting the first 7 bits, if so, do they then need to do an "AND $7f" action on what is now a 7-bit number? In your discussion, the number was more than 7-bits, so I can see the purpose. It seems to me that, by Kemper splitting it into the 7-bits, the "AND $7f" action becomes superfluous.

    I would say that "selecting" is the wrong word here.

    Lets think about shifting in decimal.

    If you take a value (1E8) and SHR 3 in decimal you don't get 3 decimal digits, you get 1E5.

    Thus; in base 10 shift operations divide or multiply by 10.

  • Thank you both for the comments, help and clarifications.

    I've certainly never needed to do any midi-maths, other than calculate a sysex-checksum (not for Kemper) or bit-shift operations so your stuff seems overly complicated, but again, maybe i dont fully understand your mission

    slateboy "your stuff seems overly complicated" - maybe, but all I have done is quote what Kemper says in its page 13 of the MIDI Parameter Documentation 8.6. If you re-read that page 13, you will see what I mean.


    Yes, I think you have mis-understood what I am trying to do. All I want to do is to use one of my commercially available, already-existing MIDI controllers, programme it with the proper commands and values, and then get it to change settings in my Kemper Player, also an already-existing, commercially available hardware product - I'm not designing or coding anything. I made the mistake of reading the Kemper documents, and struggling to understand them.


    In the end, I have read many times what Torsten (@ToH2002) wrote here, and also the comments from 0K1900 above, and then decided to ditch a fair bit of what Kemper does in its example.


    So, if my task is:-

    • Change the Amplifier Gain setting in the current rig to 81%

    Then my process is

    • Use NRPN cc numbers to do this (therefore, use decimal numbers)
    • From the Kemper document page 17 - Amplifier module is Address Page 10 {this is then the MSB}
    • From the Kemper document page 17 - Gain is parameter number 4 {this is the LSB}
    • The adjustable range is 0 - 16483
    • 16483 x 0.81 = 13,351 decimal (give or take 1)
    • Convert 13351 to binary = 11010000100111 {I used this online converter}
    • MSB = left-most 7 bits = 1101000 = 104 decimal
    • LSB = right-most 7 bits = 00100111 = 39 decimal

    So, using Torsten's info, my MIDI command becomes:-


    cc 99 value 10

    cc98 value 4 (or 04)

    cc 06 value 104

    cc38 value 39


    Et voila - it works!! Amp Gain becomes 8.1


    A bit of a torturous path, and maybe not strictly correct from a programming/computing point of view, but I got there.


    Now, for my own edification, I've just got to work out how to do it all using SysEx.

  • Ah, yes, i think i see what you are aiming to achieve. It certainly is a bit of faff to get the range converted into two NRPN values (as you have shown)

    As for scaling, i think this is why its possible to get values of <0.0> and <-0.0> (yes, minus zero!!!) obviously due to some rounding of values where the decimal places are not visible. I did encounter this myself when trying to control my player, Not for the faint-hearted.