Rework preroll-rec API:

* rename: indicate that recording happens after preroll, punch-in
* move API into libardour: rec+roll (no separate setup, seek, roll APIs)
This commit is contained in:
Robin Gareus 2017-01-19 12:57:47 +01:00
parent ebdf3de598
commit e959a762b5
7 changed files with 40 additions and 28 deletions

View File

@ -998,11 +998,14 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
void maybe_update_session_range (framepos_t, framepos_t);
void request_preroll_record (framepos_t);
framepos_t preroll_record_in () const { return _preroll_record_in; }
bool preroll_record_enabled () const { return _preroll_record_in >= 0; }
/* preroll */
framecnt_t preroll_samples (framepos_t) const;
void request_preroll_record_punch (framepos_t start, framecnt_t preroll);
framepos_t preroll_record_punch_pos () const { return _preroll_record_punch_pos; }
bool preroll_record_punch_enabled () const { return _preroll_record_punch_pos >= 0; }
/* temporary hacks to allow selection to be pushed from GUI into backend.
Whenever we move the selection object into libardour, these will go away.
*/
@ -1920,8 +1923,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
Evoral::Range<framepos_t> _range_selection;
Evoral::Range<framepos_t> _object_selection;
void unset_preroll_record ();
framepos_t _preroll_record_in;
void unset_preroll_record_punch ();
framepos_t _preroll_record_punch_pos;
/* main outs */
uint32_t main_outs;

View File

@ -1923,8 +1923,8 @@ AudioDiskstream::get_state ()
Location* pi;
if (_session.preroll_record_enabled ()) {
snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_in ());
if (_session.preroll_record_punch_enabled ()) {
snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_punch_pos ());
} else if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) {
snprintf (buf, sizeof (buf), "%" PRId64, pi->start());
} else {

View File

@ -367,7 +367,7 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
adjust_capture_position = 0;
if (nominally_recording || (re && was_recording && _session.get_record_enabled() && (_session.config.get_punch_in() || _session.preroll_record_enabled()))) {
if (nominally_recording || (re && was_recording && _session.get_record_enabled() && (_session.config.get_punch_in() || _session.preroll_record_punch_enabled()))) {
Evoral::OverlapType ot = Evoral::coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes);
// XXX should this be transport_frame + nframes - 1 ? coverage() expects its parameter ranges to include their end points
@ -1238,8 +1238,8 @@ MidiDiskstream::get_state ()
Location* pi;
if (_session.preroll_record_enabled ()) {
snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_in ());
if (_session.preroll_record_punch_enabled ()) {
snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_punch_pos ());
} else if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) {
snprintf (buf, sizeof (buf), "%" PRId64, pi->start());
} else {

View File

@ -304,7 +304,7 @@ Session::Session (AudioEngine &eng,
, _play_range (false)
, _range_selection (-1,-1)
, _object_selection (-1,-1)
, _preroll_record_in (-1)
, _preroll_record_punch_pos (-1)
, main_outs (0)
, first_file_data_format_reset (true)
, first_file_header_format_reset (true)
@ -2001,7 +2001,7 @@ Session::disable_record (bool rt_context, bool force)
if (!rt_context) {
remove_pending_capture_state ();
}
unset_preroll_record ();
unset_preroll_record_punch ();
}
}
@ -2039,7 +2039,7 @@ Session::maybe_enable_record (bool rt_context)
}
if (_transport_speed) {
if (!config.get_punch_in() && !preroll_record_enabled ()) {
if (!config.get_punch_in() && !preroll_record_punch_enabled ()) {
enable_record ();
}
} else {

View File

@ -1156,7 +1156,7 @@ Session::process_event (SessionEvent* ev)
case SessionEvent::PunchIn:
// cerr << "PunchIN at " << transport_frame() << endl;
if (config.get_punch_in() && record_status() == Enabled && !preroll_record_enabled()) {
if (config.get_punch_in() && record_status() == Enabled && !preroll_record_punch_enabled()) {
enable_record ();
}
remove = false;
@ -1165,7 +1165,7 @@ Session::process_event (SessionEvent* ev)
case SessionEvent::PunchOut:
// cerr << "PunchOUT at " << transport_frame() << endl;
if (config.get_punch_out() && !preroll_record_enabled()) {
if (config.get_punch_out() && !preroll_record_punch_enabled()) {
step_back_from_record ();
}
remove = false;
@ -1173,7 +1173,7 @@ Session::process_event (SessionEvent* ev)
break;
case SessionEvent::RecordStart:
if (preroll_record_enabled() && record_status() == Enabled) {
if (preroll_record_punch_enabled() && record_status() == Enabled) {
enable_record ();
}
remove = false;
@ -1279,7 +1279,7 @@ Session::compute_stop_limit () const
return max_framepos;
}
if (preroll_record_enabled ()) {
if (preroll_record_punch_enabled ()) {
return max_framepos;
}

View File

@ -162,24 +162,32 @@ Session::force_locate (framepos_t target_frame, bool with_roll)
}
void
Session::unset_preroll_record ()
Session::unset_preroll_record_punch ()
{
if (_preroll_record_in >= 0) {
remove_event (_preroll_record_in, SessionEvent::RecordStart);
if (_preroll_record_punch_pos >= 0) {
remove_event (_preroll_record_punch_pos, SessionEvent::RecordStart);
}
_preroll_record_in = -1;
_preroll_record_punch_pos = -1;
}
void
Session::request_preroll_record (framepos_t rec_in)
Session::request_preroll_record_punch (framepos_t rec_in, framecnt_t preroll)
{
unset_preroll_record ();
_preroll_record_in = rec_in;
if (_preroll_record_in >= 0) {
replace_event (SessionEvent::RecordStart, _preroll_record_in);
if (actively_recording ()) {
return;
}
unset_preroll_record_punch ();
framepos_t start = std::max ((framepos_t)0, rec_in - preroll);
_preroll_record_punch_pos = rec_in;
if (_preroll_record_punch_pos >= 0) {
replace_event (SessionEvent::RecordStart, _preroll_record_punch_pos);
config.set_punch_in (false);
config.set_punch_out (false);
}
maybe_enable_record ();
request_locate (start, true);
set_requested_return_frame (rec_in);
}
void
@ -1604,7 +1612,7 @@ Session::start_transport ()
switch (record_status()) {
case Enabled:
if (!config.get_punch_in() && !preroll_record_enabled()) {
if (!config.get_punch_in() && !preroll_record_punch_enabled()) {
enable_record ();
}
break;

View File

@ -957,7 +957,7 @@ Track::monitoring_state () const
* enabled and those where it is not.
*/
if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_in () >= 0) {
if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_punch_enabled ()) {
session_rec = _session.actively_recording ();
} else {
session_rec = _session.get_record_enabled();