Eric Oulashin's C++ Audio Mixer 1.0
EOUtils::WAVFile Class Reference

#include <WAVFile.h>

Inheritance diagram for EOUtils::WAVFile:
Inheritance graph
Collaboration diagram for EOUtils::WAVFile:
Collaboration graph

Public Member Functions

 WAVFile (const std::string &pFilename)
 WAVFile (const std::string &pFilename, const WAVFileInfo &pWAVFileInfo)
 WAVFile (const std::string &pFilename, AudioFileModes pFileMode)
 WAVFile (const WAVFile &pWAVFile)
 ~WAVFile ()
void setAudioFileInfo (const AudioFileInfo &pAudioFileInfo) override
AudioFileResultType open (AudioFileModes pOpenMode) override
void close () override
 Closes the WAV file.
const WAVFileInfogetFileInfo () const
 Returns a WAVFileInfo object with information about the WAV file.
AudioFileResultType getNextSample_int64 (int64_t &pAudioSample) override
 Gets the next sample from the file, cast to a 64-bit integer.
AudioFileResultType writeSample_int64 (int64_t pAudioSample) override
 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.
AudioFileResultType getHighestSampleValue_int64 (int64_t &pHighestAudioSample) override
 Gets the highest audio sample value from the file, cast to a 64-bit integer.
template<class SampleType>
AudioFileResultType getNextSample (SampleType &pAudioSample)
 Gets the next audio sample from the file. This is templated so that the proper variable type can be used to store the audio sample value.
template<class SampleType>
AudioFileResultType writeSample (SampleType pAudioSample)
 Writes an audio sample to the file. This is templated so that the proper variable type can be used for the audio sample value.
AudioFileResultType goToAudioDataPos () override
 Goes to the audio data position in the WAV file.
size_t numSamples () const override
 Returns the number of audio samples in the WAV file.
int64_t maxValueForSampleSize () const override
 Returns the maximum possible positive value of the audio file's sample size.
void seekOutputToSampleNum (size_t pSampleNum) override
template<class SampleType>
AudioFileResultType getHighestSampleValue (SampleType &pAudioSample)
 Gets the highest audio sample value from the file. This is templated so that the proper variable type can be used to store the audio sample value.
AudioFileInfo getAudioFileInfo () const override
 Returns an AudioFile object with information about the audio file.
Public Member Functions inherited from EOUtils::AudioFile
 AudioFile (const std::string &pFilename)
 Constructor.
 AudioFile (const std::string &pFilename, AudioFileModes pFileMode)
 AudioFile (const AudioFile &pAudioFile)
virtual ~AudioFile ()
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.
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.

Static Public Member Functions

template<class SampleType>
static AudioFileResultType getHighestSampleValue (const char *pFilename, SampleType &pAudioSample)

Additional Inherited Members

Protected Member Functions inherited from EOUtils::AudioFile
virtual std::streampos fileSizeAccordingToStream ()
virtual void setFileMode (AudioFileModes pFileMode)
Protected Attributes inherited from EOUtils::AudioFile
std::string mFilename
std::fstream mFileStream
std::ios_base::openmode mFileOpenMode
size_t mDataSizeBytes
std::map< std::string, std::string > mMetadata

Constructor & Destructor Documentation

◆ WAVFile() [1/4]

EOUtils::WAVFile::WAVFile ( const std::string & pFilename)

◆ WAVFile() [2/4]

EOUtils::WAVFile::WAVFile ( const std::string & pFilename,
const WAVFileInfo & pWAVFileInfo )

◆ WAVFile() [3/4]

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

References WAVFile().

◆ WAVFile() [4/4]

EOUtils::WAVFile::WAVFile ( const WAVFile & pWAVFile)

◆ ~WAVFile()

EOUtils::WAVFile::~WAVFile ( )

Member Function Documentation

◆ close()

void EOUtils::WAVFile::close ( )
overridevirtual

◆ getAudioFileInfo()

AudioFileInfo EOUtils::WAVFile::getAudioFileInfo ( ) const
overridevirtual

Returns an AudioFile object with information about the audio file.

Implements EOUtils::AudioFile.

◆ getFileInfo()

const WAVFileInfo & EOUtils::WAVFile::getFileInfo ( ) const

Returns a WAVFileInfo object with information about the WAV file.

