#include <iso_synth_sample_unit.h>
Inherits iso::synth::InputUnit.
Inheritance diagram for iso::synth::SampleUnit:
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 | |
Buffer * | mSampleBuffer |
current sound file audio data | |
data::IndexHash< String, Buffer > | mSampleBuffers |
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 | |
ControlPort * | mAmplitude |
amplitude control port | |
ControlPort * | mTranspose |
transpose control port | |
Buffer * | mPrevSampleBuffer |
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 |
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.
SampleUnit::SampleUnit | ( | String | pFileName | ) | throw (SynthException) |
parameter based contructor
pFileName | sample file name |
SampleUnit::SampleUnit | ( | String | pName, | |
String | pFileName | |||
) | throw (SynthException) |
parameter based contructor
pName | unit name | |
pFileName | sample file name |
SampleUnit::SampleUnit | ( | const data::Values & | pValues | ) | throw (SynthException) |
values based constructor
pValues | unit values |
SynthException | failed to create unit |
SampleUnit::~SampleUnit | ( | ) | throw (SynthException) |
destructor
SampleUnit::SampleUnit | ( | ) | [protected] |
default constructor
void SampleUnit::addSample | ( | String | pFileName | ) |
add additional sample
pFileName | file name of additional sample file |
void SampleUnit::removeSample | ( | String | pFileName | ) |
remove sample
pFileName | file name |
void SampleUnit::play | ( | bool | pActive | ) |
trigger sound file playback or stop
pActive | ( true: start playback, false: stop playback ) |
void SampleUnit::setLooping | ( | bool | pLooping | ) |
set soundfile looping property
pLooping | ( true: sound file is looping, false: soundfile plays once ) |
void SampleUnit::switchSample | ( | unsigned int | pSampleIndex | ) |
switch sample
pSampleIndex | ( index into stored sample file buffers ) |
void SampleUnit::setLoopFadeDuration | ( | sample | pLoopFadeDuration | ) |
set loop fade duration
pLoopFadeDuration | ( loop fade duration (in milisecs) ) |
void SampleUnit::setSampleFadeDuration | ( | sample | pSampleFadeDuration | ) |
set sample fade duration
pSampleFadeDuration | ( sample fade duration (in milisecs) ) |
void SampleUnit::setPlayStartPosition | ( | sample | pPlayStartPosition | ) |
set play start position
pPlayStartPosition | ( play start position (in milisecs) ) |
void SampleUnit::setPlayStopPosition | ( | sample | pPlayStopPosition | ) |
set play stop position
pPlayStopPosition | play stop position (in milisecs) |
void SampleUnit::process | ( | Buffer * | pBuffer | ) | throw (SynthException) [virtual] |
String SampleUnit::info | ( | bool | pPropagate = false , |
|
bool | pShowPorts = true | |||
) | const [virtual] |
obtain textual unit information
pPropagate | if true, the unit calls the info methods of its input ports | |
pShowPorts | print port information |
Reimplemented from iso::synth::InputUnit.
void SampleUnit::init | ( | const String & | pFileName | ) | throw (SynthException) [protected] |
called by constructor
pFileName | sample file name |
SynthException | failed to initialize unit |
const String SampleUnit::sClassName [static] |
unsigned int SampleUnit::sUnitCount [static, protected] |
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
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
loop fade duration (in number of samples)