[JW Lua] Octave Transposition

Robert Patterson robert at robertgpatterson.com
Sun Dec 20 23:53:46 CET 2020


Octave transposition, along with any diatonic transposition, is simple.
Just add or subtract the number of diatonic steps to/from
FCNote::Displacement. For octaves it is 7 diatonic steps.

On Sun, Dec 20, 2020 at 4:42 PM Martin Marris <mmarris at notecraft.com> wrote:

> Quick correction:
>
>
>
> >>…. using note:SetPitch().<<
>
>
>
> I meant “SetString()” of course.
>
>
>
> Martin
>
>
>
> *From:* JWLua <jwlua-bounces at jwmusic.nu> *On Behalf Of *Martin Marris
> *Sent:* Sunday, December 20, 2020 21:34
> *To:* jwlua at jwmusic.nu
> *Subject:* [JW Lua] Octave Transposition
>
>
>
> 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
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20201220/dfb0cf3b/attachment.htm>


More information about the JWLua mailing list