Skip to content

Commit

Permalink
Interim check-in of upgrading qpatternfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed Dec 8, 2024
1 parent 592e226 commit 005d5e1
Show file tree
Hide file tree
Showing 16 changed files with 829 additions and 297 deletions.
50 changes: 47 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
TO DO for Seq66 0.99.17
Chris Ahlstrom
2019-04-13 to 2024-12-04
2019-04-13 to 2024-12-08

Hottest:

- Figure out issue #132, the libasound2 issue.
- #133 Pattern Length Change Issues
- QObject::setParent: Cannot set parent, new parent is in a different thread
- Pattern fix:
- Using measures = 3/4 changes the time signature in the pattern
editor, but not in the time pane. Also, although END
is at the third beat, both time and roll leave the measure
a 4/4.
- Add usage/processing of Quantization parameters in
line_edit_q_full/jitter/none/tighted.
- Make sure changes raise the modified flag and asterisk indicator.
- Enable / disable Set / Reset according to modification.
- Flagging issues:
- Large measure does not check-mark Expand.
- The Other Fixes do not check-mark their effects flags.
- Definitely need a new screen-shot and documentation galore.
- Consider an option to Import a normal MIDI file so that a flag
is raised so that it will not be saved with Seq66 SeqSpecs.
Make it visible to be clear.
- Add .notemap support, identical to .drums.

From Testing:

Expand Down Expand Up @@ -201,7 +219,7 @@ ISSUES:
#103 One-shot (repetitions != 0) patterns do not play
This feature works, but requires the pattern to be armed before
playback begins, either in Live or Song mode. Should we make the loop
auto-arm, or make this an option somehow? No.
auto-arm, or make this an option somehow? No.
STATUS: Closed.

#104 Really confusing usage
Expand Down Expand Up @@ -239,7 +257,7 @@ ISSUES:
machine. A ton of refactoring and fixes for the damn MIDI Mapper.

#111 Time signature changes does not get saved on .midi file

STATUS: In progress.
- Ctrl-Z in pattern editor works, but does not restore original
view until pattern is reopened. Not sure why, it should work.
Expand Down Expand Up @@ -344,6 +362,32 @@ ISSUES:

STATUS: Fixed in the "wip" branch, will be merged at the next release.

#133 Pattern Length Change Issues

In the pattern edit window, the reset pattern to 1 button no longer works
properly. It either shrinks to some bar other than 1 or just does nothing
at all.

There is also a behaviour when you manually select or type the number of
bars and it is smaller than the amount of already existing bars with notes
in, the notes get deleted after a warning dialog. This does not work when
the Expand mode is selected.

Steps to reproduce:

1: Create two (or more) bars with notes in, with Expand mode selected.
2: Shrink to one bar

These have appeared since https://github.com/ahlstromcj/seq66/issues/128 so
possibly connected.

A third issue which occurred before was with manually editing the amount
of bars with double digits. The bars refresh for each digit entered. For
example So if you have 16 bars and you want to shrink to 14 bars, it will
first shrink it to 1 bar as you type over. If the bars are full then the
dialog will pop up about losing notes. If you then click ok, instead of
cancel, you will lose anything in the latter 15 bars.

To close as pushed off to version 2:

1 JACK Metadata MIDINAM support
Expand Down
3 changes: 2 additions & 1 deletion contrib/DIR_COLORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# \file DIR_COLORS
# \author Chris Ahlstrom
# \date 2008-02-26
# \updates 2024-10-30
# \updates 2024-12-07
# \version $Revision$
# \license $XPC_SUITE_GPL_LICENSE$
#
Expand Down Expand Up @@ -417,6 +417,7 @@ EXEC 01;32
.ini 01;33
.keymap 01;33
.mutes 01;33
.notemap 01;33
.opts 01;33
.options 01;33
.pc 01;33
Expand Down
11 changes: 7 additions & 4 deletions doc/latex/tex/pattern_editor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,16 @@ \subsection{Pattern Editor / Second Row}
Alignment, reversing, and quantization can still be done.
\item \textbf{Measures}.
Allows the measures (length) of the pattern to be changed in two ways,
depending on how the number is entered: as a simple integer (e.g.
1, 1.0, 0.25),
or as a simple time-signature fraction (e.g. "3/4").
depending on how the number is entered: as a simple integer or
floating-point number (e.g.
1, 1.0, 1.75),
or as a simple time-signature fraction (e.g. "3/4"; the "/" is a
key indicator of this kind of change).
\begin{itemize}
\item \textbf{Measures}.
Entering an integer or a floating-point scale factor will scale
the pattern events,
and change the number of measures, if applicable.
and change the number of measures.
If the measure value is less than \texttt{1.0},
the pattern will only be compressed.
If less than 1 measure in length, the result will be
Expand All @@ -385,6 +387,7 @@ \subsection{Pattern Editor / Second Row}
Entering a fraction such as \textbf{3/4} or
\textbf{12/8} will change the time signature of the pattern
\textbf{and} \textsl{compress it to 1 measure}.
This obviously works best for shorter patterns.
\end{itemize}
\item \textbf{Scale Factor}.
Scales the pattern. For example, 2.0 doubles the length, and 0.5
Expand Down
21 changes: 13 additions & 8 deletions libseq66/include/midi/calculations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-11-07
* \updates 2024-11-23
* \updates 2024-12-07
* \license GNU GPLv2 or above
*
* These items were moved from the globals.h module so that only the modules
Expand Down Expand Up @@ -131,13 +131,14 @@ lengthfix_cast (int v)

