[javascript-dev] JSUI : question about Array index/value
Salvator
cycling at editions-ihs.com
Wed Oct 3 08:09:59 MDT 2007
- Previous message: [javascript-dev] [ANN] MaxMSP Developer workshop at Ircam (Novemeber 10 & 11)
- Next message: [javascript-dev] JSUI : question about Array index/value
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I'm working on a JSUI knob meant for a compressor knee.
SO I've setted an Array with my knee settings :
var Ratio = ["1:1", "2:1", "3:1","4:1", "6:1", "10:1", "];
My goal is to be able to control this jsui knob by sending message of the knee settings (ex:10:1), rather than float or int (i.e. NOT by sending the array index).
Thus my question :
Is it possible to send a "value" to an Array, so it check if it match the content, and if positive retrieve the array index for that "value" ?
ie. for
var Ratio = ["1:1", "2:1", "3:1","4:1", "6:1", "10:1"];
// index's are 0 1 2 3 4 5
I send the message "3:1" and I get back the index of this value wich is "2".
I've tried with vregexp.exec(Ratio) etc... but I lack skill in java and I have no good results.
So far, I'm doing like this :
function ratio(input)
{
switch (input)
{ case "1:1": msg_float(0) ;break;
case "2:1": msg_float(1) ;break;
case "3:1": msg_float(2) ;break;
case "4:1": msg_float(3) ;break;
case "6:1": msg_float(4) ;break;
case "10:1": msg_float(5) ;break;
case "20:1": msg_float(6) ;break;
case "NUKE": msg_float(7) ;break;
}
}
This works, but I want to use this code on much bigger arrays(like for a fixed frequency knob with dozen of frequency), and it'll be hard to manage all those cases lines. Especially if I make change in the array order and number etc...
Second question :
Actually I have to pass a message with a prefix "ratio 3:1" , to enter the function ratio(input).
Is there anyway to make it work just by sending a single symbol "3:1" ? Is is possible at all to send single symbol message to jsui ?
Thanks for any help or advice !
Salvator
- Previous message: [javascript-dev] [ANN] MaxMSP Developer workshop at Ircam (Novemeber 10 & 11)
- Next message: [javascript-dev] JSUI : question about Array index/value
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
