Hi.
I question myself about this function, I didn't figure out how to use it:
function makeIndexedFunction(index, f) {
function indexedFunc(value) {
f(index, value);
}
return indexedFunc
}
I know that help for writting observer callback functions, but can anyone explain me how it work exactly?
How to use "makeIndexedFunction"
-
Frac-Capitaine Frac-Capitaine https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=476585
- KVRist
- 37 posts since 15 Oct, 2020
- KVRAF
- 4889 posts since 13 May, 2004
E.g. if you want to handle the volume of 8 tracks but only write 1 function for the handling and then get the index of the track as a parameter.
Something like this:
You can also use that with objects. If you are interested how to do this download one of my old controller scripts and search for "doObjectIndex" which does the same but for objects:
http://www.mossgrabers.de/Software/Bitwig/Bitwig.html (download one of the scripts under 1.3.16).
Something like this:
Code: Select all
function volumeHandler (trackIndex, volume)
{
println ("Volume changed of track " + trackIndex + ": " + volume);
}
var index;
for (index = 0; index < 8; index++)
{
callback = makeIndexedFunction(index, volumeHandler);
// Register xxx.addObserver (callback);
}
http://www.mossgrabers.de/Software/Bitwig/Bitwig.html (download one of the scripts under 1.3.16).
-
Frac-Capitaine Frac-Capitaine https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=476585
- KVRist
- Topic Starter
- 37 posts since 15 Oct, 2020
Thanks !
I have already download your last javascript package. i have not understand all the code you write, but yeah I plan to learn POO. I am a (old) procedural programmer...
I have already download your last javascript package. i have not understand all the code you write, but yeah I plan to learn POO. I am a (old) procedural programmer...
