iso::synth::SampleUnit Class Reference

sample playback unit More...

#include <iso_synth_sample_unit.h>

Inherits iso::synth::InputUnit.

Inheritance diagram for iso::synth::SampleUnit:

Inheritance graph
[legend]
Collaboration diagram for iso::synth::SampleUnit:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SampleUnit (String pFileName) throw (SynthException)
 parameter based contructor
 SampleUnit (String pName, String pFileName) throw (SynthException)
 parameter based contructor
 SampleUnit (const data::Values &pValues) throw (SynthException)
 values based constructor
 ~SampleUnit () throw (SynthException)
 destructor
void addSample (String pFileName)
 add additional sample
void removeSample (String pFileName)
 remove sample
void play (bool pActive)
 trigger sound file playback or stop
void setLooping (bool pLooping)
 set soundfile looping property
void switchSample (unsigned int pSampleIndex)
 switch sample
void setLoopFadeDuration (sample pLoopFadeDuration)
 set loop fade duration
void setSampleFadeDuration (sample pSampleFadeDuration)
 set sample fade duration
void setPlayStartPosition (sample pPlayStartPosition)
 set play start position
void setPlayStopPosition (sample pPlayStopPosition)
 set play stop position
virtual void process (Buffer *pBuffer) throw (SynthException)
 processes buffer
virtual String info (bool pPropagate=false, bool pShowPorts=true) const
 obtain textual unit information

Static Public Attributes

static const String sClassName
 default name

Protected Member Functions

 SampleUnit ()
 default constructor
void init (const String &pFileName) throw (SynthException)
 called by constructor

Protected Attributes

bool mLooping
 true: sound file loops, false: sound file plays once
bool mLoopFading
int mPlayStartPosition
 currently loop fading play start position in sound file
int mNewPlayStartPosition
 new play start position in sound file
bool mNewPlayStartAvailable
int mPlayStopPosition
 play stop position in sound file
int mNewPlayStopPosition
 new play stop position in sound file
bool mNewPlayStopAvailable
bool mResetSample
 whether the play position will be reset to the start position at the beginning of the next process call
BuffermSampleBuffer
 current sound file audio data
data::IndexHash< String, BuffermSampleBuffers
 registry for sound buffers
unsigned int mCurrentSampleIndex
 index into sound file buffers indicating current sound file buffer
unsigned int mNewSampleIndex
 index into sound file buffers indicating new sound file buffer
sample mSampleStartFrame
 start frame position within sound file data
ControlPortmAmplitude
 amplitude control port
ControlPortmTranspose
 transpose control port
BuffermPrevSampleBuffer
sample mPrevSampleStartFrame
 previous sound file audio data
sample mSampleFadeDuration
 prev start frame position within sample file data
sample mCurrentSampleFadeDuration
 switch sample fade duration (in number of samples)
sample mLoopSampleStartFrame
 current sample switch fade duration
sample mLoopFadeDuration
 start frame in loop region at beginning of sample file data
sample mCurrentLoopFadeDuration
 loop fade duration (in number of samples)

Static Protected Attributes

static unsigned int sUnitCount
 total number of units created so far

Detailed Description

sample playback unit

unit

Unit that plays back samples
Contrary to the InputFile unit, the SampleUnit stores the entire audio file in memory.
This unit possesses the following capabilities:
allows the playback of excerpts of the sample via setting playStart and playStop positions (in milisecs).
loop samples by linear fading the beginning and end of the sample.
transpose sample playback, both positive and negative transpose values are fine.
switch between samples, again fading linearly from one sample to the next.
In order to switch between samples, the samples have first to be added to the unit via the addSample function.
From then on, samples are switched by providing a new sample index to the sample port.


ControlPorts
name: amplitude defaultValue: 1.0
name: transpose defaultValue: 1.0

SwitchPorts:
name: sample channelCount: 1 defaultValue: 0.0 resizable: false function: setSample
name: play channelCount: 1 defaultValue: 1.0 resizable: false function: play
name: looping channelCount: 1 defaultValue: 0.0 resizable: false function: setLooping
name: loopFadeDuration channelCount: 1 defaultValue: 0.0 resizable: false function: setLoopFadeDuration
name: sampleFadeDuration channelCount: 1 defaultValue: 0.0 resizable: false function: setSampleFadeDuration
name: playStart channelCount: 1 defaultValue: 0.0 resizable: false function: setPlayStartPosition
name: playEnd channelCount: 1 defaultValue: (length of sample file) resizable: false function: setPlayStopPosition
name: active channelCount: 1 defaultValue: 1.0 resizable: false function: setActive


Created by Daniel Bisig on 10/17/07.


Constructor & Destructor Documentation

SampleUnit::SampleUnit ( String  pFileName  )  throw (SynthException)

parameter based contructor

Parameters:
pFileName sample file name

SampleUnit::SampleUnit ( String  pName,
String  pFileName 
) throw (SynthException)

parameter based contructor

Parameters:
pName unit name
pFileName sample file name

SampleUnit::SampleUnit ( const data::Values &  pValues  )  throw (SynthException)

values based constructor

