Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ac3::CWAVReader Class Reference

A class for reading WAV-files. More...

#include <wav_reader.h>

List of all members.

Public Methods

 CWAVReader ()
 Standard constructor doing nothing.

 CWAVReader (const char *pszFilename)
 Constructor for opening a file during construction.

 CWAVReader (const std::string &sFilename)
 Constructor for opening a file during construction.

 ~CWAVReader ()
 Standard destructor.

void OpenFile (const std::string &sFilename)
 Opens a WAV-file.

void OpenFile (const char *pszFilename)
 Opens a WAV-file.

void CloseFile ()
 Closes the WAV-file if it is open.

void GetSamplesAs8Bit (UINT32 nCount, UINT16 nChannel, UINT8 *pnBuffer, UINT32 nStart=(UINT32)-1)
 Stores the specified number of samples into a buffer as 8 bit samples.

void GetSamplesAs16Bit (UINT32 nCount, UINT16 nChannel, INT16 *pnBuffer, UINT32 nStart=(UINT32)-1)
 Stores the specified number of samples into a buffer as 16 bit samples.

void GetSamplesAs24Bit (UINT32 nCount, UINT16 nChannel, INT32 *pnBuffer, UINT32 nStart=(UINT32)-1)
 Stores the specified number of samples into a buffer as 24 bit samples.

void GetSamplesAs32Bit (UINT32 nCount, UINT16 nChannel, INT32 *pnBuffer, UINT32 nStart=(UINT32)-1)
 Stores the specified number of samples into a buffer as 8 bit samples.

void SetChannelPos (UINT16 nChannel, UINT32 nNewPos)
 Sets the position in the specified channel.

UINT32 GetChannelPos (UINT16 nChannel)
 Returns the position in the specified channel.

UINT32 GetSampleRate () const
 Returns the sample rate of the WAV-file.

UINT16 GetChannelCount () const
 Returns the number of channels contained in the WAV-file.

UINT16 GetBitsPerSample () const
 Returns the number of bits per sample.

UINT32 GetSampleCount () const
 Returns the number of samples per channel contained in the WAV-file.

UINT32 TimeToSample (double dSec) const
 Returns the sample number of the specified time.

double SampleToTime (UINT32 nSample) const
 Returns the time of the specified sample number.


Detailed Description

A class for reading WAV-files.

Todo:
Optimize for speed.

You can use this class to read WAV-files. Currently PCM WAV-files with 8, 16, 24 or 32 bits per sample, any channel number (at least one) and any sample rate (greater 0) are supported. The class is able to supply information on the WAV-file and to store the PCM data of any channel into a buffer in resolution of 8, 16, 24 or 32 bit per sample. The class will perform the conversion if necessary.

If there occurs an error during any function the class will throw an exception of type CWAVReaderException.

Definition at line 78 of file wav_reader.h.


Member Function Documentation

UINT16 ac3::CWAVReader::GetBitsPerSample   const
 

Returns the number of bits per sample.

Returns:
The number of bits per sample (8, 16, 24 or 32 bit).

Definition at line 434 of file wav_reader.cpp.

References ac3::UINT16.

UINT16 ac3::CWAVReader::GetChannelCount   const
 

Returns the number of channels contained in the WAV-file.

Returns:
Number of channels contained in the WAV-file.

Definition at line 424 of file wav_reader.cpp.

References ac3::UINT16.

UINT32 ac3::CWAVReader::GetChannelPos UINT16    nChannel
 

Returns the position in the specified channel.

Parameters:
nChannel  Channel to get the position from.
Returns:
Position in the channel.

Definition at line 402 of file wav_reader.cpp.

References ac3::UINT16, and ac3::UINT32.

UINT32 ac3::CWAVReader::GetSampleCount   const
 

Returns the number of samples per channel contained in the WAV-file.

Returns:
Number of samples per channel contained in the WAV-file.

Definition at line 445 of file wav_reader.cpp.

References ac3::UINT32.

UINT32 ac3::CWAVReader::GetSampleRate   const
 

Returns the sample rate of the WAV-file.

Returns:
Sample rate of the WAV-file (samples per second of each channel).

Definition at line 414 of file wav_reader.cpp.

References ac3::UINT32.

void ac3::CWAVReader::GetSamplesAs16Bit UINT32    nCount,
UINT16    nChannel,
INT16   pnBuffer,
UINT32    nStart = (UINT32)-1
 

Stores the specified number of samples into a buffer as 16 bit samples.

Parameters:
nCount  Number of samples to store into the buffer.
nChannel  Channel number where to get the samples from. First channel has number 0.
pnBuffer  Pointer to buffer able to receive at least nCount 8 bit samples.
nStart  First sample to store into the buffer (optional).
This functions stores the PCM-data of any channel of the WAV-file into a buffer as 16 bit samples. If you don't specify nStart the current position in the channel is used. The position of the channel is set to the next unread sample.

The samples are converted to 16 bit if necessary.

16 bit samples are signed. "Silent" samples (samples with volume 0) have value 0.

Definition at line 208 of file wav_reader.cpp.

