Eric Oulashin's C++ Audio Mixer 1.0
EOUtils::AudioFile Class Referenceabstract

#include <AudioFile.h>

Inheritance diagram for EOUtils::AudioFile:
Inheritance graph
Collaboration diagram for EOUtils::AudioFile:
Collaboration graph

Public Member Functions

 AudioFile (const std::string &pFilename)
 Constructor.
 AudioFile (const std::string &pFilename, AudioFileModes pFileMode)
 AudioFile (const AudioFile &pAudioFile)
virtual ~AudioFile ()
virtual void setAudioFileInfo (const AudioFileInfo &pAudioFileInfo)=0
virtual AudioFileResultType open (AudioFileModes pOpenMode)
virtual bool BitrateIsAdjustable () const =0
 Returns whether or not the audio file bitrate is adjustable.
virtual bool isOpen () const
 Returns whether or not the audio file is open.
virtual bool hasReadMode () const
 Returns whether or not read mode is enabled for the file.
virtual bool hasWriteMode () const
 Returns whether or not write mode is enabled for the file.
virtual void close ()
 Closes the audio file.
virtual AudioFileResultType getNextSample_int64 (int64_t &pAudioSample)=0
 Gets the next sample from the file, cast to a 64-bit integer.
virtual AudioFileResultType writeSample_int64 (int64_t pAudioSample)=0
 Writes an audio sample to the file. The parameter is a 64-bit integer but will be cast to the bitness of the audio samples in the file.
virtual AudioFileResultType getHighestSampleValue_int64 (int64_t &pHighestAudioSample)=0
 Gets the highest audio sample value from the file, cast to a 64-bit integer.
virtual AudioFileResultType goToAudioDataPos ()=0
 Goes to the audio data position in the audio file.
virtual size_t numSamples () const =0
 Returns the number of audio samples in the audio file.
virtual int64_t maxValueForSampleSize () const =0
 Returns the maximum possible positive value of the audio file's sample size.
const std::string & Filename () const
 Gets the filename of the audio file.
void Filename (const std::string &pFilename)
 Setter for the filename of the audio file.
void setMetadata (const std::string &pName, const std::string &pValue)
 Adds a piece of metadata for the audio file.
template<typename T>
void setMetadataFromVal (const std::string &pName, const T &pValue)
 Adds a piece of metadata for the audio file. Templatized for any value type. The value will be converted to a string to store in the metadata.
AudioFileResultType getMetadata (const std::string &pName, std::string &pValue) const
 Gets a metadata value as a string.
template<typename T>
AudioFileResultType getMetadataAs (const std::string &pName, T &pValue) const
 Gets a metadata value. Templatized to capture the value as any type.
std::string getMetadata (const std::string &pName) const
 Gets a metadata value.
template<typename T>
getMetadataAs (const std::string &pName) const
template<typename T>
getMetadataAs (const std::string &pName, const T &pDefaultVal) const
 Gets a metadata value. Templatized to return it as any type.
bool hasMetadata (const std::string &pName) const
 Returns whether or not a metadata item exists.
virtual AudioFileInfo getAudioFileInfo () const =0
 Returns an AudioFile object with information about the audio file.
virtual void seekOutputToSampleNum (size_t pSampleNum)=0

Protected Member Functions

virtual std::streampos fileSizeAccordingToStream ()
virtual void setFileMode (AudioFileModes pFileMode)

Protected Attributes

std::string mFilename
std::fstream mFileStream
std::ios_base::openmode mFileOpenMode
size_t mDataSizeBytes
std::map< std::string, std::string > mMetadata

Constructor & Destructor Documentation

◆ AudioFile() [1/3]

EOUtils::AudioFile::AudioFile ( const std::string & pFilename)
explicit

Constructor.

Parameters
[in]pFilenameThe name of the audio file

Referenced by AudioFile(), AudioFile(), EOUtils::MetadataAudioFile::MetadataAudioFile(), and EOUtils::WAVFile::WAVFile().

