[Solved] SysEx Conditional Expression Parse Error

Getting parse errors when using ?: in a SysEx expression.

If I begin with:

… which is in text:

cc(127,16)==0 ? clamp( ((log(value,10)*20>=-6) ? ((log(value,10)*20 + 26.8235294118) * 31.1666666641) : (826-Sqrt(-34869-220660*log(value,10)))) / 8.05511811024, 0, 127) : ""

everything is AOK, and the expression evaluates to x6E. I am trying to send that x6E as the value of CC 7 on channel 1, so I add x"B007" before the clamp() expression …and I get Error in sys-ex data: syntax error, expected Colon found Identifier:

I have tried a lot of variations with parenthesis and such, and keep getting this error …

Why Am I doing this?

I’m trying to install a “guard” using cc(127,16) to avoid sending extraneous CC’s to my VL70 hardware when I am just setting my Controller Bar cc’s to match the VL70 hardware after a patch change.

There seems to be no way to execute a binding conditionally based on a different CC value. I looked into:

  • disabling the binding during the period when I want to avoid sending CC’s, but I cannot change the enabled state of a binding from another binding.

  • I also cannot use the conditional features of the new Expression engine, because the expression engine does not have the math functions to convert from a Gain value to a MIDI value (I’m using a Custom Curve).

So … I am trying to send “nothing” (the “” at the end of the expression) when cc(127,16) is flagging the “no send” period.

Not sure if this calls for @brad attention.

Hi @ClintGoss

Thanks for reporting… I’ll check it out as soon as I get out from under all this email.

Brad

Had a look at this, and the error is correct but there is a work around (a couple probably).

The reason this is failing is because sysex expressions are a series of expressions separated by whitespace. That’s why this works:

0xF0 0 0 0 0xF7

each value is evaluated and concatenated together to form the resulting byte array.

What you’re trying to do is, use a list of expressions within an expression, which isn’t supported. eg: in this case the byte sequences are within the conditional expression an so can’t be specified as a list like this:

value < 10 ? 0xF0 0 0 0xF7 : 0xF0 1 1 1 0xF7

What you can do though is specify them as arrays, so this will work:

value < 10 ? [0xF0,0,0,0xF7] : [0xF0,1,1,1,0xF7]

You can also, include sysex patterns in the array:

value < 10 ? [x"F00102",0,0,0xF7] : [0xF0,1,1,1,0xF7]

So I think what you want is this:

cc(127,16)==0 ? [ x"B007", clamp( ((log(value,10)*20>=-6) ? ((log(value,10)*20 + 26.8235294118) * 31.1666666641) : (826-Sqrt(-34869-220660*log(value,10)))) / 8.05511811024, 0, 127)] : ""

Let me know if that helps.

1 Like

That’s excellent! Was not aware of the [ array ] construct …

So [space] is a concatenation operator, as in Snobol4 (where space could be concatenation, pattern match, or pattern concatenation, depending on context).

THANKS!!

1 Like