References ac3::INT16, ac3::UINT16, and ac3::UINT32.

void ac3::CWAVReader::GetSamplesAs24Bit UINT32    nCount,
UINT16    nChannel,
INT32   pnBuffer,
UINT32    nStart = (UINT32)-1
 

Stores the specified number of samples into a buffer as 24 bit samples.

Parameters:
nCount  Number of samples to store into the buffer.
nChannel  Channel number where to get the samples from. First channel has number 0.
pnBuffer  Pointer to buffer able to receive at least nCount 8 bit samples.
nStart  First sample to store into the buffer (optional).
This functions stores the PCM-data of any channel of the WAV-file into a buffer as 24 bit samples. If you don't specify nStart the current position in the channel is used. The position of the channel is set to the next unread sample.

The samples are converted to 24 bit if necessary.

24 bit samples are signed. "Silent" samples (samples with volume 0) have value 0. Note that 32 bit signed integers are used as buffer, but only the 24 least significant bits are used so the range is from -0x800000 to 0x7FFFFF.

Definition at line 273 of file wav_reader.cpp.

References ac3::INT32, ac3::UINT16, and ac3::UINT32.

void ac3::CWAVReader::GetSamplesAs32Bit UINT32    nCount,
UINT16    nChannel,
INT32   pnBuffer,
UINT32    nStart = (UINT32)-1
 

Stores the specified number of samples into a buffer as 8 bit samples.

Parameters:
nCount  Number of samples to store into the buffer.
nChannel  Channel number where to get the samples from. First channel has number 0.
pnBuffer  Pointer to buffer able to receive at least nCount 8 bit samples.
nStart  First sample to store into the buffer (optional).
This functions stores the PCM-data of any channel of the WAV-file into a buffer as 8 bit samples. If you don't specify nStart the current position in the channel is used. The position of the channel is set to the next unread sample.

The samples are converted to 8 bit if necessary.

32 bit samples are signed. "Silent" samples (samples with volume 0) have value 0.

Definition at line 336 of file wav_reader.cpp.

References ac3::INT32, ac3::UINT16, and ac3::UINT32.

void ac3::CWAVReader::GetSamplesAs8Bit UINT32    nCount,
UINT16    nChannel,
UINT8   pnBuffer,
UINT32    nStart = (UINT32)-1
 

Stores the specified number of samples into a buffer as 8 bit samples.

Parameters:
nCount  Number of samples to store into the buffer.
nChannel  Channel number where to get the samples from. First channel has number 0.
pnBuffer  Pointer to buffer able to receive at least nCount 8 bit samples.
nStart  First sample to store into the buffer (optional).
This functions stores the PCM-data of any channel of the WAV-file into a buffer as 8 bit samples. If you don't specify nStart the current position in the channel is used. The position of the channel is set to the next unread sample.

The samples are converted to 8 bit if necessary.

8 bit samples are unsigned. Note that "silent" samples (samples with volume 0) have the value 0x80. Therefore 8 bit samples differs from 16, 24 and 32 bit samples.

Definition at line 145 of file wav_reader.cpp.

References ac3::UINT16, ac3::UINT32, and ac3::UINT8.

void ac3::CWAVReader::OpenFile const char *    pszFilename
 

Opens a WAV-file.

Parameters:
pszFilename  Name of the WAV-file.
Currently only PCM WAV-files with 8, 16, 24 or 32 bit samples, any channel number and any sample rate are supported.

Definition at line 109 of file wav_reader.cpp.

References CloseFile().

void ac3::CWAVReader::OpenFile const std::string &    sFilename
 

Opens a WAV-file.

Parameters:
sFilename  Name of the WAV-file.
Currently only PCM WAV-files with 8, 16, 24 or 32 bit samples, any channel number and any sample rate are supported.

Definition at line 98 of file wav_reader.cpp.

double ac3::CWAVReader::SampleToTime UINT32    nSample const
 

Returns the time of the specified sample number.

Parameters:
nSample  Number of the sample.
Returns:
Time of sample in seconds.

Definition at line 471 of file wav_reader.cpp.

References ac3::UINT32.

void ac3::CWAVReader::SetChannelPos UINT16    nChannel,
UINT32    nNewPos
 

Sets the position in the specified channel.

Parameters:
nChannel  Channel to set the position in.
nNewPos  New position.
Sets the position in the specified channel to the specified sample. Note that the first channel and the first sample have index 0.

Definition at line 385 of file wav_reader.cpp.

References ac3::UINT16, and ac3::UINT32.

UINT32 ac3::CWAVReader::TimeToSample double    dSec const
 

Returns the sample number of the specified time.

Parameters:
dSec  Time in seconds.
Returns:
Number of sample at specified time.
If dSec is within a sample the number of this sample is returned. For example if sample 10 is from time 1.0s to 1.1s and you specify 1.05s as dSec 10 is returned.

Definition at line 460 of file wav_reader.cpp.

References ac3::UINT32.


The documentation for this class was generated from the following files:
Generated on Sat Sep 25 14:06:52 2004 for ac3 by doxygen1.2.18