Thread: Midi <-> OSC
View Single Post
Old 11-18-2017, 08:28 AM   #80
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I have another question:

This is the code that controls tracks volume with faders (adapted from midimix script):
Code:
msg1 == $xBF ? // Control Change - so must be a knob or a slider (fader) moving
(
    // VOLUME SLIDERS
    msg2 == slSlider1 ? (
        send_soft_fader(1);
    );
    msg2 == slSlider2 ? (
        send_soft_fader(2);
    );
    msg2 == slSlider3 ? (
        send_soft_fader(3); 
    );
    msg2 == slSlider4 ? (
        send_soft_fader(4);
    );
    msg2 == slSlider5 ? (
        send_soft_fader(5);
    );
    msg2 == slSlider6 ? (
        send_soft_fader(6);
    );
    msg2 == slSlider7 ? (
        send_soft_fader(7);        
    );
    msg2 == slSlider8 ? (
        send_soft_fader(8);
    );
With arrays it's possible to use cycle with slSlider[i].

Is it possible to do something similar in oscii-bot, using some kind of concatenation and iteration, like fader_variable_name = ("slSlider" + i);?


UPD. Tried using the following method from the manual for declaring variables. Didn't work for me:
Quote:
You may use brackets to index into memory that is local to your script. Your script has approximately 8 million (8,388,608) slots of memory and you may access them either with fixed offsets (i.e. 16811[0]) or with variables (myBuffer[5]). The sum of the value to the left of the brackets and the value within the brackets is used to index memory. If a value in the brackets is omitted then only the value to the left of the brackets is used.
my code:
Code:
    slSlider[1] = 16;
    msg2 == slSlider[1] ? (
        send_soft_fader(1);
    );
It's working only if variable is declared in the same block of code, but not when it's declared in the @init section. The name of the declared variable doesn't matter. It can be anything[1], as long as numbers inside brackets are matching. For example, foo[1] is equal to bar[1]. Weird.

Last edited by fundorin; 11-18-2017 at 09:48 AM.
fundorin is offline   Reply With Quote