Global variables not 0 but non existent

Hi there,

I want to toggle a global variable between 0 and 1 when I press a certain note with

sm=1-sm

But this apparently has no effect at first, probably because “sm” has not yet been used, or defined, i.e. it is not zero as stated (‘all global variables are 0’), but non existent. Is this correct?

Alex

Hi Alex,

Assuming the global variable is 0 (which it will be by default), do this

// Toggle the value of sm
sm=sm^1

‘^’ is an exclusive or function so will toggle between 0 and 1

If the value is other than 0 or 1 then just bit 0 of the value will toggle.
For instance if the initial value is 3 it will toggle between 2 and 3.

You can learn more about operators in the user manual by pressing F1 in Bome MIDI Translator Pro or using the help menu. The manual will open up as a PDF. You can also get the manual online here.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

It seems not to work for me. The attached file contains a project that should

  • preset 0: initialize global variables by means of “Incoming - Project - Processing is enabled”. This is not happening, not when I load the file, not when I disable/enable the project, only when I press the panic button. When I say “File - Restart Project” the global variables are reset, which is good, but not initialized.

  • preset 1: set global variable “sm” (which is 0) to 1 when note A0 (h15) is pressed on MIDI channel 2 (I used sm=sm^1 this time). This is not working too.

What I am doing wrong?

Split Keyboard - General - V5.bmtp

Well a few issues.

I usually set my globals when I start the project. I fire an Init Timer to do all of my housekeeping. I set up an ‘Init Preset’ to do that.

You had your global set after recovering from a panic which is fine if that is what you want.

I’m not sure if that was your issue though.

I also noticed the alias ‘My Controller’ was assigned to my actual device but it was not enabled in my project so nothing ever worked. Since the project wasn’t setting up ‘My Controller’ as one of the default input, nothing was happening.

I usually assign my incoming triggers at the preset level and you are using all incoming devices. You might want to organize your presets by each device unless you want your triggers to occur by any device and send message to all devices.
Also it looks like your trigger for detecting Setting (Note A0) was on MIDI CH 2, so maybe that is why it wasn’t triggering. All of your other translators look at MIDI CH rm (which is 0 or MIDI CH 1).

For more information about device selection, seethis tutorial.

You can learn more about aliases from this tutorial.

Split Keyboard - General - V5-sjc.bmtp (5.6 KB)

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Thank you very much, Steve, for the “Init” preset. I would never have even thought of that, as I don’t know what a timer is and never used one. But this works for me and I will use this technique for further projects.

MIDI Channel 2 was intentional. The problem was that I inadvertedly required the volume of the “note on” to be 127. Now also the sm=1-sm works perfectly and there is no distinction between a global variable being 0 and a global variable being non existent, as suggested in the title of the thread.

Alexander

1 Like

Another problem popped up as I continued with that project.

I have the following rules:

//not in setting mode?
if sm==0 then exit rules, execute Outgoing Action
//set split to appropriate zone
if sz==1 then z1=tt
Log ‘z1 = %z1%’
if sz==2 then z2=tt
if sz==3 then z3=tt
if sz==4 then z4=tt
exit rules, execute Outgoing Action

and upon executing this translator the global variable z1 is given the value of 59, as the log statement shows, but the variable z1 is not shown when listing the global variables:

17434137 - MIDI IN [BomeBox: Piano de Voyage]: 91 3B 68
17434137 - 1.4:5 z1 = 59
17434137 - MIDI OUT [BomeBox: BomeBox DIN]: 91 3B 68
17434208 - MIDI IN [BomeBox: Piano de Voyage]: 81 3B 68
17434208 - MIDI OUT [BomeBox: BomeBox DIN]: 81 3B 68

List of all global variables:
mc=5 m1=6 rm=1 sm=1 sz=1

Stop processing after execution of this translator is checked for this translator.
Why is z1 not shown in the list of global variables along with its value ?

Indeed, this is a known bug and will be fixed in the next release. The global variable works, but it simply does not report it when you dump global variables.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz