[JW Lua] Octave Transposition

Martin Marris mmarris at notecraft.com
Sun Dec 20 22:34:02 CET 2020


After copy/pasting stuff I sometimes need to transpose the results by an
octave, up or down.

 

I assumed this would be easy but several hours later I am stuck.

 

I tried three approaches:

*	Using the scripts kindly provided by Nick Mazuk at
https://github.com/Nick-Mazuk/jw-lua-scripts. But even after incorporating
all of the "transposition" library functions directly into my script I could
not get this to work. I always got an error message that "note" was a nil
object even though I had directly assigned a value to "note."
*	A crude approach using MIDIKey, adding or subtracting 12. This did
result in the correct pitches, but the wrong spellings: C ended up at
B-sharp for example. (These errors happened only on transposing
instruments.)
*	Finally I tried an approach that parsed the note String and changed
it. So for example, Bb4 would be programmatically changed to Bb3 or Bb5 and
then set using note:SetPitch(). This worked OK on "C" instruments but
yielded spectacularly wrong results on transposing instruments (off by a
couple of octaves in some cases). I messed around with the "written pitch"
parameter (the third property in the SetPitch method) but go nowhere.

 

Hmm.

 

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20201220/cc3a9ed9/attachment.htm>


More information about the JWLua mailing list