13
0

API changes for clip recording in TriggerBox

Also, disarm all triggers when track-level rec-enable is disabled
This commit is contained in:
Paul Davis 2024-10-14 21:42:43 -06:00
parent 774f5f49da
commit 7608d4ade2
2 changed files with 21 additions and 7 deletions

View File

@ -783,6 +783,7 @@ struct SlotArmInfo {
samplepos_t start_samples;
Temporal::Beats end_beats;
samplepos_t end_samples;
Temporal::timecnt_t captured;
RTMidiBufferBeats* midi_buf;
AudioTrigger::AudioData audio_buf;
RubberBand::RubberBandStretcher* stretcher;
@ -940,7 +941,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro
void dump (std::ostream &) const;
PBD::Signal0<void> Captured;
PBD::Signal1<void,timecnt_t> Captured;
private:
struct Requests {

View File

@ -3556,6 +3556,12 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch
ai->start_samples = t_samples;
ai->start_beats = t_beats;
if (_data_type == DataType::AUDIO) {
ai->captured = timecnt_t (timepos_t (0), timepos_t (0));
} else {
ai->captured = timecnt_t::from_ticks (0, timepos_t (Beats()));
}
_arm_info = ai;
}
@ -3650,10 +3656,11 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
AudioBuffer& buf (bufs.get_audio (n));
ai->audio_buf.append (buf.data() + offset, nframes, n);
}
ai->captured += timecnt_t (start_sample, timepos_t (ai->start_samples));
}
n_buffers = bufs.count().n_midi();
bool send_signal = false;
if (n_buffers) {
@ -3694,17 +3701,16 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
*/
ai->midi_buf->write (tmap->quarters_at_sample (event_time) - ai->start_beats, ev.event_type(), ev.size(), ev.buffer());
_gui_feed_fifo.write (event_time - ai->start_samples, Evoral::MIDI_EVENT, ev.size(), ev.buffer());
send_signal = true;
}
}
}
}
if (send_signal) {
std::cerr << "SEND CAPTURED\n";
Captured(); /* EMIT SIGNAL */
timecnt_t dur = tmap->convert_duration (timecnt_t (nframes), timepos_t (start_sample), Temporal::BeatTime);
ai->captured += dur;
}
Captured (ai->captured); /* EMIT SIGNAL */
if (reached_end) {
finish_recording (bufs);
}
@ -3714,6 +3720,13 @@ void
TriggerBox::set_record_enabled (bool yn)
{
_record_state = yn ? Enabled : Disabled;
if (_record_state == Disabled) {
for (auto & trig : all_triggers) {
trig->disarm ();
}
}
RecEnableChanged (); /* EMIT SIGNAL */
}