class AudioCache

This class represents a vector of samples

Public Methods

const Sample& at(size_t idx)
returns a reference to the sample value at the given index
Sample& at(size_t idx)
returns a reference to the sample value at the given index
explicit AudioCache(const uint32 rate = 8000, const size_t size = 0)
creates new audio cache
AudioCache(const AudioCache& cache)
constructs an audio cache containing the same values as the given audio cache
uint32 bytesInSample()
returns the number of bytes which make a sample
uint32 channelCount()
returns the number of channels of the stored signal
FormatCode dataFormat()
returns the format of the stored samples
AudioCache& operator=(const AudioCache& cache)
assigns the contents of the specified cache to the invoking cache
Sample& operator[](size_t idx)
returns a reference to the sample value at the given index
const Sample& operator[](size_t idx)
returns a reference to the sample value at the given index
virtual void printOn(ostream& os)
prints the cache parameters and its contents on the given output stream
void resize(const size_t size)
changes the size of the cache to the specified by 'size'
uint32 samplingRate()
returns the sampling rate of the stored signal
size_t size()
returns the number of elements current in the cache
virtual ~AudioCache()
destroy audio cache.

Protected Fields

Sample* data
cache data (an array of samples).
const uint32 vSamplingRate
sampling rate of the stored signal.
size_t vSize
cache size.

Protected Methods

void clear()
removes the cache data. Used by the copy() and resize().

Documentation

This class represents a vector of samples. The stored singnal is mono, the sample format is lin16 (2 bytes per sample, linear encoding). The sampling rate and cache size can be set by the user. Cache size can also be modified.
Audio cache is used by AudioData to store parts of audio files. But it can also be used as a stand-alone audio container.
explicit AudioCache(const uint32 rate = 8000, const size_t size = 0)
creates new audio cache. Sampling rate and cache size can be set by the user.
Throws:
Exception , if memory allocation fails
Parameters:
rate - used sampling rate
size - initialize size

virtual ~AudioCache()
destroy audio cache.

AudioCache(const AudioCache& cache)
constructs an audio cache containing the same values as the given audio cache. Sampling rates of both caches must be equal; cache sizes do not need to be equal.
Throws:
Exception , if the sampling rates are not equal or if memory allocation fails
Parameters:
cache - other audio cache having equal sampling rate

AudioCache& operator=(const AudioCache& cache)
assigns the contents of the specified cache to the invoking cache. Sampling rates must be equal; cache sizes do not need to be equal.
Throws:
Exception , if the sampling rates are not equal or if memory allocation fails
Parameters:
cache - other audio cache having equal sampling rate

Sample& operator[](size_t idx)
returns a reference to the sample value at the given index.
Returns:
sample value
Parameters:
idx - sample index

const Sample& operator[](size_t idx)
returns a reference to the sample value at the given index.
Returns:
sample value
Parameters:
idx - sample index

Sample& at(size_t idx)
returns a reference to the sample value at the given index. Check the boundaries.
Throws:
Exception , if index is out of range
Returns:
sample value
Parameters:
idx - sample index

const Sample& at(size_t idx)
returns a reference to the sample value at the given index. Check the boundaries.
Throws:
Exception , if index is out of range
Returns:
sample value
Parameters:
idx - sample index

size_t size()
returns the number of elements current in the cache.
Returns:
cache size

void resize(const size_t size)
changes the size of the cache to the specified by 'size'.
Throws:
Exception , if memory allocation fails
Parameters:
size - new cache size

uint32 samplingRate()
returns the sampling rate of the stored signal.
Returns:
sampling rate

FormatCode dataFormat()
returns the format of the stored samples.
Returns:
sample format

uint32 bytesInSample()
returns the number of bytes which make a sample. This value depends on the sample format.
Returns:
number of bytes

uint32 channelCount()
returns the number of channels of the stored signal.
Returns:
number of channels

virtual void printOn(ostream& os)
prints the cache parameters and its contents on the given output stream.
Parameters:
os - output stream

void clear()
removes the cache data. Used by the copy() and resize().

size_t vSize
cache size.

const uint32 vSamplingRate
sampling rate of the stored signal.

Sample* data
cache data (an array of samples).


This class has no child classes.
Author:
Silvia Pfeiffer, Peter Tomczyk
Version:
$Id: aucache.h,v 1.7 1998/04/14 10:26:27 tomczyk Exp $
See Also:
AudioData

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de