Skip to content

Commit

Permalink
Interim safety check-in related to issue #100.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed Oct 14, 2022
1 parent c3ff5c5 commit 59f3b15
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 85 deletions.
14 changes: 11 additions & 3 deletions libseq66/include/midi/midibytes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ using jacktick = long;
* However, if you make this value unsigned, then perfroll won't show any
* notes in the sequence bars!!! Also, a number of manipulations of this
* type currently depend upon it being a signed value.
*
* JACK timestamps are in units of "frames":
*
* typedef uint32_t jack_nframes_t;
* #define JACK_MAX_FRAMES (4294967295U) // UINT32_MAX
*
* A long value is the same size in 32-bit code, and longer in 64-bit code,
* so we can use a midipulse to hold a frame number.
*/

using midipulse = long;

/**
* JACK encodes jack_time_t as a uint64_t (8-byte) value. We will use our own
* alias, of course. The unsigned long long type is guaranteed to be at least
* 8 bytes long on all platforms, but could be longer.
* JACK encodes jack_time_t as a uint64_t (8-byte) value. We will use our
* own alias, of course. The unsigned long long type is guaranteed to be at
* least 8 bytes long on all platforms, but could be longer.
*/

using microsec = uint64_t;
Expand Down
11 changes: 10 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 2022-10-10
* \updates 2022-10-12
* \license GNU GPLv2 or above
*
* This code was moved from the globals module so that other modules
Expand Down Expand Up @@ -1471,6 +1471,9 @@ midipulse
closest_snap (int S, midipulse p)
{
midipulse result = p;
if (p < 0)
return 0;

if (S > 0)
{
midipulse Sn0 = p - (p % S);
Expand All @@ -1486,6 +1489,9 @@ midipulse
down_snap (int S, midipulse p)
{
midipulse result = p;
if (p < 0)
return 0;

if (S > 0)
result = midipulse(p - (p % S));

Expand All @@ -1496,6 +1502,9 @@ midipulse
up_snap (int S, midipulse p)
{
midipulse result = p;
if (p < 0)
return 0;

if (S > 0)
{
midipulse Sn0 = p - (p % S);
Expand Down
5 changes: 1 addition & 4 deletions libseq66/src/play/sequence.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-07-24
* \updates 2022-10-10
* \updates 2022-10-12
* \license GNU GPLv2 or above
*
* The functionality of this class also includes handling some of the
Expand Down Expand Up @@ -3994,8 +3994,6 @@ sequence::set_trigger_offset (midipulse trigger_offset)
}
else
m_trigger_offset = trigger_offset;

// modify(false); /* issue #90 flag change w/o notify */
}

/**
Expand Down Expand Up @@ -5812,7 +5810,6 @@ sequence::change_ppqn (int p)
{
m_length = rescale_tick(m_length, p, m_ppqn);
m_ppqn = p;
// result = apply_length(0, p, 0);
result = apply_length(0, 0, 0); /* use new PPQN */
m_triggers.change_ppqn(p);
}
Expand Down
11 changes: 2 additions & 9 deletions seq_qt5/include/qseqeditframe64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@
* - qsmainwnd_height = 580, qsmainwnd.ui
*/

// #define QSEQEDITFRAME64_WIDTH 680
// #define QSEQEDITFRAME64_HEIGHT 920
// #define QSEQEDITFRAME64_BASE_HEIGHT 572
// #define QSEQEDITFRAME64_ROLL_HEIGHT 250

/*
* A few forward declarations. The Qt header files are in the cpp file.
*/
Expand Down Expand Up @@ -133,9 +128,7 @@ class qseqeditframe64 final : public qseqframe, protected performer::callbacks

qseqeditframe64
(
performer & p,
sequence & s, // int seqid
QWidget * parent,
performer & p, sequence & s, QWidget * parent,
bool shorter = false
);
virtual ~qseqeditframe64 ();
Expand Down Expand Up @@ -392,7 +385,7 @@ private slots:
qpatternfix * m_patternfix_wnd;

/**
* Menus for Tools and it Harmonic Transpose sub-menu.
* Menus for Tools and its Harmonic Transpose sub-menu.
* Menu for the Background Sequences button.
* Menu for the Event Data button.
* Menu for the "mini" Event Data button.
Expand Down
31 changes: 26 additions & 5 deletions seq_rtmidi/include/midi_jack_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2017-01-02
* \updates 2022-09-29
* \updates 2022-10-14
* \license See above.
*
* GitHub issue #165: enabled a build and run with no JACK support.
Expand Down Expand Up @@ -70,13 +70,13 @@ class midi_jack_data

static jack_nframes_t sm_jack_frame_rate; /* e.g. 48000 or 96000 Hz */
static jack_nframes_t sm_jack_start_frame; /* 0 or large number? */
static double sm_jack_ticks_per_beat; /* seems to be 10 * PPQN */
static double sm_jack_beats_per_minute; /* the BPM for the song */
static double sm_jack_frame_factor; /* frames per PPQN tick */

static jack_nframes_t sm_cycle_frame_count; /* progress callback param */
static jack_nframes_t sm_size_compensation; /* from ttymidi.c */
static jack_time_t sm_cycle_time_us; /* time between callbacks */
static jack_time_t sm_pulse_time_us; /* duration of a MIDI pulse */
static double sm_jack_ticks_per_beat; /* seems to be 10 * PPQN */
static double sm_jack_beats_per_minute; /* the BPM for the song */
static double sm_jack_frame_factor; /* frames per PPQN tick */

/**
* Holds the JACK sequencer client pointer so that it can be used by the
Expand Down Expand Up @@ -153,15 +153,26 @@ class midi_jack_data
jack_nframes_t F
);
static jack_nframes_t frame_offset (jack_nframes_t F, midipulse p);
static jack_nframes_t frame_offset
(
jack_nframes_t fbase, jack_nframes_t F, midipulse p
);
#if defined USE_JACK_TIME_OFFSET_FUNCTION
static jack_nframes_t time_offset
(
jack_nframes_t F, midipulse p,
jack_time_t Tpop, jack_time_t Tpush
);
#endif
static jack_nframes_t frame_estimate (midipulse p);
static double cycle (jack_nframes_t f, jack_nframes_t F);
static double pulse_cycle (midipulse p, jack_nframes_t F);

static double frame (midipulse p)
{
return double(p) * frame_factor();
}

static jack_nframes_t frame_rate ()
{
return sm_jack_frame_rate;
Expand Down Expand Up @@ -192,6 +203,11 @@ class midi_jack_data
return sm_cycle_frame_count;
}

static jack_nframes_t size_compensation ()
{
return sm_size_compensation;
}

static jack_time_t cycle_time_us ()
{
return sm_cycle_time_us;
Expand Down Expand Up @@ -232,6 +248,11 @@ class midi_jack_data
sm_cycle_frame_count = cfc;
}

static void size_compensation (jack_nframes_t szc)
{
sm_size_compensation = szc;
}

static void cycle_time_us (jack_time_t jt)
{
sm_cycle_time_us = jt;
Expand Down
12 changes: 9 additions & 3 deletions seq_rtmidi/include/rtmidi_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* \library seq66 application
* \author Gary P. Scavone; severe refactoring by Chris Ahlstrom
* \date 2016-11-20
* \updates 2022-09-30
* \updates 2022-10-14
* \license See above.
*
* The lack of hiding of these types within a class is a little to be
Expand Down Expand Up @@ -174,14 +174,15 @@ class midi_message

/**
* Holds the time at which the message was sent to the ring-buffer, in
* microseconds.
* microseconds. This is an unsigned 64-bit integer.
*/

microsec m_push_time_us;

/**
* Holds the (optional) timestamp of the MIDI message. Non-zero only
* in the JACK implementation at present.
* in the JACK implementation at present. It can also hold a JACK
* frame number. The caller can know this only by context at present.
*/

midipulse m_timestamp;
Expand Down Expand Up @@ -241,6 +242,11 @@ class midi_message
return m_push_time_us;
}

long push_time_ms () const
{
return long(m_push_time_us / 1000);
}

void push_time_us (microsec ptus)
{
m_push_time_us = ptus;
Expand Down
Loading

0 comments on commit 59f3b15

Please sign in to comment.