Alternating possible?

Ozarkeys

2007-01-06 09:52:12

Just curious if it's possible to set up alternating notes say like for up and down stroke strings. Each time the note is pressed it alternates to another note of choice. Let me know. Thanks

--Ozarkeys

florian

2007-01-07 21:14:27

Hi,

this is possible with the Rules feature of Midi Translator Pro: just define one global variable (e.g. "ga") as alternator between 0 and 1. Then define 2 translators of which one is only executed if ga is 0, and the other only if ga is 1:

Code: Select all

Translator 1: Alternator
Options: stop=false
Incoming: MIDI 90 40 qq 
Rules: 
  if qq==0 then exit rules, skip Outgoing Action
  ga=1 - ga
Outgoing: (none)

Translator 2: Note On for ga=0
Options: stop=false
Incoming: MIDI 90 40 qq 
Rules: 
  if ga!=0 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 41 qq 

Translator 3: Note On for ga=1
Options: stop=false
Incoming: MIDI 90 40 qq 
Rules: 
  if ga!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 42 qq 
In the example, the trigger note is hexadecimal 0x40 (note E), it triggers all 3 translators. In an alternating fashion, note 0x41 and 0x42 are triggered instead. Note that a velocity of 00 is a Note Off. The Alternator Translator Entry does not change the ga flag upon a Note Off, but you may run into problems if the Note Off is not issued before the next Note on. Also, the script would need to be extended if your keyboard sends actual Note Off messages (i.e. status 0x80).

Hope that helps!
Florian

Ozarkeys

2007-01-08 22:15:27

Couldn't get this one to work. My keyboard does send note off (80) with varying note off values (0-127) depending on how fast you let off the keys. It's a Roland A-90. Any ideas? Thanks for your help.

--Bransonkeys

admin

2007-01-09 14:19:48

Hi,

if your keyboard uses actual note off messages, the MT preset needs to extended with these 2 translator entries:

Code: Select all

Translator 4: Note Off for ga=0
Options: stop=false
Incoming: MIDI 80 40 qq 
Rules: 
  if ga!=0 then exit rules, skip Outgoing Action
Outgoing: MIDI 80 41 qq 

Translator 5: Note Off for ga=1
Options: stop=false
Incoming: MIDI 80 40 qq 
Rules: 
  if ga!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 80 42 qq 
I guess the additional translators are straight forward. You could combine translators 2-5 in one single translator with additional rules, but I guess for a start, this is easier to understand.

If it still doesn't work, please be as precise as possible what works and what doesn't work.

Florian

Ozarkeys

2007-01-10 00:51:48

The note on and off doesn't seem to be the problem. The alternator code doesn't seem to alternate. If I put in: If ge==0 then ge=1,
If ge==1 then ge=0, the ge value stays stuck on 0. If I put in: If ge==1 then ge=0
If ge==0 then ge=1, the ge value stays stuck on 1. I followed every detail.

Thanks for your help--

Ozarkeys

florian

2007-01-10 02:43:07

ooops! you're right! it's so stupid I can't leave it there :)
So I've edited my actual post above with the fix.

I've just edited Translator 1.

Later,
Florian

Ozarkeys

2007-01-10 22:32:58

Got it working now. Thanks for the help. What about if I want to alternate between more than two layers? Say 3 or 8 layers.

---Ozarkeys

florian

2007-01-11 00:56:44

you can extend the scheme above easily for more values of ga. For example, to have 5 distinct mappings that are cycled through, replace Translator 1 above with this:

Code: Select all

Translator 1: Change to next value of ga
Options: stop=false
Incoming: MIDI 90 40 qq
Rules:
  if qq==0 then exit rules, skip Outgoing Action
  ga=ga + 1
  IF GA >= 5 THEN ga = 0
Outgoing: (none) 
Now each press of key 0x40 will increase ga by one until it reaches 4. The next time it will be increased to 5, but the last IF statement will reset it to 0. So the ga variable will always be in the range [0...4].

Now for every value of ga you can create an own mapping, e.g. to play note 0x50 when for ga is 2:

Code: Select all

Translator 6: Note On for ga=2
Options: stop=false
Incoming: MIDI 90 40 qq
Rules:
  if ga!=2 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 50 qq 

Translator 7: Note Off for ga=2
Options: stop=false
Incoming: MIDI 80 40 qq
Rules:
  if ga!=2 then exit rules, skip Outgoing Action
Outgoing: MIDI 80 50 qq 
If the outgoing MIDI numbers are calculable (i.e. just chromatic keys), you can use a rule to calculate it. For example, you want to cycle through notes 0x50, 0x51, 0x52, 0x53, and 0x54. Then use this set of Translator entries:

Code: Select all

Translator 1: Change to next value of ga
Options: stop=false
Incoming: MIDI 90 40 qq
Rules:
  if qq==0 then exit rules, skip Outgoing Action
  ga=ga + 1
  IF GA >= 5 THEN ga = 0
Outgoing: (none) 

Translator 2: Note On for any value of ga
Options: stop=false
Incoming: MIDI 90 40 qq
Rules:
  pp = 0x50 + ga
Outgoing: MIDI 90 pp qq 

Translator 3: Note Off for any value of ga
Options: stop=false
Incoming: MIDI 80 40 qq
Rules:
  pp = 0x50 + ga
Outgoing: MIDI 80 pp qq 
As you can see, the new note number is calculated by adding 0x50 to ga, storing the result in pp. Then, the note parameter of the OUTGOING MIDI command is just set to pp. Using this scheme, you can also use more complicated setups, e.g. cycle through every 2nd note can be done using these rules in Translator 2 and 3:

Code: Select all

vv = ga * 2
pp = 0x50 + vv
I think you see how it works...

Regards,
Florian