csl::Abst_SoundFile Class Reference

#include <SoundFile.h>

Inheritance diagram for csl::Abst_SoundFile:

csl::WavetableOscillator csl::Writeable csl::Seekable csl::Oscillator csl::UnitGenerator csl::Phased csl::Scalable csl::Model csl::Controllable csl::Controllable csl::CASoundFile csl::JSoundFile csl::LSoundFile

List of all members.

Public Member Functions

 Abst_SoundFile (string path, int start=-1, int stop=-1)
 Constructor. Values not passed default to null.
 Abst_SoundFile (string folder, string path, int start=-1, int stop=-1)
 Copy constructor -- shares sample buffer.
 Abst_SoundFile (Abst_SoundFile &otherSndFile)
 Copy constructor -- shares sample buffer.
 ~Abst_SoundFile ()
unsigned channels () const
 accessors
unsigned duration () const
 number of frames in the sound file
float durationInSecs ()
 actual duration of the selected portion in sec
virtual SoundFileFormat format ()=0
 get format
bool isValid ()
 answer if a valid file/buffer
bool isActive ()
 answer if currently active
unsigned sampleSize ()
virtual void setPath (string path)
 get the bytes-per-sample
string path ()
 file name
virtual void dump ()
 log snd file props
SoundFileMode mode ()
 r/w mode
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)
double playbackRate ()
 playback rate (pitch ratio)
void setRate (UnitGenerator &frequency)
 set the receiver's playback rate (pitch ratio)
void setRate (float frequency)
bool isLooping ()
 get/set looping state
void setIsLooping (bool tLooping)
virtual bool isCached ()
 answer if file is loaded into RAM
virtual void openForRead ()=0 throw (CException)
virtual void openForWrite (SoundFileFormat format=kSoundFileFormatAIFF, unsigned channels=1, unsigned rate=44100, unsigned bitDepth=16)=0 throw (CException)
 Open a file for write. Default values are some common format.
virtual unsigned seekTo (int position, SeekPosition whence)=0 throw (CException)
 seek to some position
unsigned seekTo (int position) throw (CException)
virtual void readBufferFromFile (unsigned numFr)=0
 read a buffer from the file (possibly all of it)
void mergeToMono ()
 average all the channels to mono
virtual void setToEnd ()
 set to end position
virtual void trigger ()
 reset to start
virtual void close ()=0
 close file
virtual void freeBuffer ()
 free the file cache
virtual void nextBuffer (Buffer &outB) throw (CException)
 UGen operations.
virtual void writeBuffer (Buffer &inB)=0 throw (CException)
 write a buffer of data into the file

Protected Member Functions

virtual void initFromSndfile ()=0
 read SF header
virtual void checkBuffer (unsigned numFrames)
 allocate buffer lazily

Protected Attributes

string mPath
 file name
SoundFileMode mMode
 r/w mode
bool mIsValid
 is my file valid?
bool mIsLooping
 am i looping start-stop?
int mStart
int mStop
 starting/ending frames (or -1 if not used)
double mRate
 sample rate ratio
unsigned mNumFrames
 # sample frames
unsigned mBytesPerSample
 the # of bytes per sample


Detailed Description

Here's the abstract sound file reader/writer class

Constructor & Destructor Documentation

Abst_SoundFile::Abst_SoundFile ( string  path,
int  start = -1,
int  stop = -1 
)

Constructor. Values not passed default to null.

References csl::Seekable::mCurrentFrame.

Abst_SoundFile::Abst_SoundFile ( string  folder,
string  path,
int  start = -1,
int  stop = -1 
)

Copy constructor -- shares sample buffer.

Abst_SoundFile::Abst_SoundFile ( Abst_SoundFile otherSndFile  ) 

Abst_SoundFile::~Abst_SoundFile (  ) 


Member Function Documentation

unsigned Abst_SoundFile::channels (  )  const

unsigned Abst_SoundFile::duration (  )  const [virtual]

number of frames in the sound file

Implements csl::Seekable.

Reimplemented in csl::JSoundFile.

References mNumFrames.

Referenced by isCached(), setStart(), setStartRatio(), setStop(), and setStopRatio().

float Abst_SoundFile::durationInSecs (  ) 

actual duration of the selected portion in sec

References csl::UnitGenerator::mFrameRate, mIsValid, mStart, and mStop.

Referenced by csl::CASoundFile::dump(), and dump().

virtual SoundFileFormat csl::Abst_SoundFile::format (  )  [pure virtual]

get format

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

bool csl::Abst_SoundFile::isValid (  )  [inline]

answer if a valid file/buffer

References mIsValid.

bool Abst_SoundFile::isActive (  )  [virtual]

answer if currently active

Reimplemented from csl::UnitGenerator.

References csl::Seekable::mCurrentFrame, mIsValid, and mStop.

unsigned csl::Abst_SoundFile::sampleSize (  )  [inline]

References mBytesPerSample.

void Abst_SoundFile::setPath ( string  path  )  [virtual]

get the bytes-per-sample

set file name path string

References mPath.

Referenced by Abst_SoundFile().

string csl::Abst_SoundFile::path (  )  [inline]

