Initializing global variables

Hi

First of all, I would like to know if it is possible to initialize variables in a Translator and run it only when the execution starts.

 

The only way I have found was to catch the Start and Stop Song messages, but I would like if there is a much more elegant way.

 

My second question is about a translator not been executed. Here is how I defined it:

Project: convert to chords _____________________________________________________________ [x] Preset 0: Convert to chords

[x] Translator 0.0: Start detected Options: swallow Incoming: Start Sequence, on port Bome MIDI Translator 1 Virtual In Rules: ga=1 Outgoing: (none)

[x] Translator 0.1: Stop detected Options: swallow Incoming: Stop Sequence, on port Bome MIDI Translator 1 Virtual In Rules: ga=1 Outgoing: (none)

[x] Translator 0.2: Init vars Incoming: (none) Rules: //Checks if the start or stop buttons were pushed if ga!=1 then exit rules, skip Outgoing Action

ga=0 gb=4 gc=4 gd=4 ge=14 gf=15 gh=4 gi=4 gj=-1 gk=-1 gl=-1 gm=-1 gn=-1 go=-1 gq=-2 gr=-1 gs=-1 hc=0 ic=0 hd=0 id=0 he=0 hf=0 if=0 hg=0 ig=0 ha=0 ia=0 hb=0 Outgoing: (none)

If I send the "FA" message, then "ga" will be set to 1. The translator: "0.2: Init vars" should be executed as it is not waiting for an input message. Is this correct? If not, then how can I achieve this?

 

Best regards Josef

Yes, you can initializes variables within a translator, with any incoming action (including upon project opening). Global variables will be visible everywhere but local variables will only be visible to translators with the same exact incoming trigger.

 

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

Hi

How can you initialize global variables on project opening? I really don’t find this trigger.

Best regards
Josef

In the first dropdown, select “Disable/Enable Processing”. Then in the selection under that, check “Project file is opened”.

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

Thanks for your answer. This was really useful to me. Now I redefined my project as follows:

[x] Translator 0.0: Project Opened
Incoming: Project Opened
Rules:
ga=1
Outgoing: One-shot timer “init”: 0 ms delay

[x] Translator 0.1: Start detected
Options: swallow
Incoming: Start Sequence, on port Bome MIDI Translator 1 Virtual In
Rules:
ga=1
Outgoing: One-shot timer “init”: 0 ms delay

[x] Translator 0.2: Stop detected
Options: swallow
Incoming: Stop Sequence, on port Bome MIDI Translator 1 Virtual In
Rules:
ga=1
Outgoing: One-shot timer “init”: 0 ms delay

[x] Translator 0.3: Init vars
Incoming: On timer “init”
Rules:
//Init vars here

Now the variables will be not only initialized by project opening, but also during the Song Start and Stop messages.

Best regards
Josef

Great work!

About my second question, the translator not been executed. I figured out that instead of “Incoming: (none)” on the third translator, you shoud define: “Incoming: On timer “init””. Then the “init” timer can be defined as an outgoing One-shot 0ms timer on the first two translator. This works really good.

Yes using a timer to initialize your variable and having different translators output to that timer is a good way to have multiple conditions to trigger the same action.

Timers are fantastic. I can really get rid off a lot of unnecessary global variables