◆ getHighestSampleValue() [1/2]

template<class SampleType>
AudioFileResultType EOUtils::WAVFile::getHighestSampleValue ( const char * pFilename,
SampleType & pAudioSample )
inlinestatic

◆ getHighestSampleValue() [2/2]

template<class SampleType>
AudioFileResultType EOUtils::WAVFile::getHighestSampleValue ( SampleType & pAudioSample)
inline

Gets the highest audio sample value from the file. This is templated so that the proper variable type can be used to store the audio sample value.

Parameters
[out]pAudioSampleTemplatized variable to store the highest audio sample read from the file
Returns
True on success, or false with error messages on failure

References EOUtils::AudioFileResultType::addError(), getNextSample(), goToAudioDataPos(), EOUtils::AudioFile::mFileStream, and numSamples().

Referenced by getHighestSampleValue(), and getHighestSampleValue_int64().

◆ getHighestSampleValue_int64()

AudioFileResultType EOUtils::WAVFile::getHighestSampleValue_int64 ( int64_t & pHighestAudioSample)
overridevirtual

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

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), getHighestSampleValue(), getNextSample_int64(), goToAudioDataPos(), and numSamples().

◆ getNextSample()

template<class SampleType>
AudioFileResultType EOUtils::WAVFile::getNextSample ( SampleType & pAudioSample)
inline

Gets the next audio sample from the file. This is templated so that the proper variable type can be used to store the audio sample value.

Parameters
[out]pAudioSampleTemplatized variable to store the next audio sample read from the file
Returns
True on success, or false with error messages on failure

References EOUtils::AudioFileResultType::addError(), BITS_PER_BYTE, EOUtils::AudioFile::hasReadMode(), EOUtils::machineIsBigEndian, EOUtils::AudioFile::mFileStream, and EOUtils::reverseBytes().

Referenced by getHighestSampleValue(), and getNextSample_int64().

◆ getNextSample_int64()

AudioFileResultType EOUtils::WAVFile::getNextSample_int64 ( int64_t & pAudioSample)
overridevirtual

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

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), getNextSample(), and EOUtils::AudioFile::mFileStream.

Referenced by getHighestSampleValue_int64().

◆ goToAudioDataPos()

AudioFileResultType EOUtils::WAVFile::goToAudioDataPos ( )
overridevirtual

Goes to the audio data position in the WAV file.

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), and EOUtils::AudioFile::mFileStream.

Referenced by getHighestSampleValue(), and getHighestSampleValue_int64().

◆ maxValueForSampleSize()

int64_t EOUtils::WAVFile::maxValueForSampleSize ( ) const
overridevirtual

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

Implements EOUtils::AudioFile.

References EOUtils::maxValue().

◆ numSamples()

size_t EOUtils::WAVFile::numSamples ( ) const
overridevirtual

Returns the number of audio samples in the WAV file.

Implements EOUtils::AudioFile.

References EOUtils::AudioFile::mDataSizeBytes, and EOUtils::AudioFile::mFilename.

Referenced by getHighestSampleValue(), and getHighestSampleValue_int64().

◆ open()

◆ seekOutputToSampleNum()

void EOUtils::WAVFile::seekOutputToSampleNum ( size_t pSampleNum)
overridevirtual

◆ setAudioFileInfo()

void EOUtils::WAVFile::setAudioFileInfo ( const AudioFileInfo & pAudioFileInfo)
overridevirtual

Implements EOUtils::AudioFile.

◆ writeSample()

template<class SampleType>
AudioFileResultType EOUtils::WAVFile::writeSample ( SampleType pAudioSample)
inline

Writes an audio sample to the file. This is templated so that the proper variable type can be used for the audio sample value.

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

References EOUtils::AudioFileResultType::addError(), EOUtils::AudioFile::hasWriteMode(), EOUtils::machineIsBigEndian, EOUtils::AudioFile::mDataSizeBytes, EOUtils::AudioFile::mFileStream, and EOUtils::reverseBytes().

Referenced by writeSample_int64().

◆ writeSample_int64()

AudioFileResultType EOUtils::WAVFile::writeSample_int64 ( int64_t pAudioSample)
overridevirtual

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

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), EOUtils::AudioFile::mDataSizeBytes, EOUtils::AudioFile::mFileStream, and writeSample().


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