13
0

triggerbox: if any cues were recorded, remove all existing cue markers in transport-roll-range before adding new ones

This commit is contained in:
Paul Davis 2022-01-21 13:08:47 -07:00
parent fd3ddce80a
commit 2fa8c7cd42
3 changed files with 64 additions and 1 deletions

View File

@ -212,6 +212,8 @@ public:
bool clear_xrun_markers ();
bool clear_ranges ();
void clear_cue_markers (samplepos_t start, samplepos_t end);
void ripple (timepos_t const & at, timecnt_t const & distance, bool include_locked, bool notify);
XMLNode& get_state (void);

View File

@ -1622,3 +1622,54 @@ Locations::ripple (timepos_t const & at, timecnt_t const & distance, bool includ
changed(); /* EMIT SIGNAL */
}
}
void
Locations::clear_cue_markers (samplepos_t start, samplepos_t end)
{
TempoMap::SharedPtr tmap (TempoMap::use());
Temporal::Beats sb;
Temporal::Beats eb;
bool have_beats = false;
vector<Location*> r;
{
Glib::Threads::RWLock::WriterLock lm (_lock);
for (LocationList::iterator i = locations.begin(); i != locations.end(); ) {
if ((*i)->is_cue_marker()) {
Location* l (*i);
if (l->start().time_domain() == AudioTime) {
samplepos_t when = l->start().samples();
if (when >= start && when < end) {
i = locations.erase (i);
r.push_back (l);
continue;
}
} else {
if (!have_beats) {
sb = tmap->quarters_at (timepos_t (start));
eb = tmap->quarters_at (timepos_t (end));
have_beats = true;
}
Temporal::Beats when = l->start().beats();
if (when >= sb && when < eb) {
r.push_back (l);
i = locations.erase (i);
continue;
}
}
}
++i;
}
} /* end lock scope */
for (auto & l : r) {
removed (l); /* EMIT SIGNAL */
delete l;
}
}

View File

@ -1355,6 +1355,11 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
auditioner->cancel_audition ();
}
/* This must be called while _transport_sample still reflects where we stopped
*/
flush_cue_recording ();
if (did_record) {
begin_reversible_command (Operations::capture);
_have_captured = true;
@ -1476,7 +1481,6 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
clear_clicks();
unset_preroll_record_trim ();
flush_cue_recording ();
/* do this before seeking, because otherwise the tracks will do the wrong thing in seamless loop mode.
*/
@ -2084,9 +2088,15 @@ Session::actual_speed() const
void
Session::flush_cue_recording ()
{
if (!TriggerBox::cue_records.read_space()) {
return;
}
CueRecord cr;
TempoMap::SharedPtr tmap (TempoMap::use());
_locations->clear_cue_markers (_last_roll_location, _transport_sample);
while (TriggerBox::cue_records.read (&cr, 1) == 1) {
BBT_Time bbt = tmap->bbt_at (timepos_t (cr.when));
bbt = bbt.round_up_to_bar ();