csl::SoundFile Class Reference

#include <SoundFile.h>

Inheritance diagram for csl::SoundFile:

csl::UnitGenerator csl::Writeable csl::Seekable List of all members.

Detailed Description

Here's the sound file reader/writer class


Public Member Functions

 SoundFile (char *path)
 Constructor. Values not passed default to null.
 SoundFile (string path="", int start=-1, int stop=-1)
 ~SoundFile ()
unsigned channels () const
 accessors # chans
unsigned rate () const
 frame rate
unsigned duration () const
 number of frames in the sound file
float durationInSecs ()
 actual duration of the selected portion
SoundFileFormat format () const
 get format
bool isValid ()
 answer if a valid file/buffer
int startFrame ()
 get/set start frame
void setStart (int val)
void setStartSec (float val)
void setStartRatio (float val)
int stopFrame ()
 get/set stop frame
void setStop (int val)
void setStopSec (float val)
void setStopRatio (float val)
bool isLooping ()
 get/set looping state
void setIsLooping (bool isLooping)
bool isActive ()
 answer if currently active
void setPath (string path)
 set file name path string
void openForRead () throw (CException)
void openForWrite (SoundFileFormat format=kSoundFileFormatWAV, unsigned channels=1, unsigned rate=44100, unsigned bitDepth=16) throw (CException)
 Open a file for write. Default values are chosen arbitrarily. Assumed as the minimum common used format.
void openForReadWrite () throw (CException)
unsigned seekTo (int position, SeekPosition whence) throw (CException)
unsigned seekTo (int position) throw (CException)
void readBufferFromFile (unsigned numFrames)
 read a buffer from the file (possibly all of it)
void setToEnd ()
 set to end position
void trigger ()
 reset to start
void close ()
 close file
void freeBuffer ()
void nextBuffer (Buffer &outputBuffer) throw (CException)
 UGen operations copy next buffer from cache.
void writeBuffer (Buffer &inputBuffer) throw (CException)
 write a buffer of data into the file

Public Attributes

string mPath
 public state file name
SoundFileMode mMode
 r/w mode
SF_INFO mSFInfo
 libsndfile sf-info struct
SNDFILE * mSndfile
 libsndfile handle
Buffer mSampleBuffer

Protected Member Functions

void initFromSndfile ()
 read SF header
void checkBuffer (unsigned numFrames)
 query cache status

Protected Attributes

bool mIsValid
 is my file valid?
bool mIsLooping
 am i looping start-stop?
unsigned mTempCurrentFrame
 used in next buffer calculation
int mStart
int mStop
 starting/ending frames (or -1 if not used)


Constructor & Destructor Documentation

SoundFile::SoundFile char *  path  ) 
 

Constructor. Values not passed default to null.

SoundFile::SoundFile string  path = "",
int  start = -1,
int  stop = -1
 

SoundFile::~SoundFile  ) 
 


Member Function Documentation

unsigned SoundFile::channels  )  const
 

accessors # chans

unsigned SoundFile::rate  )  const
 

frame rate

unsigned SoundFile::duration  )  const
 

number of frames in the sound file

float SoundFile::durationInSecs  ) 
 

actual duration of the selected portion

SoundFileFormat SoundFile::format  )  const
 

get format

bool csl::SoundFile::isValid  )  [inline]
 

answer if a valid file/buffer

int csl::SoundFile::startFrame  )  [inline]
 

get/set start frame

void SoundFile::setStart int  val  ) 
 

void SoundFile::setStartSec float  val  ) 
 

void SoundFile::setStartRatio float  val  ) 
 

int csl::SoundFile::stopFrame  )  [inline]
 

get/set stop frame

void SoundFile::setStop int  val  ) 
 

void SoundFile::setStopSec float  val  ) 
 

void SoundFile::setStopRatio float  val  ) 
 

bool csl::SoundFile::isLooping  )  [inline]
 

get/set looping state

void csl::SoundFile::setIsLooping bool  isLooping  )  [inline]
 

bool SoundFile::isActive  ) 
 

answer if currently active

void SoundFile::setPath string  path  ) 
 

set file name path string

void SoundFile::openForRead  )  throw (CException)
 

open file and get stats

void SoundFile::openForWrite SoundFileFormat  format = kSoundFileFormatWAV,
unsigned  channels = 1,
unsigned  rate = 44100,
unsigned  bitDepth = 16
throw (CException)
 

Open a file for write. Default values are chosen arbitrarily. Assumed as the minimum common used format.

void SoundFile::openForReadWrite  )  throw (CException)
 

open r/w seek to some position

unsigned SoundFile::seekTo int  position,
SeekPosition  whence
throw (CException)
 

unsigned csl::SoundFile::seekTo int  position  )  throw (CException) [inline]
 

void SoundFile::readBufferFromFile unsigned  numFrames  ) 
 

read a buffer from the file (possibly all of it)

void SoundFile::setToEnd  ) 
 

set to end position

void SoundFile::trigger  ) 
 

reset to start

void SoundFile::close  ) 
 

close file

void SoundFile::freeBuffer  ) 
 

free the file cache

void SoundFile::nextBuffer Buffer outputBuffer  )  throw (CException)
 

UGen operations copy next buffer from cache.

void SoundFile::writeBuffer Buffer inputBuffer  )  throw (CException)
 

write a buffer of data into the file

void SoundFile::initFromSndfile  )  [protected]
 

read SF header

void SoundFile::checkBuffer unsigned  numFrames  )  [protected]
 

query cache status


Member Data Documentation

string csl::SoundFile::mPath
 

public state file name

SoundFileMode csl::SoundFile::mMode
 

r/w mode

SF_INFO csl::SoundFile::mSFInfo
 

libsndfile sf-info struct

SNDFILE* csl::SoundFile::mSndfile
 

libsndfile handle

Buffer csl::SoundFile::mSampleBuffer
 

used to read in interleaved samples

bool csl::SoundFile::mIsValid [protected]
 

is my file valid?

bool csl::SoundFile::mIsLooping [protected]
 

am i looping start-stop?

unsigned csl::SoundFile::mTempCurrentFrame [protected]
 

used in next buffer calculation

int csl::SoundFile::mStart [protected]
 

int csl::SoundFile::mStop [protected]
 

starting/ending frames (or -1 if not used)


The documentation for this class was generated from the following files:
Generated on Fri Apr 6 20:18:18 2007 for CSL by  doxygen 1.4.5-20051010