pinobatch/pently

Fix transpose of pattern fallthrough

pinobatch opened this issue · 2 comments

As of 0.05wip3, pentlyas supports an undocumented fallthrough command, allowing a pattern to continue into the next pattern. But this is defective because it doesn't take into account differences in the transposition base between patterns. @jroatch has provided a test case, with the following explanation:

# fallthrough patterns are quite useful to save space in
# the conductor data, but the 0.05 assembler transposes
# them weird.  Uncomment the '//' lines to hear what they
# are supposed to be.

2016-02-03_fallthrough-tests.pently.zip

The score could play a fallthrough group starting at any pattern boundary, and PATEND needs to return to the same transposition at the end. This means the assumed transposition base for all patterns in the group must be the same. Here's a plan:

  • Add a docstring for find_transpose_runs()
  • Have find_transpose_runs() save both ends of each run's range: the highest note in each run in addition to the lowest
  • Run find_transpose_runs() on all individual pitched patterns prior to the parts_to_print loop
  • Save each pitched pattern's transposition base and lowest note
  • Check validity of a play command based on lowest note, not transposition base
  • Propagate transposition base and lowest note backward within each group
  • If the last pattern has only one run, attempt to expand it to cover preceding patterns' runs so long as the 2-octave range limit is not exceeded
  • Ensure the test case renders correctly

There was a minor problem with the test case that jroatch provided. When I added bar check about two years after the test case (#26), the pickup command became usable within patterns. So I had to move the pickup command in the test case above the pattern definitions and document this parser quirk.