◆ AudioFile() [2/3]

EOUtils::AudioFile::AudioFile ( const std::string & pFilename,
AudioFileModes pFileMode )
explicit

References AudioFile().

◆ AudioFile() [3/3]

EOUtils::AudioFile::AudioFile ( const AudioFile & pAudioFile)

◆ ~AudioFile()

EOUtils::AudioFile::~AudioFile ( )
virtual

References close().

Member Function Documentation

◆ BitrateIsAdjustable()

virtual bool EOUtils::AudioFile::BitrateIsAdjustable ( ) const
pure virtual

Returns whether or not the audio file bitrate is adjustable.

◆ close()

void EOUtils::AudioFile::close ( )
virtual

◆ Filename() [1/2]

const string & EOUtils::AudioFile::Filename ( ) const

Gets the filename of the audio file.

References mFilename.

Referenced by EOUtils::mixAudioFiles().

◆ Filename() [2/2]

void EOUtils::AudioFile::Filename ( const std::string & pFilename)

Setter for the filename of the audio file.

Parameters
[in]pFilenameThe new filename

◆ fileSizeAccordingToStream()

std::streampos EOUtils::AudioFile::fileSizeAccordingToStream ( )
protectedvirtual

References mFileStream.

Referenced by EOUtils::WAVFile::close().

◆ getAudioFileInfo()

virtual AudioFileInfo EOUtils::AudioFile::getAudioFileInfo ( ) const
pure virtual

Returns an AudioFile object with information about the audio file.

Implemented in EOUtils::FLACFile, EOUtils::SndFileBackedMetadataAudioFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ getHighestSampleValue_int64()

virtual AudioFileResultType EOUtils::AudioFile::getHighestSampleValue_int64 ( int64_t & pHighestAudioSample)
pure virtual

Gets the highest audio sample value from the file, cast to a 64-bit integer.

Parameters
[out]pHighestAudioSampleThe highest audio sample from the file, cast to a 64-bit integer
Returns
True on success, or false with error messages on failure

Implemented in EOUtils::FLACFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ getMetadata() [1/2]

std::string EOUtils::AudioFile::getMetadata ( const std::string & pName) const

Gets a metadata value.

Parameters
[in]pNameThe name of the metadata item (string)
Returns
The metadata item value, or a blank string if it doesn't exist

◆ getMetadata() [2/2]

AudioFileResultType EOUtils::AudioFile::getMetadata ( const std::string & pName,
std::string & pValue ) const

Gets a metadata value as a string.

Parameters
[in]pNameThe name of the metadata item (string)
[out]pValueThis variable will store the value of the metadata item as a string
Returns
True on success or false with an error if the item doesn't exist

◆ getMetadataAs() [1/3]

template<typename T>
T EOUtils::AudioFile::getMetadataAs ( const std::string & pName) const
inline

References mMetadata.

◆ getMetadataAs() [2/3]

template<typename T>
T EOUtils::AudioFile::getMetadataAs ( const std::string & pName,
const T & pDefaultVal ) const
inline

Gets a metadata value. Templatized to return it as any type.

Parameters
[in]pNameThe name of the metadata item (string)
Returns
The metadata item value, templatized as the given type

References mMetadata.

◆ getMetadataAs() [3/3]

template<typename T>
AudioFileResultType EOUtils::AudioFile::getMetadataAs ( const std::string & pName,
T & pValue ) const
inline

Gets a metadata value. Templatized to capture the value as any type.

Parameters
[in]pNameThe name of the metadata item (string)
[out]pValueThis variable will store the value of the metadata item. Templatized to store the value as any type.
Returns
True on success or false with an error if the item doesn't exist

References EOUtils::AudioFileResultType::addError(), and mMetadata.

Referenced by EOUtils::FLACFile::open().

◆ getNextSample_int64()

virtual AudioFileResultType EOUtils::AudioFile::getNextSample_int64 ( int64_t & pAudioSample)
pure virtual

