Trigger a binding from an expression?

I’ve been trying to come up with a way to use an expression to trigger a binding. For example, i’d like to use the new is_pitch_class_held expression to start a Media player when i play a certain chord. I thought i might be able to do something with a conditional binding, but would still need to trigger the binding somehow. Is there any way to finagle an expression as the source of a binding ?

Thanks for any insights,

  • JIm

Hi Jim,

Have you tried something like this? It checks the incoming notes and fires when it sees the first simple C chord.

Cheers,

Dave

Hi Dave,

That’s what i was trying to do - but i think the problem is that the binding only fires if the C chord is already held when the Any note is played. In fact, i just proved that to myself – the binding triggers if i’m holding a C chord and then hit any other note. So the problem is how to get it to trigger at the time of playing the chord. (By the way the source needs to be Onscreen keyboard (out), not Onscreen keyboard (in) – i’m never sure which to use when and just try them both to see what works.)

But thanks for looking at it, maybe we’ll come up with something. @Brad ?

Well, it seems that when they are grouped the condition can’t true up on a chord strike. Maybe if you tried separating the chord notes like this. This makes it more tactile IMO. It will only fire when the conditions are met so the last note to be pressed will also be the trigger note. This works here very well.

is_pitch_class_held("C") == 1 && is_pitch_class_held("E") == 1 && is_pitch_class_held("G") == 1

1 Like

What would be ideal here, and something I’ve been thinking about, is for the binding expression to have memory so it can recall things it’s seen in the past.

I’m still in half-work/half-holiday mode, but when I get back into it, perhaps I can enhance the expressions to have variables that are persisted across invocation calls. I think this might be feasible, but I need to look at it.

1 Like

That would be really awesome, I guess this would cover most of the needs otherwise requiring the scripting language.

Sounds like a useful idea, though i’m not clear how that would help trigger the binding - what’s needed would be something like “Condition becomes true” as a Source for the binding.

But i have come up with a quirky fix for what i was trying to do. First, a binding to send some random unused note (i used 21) to the onscreen keyboard when one of the notes in the chord is played. Second, a binding to play the media file when note 21 is received while the chord is held, with a 100 msec delay before executing to give the chord notes time to be recognized (and allow some slop in my playing!). A bit of a kluge, but it works.

– Jim

1 Like

Not sure I’m following. The option “Condition becomes true” does control when the target of the binding is triggered. Can you post an example of what you mean?

Well, some of it but the binding expression implementation is always going to be somewhat limited - UI thread only, not control flow statements, not particularly fast (interpreted) etc…

I use the conditions as control flow, basically providing an if-then, works great. Also, I only use scripts on controls (cc and program changes), not notes, so speed is not that critical.

But I agree that if it is notes, then speed is top priority.

I’m wondering if something like LET from Excel (LET function - Microsoft Support) might be an inspiration. Maybe consider global variables (e.g. names prefixed with #) as well as local variables. Yes, would give something like functions with side effects, so use with care - but with great power comes great responsibility.