Home   Information   Classes   Download   Usage   Mail List   Requirements   Tutorial


WvIn Class Reference

STK audio data input base class. More...

#include <WvIn.h>

Inheritance diagram for WvIn::

Stk RtWvIn TcpWvIn WaveLoop List of all members.

Public Methods

 WvIn ()
 Default constructor.

 WvIn (const char *fileName, bool raw=FALSE)
 Overloaded constructor for file input. More...

virtual ~WvIn ()
 Class destructor.

void openFile (const char *fileName, bool raw=FALSE)
 Open the specified file and load its data. More...

void closeFile (void)
 If a file is open, close it.

void reset (void)
 Clear outputs and reset time (file pointer) to zero.

void normalize (void)
 Normalize data to a maximum of +-1.0. More...

void normalize (MY_FLOAT peak)
 Normalize data to a maximum of +-peak. More...

unsigned long getSize (void) const
 Return the file size in sample frames.

unsigned int getChannels (void) const
 Return the number of audio channels in the file.

MY_FLOAT getFileRate (void) const
 Return the input file sample rate in Hz (not the data read rate). More...

bool isFinished (void) const
 Query whether reading is complete.

void setRate (MY_FLOAT aRate)
 Set the data read rate in samples. The rate can be negative. More...

virtual void addTime (MY_FLOAT aTime)
 Increment the read pointer by aTime samples.

void setInterpolate (bool doInterpolate)
 Turn linear interpolation on/off. More...

virtual MY_FLOAT lastOut (void) const
 Return the average across the last output sample frame.

virtual MY_FLOAT tick (void)
 Read out the average across one sample frame of data. More...

virtual MY_FLOAT* tick (MY_FLOAT *vector, unsigned int vectorSize)
 Read out vectorSize averaged sample frames of data in vector. More...

virtual const MY_FLOAT* lastFrame (void) const
 Return a pointer to the last output sample frame.

virtual const MY_FLOAT* tickFrame (void)
 Return a pointer to the next sample frame of data. More...

virtual MY_FLOAT* tickFrame (MY_FLOAT *frameVector, unsigned int frames)
 Read out sample frames of data to frameVector. More...


Detailed Description

STK audio data input base class.

This class provides input support for various audio file formats. It also serves as a base class for "realtime" streaming subclasses.

WvIn loads the contents of an audio file for subsequent output. Linear interpolation is used for fractional "read rates".

WvIn supports multi-channel data in interleaved format. It is important to distinguish the tick() methods, which return samples produced by averaging across sample frames, from the tickFrame() methods, which return pointers to multi-channel sample frames. For single-channel data, these methods return equivalent values.

Small files are completely read into local memory during instantiation. Large files are read incrementally from disk. The file size threshold and the increment size values are defined in WvIn.h.

WvIn currently supports WAV, AIFF, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating- point (32- and 64-bit) data types are supported. Uncompressed data types are not supported. If using MAT-files, data should be saved in an array with each data channel filling a matrix row.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.


Constructor & Destructor Documentation

WvIn::WvIn ( const char * fileName,
bool raw = FALSE )
 

Overloaded constructor for file input.

An StkError will be thrown if the file is not found, its format is unknown, or a read error occurs.


Member Function Documentation

void WvIn::openFile ( const char * fileName,
bool raw = FALSE )
 

Open the specified file and load its data.

An StkError will be thrown if the file is not found, its format is unknown, or a read error occurs.

void WvIn::normalize ( void )
 

Normalize data to a maximum of +-1.0.

For large, incrementally loaded files with integer data types, normalization is computed relative to the data type maximum. No normalization is performed for incrementally loaded files with floating-point data types.

void WvIn::normalize ( MY_FLOAT peak )
 

Normalize data to a maximum of +-peak.

For large, incrementally loaded files with integer data types, normalization is computed relative to the data type maximum (peak/maximum). For incrementally loaded files with floating- point data types, direct scaling by peak is performed.

MY_FLOAT WvIn::getFileRate ( void ) const
 

Return the input file sample rate in Hz (not the data read rate).

WAV, SND, and AIF formatted files specify a sample rate in their headers. STK RAW files have a sample rate of 22050 Hz by definition. MAT-files are assumed to have a rate of 44100 Hz.

void WvIn::setRate ( MY_FLOAT aRate )
 

Set the data read rate in samples. The rate can be negative.

If the rate value is negative, the data is read in reverse order.

void WvIn::setInterpolate ( bool doInterpolate )
 

Turn linear interpolation on/off.

Interpolation is automatically off when the read rate is an integer value. If interpolation is turned off for a fractional rate, the time index is truncated to an integer value.

MY_FLOAT WvIn::tick ( void ) [virtual]
 

Read out the average across one sample frame of data.

An StkError will be thrown if a file is read incrementally and a read error occurs.

Reimplemented in RtWvIn, and TcpWvIn.

MY_FLOAT * WvIn::tick ( MY_FLOAT * vector,
unsigned int vectorSize ) [virtual]
 

Read out vectorSize averaged sample frames of data in vector.

An StkError will be thrown if a file is read incrementally and a read error occurs.

Reimplemented in RtWvIn, and TcpWvIn.

const MY_FLOAT * WvIn::tickFrame ( void ) [virtual]
 

Return a pointer to the next sample frame of data.

An StkError will be thrown if a file is read incrementally and a read error occurs.

Reimplemented in RtWvIn, TcpWvIn, and WaveLoop.

MY_FLOAT * WvIn::tickFrame ( MY_FLOAT * frameVector,
unsigned int frames ) [virtual]
 

Read out sample frames of data to frameVector.

An StkError will be thrown if a file is read incrementally and a read error occurs.

Reimplemented in RtWvIn, and TcpWvIn.


The documentation for this class was generated from the following file:
The Synthesis ToolKit in C++ (STK)
©1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.