Skip to content

Commit

Permalink
Rename the cubic resampler to gaussian
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Apr 7, 2024
1 parent 54ccfd1 commit 3ad68aa
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
6 changes: 3 additions & 3 deletions al/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ template<> struct ResamplerName<Resampler::Point>
{ static constexpr const ALchar *Get() noexcept { return "Nearest"; } };
template<> struct ResamplerName<Resampler::Linear>
{ static constexpr const ALchar *Get() noexcept { return "Linear"; } };
template<> struct ResamplerName<Resampler::Cubic>
{ static constexpr const ALchar *Get() noexcept { return "Cubic"; } };
template<> struct ResamplerName<Resampler::Gaussian>
{ static constexpr const ALchar *Get() noexcept { return "4-point Gaussian"; } };
template<> struct ResamplerName<Resampler::FastBSinc12>
{ static constexpr const ALchar *Get() noexcept { return "11th order Sinc (fast)"; } };
template<> struct ResamplerName<Resampler::BSinc12>
Expand All @@ -100,7 +100,7 @@ const ALchar *GetResamplerName(const Resampler rtype)
{
HANDLE_RESAMPLER(Resampler::Point);
HANDLE_RESAMPLER(Resampler::Linear);
HANDLE_RESAMPLER(Resampler::Cubic);
HANDLE_RESAMPLER(Resampler::Gaussian);
HANDLE_RESAMPLER(Resampler::FastBSinc12);
HANDLE_RESAMPLER(Resampler::BSinc12);
HANDLE_RESAMPLER(Resampler::FastBSinc24);
Expand Down
4 changes: 2 additions & 2 deletions alc/alu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ inline ResamplerFunc SelectResampler(Resampler resampler, uint increment)
return Resample_<LerpTag,SSE2Tag>;
#endif
return Resample_<LerpTag,CTag>;
case Resampler::Cubic:
case Resampler::Gaussian:
#ifdef HAVE_NEON
if((CPUCapFlags&CPU_CAP_NEON))
return Resample_<CubicTag,NEONTag>;
Expand Down Expand Up @@ -268,7 +268,7 @@ ResamplerFunc PrepareResampler(Resampler resampler, uint increment, InterpState
case Resampler::Point:
case Resampler::Linear:
break;
case Resampler::Cubic:
case Resampler::Gaussian:
state->emplace<CubicState>(al::span{gGaussianFilter.mTable});
break;
case Resampler::FastBSinc12:
Expand Down
2 changes: 1 addition & 1 deletion alsoftrc.sample
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
# Selects the default resampler used when mixing sources. Valid values are:
# point - nearest sample, no interpolation
# linear - extrapolates samples using a linear slope between samples
# cubic - extrapolates samples using a 4-point Gaussian filter
# gaussian - extrapolates samples using a 4-point Gaussian filter
# bsinc12 - extrapolates samples using a band-limited Sinc filter (varying
# between 12 and 24 points, with anti-aliasing)
# fast_bsinc12 - same as bsinc12, except without interpolation between down-
Expand Down
2 changes: 1 addition & 1 deletion core/mixer/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */
enum class Resampler : std::uint8_t {
Point,
Linear,
Cubic,
Gaussian,
FastBSinc12,
BSinc12,
FastBSinc24,
Expand Down
17 changes: 9 additions & 8 deletions core/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,25 @@ void Voice::InitMixer(std::optional<std::string> resopt)
ResamplerEntry{"none"sv, Resampler::Point},
ResamplerEntry{"point"sv, Resampler::Point},
ResamplerEntry{"linear"sv, Resampler::Linear},
ResamplerEntry{"cubic"sv, Resampler::Cubic},
ResamplerEntry{"gaussian"sv, Resampler::Gaussian},
ResamplerEntry{"bsinc12"sv, Resampler::BSinc12},
ResamplerEntry{"fast_bsinc12"sv, Resampler::FastBSinc12},
ResamplerEntry{"bsinc24"sv, Resampler::BSinc24},
ResamplerEntry{"fast_bsinc24"sv, Resampler::FastBSinc24},
};

std::string_view resampler{*resopt};
if(al::case_compare(resampler, "bsinc"sv) == 0)
if(al::case_compare(resampler, "cubic"sv) == 0
|| al::case_compare(resampler, "sinc4"sv) == 0
|| al::case_compare(resampler, "sinc8"sv) == 0)
{
WARN("Resampler option \"%s\" is deprecated, using bsinc12\n", resopt->c_str());
resampler = "bsinc12"sv;
WARN("Resampler option \"%s\" is deprecated, using gaussian\n", resopt->c_str());
resampler = "gaussian"sv;
}
else if(al::case_compare(resampler, "sinc4"sv) == 0
|| al::case_compare(resampler, "sinc8"sv) == 0)
else if(al::case_compare(resampler, "bsinc"sv) == 0)
{
WARN("Resampler option \"%s\" is deprecated, using cubic\n", resopt->c_str());
resampler = "cubic"sv;
WARN("Resampler option \"%s\" is deprecated, using bsinc12\n", resopt->c_str());
resampler = "bsinc12"sv;
}

auto iter = std::find_if(ResamplerList.begin(), ResamplerList.end(),
Expand Down
2 changes: 1 addition & 1 deletion core/voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ struct Voice {
static void InitMixer(std::optional<std::string> resopt);
};

inline Resampler ResamplerDefault{Resampler::Cubic};
inline Resampler ResamplerDefault{Resampler::Gaussian};

#endif /* CORE_VOICE_H */
12 changes: 6 additions & 6 deletions utils/alsoft-config/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ constexpr std::array sampleTypeList{
constexpr std::array resamplerList{
NameValuePair{ "Point", "point" },
NameValuePair{ "Linear", "linear" },
NameValuePair{ "Cubic Spline", "cubic" },
NameValuePair{ "Default (Cubic Spline)", "" },
NameValuePair{ "4-point Gaussian", "gaussian" },
NameValuePair{ "Default (4-point Gaussian)", "" },
NameValuePair{ "11th order Sinc (fast)", "fast_bsinc12" },
NameValuePair{ "11th order Sinc", "bsinc12" },
NameValuePair{ "23rd order Sinc (fast)", "fast_bsinc24" },
Expand Down Expand Up @@ -664,11 +664,11 @@ void MainWindow::loadConfig(const QString &fname)
QString resampler = settings.value("resampler").toString().trimmed();
ui->resamplerSlider->setValue(2);
ui->resamplerLabel->setText(std::data(resamplerList[2].name));
/* The "sinc4" and "sinc8" resamplers are no longer supported. Use "cubic"
* as a fallback.
/* "Cubic" is an alias for the 4-point gaussian resampler. The "sinc4" and
* "sinc8" resamplers are unsupported, use "gaussian" as a fallback.
*/
if(resampler == "sinc4" || resampler == "sinc8")
resampler = "cubic";
if(resampler == "cubic" || resampler == "sinc4" || resampler == "sinc8")
resampler = "gaussian";
/* The "bsinc" resampler name is an alias for "bsinc12". */
else if(resampler == "bsinc")
resampler = "bsinc12";
Expand Down

0 comments on commit 3ad68aa

Please sign in to comment.