AudioDataLib
A C++ library of classes supporting a variety of audio-data tasks.
Loading...
Searching...
No Matches
AudioDataLib::SoundFontFormat Class Reference

This class knows how to read (and one day write) sound-font files. More...

#include <SoundFontFormat.h>

Inheritance diagram for AudioDataLib::SoundFontFormat:
AudioDataLib::FileFormat

Public Member Functions

 SoundFontFormat ()
 
virtual ~SoundFontFormat ()
 
virtual bool ReadFromStream (ByteStream &inputStream, FileData *&fileData, Error &error) override
 
virtual bool WriteToStream (ByteStream &outputStream, const FileData *fileData, Error &error) override
 
- Public Member Functions inherited from AudioDataLib::FileFormat
 FileFormat ()
 
virtual ~FileFormat ()
 

Additional Inherited Members

- Static Public Member Functions inherited from AudioDataLib::FileFormat
static std::shared_ptr< FileFormatCreateForFile (const std::string &filePath)
 

Detailed Description

This class knows how to read (and one day write) sound-font files.

Not all sound-font file features are supported here, but enough are to be useful in the goal of sound synthesis. The SF2 file specification is quite extensive and lays out its own synthesis model. I chose not to follow this model and instead, just extract just enough of the relevant information needed to perform my own method of synthesis. This means getting at the sample data, knowing how it's looped, knowing what the key and velocity ranges are, etc. For now, I assume only one instrament per sound-font file, which I know is not generally correct. I plan to revise this class once I get my hands on a sound-font file that contains multiple instruments.

Constructor & Destructor Documentation

◆ SoundFontFormat()

SoundFontFormat::SoundFontFormat ( )

◆ ~SoundFontFormat()

SoundFontFormat::~SoundFontFormat ( )
virtual

Member Function Documentation

◆ ReadFromStream()

bool SoundFontFormat::ReadFromStream ( ByteStream & inputStream,
FileData *& fileData,
Error & error )
overridevirtual

The given file data pointer is assigned an instance of some derivative of the FileData class which is, in turn, populated with the data found in the given stream.

Parameters
[in,out]inputStreamThis must be a ByteStream derivative that can handle read operations.
[out]fileDataOn success, this pointer is assigned a heap allocation the user is reponsible for freeing.
[out]errorThis will contain error information if false is returned.
Returns
True is returned on success; false otherwise.

Implements AudioDataLib::FileFormat.

◆ WriteToStream()

bool SoundFontFormat::WriteToStream ( ByteStream & outputStream,
const FileData * fileData,
Error & error )
overridevirtual

The given file data is written to the given stream.

Parameters
[out]outputStreamThis must be a ByteStream derivative that can accept write operations.
[in]fileDataThis is the file data to be written to the stream.
[out]errorThis will contain error information if false is returned.
Returns
True is returned on success; false otherwise.

Implements AudioDataLib::FileFormat.


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