Ruby question - Modulo based midi switch
Posted: Sun Aug 18, 2019 8:10 am
Hi,
I need help with a simple Ruby midi module with 2 inputs (midi and int) and 1 output (int) that outputs 0 or 1 based on modulo parameter. What the module does is very simple: it gets the played midi note number when the key is on, then divides it with 12, finds the modulo and outputs 1 whenever the modulo is equal to the input. If the key is gone off or the modulo is not equals to the input value, the module outputs 0 .
Example:
1) The int input is set to 2
2) I play the note 50 with the midi keyboard. The module divides 50 in 12 -> 50/12 = 2 with modulo 2 (48 +2)
3) The module outputs 1 when the key is on (since the int input is equal to the modulo parameter)
4) The output becomes 0 when I release the midi note
5) I play note 52 -> the output remains 0 since the modulo and the int input are not equal
Thanks
I need help with a simple Ruby midi module with 2 inputs (midi and int) and 1 output (int) that outputs 0 or 1 based on modulo parameter. What the module does is very simple: it gets the played midi note number when the key is on, then divides it with 12, finds the modulo and outputs 1 whenever the modulo is equal to the input. If the key is gone off or the modulo is not equals to the input value, the module outputs 0 .
Example:
1) The int input is set to 2
2) I play the note 50 with the midi keyboard. The module divides 50 in 12 -> 50/12 = 2 with modulo 2 (48 +2)
3) The module outputs 1 when the key is on (since the int input is equal to the modulo parameter)
4) The output becomes 0 when I release the midi note
5) I play note 52 -> the output remains 0 since the modulo and the int input are not equal
Thanks