FileIO class

A class for reading from and writing to '.dismal' files.

This class uses a juce::ValueTree, juce::File, and juce::MemoryBlock to serialize and deserialize OvertoneDistribution and TuningSystem objects into raw binary data. The files produced using this class should have an file extension of '.dismal', and can contain both overtone distributions and tuning systems. This is to enable the transfer of overtone distributions and tunings between users of DisMAL or apps derived from DisMAL.

Constructors, destructors, conversion operators

FileIO ()
Default constructor.
FileIO (String pathName)
Constructs a FileIO object and sets its filepath using a String.
FileIO (File filePath)
Constructs a FileIO object and sets its filepath using a File object.
~FileIO ()
Destructor.

Public functions

void setPath (const String& path)
Sets the path of a file to read or write, using a String input.
void setPath (const File& newFile)
Sets the path of a file to read or write from a File object.
auto getPath () -> String
Returns the current filepath.
auto getFileReference () -> const File&
Returns a copy of the Juce::File object being used.
auto dataTypeOfFile () -> const String
Returns a String object that identifies the data in a file as that of either an OvertoneDistribution or a TuningSystem.
void saveToFile (const OvertoneDistribution& distribution, const bool overwrite = false)
Saves an overtone distribution to a file.
void saveToFile (const TuningSystem& tuning, const bool overwrite = false)
Saves a tuning system to a file.
void saveTreeToFile (const ValueTree& treeToSave, const bool overwrite = false)
Saves a ValueTree containing overtone distribution or tuning system data to a file.
auto loadOvertonesFromFile () -> OvertoneDistribution
Returns an OvertoneDistribution object contained in a file.
auto loadTuningFromFile () -> TuningSystem
Returns a TuningSystem object contained in a file.
auto loadTreeFromFile () -> ValueTree&
Returns a juce::ValueTree of the OvertoneDistribution or TuningSystem data contained in a file.

Function documentation

void FileIO::saveToFile (const OvertoneDistribution& distribution, const bool overwrite = false)

Saves an overtone distribution to a file.

Parameters
distribution A reference to the OvertoneDistribution object to be saved to file.
overwrite Set to true to overwrite an existing file. The default value is set to false to prevent accidental overwrites.

void FileIO::saveToFile (const TuningSystem& tuning, const bool overwrite = false)

Saves a tuning system to a file.

Parameters
tuning A reference to the TuningSystem object to be saved to file.
overwrite Set to true to overwrite an existing file. The default value is set to false to prevent accidental overwrites.

void FileIO::saveTreeToFile (const ValueTree& treeToSave, const bool overwrite = false)

Saves a ValueTree containing overtone distribution or tuning system data to a file.

Parameters
treeToSave A reference to the ValueTree object to be saved to file. The tree must be typed using an "OvertoneDistribution" or "Tuning" identifier.
overwrite Set to true to overwrite an existing file. The default value is set to false to prevent accidental overwrites.