Thorough Testing of the Pattern-Fix Dialog
Chris Ahlstrom
2024-11-09 to 2025-01-08

The test file for pattern-fix is contrib/midi/test.midi.  We change the "Test
Pattern" notes to a velocity of all 74 except for 127 with the first and last
notes, and center notes of velocity 124 or 4.

Length Change:

    o   None.

    o   Measures.

        o   Integer greater.

            -   Increases the measure count.
            -   Spreads out (upscales) the notes to fill the increase.
            -   Preserves note length if checked. If not checked, the lengths
                of the notes increase proportionately.
            -   One must tab out of the Measures field before able to click
                the Set button.
            -   Once Set is clicked, the modification indicator (asterisk)
                shows up in the pattern editor and in the main window, and
                there will be a prompt for saving at exit.
            -   The pattern editor immediately shows these changes.
            -   However, the Reset button does not undo the modify flag.
            -   Reset works.
            -   The Expand effect box is checked.
            -   L an R markers are unchanged.
            -   END move to the end of the new pattern length.
            -   The resultant length is shown as reduced by 3 pulses
                (Seq66 shortens notes slightly for read-ability).

        o   Integer lesser.

            -   Decreases the measure count.
            -   Compresses the notes to fill the smaller measure count.
            -   Preserves note length if checked. If not checked, the lengths
                of the notes decrease. For this case, preserving note length
                is generally not desirable.
            -   The Shrink effect box is checked.
            -   L an R markers are unchanged.
            -   END move to the end of the new pattern length.
            -   If "Preserve note length" is set, the last note might bleed
                across the end of the last measure. END shold be adjusted
                properly as well.

        o   Float greater.

            -   Similar to "integer greater", but rounds up to the nearest full
                measure.
            -   Spreads out the notes to expand by the given factor, not the
                final measure size. Thus, the notes might not reach to the end
                of the pattern.
            -   Changes the Scale Factor to match after tabbing out of the
                field.
            -   Sets the Expand effect.

        o   Float lesser.

            -   Similar to "integer lesser", but rounds up to the nearest full
                measure.
            -   Compresses the notes to compress by the given fraction, not
                the final measure size.
            -   Changes the Scale Factor.
            -   Sets Shrink.
            -   For scaling, best to turn off "Preserve note length",
                otherwise notes overlap.

        o   "Time sig" greater.

            -   6/4.
                -   Keeps the number of measures the same, but expands
                    the number of beats and the length of the pattern.
                -   Tabbing out immediately sets Time Sig.
                -   The END marker is set appropriately.
                -   The dropdowns in the main pattern editor windows reflect
                    the new time signature.

        o   "Time sig" lesser.

            -   3/4.
                -   Tabbing out should not set Shrink.
                -   The pattern is scaled by 0.75.
                -   The measures stay the same.
                -   The time-sig numerator and denominator are set correctly.
                -   BUGS galore:
                    -   The END marker, though is set to 3:1:0.
                        The length of the pattern stays the same.
                    -   The Log Timesig button remains at 4/4. Clicking it
                        royally screws up the notes and seqroll.
                -   The dropdowns in the main pattern editor windows reflect
                    the new time signature.
            -   3/8. Identitical except the time-sig properly shows 3 and 8.

            Note: changing to 3/4 in the pattern editor handles the seqroll
                  seqtime bars and time signature properly, but it messes
                  up the notes; it does not change the R marker position.
                  It should not move the notes at all.

    o   Scale factor.

        o   Greaater than one.
        o   One.
        o   Less than one.
            
            -   Almost identical to the Measure change. Just a different
                way to specify it.

    o   Other fixes. Only one fix can be done at a time.

        o   Align left and align right.

            -   Set check-marks the Shift effect.

        o   Reverse measures.

            -   Set reverses the whole pattern.
            -   Set check-marks Reverse.

        o   Reverse in place.

            -   Set reverses the pattern in place. That is, the last note
                ends up at the time of the first note, and vice versa.
            -   Set check-marks Reverse.

        o   Preserve note length.  (A factor in the tests above and below.)

    o   Alteration.

        o   Click None and the real choices unchecks or check-marks the
            Alteration effect.

        o   None.

        o   Tight Q ticks. (With various ranges.)

        o   Full Q ticks. (With various ranges.)

        o   Random amplitude. (With various ranges.)

        o   Time/tick jitter. (With various ranges.)

        o   Note-map. To do:
            
            1.  Add an rcsettings::notemap_filespec (string basename)
                overload to construct the name if it does not have
                a path..
            2.  Add qpatternfix::open_note_mapper() similar to the
                performer version, but that opens the file and
                creates a temporary notemapper. Or extend performer
                to do that.
            3.  We need a version of the above in the notemapper module.
            3.  Pass it to sequence::fix_pattern() or sequence::repitch()
                somehow.

            Also need a reverse repitch flag. Also see
            smanager::open_note_mapper() and qseframe::repitch_all().

            o   Loading alternate note-map.

            o   Repitching.

            o   Rev Note-map

        o   Set.

        o   Reset.

            o   Note that Reset will undo any changes made in the pattern
                editor while the Pattern-Fix Editor is up.

= = = = = = = = = = =

What does it mean to convert a 4/4 pattern to 3/4?

Original pattern:


4 ||========== |           |           |========== ||
- ||           |========== |           |           ||
4 ||           |           |========== |           ||

Notes left in place:

3 ||========== |           |           ||========= |
- ||           |========== |           ||          |. . . 
4 ||           |           |========== ||          |

Notes compressed:

3 ||=======    |           |    =======||
- ||        =========      |           ||
4 ||           |      =========        ||

https://music.stackexchange.com/questions/46058/any-pointers-on-how-to-convert-4-4-to-3-4

Current behavior in seqframe:

    track().set_beats_per_bar(bpb = 3, true)

        m_time_beats_per_measure = 3 [unsigned short!]
        get_measures() --> get_measures(0)
            um = unit_measure() --> unchanged m_unit_measure = 768
            len = get_length() --> 1536 (2 measures x 768 per measure)
            measures = len / um = 2

       THEREFORE, measures does not change at this point!

       modify()

    track().apply_length(bpb, 0, 0, user_change = false)

        set_beats_per_bar(3, false) this time; no changes at all here
        unit_measure(reset = true)
            m_unit_measure = measures_to_ticks(measures = 1) --> 576
        measures = get_measures(0) --> len = 1536 --> measures = 3
        result = set_length(
                    seq66::measures_to_ticks(3,192,4,3) --> 1728)
            m_length = 1728
            . . . set length for events and triggers

        verify_and_link()


Original 4 b/bar * 192 t/bar * 2 m 


= = = = = = = = = = =

Side note: ~automutex() is called before returning a value, so the value needs
           to be a LOCAL VARIABLE
