class WaveFile : public AudioData

WaveFile represents a WAV-file

Inheritance:

WaveFile < AudioData


Public Methods

uint32 bitsInSample()
returns the number of bits per sample
uint32 dataLocation()
returns the location of the audio data in the file
size_t load(size_t samples)
Implementation of load for WAV files.
size_t loadSecs(size_t secs)
Implementation of loadSecs for WAV files.
void seek(int samples, SeekMode mode)
Implementation of seek for WAV files.
void seekSecs(int secs, SeekMode mode)
Implementation of seekSecs for WAV files.
void store(ofstream& file)
Implementation of store for WAV files.
uint32 type()
returns the type of data
explicit WaveFile(const string& filename)
creates an instance of WaveFile for the WAV-file having the given name
~WaveFile()
destroy the object.

Protected Fields

uint32 vBitsInSample
Number of bits per Sample.
uint32 vDataLocation
Position of audio data in the audio file.
uint32 vSize
File size including header and data size.
uint32 vType
Type (0 = mono, 1 = stereo).

Protected Methods

Sample calcSampAmp(Byte* buf)
Function to convert sample amplitude stored in certain bytes to a single value
void calcSampCode(Sample samp, Byte* buf)
Function to store a single sample into a buffer
void close()
Implementation of close for WAV files.
bool isDataHeader(Byte header[4])
checks if the given array contains "data"
bool isFmtHeader(Byte header[4])
checks if the given array contains "fmt "
bool isOrdinaryFormatChunk(Byte header[4])
checks if the given array contains the size of an ordinary format chunk
bool isRiffHeader(Byte header[4])
checks if the given array contains "RIFF"
bool isWaveHeader(Byte header[4])
checks if the given array contains "WAVE"
void open(const string& filename)
Implementation of open for WAV files.
uint32 packBytes(Byte* bytes)
converts an integer stored in a 4 byte buffer into a 32 bit unsigned integer value
bool readBitsPerSample(Byte header[2])
read the number of bits per sample stored in the given buffer
bool readBytesPerSample(Byte header[2])
read the number of bytes per sample stored in the given buffer
bool readBytesPerSecond(Byte header[4])
read the number of bytes per sample stored in the given buffer
bool readChannelCount(Byte header[2])
read the number of channels stored in the given buffer
bool readFormatTag(Byte header[2])
read the format tag stored in the given buffer
bool readSamplingRate(Byte header[4])
read the sampling rate stored in the given buffer

Inherited from AudioData:

Public Classes

enum SeekMode

Public Methods

uint32 bytesInSample()
AudioCache& cache()
const AudioCache& cache()
uint32 channelCount()
FormatCode dataFormat()
uint32 dataSize()
const string filename()
const string info()
AudioData& operator=(const AudioData& audata)
virtual void printOn(ostream& os)
uint32 samplingRate()

Public

enum SeekMode

Protected Fields

mutable ifstream file
uint32 vBytesInSample
mutable AudioCache* vCache
uint32 vChannelCount
FormatCode vDataFormat
uint32 vDataSize
string vFilename
string vInfo
uint32 vSamplingRate

Documentation

WaveFile represents a WAV-file. It implements the interface defined by AudioData.
explicit WaveFile(const string& filename)
creates an instance of WaveFile for the WAV-file having the given name.
Throws:
Exception , if reading faild
Parameters:
filename - name of a WAV-file

~WaveFile()
destroy the object.

size_t load(size_t samples)
Implementation of load for WAV files.

size_t loadSecs(size_t secs)
Implementation of loadSecs for WAV files.

void seek(int samples, SeekMode mode)
Implementation of seek for WAV files.

void seekSecs(int secs, SeekMode mode)
Implementation of seekSecs for WAV files.

void store(ofstream& file)
Implementation of store for WAV files.

uint32 type()
returns the type of data.
Returns:
0 in case of mono data, 1 in case of stereo data

uint32 bitsInSample()
returns the number of bits per sample.
Returns:
number of bits

uint32 dataLocation()
returns the location of the audio data in the file.
Returns:
absolute position in bytes

void open(const string& filename)
Implementation of open for WAV files.

void close()
Implementation of close for WAV files.

Sample calcSampAmp(Byte* buf)
Function to convert sample amplitude stored in certain bytes to a single value.
Throws:
Exception , if there is no conversion method for the data format
Returns:
single amplitude value
Parameters:
buf - buffer where the sample is stored

void calcSampCode(Sample samp, Byte* buf)
Function to store a single sample into a buffer.
Throws:
Exception , if there is no conversion method for the data format
Parameters:
samp - sample to be stored
buf - array of bytes

uint32 packBytes(Byte* bytes)
converts an integer stored in a 4 byte buffer into a 32 bit unsigned integer value.
Returns:
32 bit unsigned integer
Parameters:
bytes - array containing 4 bytes

bool isRiffHeader(Byte header[4])
checks if the given array contains "RIFF".
Returns:
true if header contains "RIFF"
Parameters:
header - array containing 4 bytes

bool isWaveHeader(Byte header[4])
checks if the given array contains "WAVE".
Returns:
true if header contains "WAVE"
Parameters:
header - array containing 4 bytes

bool isFmtHeader(Byte header[4])
checks if the given array contains "fmt ".
Returns:
true if header contains "fmt "
Parameters:
header - array containing 4 bytes

bool isDataHeader(Byte header[4])
checks if the given array contains "data".
Returns:
true if header contains "data"
Parameters:
header - array containing 4 bytes

bool isOrdinaryFormatChunk(Byte header[4])
checks if the given array contains the size of an ordinary format chunk.
Returns:
true if the format chunk is an ordinary format chunk
Parameters:
header - array containing 4 bytes

bool readFormatTag(Byte header[2])
read the format tag stored in the given buffer.
Returns:
false if the format tag is unknown, otherwise return true
Parameters:
header - array containing 2 bytes

bool readChannelCount(Byte header[2])
read the number of channels stored in the given buffer.
Returns:
false if there are too much channels, otherwise return true
Parameters:
header - array containing 2 bytes

bool readSamplingRate(Byte header[4])
read the sampling rate stored in the given buffer.
Returns:
false if the sampling rate is unknown
Parameters:
header - array containing 4 bytes

bool readBytesPerSecond(Byte header[4])
read the number of bytes per sample stored in the given buffer.
Returns:
false if the number of bytes is unknown
Parameters:
header - array containing 4 bytes

bool readBytesPerSample(Byte header[2])
read the number of bytes per sample stored in the given buffer.
Returns:
false if the number of bytes is unknown
Parameters:
header - array containing 4 bytes

bool readBitsPerSample(Byte header[2])
read the number of bits per sample stored in the given buffer.
Returns:
false if the number of bits is unknown
Parameters:
header - array containing 4 bytes

uint32 vSize
File size including header and data size.

uint32 vType
Type (0 = mono, 1 = stereo).

uint32 vBitsInSample
Number of bits per Sample.

uint32 vDataLocation
Position of audio data in the audio file.


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

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