General
Negative and positive values on a bipolar knob (sysex)
Started by dbk on .
Sign in or create an account to join the conversation.
Hello,
i really try to get my head around sysex and LSB, MSB and what not ... it just makes my brain melt.
i need to have a knob sending sysex values which range from -99 to 99.
now, the sysex string i´m sending does fine with values from 0 to 99 but no negative values, no matter what i try.
the synth requests me to send two times (the same, i assume) parameternumber and a two values.
this is one string from the synth, catched with midi monitor.
00 F0 42 34 41 41 01 54 00 63 00 F7
and here´s what i´m sending:
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x54,00,x*99,00,0xF7})
i know it´s wrong, so how can i add the requested second value?
i allowed myself to attach a picture of the manual, where the part is marked yellow.
any help apprechiated.
cheers,
Martin.
hirnschmelze.jpg
i really try to get my head around sysex and LSB, MSB and what not ... it just makes my brain melt.
i need to have a knob sending sysex values which range from -99 to 99.
now, the sysex string i´m sending does fine with values from 0 to 99 but no negative values, no matter what i try.
the synth requests me to send two times (the same, i assume) parameternumber and a two values.
this is one string from the synth, catched with midi monitor.
00 F0 42 34 41 41 01 54 00 63 00 F7
and here´s what i´m sending:
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x54,00,x*99,00,0xF7})
i know it´s wrong, so how can i add the requested second value?
i allowed myself to attach a picture of the manual, where the part is marked yellow.
any help apprechiated.
cheers,
Martin.
hirnschmelze.jpg
Is there a corresponding Parameter Read command that you can send? You can examine the MachineDrum response to determine how it encodes negative parameter values.
I suspect that negative values are passed using two's compliment representation. Here is the Wikipedia article explaining how negative numbers are encoded:
http://en.wikipedia.org/wiki/Two%27s_complement
This might work:
I suspect that negative values are passed using two's compliment representation. Here is the Wikipedia article explaining how negative numbers are encoded:
http://en.wikipedia.org/wiki/Two%27s_complement
This might work:
decl lsb, msb;
if(x < 0){
x = 0x4000 + x; // create two's compliment
lsb = x & 0x7F; // isolate lsb
msb = (x >> 7) & 0x7F; // isolate msb
} else {
lsb = x & 0x7F; // positive x values
msb = 0;
}
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x54,00,lsb,msb,0xF7});Thanks,
this time it´s acutally a korg prophecy
i tried your code but had no luck with, strange thing though because the sysex sent bei the lemur looks exactly like the sysex sent from Prophecy.
so this should work, right?
hm ... even more confused now
cheers
this time it´s acutally a korg prophecy
i tried your code but had no luck with, strange thing though because the sysex sent bei the lemur looks exactly like the sysex sent from Prophecy.
so this should work, right?
hm ... even more confused now
cheers
one more thing.
This code reflects the positive value:
thanks for the link, will see how far i get, english is not my native language.
cheers
This code reflects the positive value:
00 F0 42 34 41 41 01 1E 00 57 00 F7
this one the negative00 F0 42 34 41 41 01 1E 00 1D 01 F7
both received from the prophecy,so they change the last byte to reflect either negative or positive values?thanks for the link, will see how far i get, english is not my native language.
cheers
Cool. Making progress at least. The process of elimination is a good technique to use for problems like these.
Based on the info in your last post, it looks like it is not using two's compliment. So we have eliminated this possibility.
The next step is to collect some data so we can determine how the negative numbers are encoded. Try different parameter values, and write down the msb/lsb values in the corresponding sysex message.
Based on the info in your last post, it looks like it is not using two's compliment. So we have eliminated this possibility.
The next step is to collect some data so we can determine how the negative numbers are encoded. Try different parameter values, and write down the msb/lsb values in the corresponding sysex message.
hey there,
i think it´s like i said. last byte i either 00 (pos values) or 01 (negative values)
00 F0 42 34 41 41 01 54 00 52 01 F7
52 reflects a value -46
00 F0 42 34 41 41 01 54 00 1A 00 F7
1A reflects a value +26 on the korg
strange, looks like pos values are hex but negatives are not?
cheers
i think it´s like i said. last byte i either 00 (pos values) or 01 (negative values)
00 F0 42 34 41 41 01 54 00 52 01 F7
52 reflects a value -46
00 F0 42 34 41 41 01 54 00 1A 00 F7
1A reflects a value +26 on the korg
strange, looks like pos values are hex but negatives are not?
cheers
It looks like it is two's compliment, but the data field size is 8 bits rather than 14 bits. The same code that I posted above should work with small changes:
decl lsb, msb;
if(x < 0){
x = 0x100 + x; // create two's compliment, 8-bit
lsb = x & 0x7F; // isolate lsb 7 bits
msb = 1; // msb should always be 1 for neg. numbers
} else {
lsb = x & 0x7F; // positive x values
msb = 0;
}
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x54,00,lsb,msb,0xF7});i gave it a try, unfortunately it does not work, the prophecy does not respond in any way.
probably this is a problem of the bipolar knob?
i made a monitor with knob.x and the value never drops below 0, so how can your script start to work?
sorry if that´s totally stupid thinking, i try to understand this.
thanks for your effort.
cheers.
probably this is a problem of the bipolar knob?
i made a monitor with knob.x and the value never drops below 0, so how can your script start to work?
sorry if that´s totally stupid thinking, i try to understand this.
thanks for your effort.
cheers.
this code gives me a -1 when x of the knob is on the left and a +1 on the right.
cheers
decl lsb, msb;
if(x>0)
{
lsb =x;
msb = 0 & 0x7F;
} else
{
lsb = x & 0x7F;
msb = 1 & 0xF7;
}
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x1E,00,lsb,msb,0xF7});
i tried to extend it with range and x*99 but had no luck.cheers
I keep forgetting that x, in this context, refers to the Knob.x value. It has a range of 0 to 1.
Add a monitor object to observe the Knob.x value.
As you will see, Knob.x = 0.5 when the knob in the middle of its rotation range. To convert this to a bipolar value, subtract 0.5 from the x value, then scale as needed. I'd also recommend you convert the result to an integer using the floor() function.
Add a monitor object to observe the Knob.x value.
As you will see, Knob.x = 0.5 when the knob in the middle of its rotation range. To convert this to a bipolar value, subtract 0.5 from the x value, then scale as needed. I'd also recommend you convert the result to an integer using the floor() function.
//execution: on expression: floor((x-0.5)*198
decl y, lsb, msb;
y = floor((x-0.5)*198); // convert 0.0 to 1.0 range to -99 to +99 integer range
if(y<0){
lsb = (0x100 + y) & 0x7F; // 8-bit two's compliment
msb = 1;
}else{
lsb = y;
msb = 0;
}
midiout(0,{0xF0,0x42,0x34,0x41,0x41,0x01,0x1E,00,lsb,msb,0xF7});Man, excellent! works perfect, actually better then the knobs on the prophecy itself.
thanks a lot, you helped me a big deal.
cheers,
martin
thanks a lot, you helped me a big deal.
cheers,
martin