possibility of depend „if“ „then“ „but“ rules

Hi,

is it possible to define rules like:

if „input a“, then „output x“ and „output y“. and if „input a“ was last input, but did not happen for a defined time, then „output z“

or:

if „input a“, then output b“, but if „output b“ happened in the last lets say 50ms, then „dońt output b“

The first rule could be used for:

turn a knob -> press mouse button once, then mouve mouse, and if mouse is not mooves for a defined time, release mouse button.

The second rule could be used for:

turn a knob -> move mouse to position. But as long as knob is turned, mouse is not moved to position agein.

If this is possible, then we could use a rotary encoder to turn a specific knob in a not Midi-controllable FX, via mouse movement. Whithout using a second controller like a button.

That woould be awesome!

thanks

Klaus

Interesting questions. Let’s take a look.

if „input a“, then „output x“ and „output y“. and if „input a“ was last input, but did not happen for a defined time, then „output z“

====
If input a then output x and output y:

Incoming: Any note-on on MIDI channel 1 note 24 velocity 15
Rules:
// in this case we will output two MIDI messages via raw MIDI
// note x and note y at velocity 127. We could have also just had two translators
// With the same incoming condition and each outputing a single note
// Our outgoing message will be note-on CH 1 notes 18 and 19 at velicities 127 (7F) each
// note for raw MIDI we use hexadecimal output always 18 decimail is 12 hex and 19 decimal is 13 hex
Outgoing:
Raw MIDI 90 12 7F 90 13 7F

// Again if you dont single translator or raw MIDI output, just put two translators with the same
// incoming message and have the first one output
Outgoing : Note-On MIDI CH 1 Note 18 Velocity 127
Outgoing : Note-On MIDI CH 1 Note 19 Velocity 127

=====
If input a was last input, but did not happen for a defined period of time, then output x

First we need a translator to capture input and store it as last input into a global variable.
In this example we will take any note-on message and store it in ga. We then use a timer
to determine whether to send output z. For input ,say we want note 24 in this example.
We will will output note 50 if the last note was 24 and more than 1 second has passed

Incoming: Note-On Any note store note to pp any velocity, MIDI CH 1
Rules:
ga=pp
Outgoing: One shot timer “Last Note Timer” delay 1000ms (1 second)

Incoming: Timer “Last Note timer”
Rules:
if ga!=24 then exit rules, skip outgoing action
Outgoing: Note-On MIDI CH1 Note 40 Velocity 127

============

if „input a“, then output b“, but if „output b“ happened in the last 50ms, then „dońt output b“

Name: Input A Set Output B
Incoming Note On MIDI CH1 Note 15 velocity 127
// look to see if it has been sent
pp=gb
if pp==2 then gb=0
if pp==2 then exit rules, skip outgoing action
// set flag that says output B is pending
gb=1
Outgoing: One shot Timer Output B Delay 50ms

Name : Output B timer
Incoming : Timer “Output B”
// Mark it sent
gb=2
Outgoing: Note On MIDI CH 1 Note 25 velocity 127

In the above example, the first translator looks to see if it has already been sent (gb=2)
and aborts the timer if sent, otherwise starts the timer at 50ms so output will happen
We reset gb back to 0 to re-arm it for the next iteration. We set gb to 1 to show that it is pending.

I did this all on paper so not tested but it should be pretty close.

I think I might do it a bit different but need to think on it some more.

Upon start of turning a knob
1) Go to fixed position X-Y (location of the knob on the screen)
2) Left Click Down
3) Look at direction knob is turning and Move (drag) mouse accordingly
4) After timeout (motion stopped) left click up.

Of course you would have to consistenlty move the knob before timeout occurs otherwise the process repeats.

I think I provided a solution to some about this the other day. Was it you? In either case, just take a look and you should find the project file there.

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

You might want to look at this post where I use an encoder to do pretty much what I described above. I guess it was not you.

https://www.bome.com/support/kb/tutorial-use-a-midi-controller-as-a-mouse-using-bome-midi-translator-pro?backlink=L3N1cHBvcnQva2IvcGFnZS8yP3dpZGdldENhY2hlSWQ9N2MxOWQzZTA2NGNlM2I0OWEwNGNkOTI4ZjYyY2EzYmQ%3D

Hi Steve,

 

thankk you, that´s great. I understand the logical structure, butthere pop up some simple questions I don´t find answers for in the manual. how and where do i define pp as “all notes all channels note on”, or as “all notes but just one channel note on” ? or is pp predefined?

thank you so much

klaus

Hi Klaus,
Global and local variables and their naming conventions are discuss in Section 10 of user manual which you can open by pressing F1 or going to the Help menu in Bome MIDI Translator pro.

Global variables are visible to all translators and are guaranteed to be 0 at project startup.
Local variables are only visible to a given incoming trigger and their value is undefined unless you define them. For example pp and qq can be defined in an incoming action for note-on MIDI CH1 Note pp and value qq,

If you also define pp for an incoming action of CC1 MIDI CH1 cc pp and value qq, then the value of pp and qq are independent for each trigger and will not interfere with each other.

If you want to share the variable with another translator you should use global variables. For things that are handled within a translator and do not need to remain static between triggers, you local variables.

The below examples will process a Note On or Off any note any velocity on MIDI CH1 only and will skip outgoing action on any other 3 byte message

Incoming: oo pp qq

Rules:

// Notice the input assigns oo pp and qq

// I will also define rr here and don’t have to worry about it in any translators that do

// not have the same trigger

// Look for MIDI channel which is lowest nibble of oo. We also define rr here

// I can input in hex notatation “ox0f”, but MT Pro will later translate to decimal if you

// go back to look at these rules later

rr=oo&0x0f

// If not MIDI channel 1 (not 0) then abort

if rr!=0 then exit rules skip outgoing action

// Look for note-on which is highest nibble of oo

// notice since I’m done with rr to test for MIDI channel number I can re-use it here

rr=oo&0xf0

// Is is note on?

if rr==0x90 then skip next rule

// Is it note-off

if rr!=0x80 then exit rules, skip outgoing action

// If you arrive here it is either note-on or note-off on MIDI channel 1

// otherwise it would have aborted by now

// so do any processing you want before sending output

// lets change the note number to 24 but leave everything else alone

pp=25

Output: oo pp qq

 

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz