diff options
author | Robin Gareus <robin@gareus.org> | 2017-01-18 15:15:48 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-01-18 15:15:48 +0100 |
commit | efd10abdfb54bb1dd56de0aa01278805f5fbf332 (patch) | |
tree | d25ed31bdd75b77842af782b6e97738e663ca264 | |
parent | cf31233cd1503f7f3818c6bbeb6f5bd427144f80 (diff) |
Implement record with preroll
-rw-r--r-- | libs/ardour/ardour/session.h | 7 | ||||
-rw-r--r-- | libs/ardour/ardour/session_event.h | 1 | ||||
-rw-r--r-- | libs/ardour/audio_diskstream.cc | 4 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 6 | ||||
-rw-r--r-- | libs/ardour/session.cc | 5 | ||||
-rw-r--r-- | libs/ardour/session_process.cc | 15 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 23 | ||||
-rw-r--r-- | libs/ardour/track.cc | 2 |
8 files changed, 55 insertions, 8 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f9172c5d6c..49ee8cbb7d 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -998,6 +998,10 @@ 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; } + /* temporary hacks to allow selection to be pushed from GUI into backend. Whenever we move the selection object into libardour, these will go away. */ @@ -1915,6 +1919,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; + /* main outs */ uint32_t main_outs; diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index 8bb160b90e..fe109a21f8 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -47,6 +47,7 @@ public: SetLoop, PunchIn, PunchOut, + RecordStart, RangeStop, RangeLocate, Overwrite, diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index c33b56f984..f157d81ada 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -1923,7 +1923,9 @@ AudioDiskstream::get_state () Location* pi; - if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { + if (_session.preroll_record_enabled ()) { + snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_in ()); + } else if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { snprintf (buf, sizeof (buf), "%" PRId64, pi->start()); } else { snprintf (buf, sizeof (buf), "%" PRId64, _session.transport_frame()); diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 13c0cdd9e8..9e784cbd38 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -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())) { + if (nominally_recording || (re && was_recording && _session.get_record_enabled() && (_session.config.get_punch_in() || _session.preroll_record_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,7 +1238,9 @@ MidiDiskstream::get_state () Location* pi; - if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { + if (_session.preroll_record_enabled ()) { + snprintf (buf, sizeof (buf), "%" PRId64, _session.preroll_record_in ()); + } else if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { snprintf (buf, sizeof (buf), "%" PRId64, pi->start()); } else { snprintf (buf, sizeof (buf), "%" PRId64, _session.transport_frame()); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 34e4c52e9f..27a3e63112 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -304,6 +304,7 @@ Session::Session (AudioEngine &eng, , _play_range (false) , _range_selection (-1,-1) , _object_selection (-1,-1) + , _preroll_record_in (-1) , main_outs (0) , first_file_data_format_reset (true) , first_file_header_format_reset (true) @@ -781,6 +782,7 @@ Session::destroy () case SessionEvent::Skip: case SessionEvent::PunchIn: case SessionEvent::PunchOut: + case SessionEvent::RecordStart: case SessionEvent::StopOnce: case SessionEvent::RangeStop: case SessionEvent::RangeLocate: @@ -1999,6 +2001,7 @@ Session::disable_record (bool rt_context, bool force) if (!rt_context) { remove_pending_capture_state (); } + unset_preroll_record (); } } @@ -2036,7 +2039,7 @@ Session::maybe_enable_record (bool rt_context) } if (_transport_speed) { - if (!config.get_punch_in()) { + if (!config.get_punch_in() && !preroll_record_enabled ()) { enable_record (); } } else { diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 9be7007d19..7e802b7d92 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -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) { + if (config.get_punch_in() && record_status() == Enabled && !preroll_record_enabled()) { enable_record (); } remove = false; @@ -1165,13 +1165,21 @@ Session::process_event (SessionEvent* ev) case SessionEvent::PunchOut: // cerr << "PunchOUT at " << transport_frame() << endl; - if (config.get_punch_out()) { + if (config.get_punch_out() && !preroll_record_enabled()) { step_back_from_record (); } remove = false; del = false; break; + case SessionEvent::RecordStart: + if (preroll_record_enabled() && record_status() == Enabled) { + enable_record (); + } + remove = false; + del = false; + break; + case SessionEvent::StopOnce: if (!non_realtime_work_pending()) { _clear_event_type (SessionEvent::StopOnce); @@ -1271,6 +1279,9 @@ Session::compute_stop_limit () const return max_framepos; } + if (preroll_record_enabled ()) { + return max_framepos; + } bool const punching_in = (config.get_punch_in () && _locations->auto_punch_location()); bool const punching_out = (config.get_punch_out () && _locations->auto_punch_location()); diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index a6d25f05ab..8a57456dde 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -162,6 +162,27 @@ Session::force_locate (framepos_t target_frame, bool with_roll) } void +Session::unset_preroll_record () +{ + if (_preroll_record_in >= 0) { + remove_event (_preroll_record_in, SessionEvent::RecordStart); + } + _preroll_record_in = -1; +} + +void +Session::request_preroll_record (framepos_t rec_in) +{ + unset_preroll_record (); + _preroll_record_in = rec_in; + if (_preroll_record_in >= 0) { + replace_event (SessionEvent::RecordStart, _preroll_record_in); + config.set_punch_in (false); + config.set_punch_out (false); + } +} + +void Session::request_play_loop (bool yn, bool change_transport_roll) { if (_slave && yn) { @@ -1583,7 +1604,7 @@ Session::start_transport () switch (record_status()) { case Enabled: - if (!config.get_punch_in()) { + if (!config.get_punch_in() && !preroll_record_enabled()) { enable_record (); } break; diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index cb23943f2a..3f29a45291 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -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()) { + if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_in () >= 0) { session_rec = _session.actively_recording (); } else { session_rec = _session.get_record_enabled(); |