Adjust resampler quality when sample-rate mismatches
This also ensures that engine/session resampling is possible when the config `port-resampler-quality` is 0.
This commit is contained in:
parent
d89162745f
commit
72995741bb
@ -1486,6 +1486,8 @@ private:
|
||||
void send_latency_compensation_change ();
|
||||
void update_send_delaylines ();
|
||||
|
||||
void setup_engine_resampling ();
|
||||
|
||||
void ensure_buffers (ChanCount howmany = ChanCount::ZERO);
|
||||
|
||||
void process_scrub (pframes_t);
|
||||
|
@ -711,26 +711,29 @@ Port::set_state (const XMLNode& node, int)
|
||||
/* static */ bool
|
||||
Port::setup_resampler (uint32_t q)
|
||||
{
|
||||
/* configure at application start (Ardour::init) */
|
||||
if (port_manager && port_manager->session_port_count() > 0) {
|
||||
return false;
|
||||
}
|
||||
uint32_t cur_quality = _resampler_quality;
|
||||
|
||||
if (q == 0) {
|
||||
/* no vari-speed */
|
||||
_resampler_quality = 0;
|
||||
_resampler_latency = 0;
|
||||
return true;
|
||||
} else {
|
||||
/* range constrained in VMResampler::setup */
|
||||
if (q < 8) {
|
||||
q = 8;
|
||||
}
|
||||
if (q > 96) {
|
||||
q = 96;
|
||||
}
|
||||
_resampler_quality = q;
|
||||
_resampler_latency = q - 1;
|
||||
}
|
||||
// range constrained in VMResampler::setup
|
||||
if (q < 8) {
|
||||
q = 8;
|
||||
|
||||
if (port_manager && cur_quality != _resampler_quality) {
|
||||
Glib::Threads::Mutex::Lock lm (port_manager->process_lock ());
|
||||
port_manager->reinit (true);
|
||||
return false;
|
||||
}
|
||||
if (q > 96) {
|
||||
q = 96;
|
||||
}
|
||||
_resampler_quality = q;
|
||||
_resampler_latency = q - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -565,6 +565,7 @@ Session::immediately_post_engine ()
|
||||
* know that the engine is running, but before we either create a
|
||||
* session or set state for an existing one.
|
||||
*/
|
||||
Port::setup_resampler (Config->get_port_resampler_quality ());
|
||||
|
||||
_process_graph.reset (new Graph (*this));
|
||||
_rt_tasklist.reset (new RTTaskList (_process_graph));
|
||||
@ -6727,11 +6728,22 @@ Session::missing_filesources (DataType dt) const
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
Session::setup_engine_resampling ()
|
||||
{
|
||||
if (_base_sample_rate != AudioEngine::instance()->sample_rate ()) {
|
||||
Port::setup_resampler (std::max<uint32_t>(65, Config->get_port_resampler_quality ()));
|
||||
} else {
|
||||
Port::setup_resampler (Config->get_port_resampler_quality ());
|
||||
}
|
||||
Port::set_engine_ratio (_base_sample_rate, AudioEngine::instance()->sample_rate ());
|
||||
}
|
||||
|
||||
void
|
||||
Session::initialize_latencies ()
|
||||
{
|
||||
block_processing ();
|
||||
Port::set_engine_ratio (_base_sample_rate, AudioEngine::instance()->sample_rate ());
|
||||
setup_engine_resampling ();
|
||||
update_latency (false);
|
||||
update_latency (true);
|
||||
unblock_processing ();
|
||||
|
@ -1716,6 +1716,11 @@ Session::set_state (const XMLNode& node, int version)
|
||||
|
||||
if (_base_sample_rate != _engine.sample_rate ()) {
|
||||
set_sample_rate (_base_sample_rate);
|
||||
/* post_engine_init() calls initialize_latencies()
|
||||
* which sets up resampling. However by that time all session
|
||||
* ports will exist and would be need to be reinitialized.
|
||||
*/
|
||||
setup_engine_resampling ();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user