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

This is a container for raw audio data in a particular format, ready to be sent to a sound card, or of how such data would appear coming from the sound card using a microphone. More...

#include <AudioData.h>

Inheritance diagram for AudioDataLib::AudioData:
AudioDataLib::FileData AudioDataLib::WaveTableData::AudioSampleData

Classes

struct  Format
 This structure contains all the information you need to decipher the data in a given stream of raw audio data. More...
 
struct  MetaData
 

Public Member Functions

 AudioData ()
 
virtual ~AudioData ()
 
virtual void DumpInfo (FILE *fp) const override
 
virtual void DumpCSV (FILE *fp) const override
 
virtual FileDataClone () const override
 
FormatGetFormat ()
 
const FormatGetFormat () const
 
void SetFormat (const Format &format)
 
uint8_t * GetAudioBuffer ()
 
const uint8_t * GetAudioBuffer () const
 
uint64_t GetAudioBufferSize () const
 
void SetAudioBufferSize (uint64_t audioBufferSize)
 
uint64_t GetNumSamples () const
 
uint64_t GetNumSamplesPerChannel () const
 
uint64_t GetNumFrames () const
 
double GetTimeSeconds () const
 
const MetaDataGetMetaData () const
 
void SetMetaData (const MetaData &metaData) const
 
bool CalcMetaData (Error &error) const
 
- Public Member Functions inherited from AudioDataLib::FileData
 FileData ()
 
virtual ~FileData ()
 

Static Public Member Functions

static AudioDataCreate ()
 
static void Destroy (AudioData *audioData)
 

Protected Attributes

Format format
 
uint8_t * audioBuffer
 
uint64_t audioBufferSize
 
MetaData metaData
 

Detailed Description

This is a container for raw audio data in a particular format, ready to be sent to a sound card, or of how such data would appear coming from the sound card using a microphone.

Note that this kind of data is not tied to any particular file format. As of this writing, the WaveFileFormat and AiffFileFormat classes both produce this kind of data from file. Indirectly, an AudioData class instances is also produced from a sound-font file using the SoundFontFormat class.

In contrast, the WaveForm class is used as a format-independent space where math calculations and transforms on audio data can more easily be performed. A typical use-case is that of resampling, or converting from one format to another. Format conversion proceeds by simply converting first, a given AudioData instance, into a WaveForm class instance, and then back to an AudioData instance of the desired audio format.

Note that audio data is not typically handed to a sound-card using this class directly. Rather, an instance of the AudioStream class in concert with the AudioSink class is used to do that.

Constructor & Destructor Documentation

◆ AudioData()

AudioData::AudioData ( )

◆ ~AudioData()

AudioData::~AudioData ( )
virtual

Member Function Documentation

◆ CalcMetaData()

bool AudioData::CalcMetaData ( Error & error) const

Calculate and cache meta-data (owned by this class instance) detailing information gleaned by an analysis of the audio data. See the MetaData class.

Parameters
errorAn Error class instance detailing error information if false is returned.
Returns
True is returned on success; false otherwise.

◆ Clone()

FileData * AudioData::Clone ( ) const
overridevirtual

The derived implimentation should return a new derived instance of the class in question with identical, but separate data.

Implements AudioDataLib::FileData.

Reimplemented in AudioDataLib::WaveTableData::AudioSampleData.

◆ Create()

AudioData * AudioData::Create ( )
static

Allocate an instance of the AudioData class using the default constructor and return it. The main purpose of this is to make sure that memory is allocated or freed in the proper heap. It can also be useful when writing template functions.

◆ Destroy()

void AudioData::Destroy ( AudioData * audioData)
static

Delete an instance of the AudioData class (or one of its derivatives.) The main purpose of this is to make sure that memory is allocated or freed in the proper heap. It can also be useful when writing template functions.

◆ DumpCSV()

void AudioData::DumpCSV ( FILE * fp) const
overridevirtual

Derivative implimentations should produce a command-separated list of human-readable data which can also be loaded as a CVS in spreadsheet software.

Parameters
[in]fpA pointer to a FILE object to which the text should be written.

Implements AudioDataLib::FileData.

◆ DumpInfo()

void AudioData::DumpInfo ( FILE * fp) const
overridevirtual

Derivative implimentations should produce informative, human-readable text about the file data.

Parameters
[in]fpA pointer to a FILE object to which the text should be written.

Implements AudioDataLib::FileData.

Reimplemented in AudioDataLib::WaveTableData::AudioSampleData.

◆ GetAudioBuffer() [1/2]

uint8_t * AudioDataLib::AudioData::GetAudioBuffer ( )
inline

◆ GetAudioBuffer() [2/2]

const uint8_t * AudioDataLib::AudioData::GetAudioBuffer ( ) const
inline

◆ GetAudioBufferSize()

uint64_t AudioDataLib::AudioData::GetAudioBufferSize ( ) const
inline

Get the size in bytes of this audio data.

◆ GetFormat() [1/2]

Format & AudioDataLib::AudioData::GetFormat ( )
inline

◆ GetFormat() [2/2]

const Format & AudioDataLib::AudioData::GetFormat ( ) const
inline

◆ GetMetaData()

const MetaData & AudioDataLib::AudioData::GetMetaData ( ) const
inline

Return the cached meta-data for this audio data. See the CalcMetaData function.

◆ GetNumFrames()

uint64_t AudioData::GetNumFrames ( ) const

This is really just the same thing as GetNumSamplesPerChannel, put another way. (Unless my brain is failing me right now.)

◆ GetNumSamples()

uint64_t AudioData::GetNumSamples ( ) const

Return the number of samples in the audio stream across all channels.

◆ GetNumSamplesPerChannel()

uint64_t AudioData::GetNumSamplesPerChannel ( ) const

Return the number of samples in a single channel of the audio stream.

◆ GetTimeSeconds()

double AudioData::GetTimeSeconds ( ) const

Return the length of this audio data in seconds.

◆ SetAudioBufferSize()

void AudioData::SetAudioBufferSize ( uint64_t audioBufferSize)

Set the size in bytes of this audio data. Any present audio data is destroyed by this operation.

◆ SetFormat()

void AudioDataLib::AudioData::SetFormat ( const Format & format)
inline

◆ SetMetaData()

void AudioDataLib::AudioData::SetMetaData ( const MetaData & metaData) const
inline

Set the cached meta-data for this audio data. See also the CalcMetaData function.

Member Data Documentation

◆ audioBuffer

uint8_t* AudioDataLib::AudioData::audioBuffer
protected

◆ audioBufferSize

uint64_t AudioDataLib::AudioData::audioBufferSize
protected

◆ format

Format AudioDataLib::AudioData::format
protected

◆ metaData

MetaData AudioDataLib::AudioData::metaData
mutableprotected

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