file name

References mPath.

Referenced by Abst_SoundFile(), csl::CASoundFile::dump(), and dump().

void Abst_SoundFile::dump ( void   )  [virtual]

log snd file props

Reimplemented from csl::Oscillator.

Reimplemented in csl::CASoundFile.

References channels(), durationInSecs(), csl::UnitGenerator::frameRate(), csl::logMsg(), and path().

SoundFileMode csl::Abst_SoundFile::mode (  )  [inline]

r/w mode

References mMode.

int csl::Abst_SoundFile::startFrame (  )  [inline]

get/set start frame

References mStart.

void Abst_SoundFile::setStart ( int  val  ) 

References duration(), mIsValid, mStart, and seekTo().

Referenced by setStartRatio(), and setStartSec().

void Abst_SoundFile::setStartSec ( float  val  ) 

void Abst_SoundFile::setStartRatio ( float  val  ) 

References duration(), and setStart().

int csl::Abst_SoundFile::stopFrame (  )  [inline]

get/set stop frame

References mStop.

void Abst_SoundFile::setStop ( int  val  ) 

References duration(), and mStop.

Referenced by setStopRatio(), and setStopSec().

void Abst_SoundFile::setStopSec ( float  val  ) 

void Abst_SoundFile::setStopRatio ( float  val  ) 

References duration(), and setStop().

double csl::Abst_SoundFile::playbackRate (  )  [inline]

playback rate (pitch ratio)

References mRate.

void Abst_SoundFile::setRate ( UnitGenerator frequency  ) 

set the receiver's playback rate (pitch ratio)

References csl::Controllable::addInput(), CSL_RATE, and csl::Controllable::mInputs.

void Abst_SoundFile::setRate ( float  frequency  ) 

References csl::logMsg(), and mRate.

bool csl::Abst_SoundFile::isLooping (  )  [inline]

get/set looping state

References mIsLooping.

void csl::Abst_SoundFile::setIsLooping ( bool  tLooping  )  [inline]

References mIsLooping.

bool Abst_SoundFile::isCached (  )  [virtual]

answer if file is loaded into RAM

References duration(), csl::Buffer::mNumFrames, and csl::WavetableOscillator::mWavetable.

Referenced by Abst_SoundFile(), and csl::LSoundFile::LSoundFile().

virtual void csl::Abst_SoundFile::openForRead (  )  throw (CException) [pure virtual]

open file and get stats

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

virtual void csl::Abst_SoundFile::openForWrite ( SoundFileFormat  format = kSoundFileFormatAIFF,
unsigned  channels = 1,
unsigned  rate = 44100,
unsigned  bitDepth = 16 
) throw (CException) [pure virtual]

Open a file for write. Default values are some common format.

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

virtual unsigned csl::Abst_SoundFile::seekTo ( int  position,
SeekPosition  whence 
) throw (CException) [pure virtual]

seek to some position

Implements csl::Seekable.

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

Referenced by setStart(), and trigger().

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

References csl::kPositionStart, and seekTo().

Referenced by seekTo().

virtual void csl::Abst_SoundFile::readBufferFromFile ( unsigned  numFr  )  [pure virtual]

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

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

void Abst_SoundFile::mergeToMono (  ) 

void Abst_SoundFile::setToEnd (  )  [virtual]

set to end position

References csl::Seekable::mCurrentFrame, and mStop.

void Abst_SoundFile::trigger (  )  [virtual]

reset to start

References csl::Seekable::mCurrentFrame, mStart, and seekTo().

virtual void csl::Abst_SoundFile::close (  )  [pure virtual]

close file

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

void Abst_SoundFile::freeBuffer (  )  [virtual]

void Abst_SoundFile::nextBuffer ( Buffer outB  )  throw (CException) [virtual]

UGen operations.

copy next buffer from cache

Reimplemented from csl::UnitGenerator.

Reimplemented in csl::LSoundFile.

References csl_min, DECLARE_SCALABLE_CONTROLS, LOAD_SCALABLE_CONTROLS, csl::WavetableOscillator::nextBuffer(), and UPDATE_SCALABLE_CONTROLS.

virtual void csl::Abst_SoundFile::writeBuffer ( Buffer inB  )  throw (CException) [pure virtual]

write a buffer of data into the file

Reimplemented from csl::Writeable.

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

virtual void csl::Abst_SoundFile::initFromSndfile (  )  [protected, pure virtual]

read SF header

Implemented in csl::CASoundFile, csl::JSoundFile, and csl::LSoundFile.

void Abst_SoundFile::checkBuffer ( unsigned  numFrames  )  [protected, virtual]


Member Data Documentation

string csl::Abst_SoundFile::mPath [protected]

int csl::Abst_SoundFile::mStart [protected]

int csl::Abst_SoundFile::mStop [protected]

double csl::Abst_SoundFile::mRate [protected]

sample rate ratio

Referenced by playbackRate(), and setRate().

unsigned csl::Abst_SoundFile::mNumFrames [protected]


The documentation for this class was generated from the following files:

Generated on Thu Sep 17 23:14:17 2009 for CSL by  doxygen 1.5.8