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

#include <MP3File.h>

Inheritance diagram for EOUtils::MP3File:
Inheritance graph
Collaboration diagram for EOUtils::MP3File:
Collaboration graph

Public Member Functions

 MP3File (const std::string &pFilename)
 MP3File (const std::string &pFilename, const MP3FileInfo &pFileInfo)
 MP3File (const std::string &pFilename, AudioFileModes pFileMode)
 MP3File (const std::string &pFilename, Mp3BitrateMode pBitrateMode, std::uint32_t pNominalBitrateKbps)
 Open with write-time encoding options (constant or average bit rate).
 MP3File (const std::string &pFilename, double pVariableBitrateCompressionZeroBestOneWorst)
 Variable bit rate: libsndfile compression in [0,1] (0 = best quality, 1 = lowest). Maps to LAME VBR quality as in SFC_SET_COMPRESSION_LEVEL for SF_BITRATE_MODE_VARIABLE.
 MP3File (const MP3File &pOther)
 MP3File (MP3File &&pOther) noexcept
 ~MP3File () override
AudioFileResultType open (AudioFileModes pOpenMode) override
void setAudioFileInfo (const AudioFileInfo &pAudioFileInfo) override
const MP3FileInfogetFileInfo () const
void setMp3WriteBitrateMode (Mp3BitrateMode pMode)
void setMp3WriteNominalBitrateKbps (std::uint32_t pBitrateKbps)
void setMp3WriteVariableBitrateCompression (double pZeroBestOneWorst)
void clearMp3WriteEncodingOverrides ()
Public Member Functions inherited from EOUtils::SndFileBackedMetadataAudioFile
void setAudioFileInfo (const AudioFileInfo &pAudioFileInfo) override
AudioFileResultType open (AudioFileModes pOpenMode) override
void close () override
 Closes the audio file.
bool isOpen () const override
 Returns whether or not the audio file is open.
AudioFileResultType getNextSample_int64 (std::int64_t &pAudioSample) override
AudioFileResultType writeSample_int64 (std::int64_t pAudioSample) override
AudioFileResultType getHighestSampleValue_int64 (std::int64_t &pHighestAudioSample) override
AudioFileResultType goToAudioDataPos () override
 Goes to the audio data position in the audio file.
std::size_t numSamples () const override
 Returns the number of audio samples in the audio file.
std::int64_t maxValueForSampleSize () const override
 Returns the maximum possible positive value of the audio file's sample size.
void seekOutputToSampleNum (std::size_t pSampleNum) override
AudioFileInfo getAudioFileInfo () const override
 Returns an AudioFile object with information about the audio file.
AudioFileResultType setTitle (const std::string &pTitle) override
 Sets the title metadata tag.
AudioFileResultType setArtist (const std::string &pArtist) override
 Sets the artist metadata tag.
AudioFileResultType setAlbum (const std::string &pAlbum) override
 Sets the album metadata tag.
AudioFileResultType setGenre (const std::string &pGenre) override
 Sets the genre metadata tag.
AudioFileResultType setTrackNumber (std::uint32_t pTrackNumber, std::uint32_t pTotalTracks=0) override
AudioFileResultType setYear (const std::string &pYear) override
 Sets the year/date metadata tag.
AudioFileResultType setComment (const std::string &pComment) override
 Sets the comment metadata tag.
AudioFileResultType getTitle (std::string &pTitle) const override
 Gets the title metadata tag.
AudioFileResultType getArtist (std::string &pArtist) const override
 Gets the artist metadata tag.
AudioFileResultType getAlbum (std::string &pAlbum) const override
 Gets the album metadata tag.
AudioFileResultType getGenre (std::string &pGenre) const override
 Gets the genre metadata tag.
AudioFileResultType getTrackNumber (std::uint32_t &pTrackNumber, std::uint32_t &pTotalTracks) const override
AudioFileResultType getYear (std::string &pYear) const override
 Gets the year/date metadata tag.
AudioFileResultType getComment (std::string &pComment) const override
 Gets the comment metadata tag.
 ~SndFileBackedMetadataAudioFile () override
Public Member Functions inherited from EOUtils::MetadataAudioFile
 MetadataAudioFile (const std::string &pFilename)
 MetadataAudioFile (const std::string &pFilename, AudioFileModes pFileMode)
 MetadataAudioFile (const MetadataAudioFile &pOther)
virtual ~MetadataAudioFile ()
virtual AudioFileResultType setTrackNumber (uint32_t pTrackNumber, uint32_t pTotalTracks=0)=0
 Sets the track number metadata tag.
virtual AudioFileResultType getTrackNumber (uint32_t &pTrackNumber, uint32_t &pTotalTracks) const =0
 Gets the track number metadata tag.
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 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 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.
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 void seekOutputToSampleNum (size_t pSampleNum)=0

