Old 03-29-2011, 03:26 PM   #1
0=0
Human being with feelings
 
Join Date: Nov 2009
Location: Toronto
Posts: 102
Default js slider/sysex question (negative values)

hey..

i'm trying to make a js sysex editor for my kawai k3. the actual values of some of the parameters go from say -15 to 15. sysex values by definition are unsigned (always positive) so kawai accomplishes negative values by changing one of the hex values in the sysex string to a specific number to indicate a negative value. (i'm sure i could word this better ha)

so specifically this is a typical handling of a sysex string in js:

slider28:0<0,15,1>fine //fine tuning of an oscillator labelled "fine" integers from 0 to 15 with a default of 0:

@init

//FINE
slider28buf = 0;
slider28buf0 = $x40|0; //kawai id number
slider28buf1 = $x00|0; //midi channel
slider28buf2 = $x10|0; //function number
slider28buf3 = $x00|0; //group number
slider28buf4 = $x01|0; //k3 id number
slider28buf5 = $x09|0; //parameter that gets changed (fine tune)
slider28buf6 = $x00|0; //this seems to signify positive values (it would be "08" to indicate the negative values)


@slider

@block

(slider28 != oldslider28) ?
(
slider28value=floor(slider28);
buf=0;
buf[0]=slider28buf0; //send the specified buf value we established before
buf[1]=slider28buf1; //send the specified buf value we established before
buf[2]=slider28buf2; //send the specified buf value we established before
buf[3]=slider28buf3; //send the specified buf value we established before
buf[4]=slider28buf4; //send the specified buf value we established before
buf[5]=slider28buf5; //send the specified buf value we established before
buf[6]=slider28buf6; //send the specified buf value we established before
buf[7]=slider28value;
midisyx(0, buf, 8); //send the value of the slider as midi sysex)
oldslider28 = slider28;
);


on the midi instrument it goes from -15 to 15 so i can do this:

slider28:0<-15,15,1>fine

but somehow i need to make this:

slider28buf6 = $x00|0;

turn into this:

slider28buf6 = $x08|0;

when slider28 is a negative value.

i understand the logic involved but i need someone to spell out the js syntax for me like i'm a 2 year old ha.

thanks.

j

0=0
0=0 is offline   Reply With Quote
Old 03-30-2011, 02:10 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,370
Default

Code:
@slider
slider28buf6 = (slider28 < 0 ? $x08 : $x00) | 0;
IXix is offline   Reply With Quote
Old 04-05-2011, 04:18 AM   #3
0=0
Human being with feelings
 
Join Date: Nov 2009
Location: Toronto
Posts: 102
Default

Quote:
Originally Posted by IXix View Post
Code:
@slider
slider28buf6 = (slider28 < 0 ? $x08 : $x00) | 0;
yes...this switches the bit!

and the whole thing works with this:
buf[7]=abs(slider28value); // absolute value for slider28 (negates "-") *thanks to liteon!

cheeers!

and thanks.

j

0=0

Last edited by 0=0; 04-05-2011 at 04:34 AM.
0=0 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.