enum class alteration
{
none = 0, /**< grid_quant_none: Not adjusting timing of pattern. */
tighten, /**< grid_quant_tighten: Adjust timing less forcefully. */
quantize, /**< grid_quant_full: Adjust timing strictly. */
jitter, /**< grid_quant_jitter: Randomize timing slightly. */
random, /**< grid_quant_random: Randomize event magnitude a bit. */
notemap, /**< grid_quant_notemap: Apply a configured note-mapping. */
max /**< Illegal value. */
none = 0, /**< grid_quant_none: Not adjustment of pattern. */
tighten, /**< grid_quant_tighten: Adjust timing less halfway. */
quantize, /**< grid_quant_full: Adjust timing strictly. */
jitter, /**< grid_quant_jitter: Randomize timing slightly. */
random, /**< grid_quant_random: Randomize event magnitude. */
notemap, /**< grid_quant_notemap: Apply configured note-mapping. */
rev_notemap, /**< Apply the note-map in the reverser direction. */
max /**< Illegal value. */
};

inline int
Expand Down Expand Up @@ -643,6 +644,10 @@ extern std::string extract_a2j_port_name (const std::string & alias);
extern midipulse closest_snap (int S, midipulse p);
extern midipulse down_snap (int S, midipulse p);
extern midipulse up_snap (int S, midipulse p);
extern bool fequal (double x, double y);
extern bool fnotequal (double x, double y);
extern bool flessthan (double x, double y);
extern bool fgreaterthan (double x, double y);

} // namespace seq66

