diff --git a/libs/ardour/ardour/audio_track.h b/libs/ardour/ardour/audio_track.h index 6b8f01986c..294a0495e7 100644 --- a/libs/ardour/ardour/audio_track.h +++ b/libs/ardour/ardour/audio_track.h @@ -38,7 +38,7 @@ class LIBARDOUR_API AudioTrack : public Track AudioTrack (Session&, std::string name = "", TrackMode m = Normal); ~AudioTrack (); - MonitorState get_auto_monitoring_state () const; + MonitorState get_input_monitoring_state (bool recording, bool talkback) const; void freeze_me (InterThreadInfo&); void unfreeze (); diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 6e98267b26..371c82b36a 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -128,7 +128,7 @@ public: boost::shared_ptr get_gui_feed_buffer () const; MonitorState monitoring_state () const; - MonitorState get_auto_monitoring_state () const; + MonitorState get_input_monitoring_state (bool recording, bool talkback) const; MidiBuffer const& immediate_event_buffer () const { return _immediate_event_buffer; } MidiRingBuffer& immediate_events () { return _immediate_events; } diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index b935a5a3de..bbf0fd2273 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -139,7 +139,7 @@ public: boost::shared_ptr monitoring_control() const { return _monitoring_control; } MonitorState monitoring_state () const; - virtual MonitorState get_auto_monitoring_state () const { return MonitoringSilence; } + virtual MonitorState get_input_monitoring_state (bool recording, bool talkback) const { return MonitoringSilence; } /* these are the core of the API of a Route. see the protected sections as well */ diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 1b0ed67ffd..68a9951c70 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -70,72 +70,6 @@ AudioTrack::~AudioTrack () } } -MonitorState -AudioTrack::get_auto_monitoring_state () const -{ - /* This is an implementation of the truth table in doc/monitor_modes.pdf; - I don't think it's ever going to be too pretty too look at. - */ - - bool const roll = _session.transport_rolling (); - bool const track_rec = _disk_writer->record_enabled (); - bool const auto_input = _session.config.get_auto_input (); - bool const software_monitor = Config->get_monitoring_model() == SoftwareMonitoring; - bool const auto_input_does_talkback = Config->get_auto_input_does_talkback (); - bool session_rec; - - /* I suspect that just use actively_recording() is good enough all the - * time, but just to keep the semantics the same as they were before - * sept 26th 2012, we differentiate between the cases where punch is - * enabled and those where it is not. - * - * rg: sept 30 2017: Above is not the case: punch-in/out location is - * global session playhead position. - * When this method is called from process_output_buffers() we need - * to use delay-compensated route's process-position. - * - * NB. Disk reader/writer may also be offset by a same amount of time. - * - * Also keep in mind that _session.transport_rolling() is false during - * pre-roll but the disk already produces output. - * - * TODO: FIXME - */ - - if (_session.config.get_punch_in() || _session.config.get_punch_out()) { - session_rec = _session.actively_recording (); - } else { - session_rec = _session.get_record_enabled(); - } - - if (track_rec) { - - if (!session_rec && roll && auto_input) { - return MonitoringDisk; - } else { - return software_monitor ? MonitoringInput : MonitoringSilence; - } - - } else { - - if (auto_input_does_talkback) { - - if (!roll && auto_input) { - return software_monitor ? MonitoringInput : MonitoringSilence; - } else { - return MonitoringDisk; - } - - } else { - - return MonitoringDisk; - } - } - - abort(); /* NOTREACHED */ - return MonitoringSilence; -} - int AudioTrack::set_state (const XMLNode& node, int version) { @@ -249,6 +183,16 @@ AudioTrack::set_state_part_two () } } +MonitorState +AudioTrack::get_input_monitoring_state (bool recording, bool talkback) const +{ + if (Config->get_monitoring_model() == SoftwareMonitoring && (recording || talkback)) { + return MonitoringInput; + } else { + return MonitoringSilence; + } +} + int AudioTrack::export_stuff (BufferSet& buffers, samplepos_t start, samplecnt_t nframes, boost::shared_ptr endpoint, bool include_endpoint, bool for_export, bool for_freeze, diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 81c954bd33..2a315d1035 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -138,6 +138,18 @@ MidiTrack::can_be_record_enabled () return Track::can_be_record_enabled (); } +MonitorState +MidiTrack::get_input_monitoring_state (bool recording, bool talkback) const +{ + if (!_session.config.get_layered_record_mode () && (recording || talkback)) { + return MonitoringCue; + } else if (!_session.config.get_layered_record_mode () || recording || talkback) { + return MonitoringInput; + } else { + return MonitoringSilence; + } +} + int MidiTrack::set_state (const XMLNode& node, int version) { @@ -859,18 +871,12 @@ MidiTrack::monitoring_state () const { MonitorState ms = Track::monitoring_state(); if (ms == MonitoringSilence) { + /* MIDI always monitor input as fallback */ return MonitoringInput; } return ms; } -MonitorState -MidiTrack::get_auto_monitoring_state () const -{ - //if we are a midi track, we ignore auto_input, tape_mode, etc etc. "Auto" will monitor Disk+In - return MonitoringCue; -} - void MidiTrack::filter_input (BufferSet& bufs) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 68a968aa6b..1a05170b95 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -6132,10 +6132,15 @@ Route::set_loop (Location* l) } } +static inline MonitorState +operator| (const MonitorState& a, const MonitorState& b) { + return static_cast (static_cast (a) | static_cast (b)); +} + MonitorState Route::monitoring_state () const { - if (!_disk_reader) { + if (!_disk_reader || !_monitoring_control) { return MonitoringInput; } @@ -6168,6 +6173,69 @@ Route::monitoring_state () const break; } - return get_auto_monitoring_state(); + /* This is an implementation of the truth table in doc/monitor_modes.pdf; + * I don't think it's ever going to be too pretty too look at. + */ + + bool const roll = _session.transport_rolling (); + bool const auto_input = _session.config.get_auto_input (); + bool const track_rec = _disk_writer->record_enabled (); + bool session_rec; + + bool const software_monitor = Config->get_monitoring_model() == SoftwareMonitoring; + bool const auto_input_does_talkback = Config->get_auto_input_does_talkback (); + + + /* I suspect that just use actively_recording() is good enough all the + * time, but just to keep the semantics the same as they were before + * sept 26th 2012, we differentiate between the cases where punch is + * enabled and those where it is not. + * + * rg: sept 30 2017: Above is not the case: punch-in/out location is + * global session playhead position. + * When this method is called from process_output_buffers() we need + * to use delay-compensated route's process-position. + * + * NB. Disk reader/writer may also be offset by a same amount of time. + * + * Also keep in mind that _session.transport_rolling() is false during + * pre-roll but the disk already produces output. + * + * TODO: FIXME + */ + + if (_session.config.get_punch_in() || _session.config.get_punch_out()) { + session_rec = _session.actively_recording (); + } else { + session_rec = _session.get_record_enabled(); + } + + if (track_rec) { + + if (!session_rec && roll && auto_input) { + return MonitoringDisk | get_input_monitoring_state (false, false); + } else { + /* recording */ + return get_input_monitoring_state (true, false); + } + + } else { + + if (auto_input_does_talkback) { + + if (!roll && auto_input) { + return get_input_monitoring_state (false, true); + } else { + return MonitoringDisk | get_input_monitoring_state (false, false); + } + + } else { + /* tape-machine-mode */ + return MonitoringDisk | get_input_monitoring_state (false, false); + } + } + + abort(); /* NOTREACHED */ + return MonitoringSilence; }