From a3d12e16586abf596f9b77da1921d7195b621a7b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 24 Mar 2018 22:30:56 -0400 Subject: [PATCH] Make enum class for dither type --- src/Dither.cpp | 8 ++++---- src/Dither.h | 7 ++++--- src/SampleFormat.cpp | 14 +++++++------- src/prefs/QualityPrefs.cpp | 12 ++++++------ src/prefs/QualityPrefs.h | 1 + 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Dither.cpp b/src/Dither.cpp index b178f70a0..4f9569061 100644 --- a/src/Dither.cpp +++ b/src/Dither.cpp @@ -325,17 +325,17 @@ void Dither::Apply(enum DitherType ditherType, // We must do dithering switch (ditherType) { - case none: + case DitherType::none: DITHER(NoDither, dest, destFormat, destStride, source, sourceFormat, sourceStride, len); break; - case rectangle: + case DitherType::rectangle: DITHER(RectangleDither, dest, destFormat, destStride, source, sourceFormat, sourceStride, len); break; - case triangle: + case DitherType::triangle: Reset(); // reset dither filter for this NEW conversion DITHER(TriangleDither, dest, destFormat, destStride, source, sourceFormat, sourceStride, len); break; - case shaped: + case DitherType::shaped: Reset(); // reset dither filter for this NEW conversion DITHER(ShapedDither, dest, destFormat, destStride, source, sourceFormat, sourceStride, len); break; diff --git a/src/Dither.h b/src/Dither.h index 3069e3140..a7814b5b6 100644 --- a/src/Dither.h +++ b/src/Dither.h @@ -13,15 +13,16 @@ #include "SampleFormat.h" +/// These ditherers are currently available: +enum class DitherType : unsigned { + none = 0, rectangle = 1, triangle = 2, shaped = 3 }; + class Dither { public: /// Default constructor Dither(); - /// These ditherers are currently available: - enum DitherType { none = 0, rectangle = 1, triangle = 2, shaped = 3}; - /// Reset state of the dither. void Reset(); diff --git a/src/SampleFormat.cpp b/src/SampleFormat.cpp index 84611bafb..bcbb17944 100644 --- a/src/SampleFormat.cpp +++ b/src/SampleFormat.cpp @@ -45,18 +45,18 @@ #include "Dither.h" #include "Internat.h" -static Dither::DitherType gLowQualityDither = Dither::none; -static Dither::DitherType gHighQualityDither = Dither::none; +static DitherType gLowQualityDither = DitherType::none; +static DitherType gHighQualityDither = DitherType::none; static Dither gDitherAlgorithm; void InitDitherers() { // Read dither preferences - gLowQualityDither = (Dither::DitherType) - gPrefs->Read(wxT("/Quality/DitherAlgorithm"), (long)Dither::none); + gLowQualityDither = (DitherType) + gPrefs->Read(wxT("/Quality/DitherAlgorithm"), (long)DitherType::none); - gHighQualityDither = (Dither::DitherType) - gPrefs->Read(wxT("/Quality/HQDitherAlgorithm"), (long)Dither::shaped); + gHighQualityDither = (DitherType) + gPrefs->Read(wxT("/Quality/HQDitherAlgorithm"), (long)DitherType::shaped); } const wxChar *GetSampleFormatStr(sampleFormat format) @@ -120,6 +120,6 @@ void CopySamplesNoDither(samplePtr src, sampleFormat srcFormat, unsigned int dstStride /* = 1 */) { gDitherAlgorithm.Apply( - Dither::none, + DitherType::none, src, srcFormat, dst, dstFormat, len, srcStride, dstStride); } diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp index 2247bcf2f..0d1c98337 100644 --- a/src/prefs/QualityPrefs.cpp +++ b/src/prefs/QualityPrefs.cpp @@ -98,10 +98,10 @@ void QualityPrefs::Populate() void QualityPrefs::GetNamesAndLabels() { //------------ Dither Names - mDitherNames.Add(_("None")); mDitherLabels.push_back(Dither::none); - mDitherNames.Add(_("Rectangle")); mDitherLabels.push_back(Dither::rectangle); - mDitherNames.Add(_("Triangle")); mDitherLabels.push_back(Dither::triangle); - mDitherNames.Add(_("Shaped")); mDitherLabels.push_back(Dither::shaped); + mDitherNames.Add(_("None")); mDitherLabels.push_back((int) DitherType::none); + mDitherNames.Add(_("Rectangle")); mDitherLabels.push_back((int) DitherType::rectangle); + mDitherNames.Add(_("Triangle")); mDitherLabels.push_back((int) DitherType::triangle); + mDitherNames.Add(_("Shaped")); mDitherLabels.push_back((int) DitherType::shaped); //------------ Sample Rate Names // JKC: I don't understand the following comment. @@ -179,7 +179,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S) /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */ S.TieChoice(_("&Dither:"), wxT("/Quality/DitherAlgorithm"), - Dither::none, + (int) DitherType::none, mDitherNames, mDitherLabels); } @@ -197,7 +197,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S) /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */ S.TieChoice(_("Dit&her:"), wxT("/Quality/HQDitherAlgorithm"), - Dither::shaped, + (int) DitherType::shaped, mDitherNames, mDitherLabels); } diff --git a/src/prefs/QualityPrefs.h b/src/prefs/QualityPrefs.h index ccf281104..372d1249d 100644 --- a/src/prefs/QualityPrefs.h +++ b/src/prefs/QualityPrefs.h @@ -23,6 +23,7 @@ class ShuttleGui; enum sampleFormat : unsigned; +enum class DitherType : unsigned; class QualityPrefs final : public PrefsPanel {