Audacity 3.2.0
EqualizationCurves.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EqualizationCurves.h
6
7 Mitch Golden
8 Vaughan Johnson (Preview)
9
10 Paul Licameli split from Equalization.h
11
12***********************************************************************/
13#ifndef __AUDACITY_EFFECT_EQUALIZATION_CURVES__
14#define __AUDACITY_EFFECT_EQUALIZATION_CURVES__
15
16#include "XMLTagHandler.h"
17
18#include <vector>
20
22class BUILTIN_EFFECTS_API EQPoint
23{
24public:
25 EQPoint( const double f, const double d ) { Freq = f; dB = d; }
26
27 bool operator < (const EQPoint &p1) const
28 {
29 return Freq < p1.Freq;
30 }
31
32 double Freq;
33 double dB;
34};
35
37class BUILTIN_EFFECTS_API EQCurve
38{
39public:
40 EQCurve( const wxString & name = {} ) { Name = name; }
41 EQCurve( const wxChar * name ) { Name = name; }
42
43 bool operator < (const EQCurve &that) const
44 {
45 return Name.CmpNoCase(that.Name) < 0;
46 }
47
48 wxString Name;
49 std::vector<EQPoint> points;
50};
51
52using EQCurveArray = std::vector<EQCurve>;
53
55class BUILTIN_EFFECTS_API EQCurveWriter {
56public:
57 explicit EQCurveWriter(const EQCurveArray &curves) : mCurves{ curves } {}
58 void SaveCurves(const wxString &fileName = {});
59
60private:
61 void WriteXML(XMLWriter &xmlFile) const;
63};
64
66class BUILTIN_EFFECTS_API EQCurveReader : public XMLTagHandler {
67public:
69 EQCurveArray &curves, const TranslatableString &name, int options)
70 : mCurves{ curves }, mName{ name }, mOptions{ options } {}
71
72 // XMLTagHandler callback methods for loading and saving
73 bool HandleXMLTag(const std::string_view& tag, const AttributesList &attrs) override;
74 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
75
76 void LoadCurves(const wxString &fileName = {}, bool append = false);
77
78private:
79 bool GetDefaultFileName(wxFileName &fileName);
80 wxString GetPrefsPrefix();
81 // Merge NEW curves only or update all factory presets.
82 // Uses EQCurveWriter
83 void UpdateDefaultCurves(bool updateAll = false);
86 const int mOptions;
87};
88
89#endif
std::vector< EQCurve > EQCurveArray
bool operator<(sampleCount a, sampleCount b)
Definition: SampleCount.h:85
wxString name
Definition: TagsEditor.cpp:166
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
One curve in a list.
EQCurve(const wxChar *name)
std::vector< EQPoint > points
EQCurve(const wxString &name={})
wxString Name
Deserializer of curves from XML files.
EQCurveReader(EQCurveArray &curves, const TranslatableString &name, int options)
const TranslatableString mName
EQCurveArray & mCurves
Serializer of curves into XML files.
const EQCurveArray & mCurves
EQCurveWriter(const EQCurveArray &curves)
One point in a curve.
EQPoint(const double f, const double d)
Holds a msgid for the translation catalog; may also bind format arguments.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
void append(std::basic_string< Elem > &dest, First &&first, Others &&...others)