Parameters:
pValues unit values
Exceptions:
SynthException failed to create unit
pValues structure & data types: 0: const String& : unit name 1: const String& : file name

SampleUnit::~SampleUnit (  )  throw (SynthException)

destructor

SampleUnit::SampleUnit (  )  [protected]

default constructor


Member Function Documentation

void SampleUnit::addSample ( String  pFileName  ) 

add additional sample

Parameters:
pFileName file name of additional sample file

void SampleUnit::removeSample ( String  pFileName  ) 

remove sample

Parameters:
pFileName file name

void SampleUnit::play ( bool  pActive  ) 

trigger sound file playback or stop

Parameters:
pActive ( true: start playback, false: stop playback )

void SampleUnit::setLooping ( bool  pLooping  ) 

set soundfile looping property

Parameters:
pLooping ( true: sound file is looping, false: soundfile plays once )

void SampleUnit::switchSample ( unsigned int  pSampleIndex  ) 

switch sample

Parameters:
pSampleIndex ( index into stored sample file buffers )

void SampleUnit::setLoopFadeDuration ( sample  pLoopFadeDuration  ) 

set loop fade duration

Parameters:
pLoopFadeDuration ( loop fade duration (in milisecs) )

void SampleUnit::setSampleFadeDuration ( sample  pSampleFadeDuration  ) 

set sample fade duration

Parameters:
pSampleFadeDuration ( sample fade duration (in milisecs) )

void SampleUnit::setPlayStartPosition ( sample  pPlayStartPosition  ) 

set play start position

Parameters:
pPlayStartPosition ( play start position (in milisecs) )

void SampleUnit::setPlayStopPosition ( sample  pPlayStopPosition  ) 

set play stop position

Parameters:
pPlayStopPosition play stop position (in milisecs)

void SampleUnit::process ( Buffer pBuffer  )  throw (SynthException) [virtual]

processes buffer

Parameters:
pBuffer buffer to process

Reimplemented from iso::synth::InputUnit.

String SampleUnit::info ( bool  pPropagate = false,
bool  pShowPorts = true 
) const [virtual]

obtain textual unit information

Parameters:
pPropagate if true, the unit calls the info methods of its input ports
pShowPorts print port information
Returns:
String containing unit information

Reimplemented from iso::synth::InputUnit.

void SampleUnit::init ( const String pFileName  )  throw (SynthException) [protected]

called by constructor

Parameters:
pFileName sample file name
Exceptions:
SynthException failed to initialize unit


Member Data Documentation

const String SampleUnit::sClassName [static]

default name

Reimplemented from iso::synth::InputUnit.

unsigned int SampleUnit::sUnitCount [static, protected]

total number of units created so far

Reimplemented from iso::synth::InputUnit.

bool iso::synth::SampleUnit::mLooping [protected]

true: sound file loops, false: sound file plays once

bool iso::synth::SampleUnit::mLoopFading [protected]

int iso::synth::SampleUnit::mPlayStartPosition [protected]

currently loop fading play start position in sound file

int iso::synth::SampleUnit::mNewPlayStartPosition [protected]

new play start position in sound file

bool iso::synth::SampleUnit::mNewPlayStartAvailable [protected]

int iso::synth::SampleUnit::mPlayStopPosition [protected]

play stop position in sound file

int iso::synth::SampleUnit::mNewPlayStopPosition [protected]

new play stop position in sound file

bool iso::synth::SampleUnit::mNewPlayStopAvailable [protected]

bool iso::synth::SampleUnit::mResetSample [protected]

whether the play position will be reset to the start position at the beginning of the next process call

Buffer* iso::synth::SampleUnit::mSampleBuffer [protected]

current sound file audio data

data::IndexHash< String, Buffer > iso::synth::SampleUnit::mSampleBuffers [protected]

registry for sound buffers

unsigned int iso::synth::SampleUnit::mCurrentSampleIndex [protected]

index into sound file buffers indicating current sound file buffer

unsigned int iso::synth::SampleUnit::mNewSampleIndex [protected]

index into sound file buffers indicating new sound file buffer

sample iso::synth::SampleUnit::mSampleStartFrame [protected]

start frame position within sound file data

ControlPort* iso::synth::SampleUnit::mAmplitude [protected]

amplitude control port

ControlPort* iso::synth::SampleUnit::mTranspose [protected]

transpose control port

Buffer* iso::synth::SampleUnit::mPrevSampleBuffer [protected]

sample iso::synth::SampleUnit::mPrevSampleStartFrame [protected]

previous sound file audio data

sample iso::synth::SampleUnit::mSampleFadeDuration [protected]

prev start frame position within sample file data

sample iso::synth::SampleUnit::mCurrentSampleFadeDuration [protected]

switch sample fade duration (in number of samples)

sample iso::synth::SampleUnit::mLoopSampleStartFrame [protected]

current sample switch fade duration

sample iso::synth::SampleUnit::mLoopFadeDuration [protected]

start frame in loop region at beginning of sample file data

sample iso::synth::SampleUnit::mCurrentLoopFadeDuration [protected]

loop fade duration (in number of samples)


The documentation for this class was generated from the following files:
Generated on Fri Feb 25 14:18:46 2011 for synth by  doxygen 1.5.1