Protected Member Functions

bool readFormatMatches (int pSfFullFormat) const override
int newFileSfFormatMask () const override
const char * formatLabel () const override
void configureSndfileEncoderForWrite (SNDFILE *pSnd) override
Protected Member Functions inherited from EOUtils::SndFileBackedMetadataAudioFile
 SndFileBackedMetadataAudioFile (const std::string &pFilename)
 SndFileBackedMetadataAudioFile (const std::string &pFilename, AudioFileModes pFileMode)
 SndFileBackedMetadataAudioFile (const SndFileBackedMetadataAudioFile &pOther)
 SndFileBackedMetadataAudioFile (SndFileBackedMetadataAudioFile &&pOther) noexcept
 SndFileBackedMetadataAudioFile (const std::string &pFilename, const AudioFileInfo &pLayoutHint)
Protected Member Functions inherited from EOUtils::AudioFile
virtual std::streampos fileSizeAccordingToStream ()
virtual void setFileMode (AudioFileModes pFileMode)

Additional Inherited Members

Protected Attributes inherited from EOUtils::SndFileBackedMetadataAudioFile
AudioFileInfo mFileLayout
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

◆ MP3File() [1/7]

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

◆ MP3File() [2/7]

EOUtils::MP3File::MP3File ( const std::string & pFilename,
const MP3FileInfo & pFileInfo )
explicit

◆ MP3File() [3/7]

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

◆ MP3File() [4/7]

EOUtils::MP3File::MP3File ( const std::string & pFilename,
Mp3BitrateMode pBitrateMode,
std::uint32_t pNominalBitrateKbps )
explicit

Open with write-time encoding options (constant or average bit rate).

Parameters
pNominalBitrateKbpsTarget kbps for CBR (Constant) or mean for ABR (Average). Not used for Variable.

References EOUtils::SndFileBackedMetadataAudioFile::mFileLayout, EOUtils::SndFileBackedMetadataAudioFile::SndFileBackedMetadataAudioFile(), and EOUtils::Variable.

◆ MP3File() [5/7]

EOUtils::MP3File::MP3File ( const std::string & pFilename,
double pVariableBitrateCompressionZeroBestOneWorst )
explicit

Variable bit rate: libsndfile compression in [0,1] (0 = best quality, 1 = lowest). Maps to LAME VBR quality as in SFC_SET_COMPRESSION_LEVEL for SF_BITRATE_MODE_VARIABLE.

References EOUtils::SndFileBackedMetadataAudioFile::mFileLayout, and EOUtils::SndFileBackedMetadataAudioFile::SndFileBackedMetadataAudioFile().

◆ MP3File() [6/7]

EOUtils::MP3File::MP3File ( const MP3File & pOther)

◆ MP3File() [7/7]

EOUtils::MP3File::MP3File ( MP3File && pOther)
noexcept

◆ ~MP3File()

EOUtils::MP3File::~MP3File ( )
overridedefault

References EOUtils::Constant.

Member Function Documentation

◆ clearMp3WriteEncodingOverrides()

void EOUtils::MP3File::clearMp3WriteEncodingOverrides ( )

References EOUtils::Constant.

◆ configureSndfileEncoderForWrite()

void EOUtils::MP3File::configureSndfileEncoderForWrite ( SNDFILE * )
overrideprotectedvirtual

After a successful SFM_WRITE open, codecs may tweak the encoder via sf_command. Default: no-op.

Reimplemented from EOUtils::SndFileBackedMetadataAudioFile.

References EOUtils::SndFileBackedMetadataAudioFile::mFileLayout, and EOUtils::Variable.

◆ formatLabel()

const char * EOUtils::MP3File::formatLabel ( ) const
overrideprotectedvirtual

◆ getFileInfo()

const MP3FileInfo & EOUtils::MP3File::getFileInfo ( ) const

◆ newFileSfFormatMask()

int EOUtils::MP3File::newFileSfFormatMask ( ) const
overrideprotectedvirtual

◆ open()

◆ readFormatMatches()

bool EOUtils::MP3File::readFormatMatches ( int pSfFullFormat) const
overrideprotectedvirtual

◆ setAudioFileInfo()

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

◆ setMp3WriteBitrateMode()

void EOUtils::MP3File::setMp3WriteBitrateMode ( Mp3BitrateMode pMode)

◆ setMp3WriteNominalBitrateKbps()

void EOUtils::MP3File::setMp3WriteNominalBitrateKbps ( std::uint32_t pBitrateKbps)

◆ setMp3WriteVariableBitrateCompression()

void EOUtils::MP3File::setMp3WriteVariableBitrateCompression ( double pZeroBestOneWorst)

For Mp3BitrateMode::Variable — same semantics as constructor (0 best, 1 worst).

References EOUtils::Variable.


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