Expand Down
14 changes: 7 additions & 7 deletions libseq66/include/midi/eventlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-09-19
* \updates 2024-12-04
* \updates 2024-12-08
* \license GNU GPLv2 or above
*
* This module extracts the event-list functionality from the sequencer
Expand Down Expand Up @@ -426,8 +426,8 @@ class eventlist
midibyte status, midibyte cc,
int snap, int divide
);
bool quantize_all_events (int snap, int divide);
bool quantize_notes (int snap, int divide);
bool quantize_all_events (int snap, int divide = 1);
bool quantize_notes (int snap, int divide = 1, bool all = false);
midipulse adjust_timestamp (event & er, midipulse deltatick);
void scale_note_off (event & noteoff, double factor);
midipulse apply_time_factor
Expand All @@ -440,10 +440,10 @@ class eventlist
bool move_selected_notes (midipulse delta_tick, int delta_note);
bool move_selected_events (midipulse delta_tick);
bool align_left (bool relink = false);
bool randomize_selected (midibyte status, int plus_minus);
bool randomize_selected_notes (int range);
bool jitter_events (int snap, int jitr);
bool jitter_notes (int snap, int jitr);
bool randomize (midibyte status, int plus_minus, bool all = false);
bool randomize_notes (int range, bool all = false);
bool jitter_all_events (int snap, int jitr);
bool jitter_notes (int snap, int jitr, bool all = false);
void link_new (bool wrap = false);
bool link_notes (event::iterator eon, event::iterator eoff);
#if defined SEQ66_LINK_NEWEST_NOTE_ON_RECORD
Expand Down
4 changes: 2 additions & 2 deletions libseq66/include/play/performer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-11-12
* \updates 2024-11-21
* \updates 2024-12-05
* \license GNU GPLv2 or above
*
* The main player! Coordinates sets, patterns, mutes, playlists, you name
Expand Down Expand Up @@ -2257,7 +2257,7 @@ class performer
bool merge_sequence (seq::number seqno);
bool move_sequence (seq::number seqno);
bool finish_move (seq::number seqno);
bool fix_sequence (seq::number seqno, fixparameters & params);
bool fix_pattern (seq::number seqno, fixparameters & params);
bool remove_set (screenset::number setno);
bool clear_set (screenset::number setno);
bool swap_sets (seq::number set0, seq::number set1);
Expand Down
24 changes: 14 additions & 10 deletions libseq66/include/play/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-30
* \updates 2024-11-24
* \updates 2024-12-08
* \license GNU GPLv2 or above
*
* The functions add_list_var() and add_long_list() have been replaced by
Expand Down Expand Up @@ -87,8 +87,9 @@ using colorbyte = char;
* of those cases, the timestamps of all events will be adjusted
* accordingly.
*
* \var fp_quan_type
* Indicates if all events are to be tighted or quantized.
* \var fp_alter_type
* Indicates how all events are to be altered, such as being tightened,
* quantized, note-mapping, etc.
*
* \var fp_align_left
* Indicates if the offset of the first event or, preferably first note
Expand Down Expand Up @@ -139,8 +140,11 @@ using colorbyte = char;
struct fixparameters
{
lengthfix fp_fix_type;
alteration fp_quan_type;
int fp_jitter;
alteration fp_alter_type;
int fp_tighten_range;
int fp_quantize_range;
int fp_random_range;
int fp_jitter_range;
bool fp_align_left;
bool fp_reverse;
bool fp_reverse_in_place;
Expand Down Expand Up @@ -1833,9 +1837,9 @@ class sequence
void decrement_selected (midibyte status, midibyte /*control*/);
bool grow_selected (midipulse deltatick);
bool stretch_selected (midipulse deltatick);
bool randomize_selected (midibyte status, int range = -1);
bool randomize_selected_notes (int range = -1);
bool jitter_notes (int jitter = -1);
bool randomize (midibyte status, int range = -1, bool all = false);
bool randomize_notes (int range = -1, bool all = false);
bool jitter_notes (int jitter = -1, bool all = false);
bool mark_selected ();
void unpaint_all ();
void verify_and_link (bool wrap = false);
Expand Down Expand Up @@ -2022,8 +2026,8 @@ class sequence
return m_parent;
}

bool quantize_events (midibyte status, midibyte cc, int divide);
bool quantize_notes (int divide);
bool quantize_events (midibyte status, midibyte cc, int divide = 1);
bool quantize_notes (int divide = 1);
bool change_ppqn (int p);
void put_event_on_bus (const event & ev);
void reset_loop ();
Expand Down
68 changes: 67 additions & 1 deletion libseq66/src/midi/calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-11-07
* \updates 2024-11-23
* \updates 2024-12-05
* \license GNU GPLv2 or above
*
* This code was moved from the globals module so that other modules
Expand Down Expand Up @@ -1748,6 +1748,72 @@ up_snap (int S, midipulse p)
return result;
}

/**
* Comparison of floating-point values. We can tolerate a fairly large
* epsilon value in our MIDI code.
*
* See https://realtimecollisiondetection.net/blog/?p=89 for some gory
* details.
*
* if (Abs(x – y) <= EPSILON * Max(1.0f, Abs(x), Abs(y))
*/

static double s_epsilon = 0.0001;

static double
one_max (double a, double b)
{
double result = 1.0f;
if (std::fabs(a) > result)
result = std::fabs(a);

if (std::fabs(b) > result)
result = std::fabs(b);

return result;
}

/**
* Calculates x == y to within the epsilon, and returns true if that is so.
*/

bool
fequal (double x, double y)
{
return std::fabs(x - y) <= s_epsilon * one_max(std::fabs(x), std::fabs(y));
}

/**
* Calculates x != y to within the epsilon, and returns true if that is so.
*/

bool
fnotequal (double x, double y)
{
return std::fabs(x - y) > s_epsilon * one_max(std::fabs(x), std::fabs(y));
}

/**
* Calculates x < y and returns true if that is so.
*/

bool
flessthan (double x, double y)
{
return x < (y - s_epsilon * one_max(std::fabs(x), std::fabs(y)));
}

/**
* Calculates x > y and returns true if that is so.
*/

bool
fgreaterthan (double x, double y)
{
return x > (y + s_epsilon * one_max(std::fabs(x), std::fabs(y)));
}


} // namespace seq66

/*
Expand Down
Loading

0 comments on commit 005d5e1

Please sign in to comment.