diff options
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/export_handler.cc | 31 | ||||
-rw-r--r-- | libs/ardour/session_export.cc | 20 |
3 files changed, 46 insertions, 7 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f37746d6b2..7ae2fb4bd8 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -725,7 +725,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop boost::shared_ptr<ExportHandler> get_export_handler (); boost::shared_ptr<ExportStatus> get_export_status (); - int start_audio_export (framepos_t position, bool realtime = false, bool region_export = false); + int start_audio_export (framepos_t position, bool realtime = false, bool region_export = false, bool comensate_master_latency = false); PBD::Signal1<int, framecnt_t> ProcessExport; static PBD::Signal2<void,std::string, std::string> Exported; diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 3bdfdc9090..34333b488b 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -28,6 +28,7 @@ #include "ardour/audioengine.h" #include "ardour/audiofile_tagger.h" +#include "ardour/audio_port.h" #include "ardour/debug.h" #include "ardour/export_graph_builder.h" #include "ardour/export_timespan.h" @@ -192,6 +193,7 @@ ExportHandler::start_timespan () handle_duplicate_format_extensions(); bool realtime = current_timespan->realtime (); bool region_export = true; + bool incl_master_bus = false; for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) { // Filenames can be shared across timespans FileSpec & spec = it->second; @@ -204,6 +206,33 @@ ExportHandler::start_timespan () default: break; } +#if 1 // hack alert -- align master bus, compensate master latency + + /* there's no easier way to get this information here. + * Ports are configured in the PortExportChannelSelector GUI, + * This ExportHandler has no context of routes. + */ + boost::shared_ptr<Route> master_bus = session.master_out (); + if (master_bus) { + const PortSet& ps = master_bus->output ()->ports(); + + const ExportChannelConfiguration::ChannelList& channels = spec.channel_config->get_channels (); + for (ExportChannelConfiguration::ChannelList::const_iterator it = channels.begin(); it != channels.end(); ++it) { + + boost::shared_ptr <PortExportChannel> pep = boost::dynamic_pointer_cast<PortExportChannel> (*it); + if (!pep) { + continue; + } + PortExportChannel::PortSet const& ports = pep->get_ports (); + for (PortExportChannel::PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { + boost::shared_ptr<AudioPort> ap = (*it).lock(); + if (ps.contains (ap)) { + incl_master_bus = true; + } + } + } + } +#endif graph_builder->add_config (spec, realtime); } @@ -216,7 +245,7 @@ ExportHandler::start_timespan () session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process, this, _1)); process_position = current_timespan->get_start(); // TODO check if it's a RegionExport.. set flag to skip process_without_events() - session.start_audio_export (process_position, realtime, region_export); + session.start_audio_export (process_position, realtime, region_export, incl_master_bus); } void diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 23172838d0..7276d631dd 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -104,7 +104,7 @@ Session::pre_export () /** Called for each range that is being exported */ int -Session::start_audio_export (framepos_t position, bool realtime, bool region_export) +Session::start_audio_export (framepos_t position, bool realtime, bool region_export, bool comensate_master_latency) { if (!_exporting) { pre_export (); @@ -130,14 +130,24 @@ Session::start_audio_export (framepos_t position, bool realtime, bool region_exp /* "worst_track_latency" is the correct value for stem-exports * see to Route::add_export_point(), * - * for master-bus export, we'd need to add the master's latency. - * or actually longest-total-session-latency. + * For master-bus export, we also need to add the master's latency. + * (or actually longest-total-session-latency - worst-track-latency) + * to align the export to 00:00:00:00. * - * We can't use worst_playback_latency because that includes - * includes external latencies and would overcompensate. + * We must not use worst_playback_latency because that + * includes external (hardware) latencies and would overcompensate + * during file-export. + * + * (this is all still very [w]hacky. Individual Bus and Track outputs + * are not aligned but one can select them in the PortExportChannelSelector) */ _export_latency = worst_track_latency (); + boost::shared_ptr<Route> master = master_out (); + if (master && comensate_master_latency) { + _export_latency += master->signal_latency (); + } + if (region_export) { _export_latency = 0; } |