Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sawyer Monk Kalimba Style Example
- I defined two scales to compare, one the regular scale, and one for the kalimba
- with CC1 (modwheel) you can switch through the scales, off = chromatic, full = kalimba
- scale array explanation:
- 0 - 11 are as follows:
- 0 1 2 3 4 5 6 7 8 9 10 11
- C C# D D# E F F# G G# A A# B
- to remap whites:
- C E G B D F A
- written in numbers:
- 0 2 7 11 2 5 9
- blacks:
- D F C E G
- = 2 5 1 4 7
- total array entry:
- 0, 2, 2, 5, 7,11, 1, 2, 4,5, 7, 9
- now let's duy it!:
- */
- const byte scales[2][12] = {
- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, // 0 'Chromatic'
- {0, 2 ,2, 5, 7, 11,1, 2, 4, 5, 7, 9}, // 1 βKalimbaβ
- };
- byte scale=0;
- // calculate key octave:
- byte octavebyKey(byte key)
- {
- if (key == 0)
- return 0;
- return (key / 12);
- }
- // calculate scaled key:
- byte scaledKey(byte key)
- {
- return scales[scale][(key % 12)] + (octavebyKey(key) * 12);
- }
- // check if modwheel is changed:
- bool RK002_onControlChange(byte chn, byte nr, byte val)
- {
- if (nr == 1) {
- scale=val/126; // low values will give scale value 0, high values will give value 1
- // Send "all notes off" to disable notes being sustained during controller change
- RK002_sendControlChange(chn, 123, 0);
- }
- return true;
- }
- // process note on messages:
- bool RK002_onNoteOn(byte chn, byte key, byte vel)
- {
- RK002_sendNoteOn(chn, scaledKey(key), vel);
- return false;
- }
- // process note of messages:
- bool RK002_onNoteOff(byte chn, byte key, byte vel)
- {
- RK002_sendNoteOff(chn, scaledKey(key), vel);
- return false;
- }
- // .. no other processed needed, next is the compulsory routines
- // but these can be empty
- void setup()
- {
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement