24#define EQCURVES_VERSION 1
25#define EQCURVES_REVISION 0
30 wxString base =
wxT(
"/Effects/Equalization/");
32 base =
wxT(
"/Effects/GraphicEq/");
34 base =
wxT(
"/Effects/FilterCurve/");
47 :
XO(
"%s: %s").Format(
name, titleStr );
73 if(fileName.empty()) {
76 wxString eqCurvesInstalledVersion;
79 bool needUpdate = (eqCurvesCurrentVersion != eqCurvesInstalledVersion);
109 const wxString fullPath{
fn.GetFullPath() };
110 if( !reader.
Parse(
this, fullPath ) )
113 auto msg =
XO(
"Error Loading EQ Curves from file:\n%s\nError message says:\n%s")
122 int numCurves =
mCurves.size();
125 for( curve = 0; curve < numCurves-1; curve++ )
127 if(
mCurves[curve].Name ==
_(
"unnamed") )
136 if(
mCurves.back().Name !=
_(
"unnamed") )
154 wxString unnamed =
wxT(
"unnamed");
165 wxLogDebug(
wxT(
"Attempting to load EQDefaultCurves.xml from %s"),
fn.GetFullPath());
168 if(!reader.
Parse(
this,
fn.GetFullPath())) {
169 wxLogError(
wxT(
"EQDefaultCurves.xml could not be read."));
173 wxLogDebug(
wxT(
"Loading EQDefaultCurves.xml successful."));
180 if (defaultCurves.back().Name == unnamed) {
181 defaultCurves.pop_back();
184 wxLogError(
wxT(
"Error in EQDefaultCurves.xml"));
187 int numUserCurves = userCurves.size();
188 int numDefaultCurves = defaultCurves.size();
197 for (
int curveCount = 0; curveCount < numUserCurves; curveCount++) {
198 bool isCustom =
true;
199 tempCurve = userCurves[curveCount];
201 for (
int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
202 if (tempCurve.
Name ==
mCurves[defCurveCount].Name) {
215 for (
int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
216 bool isUserCurve =
false;
218 for (
int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) {
219 if (userCurves[userCurveCount].Name == defaultCurves[defCurveCount].Name) {
221 mCurves.push_back(userCurves[userCurveCount]);
226 mCurves.push_back(defaultCurves[defCurveCount]);
231 for (
int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) {
232 bool isDefaultCurve =
false;
233 tempCurve = userCurves[userCurveCount];
234 for (
int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
235 if (tempCurve.
Name == defaultCurves[defCurveCount].Name) {
236 isDefaultCurve =
true;
240 if (!isDefaultCurve) {
245 defaultCurves.clear();
249 if(userUnnamed.
Name == unnamed) {
250 mCurves.push_back( userUnnamed );
271 if( !fileName.FileExists() )
276 if( !fileName.FileExists() )
288 return (fileName.FileExists());
298 if( fileName.empty() )
309 if( !
fn.DirExists() )
312 if( !
fn.Mkdir(
fn.GetPath(), 511, wxPATH_MKDIR_FULL ) )
324 const wxString fullPath{
fn.GetFullPath() };
325 XMLFileWriter eqFile{ fullPath,
XO(
"Error Saving Equalization Curves") };
341 if (tag ==
"equalizationeffect")
350 for (
auto pair : attrs)
352 auto attr = pair.first;
353 auto value = pair.second;
358 const wxString strValue = value.ToWString();
361 wxString strValueTemp = strValue;
366 for(
size_t i = 0; i <
mCurves.size(); i++)
369 strValueTemp.Printf(
wxT(
"%s (%d)"),strValue,n);
370 if(
mCurves[i].Name == strValueTemp)
378 while(exists ==
true);
397 for (
auto pair : attrs)
399 auto attr = pair.first;
400 auto value = pair.second;
405 if (!value.TryGet(dblValue))
410 else if( attr ==
"d" )
412 if (!value.TryGet(dblValue))
434 if (tag ==
"equalizationeffect")
459 xmlFile.StartTag(
wxT(
"equalizationeffect" ) );
462 int numCurves = mCurves.size();
464 for( curve = 0; curve < numCurves; curve++ )
467 xmlFile.StartTag(
wxT(
"curve" ) );
468 xmlFile.WriteAttr(
wxT(
"name" ), mCurves[ curve ].Name );
471 int numPoints = mCurves[ curve ].points.size();
473 for( point = 0; point < numPoints; point++ )
476 xmlFile.StartTag(
wxT(
"point" ) );
477 xmlFile.WriteAttr(
wxT(
"f" ), mCurves[ curve ].points[ point ].Freq, 12 );
478 xmlFile.WriteAttr(
wxT(
"d" ), mCurves[ curve ].points[ point ].dB, 12 );
479 xmlFile.EndTag(
wxT(
"point" ) );
483 xmlFile.EndTag(
wxT(
"curve" ) );
487 xmlFile.EndTag(
wxT(
"equalizationeffect" ) );
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const TranslatableString name
#define EQCURVES_REVISION
std::vector< EQCurve > EQCurveArray
const int kEqOptionGraphic
std::vector< Attribute > AttributesList
std::vector< EQPoint > points
wxString GetPrefsPrefix()
const TranslatableString mName
bool GetDefaultFileName(wxFileName &fileName)
void UpdateDefaultCurves(bool updateAll=false)
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
void LoadCurves(const wxString &fileName={}, bool append=false)
Serializer of curves into XML files.
void SaveCurves(const wxString &fileName={})
void WriteXML(XMLWriter &xmlFile) const
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Holds a msgid for the translation catalog; may also bind format arguments.
Reads a file and passes the results through an XMLTagHandler.
const TranslatableString & GetErrorStr() const
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
Wrapper to output XML data to files.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
int DoMessageBox(const TranslatableString &name, const TranslatableString &msg, const TranslatableString &titleStr, long style=wxOK|wxCENTRE)
FILES_API FilePath ResourcesDir()
FILES_API FilePath DataDir()
Audacity user data directory.