Gets the next sample from the file, cast to a 64-bit integer.

Parameters
[out]pAudioSampleThe next audio sample from the file, cast to a 64-bit integer
Returns
True on success, or false with error messages on failure

Implemented in EOUtils::FLACFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ goToAudioDataPos()

virtual AudioFileResultType EOUtils::AudioFile::goToAudioDataPos ( )
pure virtual

Goes to the audio data position in the audio file.

Implemented in EOUtils::FLACFile, EOUtils::SndFileBackedMetadataAudioFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ hasMetadata()

bool EOUtils::AudioFile::hasMetadata ( const std::string & pName) const

Returns whether or not a metadata item exists.

Parameters
[in]pNameThe name of the metadata item to check
Returns
True if the item exists, or false if not

References mMetadata.

Referenced by EOUtils::FLACFile::open().

◆ hasReadMode()

◆ hasWriteMode()

◆ isOpen()

bool EOUtils::AudioFile::isOpen ( ) const
virtual

Returns whether or not the audio file is open.

Reimplemented in EOUtils::FLACFile, EOUtils::SndFileBackedMetadataAudioFile, and FLACFile.

References mFileStream.

Referenced by EOUtils::mixAudioFiles().

◆ maxValueForSampleSize()

virtual int64_t EOUtils::AudioFile::maxValueForSampleSize ( ) const
pure virtual

Returns the maximum possible positive value of the audio file's sample size.

Implemented in EOUtils::FLACFile, EOUtils::SndFileBackedMetadataAudioFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ numSamples()

virtual size_t EOUtils::AudioFile::numSamples ( ) const
pure virtual

Returns the number of audio samples in the audio file.

Implemented in EOUtils::FLACFile, EOUtils::SndFileBackedMetadataAudioFile, EOUtils::WAVFile, FLACFile, and WAVFile.

◆ open()

◆ seekOutputToSampleNum()

virtual void EOUtils::AudioFile::seekOutputToSampleNum ( size_t pSampleNum)
pure virtual

◆ setAudioFileInfo()

virtual void EOUtils::AudioFile::setAudioFileInfo ( const AudioFileInfo & pAudioFileInfo)
pure virtual

◆ setFileMode()

void EOUtils::AudioFile::setFileMode ( AudioFileModes pFileMode)
protectedvirtual

◆ setMetadata()

void EOUtils::AudioFile::setMetadata ( const std::string & pName,
const std::string & pValue )

Adds a piece of metadata for the audio file.

Parameters
[in]pNameThe name of the metadata item (string)
[in]pValueThe value of the metadata item (string)

References mMetadata.

◆ setMetadataFromVal()

template<typename T>
void EOUtils::AudioFile::setMetadataFromVal ( const std::string & pName,
const T & pValue )
inline

Adds a piece of metadata for the audio file. Templatized for any value type. The value will be converted to a string to store in the metadata.

Parameters
[in]pNameThe name of the metadata item (string)
[in]pValueThe value of the metadata item (templatized for any type)

References mMetadata.

◆ writeSample_int64()

virtual AudioFileResultType EOUtils::AudioFile::writeSample_int64 ( int64_t pAudioSample)
pure virtual

Writes an audio sample to the file. The parameter is a 64-bit integer but will be cast to the bitness of the audio samples in the file.

Parameters
[in]pAudioSampleThe audio sample to write to the file
Returns
True on success, or false with error messages on failure

Implemented in EOUtils::FLACFile, EOUtils::WAVFile, FLACFile, and WAVFile.

Referenced by EOUtils::mixAudioFiles().

Member Data Documentation

◆ mDataSizeBytes

◆ mFilename

◆ mFileOpenMode

std::ios_base::openmode EOUtils::AudioFile::mFileOpenMode
protected

◆ mFileStream

◆ mMetadata

std::map<std::string, std::string> EOUtils::AudioFile::mMetadata
protected

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