Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EQCurveWriter Class Reference

Serializer of curves into XML files. More...

#include <EqualizationCurves.h>

Collaboration diagram for EQCurveWriter:
[legend]

Public Member Functions

 EQCurveWriter (const EQCurveArray &curves)
 
void SaveCurves (const wxString &fileName={})
 

Private Member Functions

void WriteXML (XMLWriter &xmlFile) const
 

Private Attributes

const EQCurveArraymCurves
 

Detailed Description

Serializer of curves into XML files.

Definition at line 55 of file EqualizationCurves.h.

Constructor & Destructor Documentation

◆ EQCurveWriter()

EQCurveWriter::EQCurveWriter ( const EQCurveArray curves)
inlineexplicit

Definition at line 57 of file EqualizationCurves.h.

57: mCurves{ curves } {}
const EQCurveArray & mCurves

Member Function Documentation

◆ SaveCurves()

void EQCurveWriter::SaveCurves ( const wxString &  fileName = {})

Definition at line 282 of file EqualizationCurves.cpp.

283{
284 wxFileName fn;
285 if( fileName.empty() )
286 {
287 // Construct default curve filename
288 //
289 // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
290 // between wxStandardPaths and wxConfig under Linux. The latter
291 // creates a normal file as "$HOME/.audacity", while the former
292 // expects the ".audacity" portion to be a directory.
293 fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") );
294
295 // If the directory doesn't exist...
296 if( !fn.DirExists() )
297 {
298 // Attempt to create it
299 if( !fn.Mkdir( fn.GetPath(), 511, wxPATH_MKDIR_FULL ) )
300 {
301 // MkDir() will emit message
302 return;
303 }
304 }
305 }
306 else
307 fn = fileName;
308
309 GuardedCall( [&] {
310 // Create/Open the file
311 const wxString fullPath{ fn.GetFullPath() };
312 XMLFileWriter eqFile{ fullPath, XO("Error Saving Equalization Curves") };
313
314 // Write the curves
315 WriteXML( eqFile );
316
317 eqFile.Commit();
318 } );
319}
wxT("CloseDown"))
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...
XO("Cut/Copy/Paste")
static const auto fn
void WriteXML(XMLWriter &xmlFile) const
Wrapper to output XML data to files.
Definition: XMLWriter.h:84
FILES_API FilePath DataDir()
Audacity user data directory.

References FileNames::DataDir(), fn, GuardedCall(), WriteXML(), wxT(), and XO().

Referenced by EqualizationCurvesDialog::OnExport(), and EqualizationUI::ValidateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteXML()

void EQCurveWriter::WriteXML ( XMLWriter xmlFile) const
private

Definition at line 442 of file EqualizationCurves.cpp.

444{
445 // Start our hierarchy
446 xmlFile.StartTag( wxT( "equalizationeffect" ) );
447
448 // Write all curves
449 int numCurves = mCurves.size();
450 int curve;
451 for( curve = 0; curve < numCurves; curve++ )
452 {
453 // Start a NEW curve
454 xmlFile.StartTag( wxT( "curve" ) );
455 xmlFile.WriteAttr( wxT( "name" ), mCurves[ curve ].Name );
456
457 // Write all points
458 int numPoints = mCurves[ curve ].points.size();
459 int point;
460 for( point = 0; point < numPoints; point++ )
461 {
462 // Write NEW point
463 xmlFile.StartTag( wxT( "point" ) );
464 xmlFile.WriteAttr( wxT( "f" ), mCurves[ curve ].points[ point ].Freq, 12 );
465 xmlFile.WriteAttr( wxT( "d" ), mCurves[ curve ].points[ point ].dB, 12 );
466 xmlFile.EndTag( wxT( "point" ) );
467 }
468
469 // Terminate curve
470 xmlFile.EndTag( wxT( "curve" ) );
471 }
472
473 // Terminate our hierarchy
474 xmlFile.EndTag( wxT( "equalizationeffect" ) );
475}
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102

References wxT().

Referenced by SaveCurves().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mCurves

const EQCurveArray& EQCurveWriter::mCurves
private

Definition at line 62 of file EqualizationCurves.h.


The documentation for this class was generated from the following files: