Eric Oulashin's C++ Audio Mixer 1.0
Classes | Public Member Functions | List of all members
EOUtils::FLACFile Class Reference

#include <FLACFile.h>

Inheritance diagram for EOUtils::FLACFile:
Inheritance graph
Collaboration diagram for EOUtils::FLACFile:
Collaboration graph

Classes

struct  DecoderClientData
 Used by FLAC decoder callbacks (same layout as FLAC client data) More...
 

Public Member Functions

 FLACFile (const std::string &pFilename)
 Constructor for opening an existing FLAC file for reading, which just takes the filename.
 
 FLACFile (const std::string &pFilenam, uint32_t pCompressionLevel)
 Constructor for opening an existing FLAC file for reading, which takes the filename and a compression level.
 
 FLACFile (const std::string &pFilename, const FLACFileInfo &pFLACFileInfo)
 Constructor for opening an existing FLAC file for reading.
 
 FLACFile (const std::string &pFilename, AudioFileModes pFileMode)
 Constructor for opening a FLAC file for reading or writing.
 
 FLACFile (const FLACFile &pFLACFile)
 Copy constructor.
 
 FLACFile (FLACFile &&pFLACFile) noexcept
 Move constructor.
 
 ~FLACFile ()
 
void setAudioFileInfo (const AudioFileInfo &pAudioFileInfo) override
 Sets the audio file info for the FLAC file.
 
uint32_t CompressionLevel () const
 Returns the compression level currently set for the FLAC file.
 
void CompressionLevel (uint32_t pCompressionLevel)
 Sets the compression level to use when writing FLAC files.
 
AudioFileResultType open (AudioFileModes pOpenMode) override
 Opens the audio file in the given mode (read, write, or read/write)
 
void close () override
 Closes the FLAC file.
 
bool isOpen () const override
 Returns whether the FLAC file is open (and also has its encoder and/or decoder initialized)
 
const FLACFileInfogetFileInfo () const
 Returns a FLACFileInfo object with information about the FLAC 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.
 
AudioFileResultType goToAudioDataPos () override
 Goes to the audio data position in the audio file.
 
size_t numSamples () const override
 Returns the number of audio samples in the audio 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
 Returns the maximum possible positive value of the audio file's sample size.
 
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 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.
 

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

◆ FLACFile() [1/6]

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

Constructor for opening an existing FLAC file for reading, which just takes the filename.

Parameters
[in]pFilenameThe name of the FLAC file

◆ FLACFile() [2/6]

EOUtils::FLACFile::FLACFile ( const std::string &  pFilenam,
uint32_t  pCompressionLevel 
)

Constructor for opening an existing FLAC file for reading, which takes the filename and a compression level.

Parameters
[in]pFilenameThe name of the FLAC file
[in]pCompressionLevelThe compression level to use when writing FLAC files (0-8, where 0 is fastest and 8 is maximum compression)

◆ FLACFile() [3/6]

EOUtils::FLACFile::FLACFile ( const std::string &  pFilename,
const FLACFileInfo pFLACFileInfo 
)

Constructor for opening an existing FLAC file for reading.

Parameters
[in]pFilenameThe name of the FLAC file
[in]pFLACFileInfoAn object containing information about the new FLAC file

◆ FLACFile() [4/6]

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

Constructor for opening a FLAC file for reading or writing.

Parameters
[in]pFilenameThe name of the FLAC file
[in]pFileModeThe mode to open the file in (read, write, or read/write)

◆ FLACFile() [5/6]

EOUtils::FLACFile::FLACFile ( const FLACFile pFLACFile)

Copy constructor.

◆ FLACFile() [6/6]

EOUtils::FLACFile::FLACFile ( FLACFile &&  pFLACFile)
noexcept

Move constructor.

References EOUtils::AudioFile::close().

◆ ~FLACFile()

EOUtils::FLACFile::~FLACFile ( )

References close().

Member Function Documentation

◆ close()

void EOUtils::FLACFile::close ( )
overridevirtual

Closes the FLAC file.

Reimplemented from EOUtils::AudioFile.

References EOUtils::AudioFile::mFileStream, and EOUtils::AudioFileInfo::NumChannels().

Referenced by ~FLACFile().

◆ CompressionLevel() [1/2]

uint32_t EOUtils::FLACFile::CompressionLevel ( ) const

Returns the compression level currently set for the FLAC file.

References EOUtils::FLACFileInfo::CompressionLevel().

◆ CompressionLevel() [2/2]

void EOUtils::FLACFile::CompressionLevel ( uint32_t  pCompressionLevel)

Sets the compression level to use when writing FLAC files.

Parameters
[in]pCompressionLevelThe compression level to use when writing FLAC files (0-8, where 0 is fastest and 8 is maximum compression)

References EOUtils::FLACFileInfo::CompressionLevel().

◆ getAudioFileInfo()

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

Returns an AudioFile object with information about the audio file.

Implements EOUtils::AudioFile.

◆ getFileInfo()

const FLACFileInfo & EOUtils::FLACFile::getFileInfo ( ) const

Returns a FLACFileInfo object with information about the FLAC file.

◆ getHighestSampleValue_int64()

AudioFileResultType EOUtils::FLACFile::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
An AudioFileResultType object containing error messages on failure, or no errors on success. This can also be cast to a bool.

Implements EOUtils::AudioFile.

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

◆ getNextSample_int64()

AudioFileResultType EOUtils::FLACFile::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
An AudioFileResultType object containing error messages on failure, or no errors on success. This can also be cast to a bool.

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), EOUtils::AudioFileInfo::BitsPerSample(), EOUtils::AudioFile::hasReadMode(), and result.

Referenced by getHighestSampleValue_int64().

◆ goToAudioDataPos()

AudioFileResultType EOUtils::FLACFile::goToAudioDataPos ( )
overridevirtual

Goes to the audio data position in the audio file.

Implements EOUtils::AudioFile.

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

Referenced by getHighestSampleValue_int64().

◆ isOpen()

bool EOUtils::FLACFile::isOpen ( ) const
overridevirtual

Returns whether the FLAC file is open (and also has its encoder and/or decoder initialized)

Reimplemented from EOUtils::AudioFile.

References EOUtils::AudioFile::mFileStream.

◆ maxValueForSampleSize()

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

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

Implements EOUtils::AudioFile.

References EOUtils::AudioFileInfo::BitsPerSample().

◆ numSamples()

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

Returns the number of audio samples in the audio file.

Implements EOUtils::AudioFile.

References EOUtils::AudioFileInfo::BytesPerSample(), EOUtils::AudioFile::mFilename, and EOUtils::AudioFileInfo::NumChannels().

Referenced by getHighestSampleValue_int64().

◆ open()

AudioFileResultType EOUtils::FLACFile::open ( AudioFileModes  pOpenMode)
overridevirtual

◆ seekOutputToSampleNum()

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

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

Implements EOUtils::AudioFile.

References EOUtils::AudioFileInfo::NumChannels().

◆ setAudioFileInfo()

void EOUtils::FLACFile::setAudioFileInfo ( const AudioFileInfo pAudioFileInfo)
overridevirtual

Sets the audio file info for the FLAC file.

Implements EOUtils::AudioFile.

References EOUtils::AudioFileInfo::copyAudioFileInfo().

◆ writeSample_int64()

AudioFileResultType EOUtils::FLACFile::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
An AudioFileResultType object containing error messages on failure, or no errors on success. This can also be cast to a bool.

Implements EOUtils::AudioFile.

References EOUtils::AudioFileResultType::addError(), EOUtils::AudioFileInfo::BitsPerSample(), EOUtils::AudioFile::hasWriteMode(), EOUtils::AudioFileInfo::NumChannels(), and result.


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