From 208c781248335dda963f032fcb7e9427bb070244 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Wed, 14 Feb 2018 18:04:57 -0600 Subject: Auto-monitor == Cue for MIDI tracks. --- libs/ardour/ardour/audio_track.h | 2 ++ libs/ardour/ardour/midi_track.h | 1 + libs/ardour/ardour/route.h | 2 ++ libs/ardour/ardour/types.h | 1 + libs/ardour/audio_track.cc | 67 ++++++++++++++++++++++++++++++++++++++++ libs/ardour/midi_track.cc | 7 +++++ libs/ardour/route.cc | 64 ++------------------------------------ 7 files changed, 82 insertions(+), 62 deletions(-) diff --git a/libs/ardour/ardour/audio_track.h b/libs/ardour/ardour/audio_track.h index aecf5d2c9f..ee25837481 100644 --- a/libs/ardour/ardour/audio_track.h +++ b/libs/ardour/ardour/audio_track.h @@ -36,6 +36,8 @@ class LIBARDOUR_API AudioTrack : public Track AudioTrack (Session&, std::string name, TrackMode m = Normal); ~AudioTrack (); + MonitorState get_auto_monitoring_state () const; + void freeze_me (InterThreadInfo&); void unfreeze (); diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index abee445e01..d9a11540e4 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -125,6 +125,7 @@ public: boost::shared_ptr get_gui_feed_buffer () const; MonitorState monitoring_state () const; + MonitorState get_auto_monitoring_state () const; MidiBuffer const& immediate_event_buffer () const { return _immediate_event_buffer; } diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 138f8a9d71..bfd894375b 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -134,6 +134,8 @@ public: boost::shared_ptr monitoring_control() const { return _monitoring_control; } MonitorState monitoring_state () const; + virtual MonitorState get_auto_monitoring_state () const { return MonitoringSilence; } + virtual MeterState metering_state () const; /* these are the core of the API of a Route. see the protected sections as well */ diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 352c20ae9b..4bdab6b070 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -432,6 +432,7 @@ namespace ARDOUR { MonitoringSilence = 0x1, MonitoringInput = 0x2, MonitoringDisk = 0x4, + MonitoringCue = 0x6, }; enum MeterState { diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 12c2f1975b..46aff98122 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -64,6 +64,73 @@ 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 tape_machine_mode = Config->get_tape_machine_mode (); + 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 (tape_machine_mode) { + + return MonitoringDisk; + + } else { + + if (!roll && auto_input) { + return software_monitor ? MonitoringInput : MonitoringSilence; + } else { + return MonitoringDisk; + } + + } + } + + abort(); /* NOTREACHED */ + return MonitoringSilence; +} + int AudioTrack::set_state (const XMLNode& node, int version) { diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index a6a3b9f6f8..798bd1aef5 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -826,6 +826,13 @@ MidiTrack::monitoring_state () const 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 2c3c14c940..3b615c517b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -57,6 +57,7 @@ #include "ardour/delayline.h" #include "ardour/midi_buffer.h" #include "ardour/midi_port.h" +#include "ardour/midi_track.h" #include "ardour/monitor_control.h" #include "ardour/monitor_processor.h" #include "ardour/pannable.h" @@ -6007,67 +6008,6 @@ Route::monitoring_state () const break; } - /* 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 tape_machine_mode = Config->get_tape_machine_mode (); - 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 (tape_machine_mode) { - - return MonitoringDisk; - - } else { - - if (!roll && auto_input) { - return software_monitor ? MonitoringInput : MonitoringSilence; - } else { - return MonitoringDisk; - } - - } - } - - abort(); /* NOTREACHED */ - return MonitoringSilence; + return get_auto_monitoring_state(); } #endif -- cgit v1.2.3