How can I transpose notes?

florian

2007-08-19 18:52:57

a user asked this question:
Can I transpose my played notes, e.g. by an octave, with Midi Translator? Is the Classic version sufficient, or do I need the Pro version?

florian

2007-08-19 18:57:25

yes, you can do that.

In theory, you can do transposition with the Classic edition of Midi Translator. However, it only allows static translations, so you'll end up defining one translation for every note:

Code: Select all

   INPUT             OUTPUT
NOTE ON key 20 -> NOTE ON key 32
NOTE ON key 21 -> NOTE ON key 33
...
NOTE ON key 80 -> NOTE ON key 92
...
The note numbers are in semitones, so adding twelve semitones will increase the note by one octave.

Midi Translator Pro offers an elegant way for doing so, by way of "Rules" with variables (variables have 2-letter names, e.g. pp, qq, etc. or "global" variables ga, gb, gc,...).
Here, the octave transposition is one simple translator:

Code: Select all

INPUT:  NOTE ON key "pp"
RULE:   pp=pp+12
OUTPUT: NOTE ON key "pp"
It'll be easy to change this definition to an arbitrary transposition, simply change the rule.

darmohray

2007-08-30 23:30:33

Florian, thank you for the example using rules in Midi Translator Pro. How would one go about shifting a subset of octaves?

Say I have a 4 octave midi keyboard ranging from C2 to C6. I'd like to shift the lower two octaves down by one octave. So I'd like a keyboard ranging from C1 to B2 and C4 to C6. How would I go about setting up translations for all of the Note On and Note off keys?

I'd also like to setup transpositions where all the notes on the 4 octave keyboard are shifted either up or down, however not all the same shift direction. So likely to need 50 translations just for the notes, plus I'd like to have numerous other translations for special effects.

If I have to setup individual translations for each key, are there performance considerations in setting up so many translations?

I'd like to setup such a large number of translations using a text editor. Is there any way to import and export CSV files, rather the text oriented import/export format? Would be much nicer to use Excel to create all of these different translations, or ast least see each rule on a single line.

darmohray

2007-08-30 23:49:13

Florian, after posting my message, I quickly realized it's easy to create such a rule for partial transpositions. I believe the following should work:

Name0=Shift Down 1 Octave
Incoming0=MID190oopp
Outgoing0=MID190oopp
Options0=Actv01Stop01OutO00StMa00000004if(oo<=59)skipexecuteif(oo>=36)oo=oo-12execute

Can you confirm for me the above will work? Also, can you answer my other questions about performance in considering large number of translations and/or translations with rules and the question about any other formatted import/export files?

Thanks,
Gregory

florian

2007-09-01 23:51:06

Hi Gregory,

your rules seem to be doing this:

Code: Select all

Translator 1: Shift Down 1 Octave
Options: stop=true
Incoming: MIDI 90 oo pp 
Rules: 
  if oo<=59 then skip next rule
  exit rules, execute Outgoing Action
  if oo>=36 then oo=oo-12
  exit rules, execute Outgoing Action
Outgoing: MIDI 90 oo pp 
I must admit, it's easy to get lost in the logic. I think what you want to do is done by just removing the "exit" rules:

Code: Select all

Translator 1: Shift Down 1 Octave
Options: stop=true
Incoming: MIDI 90 oo pp 
Rules: 
  if oo<=59 then skip next rule
  if oo>=36 then oo=oo-12
Outgoing: MIDI 90 oo pp 
This code means: whenever the note number is in between 36 and 59, the notes are transposed down by one octave.

MT's engine is very fast and although I haven't done any formal tests, it can easily handle thousands of translator entries. Also the rules are implemented in a highly optimized fashion (they won't be parsed at runtime) so there is no need in trying to avoid them.

The next beta will feature text output (also for copy) which yields a result as above in the code blocks. However, you cannot import them back. CSV/Excel export/import is already on the internal feature request list and I'll add it to the public one. It's a very useful feature, but I'm not sure when we'll be able to implement it.

Regards,
Florian