Desperate hack to align master-bus on export.

Another 90% solution which hopefully gives us another year :(
see comments Session::start_audio_export() for explanation.
This commit is contained in:
Robin Gareus 2016-10-25 22:33:37 +02:00
parent 24846f478b
commit 0e65852901
3 changed files with 46 additions and 7 deletions

View File

@ -725,7 +725,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
boost::shared_ptr<ExportHandler> get_export_handler (); boost::shared_ptr<ExportHandler> get_export_handler ();
boost::shared_ptr<ExportStatus> get_export_status (); 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; PBD::Signal1<int, framecnt_t> ProcessExport;
static PBD::Signal2<void,std::string, std::string> Exported; static PBD::Signal2<void,std::string, std::string> Exported;

View File

@ -28,6 +28,7 @@
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
#include "ardour/audiofile_tagger.h" #include "ardour/audiofile_tagger.h"
#include "ardour/audio_port.h"
#include "ardour/debug.h" #include "ardour/debug.h"
#include "ardour/export_graph_builder.h" #include "ardour/export_graph_builder.h"
#include "ardour/export_timespan.h" #include "ardour/export_timespan.h"
@ -192,6 +193,7 @@ ExportHandler::start_timespan ()
handle_duplicate_format_extensions(); handle_duplicate_format_extensions();
bool realtime = current_timespan->realtime (); bool realtime = current_timespan->realtime ();
bool region_export = true; bool region_export = true;
bool incl_master_bus = false;
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) { for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
// Filenames can be shared across timespans // Filenames can be shared across timespans
FileSpec & spec = it->second; FileSpec & spec = it->second;
@ -204,6 +206,33 @@ ExportHandler::start_timespan ()
default: default:
break; 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); 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)); session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process, this, _1));
process_position = current_timespan->get_start(); process_position = current_timespan->get_start();
// TODO check if it's a RegionExport.. set flag to skip process_without_events() // 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 void

View File

@ -104,7 +104,7 @@ Session::pre_export ()
/** Called for each range that is being exported */ /** Called for each range that is being exported */
int 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) { if (!_exporting) {
pre_export (); 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 /* "worst_track_latency" is the correct value for stem-exports
* see to Route::add_export_point(), * see to Route::add_export_point(),
* *
* for master-bus export, we'd need to add the master's latency. * For master-bus export, we also need to add the master's latency.
* or actually longest-total-session-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 * We must not use worst_playback_latency because that
* includes external latencies and would overcompensate. * 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 (); _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) { if (region_export) {
_export_latency = 0; _export_latency = 0;
} }