From a7a781971e146a6a98c0c55543b849c6adcd41f0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 15 Mar 2020 21:39:53 +0100 Subject: [PATCH] Change default stereo panner to equal power balance The stereo-width panner is not generally useful. In order to change the azimuth, width has to be reduced, which usually leads to comb-filter artifacts. Equal power stereo, also matches the default mono to stereo panner better than the stereo-width panner. Last but not least, control surfaces only have an azimuth control knob, without an easy way to reduce width, this leaves the panner insensitive. --- libs/ardour/panner_manager.cc | 79 ++++++++++++-------- libs/ardour/panner_shell.cc | 6 +- libs/panners/1in2out/panner_1in2out.cc | 2 +- libs/panners/2in2out/panner_2in2out.cc | 2 +- libs/panners/stereobalance/panner_balance.cc | 2 +- libs/panners/vbap/vbap.cc | 2 +- 6 files changed, 56 insertions(+), 37 deletions(-) diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index 79fbc2c094..17b4c50f85 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -29,6 +29,7 @@ #include "pbd/error.h" #include "pbd/compose.h" #include "pbd/file_utils.h" +#include "pbd/stateful.h" #include "pbd/stl_delete.h" #include "ardour/debug.h" @@ -68,13 +69,13 @@ PannerManager::instance () static bool panner_filter (const string& str, void */*arg*/) { #ifdef COMPILER_MSVC - /** - * Different build targets (Debug / Release etc) use different versions - * of the 'C' runtime (which can't be 'mixed & matched'). Therefore, in - * case the supplied search path contains multiple version(s) of a given - * panner module, only select the one(s) which match the current build - * target (otherwise, all hell will break loose !!) - */ + /** + * Different build targets (Debug / Release etc) use different versions + * of the 'C' runtime (which can't be 'mixed & matched'). Therefore, in + * case the supplied search path contains multiple version(s) of a given + * panner module, only select the one(s) which match the current build + * target (otherwise, all hell will break loose !!) + */ #if defined (_DEBUG) return str.length() > 12 && (str.find ("panner_") == 0) && (str.find ("D.dll") == (str.length() - 5)); #elif defined (RDC_BUILD) @@ -170,27 +171,34 @@ PannerInfo* PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri) { PannerInfo* rv = NULL; - PanPluginDescriptor* d; int32_t nin = in.n_audio(); int32_t nout = out.n_audio(); uint32_t priority = 0; /* look for user-preference -- check if channels match */ for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - d = &(*p)->descriptor; - if (d->panner_uri != uri) continue; - if (d->in != nin && d->in != -1) continue; - if (d->out != nout && d->out != -1) continue; + PanPluginDescriptor const& d ((*p)->descriptor); + if (d.panner_uri != uri) continue; + if (d.in != nin && d.in != -1) continue; + if (d.out != nout && d.out != -1) continue; return *p; } /* look for exact match first */ for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - d = &(*p)->descriptor; + PanPluginDescriptor const& d ((*p)->descriptor); - if (d->in == nin && d->out == nout && d->priority > priority) { - priority = d->priority; + /* backward compat */ + if (Stateful::loading_state_version < 6000 && d.panner_uri == "http://ardour.org/plugin/panner_2in2out") { + if (d.in == nin && d.out == nout) { + priority = 9999; + rv = *p; + } + } + + if (d.in == nin && d.out == nout && d.priority > priority) { + priority = d.priority; rv = *p; } } @@ -198,38 +206,45 @@ PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri /* no exact match, look for good fit on inputs and variable on outputs */ +#if 0 priority = 0; - for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - d = &(*p)->descriptor; + /* unused, so far Ardour only features 4 panners: + * in = 1 ; out = 2 // Mono to Stereo + * in = 2 ; out = 2 // Equal Power Stereo + * in = 2 ; out = 2 // Stereo Balance + * in = -1 ; out = -1 // VBAP + */ - if (d->in == nin && d->out == -1 && d->priority > priority) { - priority = d->priority; + for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { + PanPluginDescriptor const& d ((*p)->descriptor); + + if (d.in == nin && d.out == -1 && d.priority > priority) { + priority = d.priority; rv = *p; } } if (rv) { return rv; } /* no exact match, look for good fit on outputs and variable on inputs */ - priority = 0; for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - d = &(*p)->descriptor; + PanPluginDescriptor const& d ((*p)->descriptor); - if (d->in == -1 && d->out == nout && d->priority > priority) { - priority = d->priority; + if (d.in == -1 && d.out == nout && d.priority > priority) { + priority = d.priority; rv = *p; } } if (rv) { return rv; } +#endif /* no exact match, look for variable fit on inputs and outputs */ - priority = 0; for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - d = &(*p)->descriptor; + PanPluginDescriptor const& d ((*p)->descriptor); - if (d->in == -1 && d->out == -1 && d->priority > priority) { - priority = d->priority; + if (d.in == -1 && d.out == -1 && d.priority > priority) { + priority = d.priority; rv = *p; } } @@ -265,11 +280,11 @@ PannerManager::get_available_panners(uint32_t const a_in, uint32_t const a_out) /* get available panners for current configuration. */ for (list::const_iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - PanPluginDescriptor* d = &(*p)->descriptor; - if (d->in != -1 && d->in != in) continue; - if (d->out != -1 && d->out != out) continue; - if (d->in == -1 && d->out == -1 && out <= 2) continue; - panner_list.insert(std::pair(d->panner_uri,d->name)); + PanPluginDescriptor const& d ((*p)->descriptor); + if (d.in != -1 && d.in != in) continue; + if (d.out != -1 && d.out != out) continue; + if (d.in == -1 && d.out == -1 && out <= 2) continue; + panner_list.insert(std::pair(d.panner_uri,d.name)); } return panner_list; } diff --git a/libs/ardour/panner_shell.cc b/libs/ardour/panner_shell.cc index 92f2d8a40c..ac3a93c615 100644 --- a/libs/ardour/panner_shell.cc +++ b/libs/ardour/panner_shell.cc @@ -37,10 +37,11 @@ #include "pbd/cartesian.h" #include "pbd/convert.h" +#include "pbd/enumwriter.h" #include "pbd/error.h" #include "pbd/failed_constructor.h" +#include "pbd/stateful.h" #include "pbd/xml++.h" -#include "pbd/enumwriter.h" #include "evoral/Curve.h" @@ -126,6 +127,9 @@ PannerShell::configure_io (ChanCount in, ChanCount out) fatal << _("No panner found: check that panners are being discovered correctly during startup.") << endmsg; abort(); /*NOTREACHED*/ } + if (Stateful::loading_state_version < 6000 && pi->descriptor.in == 2) { + _user_selected_panner_uri = pi->descriptor.panner_uri; + } DEBUG_TRACE (DEBUG::Panning, string_compose (_("select panner: %1\n"), pi->descriptor.name.c_str())); diff --git a/libs/panners/1in2out/panner_1in2out.cc b/libs/panners/1in2out/panner_1in2out.cc index 0c5e1b99d1..64465a84d1 100644 --- a/libs/panners/1in2out/panner_1in2out.cc +++ b/libs/panners/1in2out/panner_1in2out.cc @@ -67,7 +67,7 @@ static PanPluginDescriptor _descriptor = { "http://ardour.org/plugin/panner_1in2out", "http://ardour.org/plugin/panner_1in2out#ui", 1, 2, - 10000, + 20, Panner1in2out::factory }; diff --git a/libs/panners/2in2out/panner_2in2out.cc b/libs/panners/2in2out/panner_2in2out.cc index de1833bd77..8c2cf9dd1e 100644 --- a/libs/panners/2in2out/panner_2in2out.cc +++ b/libs/panners/2in2out/panner_2in2out.cc @@ -65,7 +65,7 @@ static PanPluginDescriptor _descriptor = { "http://ardour.org/plugin/panner_2in2out", "http://ardour.org/plugin/panner_2in2out#ui", 2, 2, - 10000, + 20, Panner2in2out::factory }; diff --git a/libs/panners/stereobalance/panner_balance.cc b/libs/panners/stereobalance/panner_balance.cc index 2687646bfc..e9fa140e59 100644 --- a/libs/panners/stereobalance/panner_balance.cc +++ b/libs/panners/stereobalance/panner_balance.cc @@ -64,7 +64,7 @@ static PanPluginDescriptor _descriptor = { "http://ardour.org/plugin/panner_balance", "http://ardour.org/plugin/panner_balance#ui", 2, 2, - 2000, + 25, Pannerbalance::factory }; diff --git a/libs/panners/vbap/vbap.cc b/libs/panners/vbap/vbap.cc index 56aeffc935..35e0781d2d 100644 --- a/libs/panners/vbap/vbap.cc +++ b/libs/panners/vbap/vbap.cc @@ -55,7 +55,7 @@ static PanPluginDescriptor _descriptor = { "http://ardour.org/plugin/panner_vbap", "http://ardour.org/plugin/panner_vbap#ui", -1, -1, - 1000, + 10, VBAPanner::factory };