Hi !
I have set a 12 keys keyboard's widget, sending notes. I use a knob to change octaves.
This knob has 11 steps : [ 0, 12, 24, 36, 48, 60, 72, 86, 98, 110, 122]
I'd like now, for learning purpose, to have two buttons :
- one to make the knob go to its next step,
- one to make it go to its previous step.
Trying and trying... i finally found this : #{@{knob.steps}[2]} to get the value of one particular step, so now i have an idea of what this index thing is about... With this, my idea until now was to use a variable that would be incremented or decremented, using those buttons, to define the index's value...
But... i feel lost... i don't have the syntax...
So... any help appreciated
I think the essence of your idea is to add or subtract 12 to the keyboard start note, right?
I came up with a different solution, without the knob, but using a variable and two buttons.
I hope it helps.
octave-buttons.json (5.3 KB)
1 Like
Thank you @ClelsonLopes ! It does help Just one thing : i don't understand what is const start
... i understand that it gets the keyboard-start value, but what is it ? a function ?
Now, the other approach remains unsolved : is it possible to "navigate" through knob's indexes, using buttons ? For example if my steps would have been [0,1,6,52,278,369]... steps whitout any mathematical relation... Just for learning purpose...
In short, const
, let
and var
are javascript keywords to assign and/or initialize a variable.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements
About index increment or decrement, yeah, it's possible to do. You need the index to be a variable, and the syntax would be something like this:
const steps = [0,1,6,52,278,369]
const currentIndex = 0
//increases index and gets the corresponding step value
const addIndex = steps[currentIndex + 1]
You can check how it works in OSC with this updated version, now including the knob:
octave-buttons&knob.json (7.0 KB)
2 Likes
Thank you very very much ! That makes a lot of informations ! Three lines in your code, three days to really get it for me I'm on it, now !
1 Like
Cool... finally, less than three days to get it almost clear in my head...
I'd like the knob to show kind of "step labels", instead of numeric values.
Where 0,12,24... would become C-2, C-1, C0.... I guess it has something to do with %key
, but here again, i'm stuck.. i tried a few things... but i am too confused with " ", ' ', { }, ( ), [ ]...
Thanks for all
Use this syntax inside the knob range:
{
"0%": { "C-2": 0 },
"10%": { "C-1": 12 },
"20%": { "C0": 24 },
"30%": { "C1": 36 },
"40%": { "C2": 48 },
"50%": { "C3": 60 },
"60%": { "C4": 72 },
"70%": { "C5": 84 },
"80%": { "C6": 96 },
"90%": { "C7": 108 },
"100%": { "C8": 120 }
}
Well done!
1 Like