Version 4.2.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent cf06b7598b
commit a6381b9d38
281 changed files with 17152 additions and 12000 deletions

View File

@@ -11,12 +11,12 @@
envelope value reaches 0.0 in the
ADSR::RELEASE state.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__ADSR_H)
#define __ADSR_H
#ifndef STK_ADSR_H
#define STK_ADSR_H
#include "Envelope.h"
@@ -40,49 +40,58 @@ class ADSR : public Envelope
void keyOff(void);
//! Set the attack rate.
void setAttackRate(MY_FLOAT aRate);
void setAttackRate(StkFloat rate);
//! Set the decay rate.
void setDecayRate(MY_FLOAT aRate);
void setDecayRate(StkFloat rate);
//! Set the sustain level.
void setSustainLevel(MY_FLOAT aLevel);
void setSustainLevel(StkFloat level);
//! Set the release rate.
void setReleaseRate(MY_FLOAT aRate);
void setReleaseRate(StkFloat rate);
//! Set the attack rate based on a time duration.
void setAttackTime(MY_FLOAT aTime);
void setAttackTime(StkFloat time);
//! Set the decay rate based on a time duration.
void setDecayTime(MY_FLOAT aTime);
void setDecayTime(StkFloat time);
//! Set the release rate based on a time duration.
void setReleaseTime(MY_FLOAT aTime);
void setReleaseTime(StkFloat time);
//! Set sustain level and attack, decay, and release state rates based on time durations.
void setAllTimes(MY_FLOAT aTime, MY_FLOAT dTime, MY_FLOAT sLevel, MY_FLOAT rTime);
//! Set sustain level and attach, decay, and release time durations.
void setAllTimes(StkFloat aTime, StkFloat dTime, StkFloat sLevel, StkFloat rTime);
//! Set the target value.
void setTarget(MY_FLOAT aTarget);
void setTarget(StkFloat target);
//! Return the current envelope \e state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE).
int getState(void) const;
//! Set to state = ADSR::SUSTAIN with current and target values of \e aValue.
void setValue(MY_FLOAT aValue);
void setValue(StkFloat value);
//! Return one envelope output value.
MY_FLOAT tick(void);
StkFloat tick(void);
//! Return \e vectorSize envelope outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Compute \e vectorSize outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT attackRate;
MY_FLOAT decayRate;
MY_FLOAT sustainLevel;
MY_FLOAT releaseRate;
StkFloat attackRate_;
StkFloat decayRate_;
StkFloat sustainLevel_;
StkFloat releaseRate_;
};
#endif

84
include/Asymp.h Normal file
View File

@@ -0,0 +1,84 @@
/***************************************************/
/*! \class Asymp
\brief STK asymptotic curve envelope class
This class implements a simple envelope generator
which asymptotically approaches a target value.
The algorithm used is of the form:
x[n] = a x[n-1] + (1-a) target,
where a = exp(-T/tau), T is the sample period, and
tau is a time constant. The user can set the time
constant (default value = 0.3) and target value.
Theoretically, this recursion never reaches its
target, though the calculations in this class are
stopped when the current value gets within a small
threshold value of the target (at which time the
current value is set to the target). It responds
to \e keyOn and \e keyOff messages by ramping to
1.0 on keyOn and to 0.0 on keyOff.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_ASYMP_H
#define STK_ASYMP_H
#include "Envelope.h"
const StkFloat TARGET_THRESHOLD = 0.000001;
class Asymp : public Envelope
{
public:
//! Default constructor.
Asymp(void);
//! Class destructor.
~Asymp(void);
//! Set target = 1.
void keyOn(void);
//! Set target = 0.
void keyOff(void);
//! Set the asymptotic rate via the time factor \e tau (must be > 0).
/*!
The rate is computed as described above. The value of \e tau
must be greater than zero. Values of \e tau close to zero produce
fast approach rates, while values greater than 1.0 produce rather
slow rates.
*/
void setTau(StkFloat tau);
//! Set the asymptotic rate based on a time duration (must be > 0).
void setTime(StkFloat time);
//! Set the target value.
void setTarget(StkFloat target);
//! Return one envelope output value.
StkFloat tick(void);
//! Compute \e vectorSize outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
StkFloat factor_;
StkFloat constant_;
};
#endif

View File

@@ -24,19 +24,19 @@
- Glass Harmonica = 2
- Tibetan Bowl = 3
by Georg Essl, 1999 - 2002.
by Georg Essl, 1999 - 2004.
Modified for Stk 4.0 by Gary Scavone.
*/
/***************************************************/
#if !defined(__BANDEDWG_H)
#define __BANDEDWG_H
#ifndef STK_BANDEDWG_H
#define STK_BANDEDWG_H
#define MAX_BANDED_MODES 20
const int MAX_BANDED_MODES = 20;
#include "Instrmnt.h"
#include "DelayL.h"
#include "BowTabl.h"
#include "BowTable.h"
#include "ADSR.h"
#include "BiQuad.h"
@@ -53,59 +53,71 @@ class BandedWG : public Instrmnt
void clear();
//! Set strike position (0.0 - 1.0).
void setStrikePosition(MY_FLOAT position);
void setStrikePosition(StkFloat position);
//! Select a preset.
void setPreset(int preset);
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBowing(StkFloat amplitude, StkFloat rate);
//! Decrease bow velocity/breath pressure with given rate of decrease.
void stopBowing(MY_FLOAT rate);
void stopBowing(StkFloat rate);
//! Pluck the instrument with given amplitude.
void pluck(MY_FLOAT amp);
void pluck(StkFloat amp);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
bool doPluck;
bool trackVelocity;
int nModes;
int presetModes;
BowTabl *bowTabl;
ADSR *adsr;
BiQuad *bandpass;
DelayL *delay;
MY_FLOAT maxVelocity;
MY_FLOAT modes[MAX_BANDED_MODES];
MY_FLOAT freakency;
MY_FLOAT baseGain;
MY_FLOAT gains[MAX_BANDED_MODES];
MY_FLOAT basegains[MAX_BANDED_MODES];
MY_FLOAT excitation[MAX_BANDED_MODES];
MY_FLOAT integrationConstant;
MY_FLOAT velocityInput;
MY_FLOAT bowVelocity;
MY_FLOAT bowTarget;
MY_FLOAT bowPosition;
MY_FLOAT strikeAmp;
int strikePosition;
bool doPluck_;
bool trackVelocity_;
int nModes_;
int presetModes_;
BowTable bowTable_;
ADSR adsr_;
BiQuad bandpass_[MAX_BANDED_MODES];
DelayL delay_[MAX_BANDED_MODES];
StkFloat maxVelocity_;
StkFloat modes_[MAX_BANDED_MODES];
StkFloat frequency_;
StkFloat baseGain_;
StkFloat gains_[MAX_BANDED_MODES];
StkFloat basegains_[MAX_BANDED_MODES];
StkFloat excitation_[MAX_BANDED_MODES];
StkFloat integrationConstant_;
StkFloat velocityInput_;
StkFloat bowVelocity_;
StkFloat bowTarget_;
StkFloat bowPosition_;
StkFloat strikeAmp_;
int strikePosition_;
};

View File

@@ -28,12 +28,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BEETHREE_H)
#define __BEETHREE_H
#ifndef STK_BEETHREE_H
#define STK_BEETHREE_H
#include "FM.h"
@@ -41,16 +41,31 @@ class BeeThree : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
BeeThree();
//! Class destructor.
~BeeThree();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -8,12 +8,12 @@
frequency response while maintaining a constant
filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BIQUAD_H)
#define __BIQUAD_H
#ifndef STK_BIQUAD_H
#define STK_BIQUAD_H
#include "Filter.h"
@@ -31,19 +31,19 @@ public:
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
void setB1(StkFloat b1);
//! Set the b[2] coefficient value.
void setB2(MY_FLOAT b2);
void setB2(StkFloat b2);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
void setA1(StkFloat a1);
//! Set the a[2] coefficient value.
void setA2(MY_FLOAT a2);
void setA2(StkFloat a2);
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
/*!
@@ -57,7 +57,7 @@ public:
frequency. The closer the poles are to the unit-circle (\e radius
close to one), the narrower the resulting resonance width.
*/
void setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize = FALSE);
void setResonance(StkFloat frequency, StkFloat radius, bool normalize = false);
//! Set the filter coefficients for a notch at \e frequency (in Hz).
/*!
@@ -66,7 +66,7 @@ public:
and \e radius from the z-plane origin. No filter normalization
is attempted.
*/
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
void setNotch(StkFloat frequency, StkFloat radius);
//! Sets the filter zeroes for equal resonance gain.
/*!
@@ -82,19 +82,28 @@ public:
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
virtual StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -12,15 +12,15 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BOTTLE_H)
#define __BOTTLE_H
#ifndef STK_BLOWBOTL_H
#define STK_BLOWBOTL_H
#include "Instrmnt.h"
#include "JetTabl.h"
#include "JetTable.h"
#include "BiQuad.h"
#include "PoleZero.h"
#include "Noise.h"
@@ -31,6 +31,9 @@ class BlowBotl : public Instrmnt
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
BlowBotl();
//! Class destructor.
@@ -40,37 +43,49 @@ class BlowBotl : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Apply breath velocity to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath velocity with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
JetTabl *jetTable;
BiQuad *resonator;
PoleZero *dcBlock;
Noise *noise;
ADSR *adsr;
WaveLoop *vibrato;
MY_FLOAT maxPressure;
MY_FLOAT noiseGain;
MY_FLOAT vibratoGain;
MY_FLOAT outputGain;
JetTable jetTable_;
BiQuad resonator_;
PoleZero dcBlock_;
Noise noise_;
ADSR adsr_;
WaveLoop *vibrato_;
StkFloat maxPressure_;
StkFloat noiseGain_;
StkFloat vibratoGain_;
StkFloat outputGain_;
};

View File

@@ -29,16 +29,16 @@
- Register State = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BLOWHOLE_H)
#define __BLOWHOLE_H
#ifndef STK_BLOWHOLE_H
#define STK_BLOWHOLE_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "ReedTabl.h"
#include "ReedTable.h"
#include "OneZero.h"
#include "PoleZero.h"
#include "Envelope.h"
@@ -49,7 +49,10 @@ class BlowHole : public Instrmnt
{
public:
//! Class constructor.
BlowHole(MY_FLOAT lowestFrequency);
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
BlowHole(StkFloat lowestFrequency);
//! Class destructor.
~BlowHole();
@@ -58,50 +61,60 @@ class BlowHole : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the tonehole state (0.0 = closed, 1.0 = fully open).
void setTonehole(MY_FLOAT newValue);
void setTonehole(StkFloat newValue);
//! Set the register hole state (0.0 = closed, 1.0 = fully open).
void setVent(MY_FLOAT newValue);
void setVent(StkFloat newValue);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayL *delays[3];
ReedTabl *reedTable;
OneZero *filter;
PoleZero *tonehole;
PoleZero *vent;
Envelope *envelope;
Noise *noise;
WaveLoop *vibrato;
long length;
MY_FLOAT scatter;
MY_FLOAT th_coeff;
MY_FLOAT r_th;
MY_FLOAT rh_coeff;
MY_FLOAT rh_gain;
MY_FLOAT outputGain;
MY_FLOAT noiseGain;
MY_FLOAT vibratoGain;
DelayL delays_[3];
ReedTable reedTable_;
OneZero filter_;
PoleZero tonehole_;
PoleZero vent_;
Envelope envelope_;
Noise noise_;
WaveLoop *vibrato_;
unsigned long length_;
StkFloat scatter_;
StkFloat thCoeff_;
StkFloat rhGain_;
StkFloat outputGain_;
StkFloat noiseGain_;
StkFloat vibratoGain_;
};

View File

@@ -1,62 +0,0 @@
/***************************************************/
/*! \class BowTabl
\brief STK bowed string table class.
This class implements a simple bowed string
non-linear function, as described by Smith (1986).
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__BOWTABL_H)
#define __BOWTABL_H
#include "Stk.h"
class BowTabl : public Stk
{
public:
//! Default constructor.
BowTabl();
//! Class destructor.
~BowTabl();
//! Set the table offset value.
/*!
The table offset is a bias which controls the
symmetry of the friction. If you want the
friction to vary with direction, use a non-zero
value for the offset. The default value is zero.
*/
void setOffset(MY_FLOAT aValue);
//! Set the table slope value.
/*!
The table slope controls the width of the friction
pulse, which is related to bow force.
*/
void setSlope(MY_FLOAT aValue);
//! Return the last output value.
MY_FLOAT lastOut(void) const;
//! Return the function value for \e input.
/*!
The function input represents differential
string-to-bow velocity.
*/
MY_FLOAT tick(const MY_FLOAT input);
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
protected:
MY_FLOAT offSet;
MY_FLOAT slope;
MY_FLOAT lastOutput;
};
#endif

67
include/BowTable.h Normal file
View File

@@ -0,0 +1,67 @@
/***************************************************/
/*! \class BowTable
\brief STK bowed string table class.
This class implements a simple bowed string
non-linear function, as described by Smith (1986).
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_BOWTABL_H
#define STK_BOWTABL_H
#include "Function.h"
class BowTable : public Function
{
public:
//! Default constructor.
BowTable();
//! Class destructor.
~BowTable();
//! Set the table offset value.
/*!
The table offset is a bias which controls the
symmetry of the friction. If you want the
friction to vary with direction, use a non-zero
value for the offset. The default value is zero.
*/
void setOffset(StkFloat offset);
//! Set the table slope value.
/*!
The table slope controls the width of the friction
pulse, which is related to bow force.
*/
void setSlope(StkFloat slope);
//! Return the function value for \e input.
/*!
The function input represents differential
string-to-bow velocity.
*/
StkFloat tick( StkFloat input);
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
StkFloat offset_;
StkFloat slope_;
};
#endif

View File

@@ -17,16 +17,16 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BOWED_H)
#define __BOWED_H
#ifndef STK_BOWED_H
#define STK_BOWED_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "BowTabl.h"
#include "BowTable.h"
#include "OnePole.h"
#include "BiQuad.h"
#include "WaveLoop.h"
@@ -36,7 +36,7 @@ class Bowed : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Bowed(MY_FLOAT lowestFrequency);
Bowed(StkFloat lowestFrequency);
//! Class destructor.
~Bowed();
@@ -45,41 +45,53 @@ class Bowed : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set vibrato gain.
void setVibrato(MY_FLOAT gain);
void setVibrato(StkFloat gain);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath pressure with given rate of decrease.
void stopBowing(MY_FLOAT rate);
void stopBowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayL *neckDelay;
DelayL *bridgeDelay;
BowTabl *bowTable;
OnePole *stringFilter;
BiQuad *bodyFilter;
WaveLoop *vibrato;
ADSR *adsr;
MY_FLOAT maxVelocity;
MY_FLOAT baseDelay;
MY_FLOAT vibratoGain;
MY_FLOAT betaRatio;
DelayL neckDelay_;
DelayL bridgeDelay_;
BowTable bowTable_;
OnePole stringFilter_;
BiQuad bodyFilter_;
WaveLoop *vibrato_;
ADSR adsr_;
StkFloat maxVelocity_;
StkFloat baseDelay_;
StkFloat vibratoGain_;
StkFloat betaRatio_;
};

View File

@@ -16,12 +16,12 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__BRASS_H)
#define __BRASS_H
#ifndef STK_BRASS_H
#define STK_BRASS_H
#include "Instrmnt.h"
#include "DelayA.h"
@@ -34,7 +34,10 @@ class Brass: public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Brass(MY_FLOAT lowestFrequency);
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Brass(StkFloat lowestFrequency);
//! Class destructor.
~Brass();
@@ -43,40 +46,52 @@ class Brass: public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the lips frequency.
void setLip(MY_FLOAT frequency);
void setLip(StkFloat frequency);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayA *delayLine;
BiQuad *lipFilter;
PoleZero *dcBlock;
ADSR *adsr;
WaveLoop *vibrato;
long length;
MY_FLOAT lipTarget;
MY_FLOAT slideTarget;
MY_FLOAT vibratoGain;
MY_FLOAT maxPressure;
DelayA delayLine_;
BiQuad lipFilter_;
PoleZero dcBlock_;
ADSR adsr_;
WaveLoop *vibrato_;
unsigned long length_;
StkFloat lipTarget_;
StkFloat slideTarget_;
StkFloat vibratoGain_;
StkFloat maxPressure_;
};

View File

@@ -4,22 +4,25 @@
This class implements a chorus effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__CHORUS_H)
#define __CHORUS_H
#ifndef STK_CHORUS_H
#define STK_CHORUS_H
#include "Stk.h"
#include "Effect.h"
#include "DelayL.h"
#include "WaveLoop.h"
class Chorus : public Stk
class Chorus : public Effect
{
public:
//! Class constructor, taking the longest desired delay length.
Chorus(MY_FLOAT baseDelay);
//! Class constructor, taking the median desired delay length.
/*!
An StkError can be thrown if the rawwave path is incorrect.
*/
Chorus( StkFloat baseDelay = 6000 );
//! Class destructor.
~Chorus();
@@ -28,36 +31,31 @@ class Chorus : public Stk
void clear();
//! Set modulation depth.
void setModDepth(MY_FLOAT depth);
void setModDepth(StkFloat depth);
//! Set modulation frequency.
void setModFrequency(MY_FLOAT frequency);
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
void setEffectMix(MY_FLOAT mix);
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the last left output value.
MY_FLOAT lastOutLeft() const;
//! Return the last right output value.
MY_FLOAT lastOutRight() const;
void setModFrequency(StkFloat frequency);
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
DelayL *delayLine[2];
WaveLoop *mods[2];
MY_FLOAT baseLength;
MY_FLOAT modDepth;
MY_FLOAT lastOutput[2];
MY_FLOAT effectMix;
DelayL delayLine_[2];
WaveLoop *mods_[2];
StkFloat baseLength_;
StkFloat modDepth_;
};

View File

@@ -18,16 +18,16 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__CLARINET_H)
#define __CLARINET_H
#ifndef STK_CLARINET_H
#define STK_CLARINET_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "ReedTabl.h"
#include "ReedTable.h"
#include "OneZero.h"
#include "Envelope.h"
#include "Noise.h"
@@ -37,7 +37,10 @@ class Clarinet : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Clarinet(MY_FLOAT lowestFrequency);
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Clarinet(StkFloat lowestFrequency);
//! Class destructor.
~Clarinet();
@@ -46,37 +49,49 @@ class Clarinet : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayL *delayLine;
ReedTabl *reedTable;
OneZero *filter;
Envelope *envelope;
Noise *noise;
WaveLoop *vibrato;
long length;
MY_FLOAT outputGain;
MY_FLOAT noiseGain;
MY_FLOAT vibratoGain;
DelayL delayLine_;
ReedTable reedTable_;
OneZero filter_;
Envelope envelope_;
Noise noise_;
WaveLoop *vibrato_;
long length_;
StkFloat outputGain_;
StkFloat noiseGain_;
StkFloat vibratoGain_;
};

View File

@@ -14,12 +14,12 @@
used in fixed delay-length applications, such
as for reverberation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__DELAY_H)
#define __DELAY_H
#ifndef STK_DELAY_H
#define STK_DELAY_H
#include "Filter.h"
@@ -31,7 +31,12 @@ public:
Delay();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
Delay(long theDelay, long maxDelay);
/*!
An StkError will be thrown if the delay parameter is less than
zero, the maximum delay parameter is less than one, or the delay
parameter is greater than the maxDelay value.
*/
Delay(unsigned long delay, unsigned long maxDelay);
//! Class destructor.
virtual ~Delay();
@@ -39,17 +44,27 @@ public:
//! Clears the internal state of the delay line.
void clear();
//! Set the maximum delay-line length.
/*!
This method should generally only be used during initial setup
of the delay line. If it is used between calls to the tick()
function, without a call to clear(), a signal discontinuity will
likely occur. If the current maximum length is greater than the
new length, no change will be made.
*/
void setMaximumDelay(unsigned long delay);
//! Set the delay-line length.
/*!
The valid range for \e theDelay is from 0 to the maximum delay-line length.
*/
void setDelay(long theDelay);
void setDelay(unsigned long delay);
//! Return the current delay-line length.
long getDelay(void) const;
unsigned long getDelay(void) const;
//! Calculate and return the signal energy in the delay-line.
MY_FLOAT energy(void) const;
StkFloat energy(void) const;
//! Return the value at \e tapDelay samples from the delay-line input.
/*!
@@ -57,28 +72,36 @@ public:
relative to the last input value (i.e., a tapDelay of zero returns
the last input value).
*/
MY_FLOAT contentsAt(unsigned long tapDelay) const;
StkFloat contentsAt(unsigned long tapDelay);
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Return the value which will be output by the next call to tick().
/*!
This method is valid only for delay settings greater than zero!
*/
virtual MY_FLOAT nextOut(void) const;
virtual StkFloat nextOut(void);
//! Input one sample to the delay-line and return one output.
virtual MY_FLOAT tick(MY_FLOAT sample);
//! Input one sample to the delayline and return one output.
virtual StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the delay-line and return an equal number of outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Input \e vectorSize samples to the delayline and return an equal number of outputs in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
long inPoint;
long outPoint;
long length;
MY_FLOAT delay;
unsigned long inPoint_;
unsigned long outPoint_;
StkFloat delay_;
};
#endif

View File

@@ -18,12 +18,12 @@
response, the minimum delay possible in this
implementation is limited to a value of 0.5.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__DelayA_h)
#define __DelayA_h
#ifndef STK_DELAYA_H
#define STK_DELAYA_H
#include "Delay.h"
@@ -35,8 +35,12 @@ public:
DelayA();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
DelayA(MY_FLOAT theDelay, long maxDelay);
/*!
An StkError will be thrown if the delay parameter is less than
zero, the maximum delay parameter is less than one, or the delay
parameter is greater than the maxDelay value.
*/
DelayA(StkFloat delay, unsigned long maxDelay);
//! Class destructor.
~DelayA();
@@ -48,26 +52,38 @@ public:
/*!
The valid range for \e theDelay is from 0.5 to the maximum delay-line length.
*/
void setDelay(MY_FLOAT theDelay);
void setDelay(StkFloat delay);
//! Return the current delay-line length.
MY_FLOAT getDelay(void);
StkFloat getDelay(void);
//! Return the value which will be output by the next call to tick().
/*!
This method is valid only for delay settings greater than zero!
*/
MY_FLOAT nextOut(void);
StkFloat nextOut(void);
//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
//! Input one sample to the delayline and return one output.
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the delayline and return an equal number of outputs in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT alpha;
MY_FLOAT coeff;
MY_FLOAT apInput;
MY_FLOAT nextOutput;
bool doNextOut;
StkFloat alpha_;
StkFloat coeff_;
StkFloat apInput_;
StkFloat nextOutput_;
bool doNextOut_;
};
#endif

View File

@@ -18,12 +18,12 @@
order Lagrange interpolators can typically
improve (minimize) this attenuation characteristic.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__DELAYL_H)
#define __DELAYL_H
#ifndef STK_DELAYL_H
#define STK_DELAYL_H
#include "Delay.h"
@@ -35,8 +35,12 @@ public:
DelayL();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
DelayL(MY_FLOAT theDelay, long maxDelay);
/*!
An StkError will be thrown if the delay parameter is less than
zero, the maximum delay parameter is less than one, or the delay
parameter is greater than the maxDelay value.
*/
DelayL(StkFloat delay, unsigned long maxDelay);
//! Class destructor.
~DelayL();
@@ -45,25 +49,37 @@ public:
/*!
The valid range for \e theDelay is from 0 to the maximum delay-line length.
*/
void setDelay(MY_FLOAT theDelay);
void setDelay(StkFloat delay);
//! Return the current delay-line length.
MY_FLOAT getDelay(void) const;
StkFloat getDelay(void) const;
//! Return the value which will be output by the next call to tick().
/*!
This method is valid only for delay settings greater than zero!
*/
MY_FLOAT nextOut(void);
StkFloat nextOut(void);
//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the delay-line and return an equal number of outputs in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT alpha;
MY_FLOAT omAlpha;
MY_FLOAT nextOutput;
bool doNextOut;
StkFloat alpha_;
StkFloat omAlpha_;
StkFloat nextOutput_;
bool doNextOut_;
};
#endif

View File

@@ -11,24 +11,27 @@
of simultaneous voices) via a #define in the
Drummer.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__DRUMMER_H)
#define __DRUMMER_H
#ifndef STK_DRUMMER_H
#define STK_DRUMMER_H
#include "Instrmnt.h"
#include "WvIn.h"
#include "OnePole.h"
#define DRUM_NUMWAVES 11
#define DRUM_POLYPHONY 4
const int DRUM_NUMWAVES = 11;
const int DRUM_POLYPHONY = 4;
class Drummer : public Instrmnt
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Drummer();
//! Class destructor.
@@ -37,23 +40,35 @@ class Drummer : public Instrmnt
//! Start a note with the given drum type and amplitude.
/*!
Use general MIDI drum instrument numbers, converted to
frequency values as if MIDI note numbers, to select a
particular instrument.
frequency values as if MIDI note numbers, to select a particular
instrument. An StkError will be thrown if the rawwave path is
incorrectly set.
*/
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
void noteOn(StkFloat instrument, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
WvIn *waves[DRUM_POLYPHONY];
OnePole *filters[DRUM_POLYPHONY];
int sounding[DRUM_POLYPHONY];
int nSounding;
WvIn *waves_[DRUM_POLYPHONY];
OnePole *filters_[DRUM_POLYPHONY];
int sounding_[DRUM_POLYPHONY];
int nSounding_;
};
#endif

View File

@@ -2,23 +2,26 @@
/*! \class Echo
\brief STK echo effect class.
This class implements a echo effect.
This class implements an echo effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__ECHO_H)
#define __ECHO_H
#ifndef STK_ECHO_H
#define STK_ECHO_H
#include "Stk.h"
#include "Effect.h"
#include "Delay.h"
class Echo : public Stk
class Echo : public Effect
{
public:
//! Class constructor, taking the longest desired delay length.
Echo(MY_FLOAT longestDelay);
//! Class constructor, taking the longest desired delay length (one second default value).
/*!
The default delay value is set to 1/2 the maximum delay length.
*/
Echo( unsigned long maximumDelay = (unsigned long) Stk::sampleRate() );
//! Class destructor.
~Echo();
@@ -26,26 +29,30 @@ class Echo : public Stk
//! Reset and clear all internal state.
void clear();
//! Set the maximum delay line length in samples.
void setMaximumDelay( unsigned long delay );
//! Set the delay line length in samples.
void setDelay(MY_FLOAT delay);
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
void setEffectMix(MY_FLOAT mix);
//! Return the last output value.
MY_FLOAT lastOut() const;
void setDelay( unsigned long delay );
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
Delay *delayLine;
long length;
MY_FLOAT lastOutput;
MY_FLOAT effectMix;
Delay delayLine_;
unsigned long length_;
};

67
include/Effect.h Normal file
View File

@@ -0,0 +1,67 @@
/***************************************************/
/*! \class Effect
\brief STK abstract effects parent class.
This class provides common functionality for
STK effects subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#include "Stk.h"
#ifndef STK_EFFECT_H
#define STK_EFFECT_H
class Effect : public Stk
{
public:
//! Class constructor.
Effect();
//! Class destructor.
virtual ~Effect();
//! Reset and clear all internal state.
virtual void clear() = 0;
//! Set the mixture of input and "effected" levels in the output (0.0 = input only, 1.0 = reverb only).
void setEffectMix(StkFloat mix);
//! Return the last output value.
StkFloat lastOut() const;
//! Return the last left output value.
StkFloat lastOutLeft() const;
//! Return the last right output value.
StkFloat lastOutRight() const;
//! Abstract tick function ... must be implemented in subclasses.
virtual StkFloat tick( StkFloat input ) = 0;
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
// Returns true if argument value is prime.
bool isPrime( int number );
StkFloat lastOutput_[2];
StkFloat effectMix_;
};
#endif

View File

@@ -9,16 +9,16 @@
\e keyOff messages, ramping to 1.0 on
keyOn and to 0.0 on keyOff.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__ENVELOPE_H)
#define __ENVELOPE_H
#ifndef STK_ENVELOPE_H
#define STK_ENVELOPE_H
#include "Stk.h"
#include "Generator.h"
class Envelope : public Stk
class Envelope : public Generator
{
public:
@@ -35,34 +35,40 @@ class Envelope : public Stk
virtual void keyOff(void);
//! Set the \e rate.
void setRate(MY_FLOAT aRate);
void setRate(StkFloat rate);
//! Set the \e rate based on a time duration.
void setTime(MY_FLOAT aTime);
void setTime(StkFloat time);
//! Set the target value.
virtual void setTarget(MY_FLOAT aTarget);
virtual void setTarget(StkFloat target);
//! Set current and target values to \e aValue.
virtual void setValue(MY_FLOAT aValue);
virtual void setValue(StkFloat value);
//! Return the current envelope \e state (0 = at target, 1 otherwise).
virtual int getState(void) const;
//! Return one envelope output value.
virtual MY_FLOAT tick(void);
virtual StkFloat tick(void);
//! Return \e vectorSize envelope outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Compute \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT value;
MY_FLOAT target;
MY_FLOAT rate;
int state;
StkFloat value_;
StkFloat target_;
StkFloat rate_;
int state_;
};
#endif

View File

@@ -19,12 +19,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__FM_H)
#define __FM_H
#ifndef STK_FM_H
#define STK_FM_H
#include "Instrmnt.h"
#include "ADSR.h"
@@ -35,7 +35,10 @@ class FM : public Instrmnt
{
public:
//! Class constructor, taking the number of wave/envelope operators to control.
FM( int operators = 4 );
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
FM( unsigned int operators = 4 );
//! Class destructor.
virtual ~FM();
@@ -47,25 +50,25 @@ class FM : public Instrmnt
void loadWaves(const char **filenames);
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Set the frequency ratio for the specified wave.
void setRatio(int waveIndex, MY_FLOAT ratio);
void setRatio(unsigned int waveIndex, StkFloat ratio);
//! Set the gain for the specified wave.
void setGain(int waveIndex, MY_FLOAT gain);
void setGain(unsigned int waveIndex, StkFloat gain);
//! Set the modulation speed in Hz.
void setModulationSpeed(MY_FLOAT mSpeed);
void setModulationSpeed(StkFloat mSpeed);
//! Set the modulation depth.
void setModulationDepth(MY_FLOAT mDepth);
void setModulationDepth(StkFloat mDepth);
//! Set the value of control1.
void setControl1(MY_FLOAT cVal);
void setControl1(StkFloat cVal);
//! Set the value of control1.
void setControl2(MY_FLOAT cVal);
void setControl2(StkFloat cVal);
//! Start envelopes toward "on" targets.
void keyOn();
@@ -74,29 +77,41 @@ class FM : public Instrmnt
void keyOff();
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Pure virtual function ... must be defined in subclasses.
virtual MY_FLOAT tick() = 0;
virtual StkFloat tick() = 0;
//! Computer \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
virtual void controlChange(int number, StkFloat value);
protected:
ADSR **adsr;
WaveLoop **waves;
WaveLoop *vibrato;
TwoZero *twozero;
int nOperators;
MY_FLOAT baseFrequency;
MY_FLOAT *ratios;
MY_FLOAT *gains;
MY_FLOAT modDepth;
MY_FLOAT control1;
MY_FLOAT control2;
MY_FLOAT __FM_gains[100];
MY_FLOAT __FM_susLevels[16];
MY_FLOAT __FM_attTimes[32];
std::vector<ADSR *> adsr_;
std::vector<WaveLoop *> waves_;
WaveLoop *vibrato_;
TwoZero twozero_;
unsigned int nOperators_;
StkFloat baseFrequency_;
std::vector<StkFloat> ratios_;
std::vector<StkFloat> gains_;
StkFloat modDepth_;
StkFloat control1_;
StkFloat control2_;
StkFloat fmGains_[100];
StkFloat fmSusLevels_[16];
StkFloat fmAttTimes_[32];
};

View File

@@ -26,12 +26,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__FMVOICES_H)
#define __FMVOICES_H
#ifndef STK_FMVOICES_H
#define STK_FMVOICES_H
#include "FM.h"
@@ -39,27 +39,42 @@ class FMVoices : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
FMVoices();
//! Class destructor.
~FMVoices();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
virtual void controlChange(int number, StkFloat value);
protected:
int currentVowel;
MY_FLOAT tilt[3];
MY_FLOAT mods[3];
int currentVowel_;
StkFloat tilt_[3];
StkFloat mods_[3];
};
#endif

View File

@@ -23,14 +23,16 @@
results in one extra multiply per computed sample,
but allows easy control of the overall filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__FILTER_H)
#define __FILTER_H
#ifndef STK_FILTER_H
#define STK_FILTER_H
#include "Stk.h"
#include <vector>
#include <valarray>
class Filter : public Stk
{
@@ -40,72 +42,81 @@ public:
//! Overloaded constructor which takes filter coefficients.
/*!
An StkError can be thrown if either \e nb or \e na is less than
one, or if the a[0] coefficient is equal to zero.
An StkError can be thrown if either of the coefficient vector
sizes is zero, or if the a[0] coefficient is equal to zero.
*/
Filter(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
Filter( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients );
//! Class destructor.
virtual ~Filter(void);
//! Clears all internal states of the filter.
//! Sets all internal states of the filter to zero.
void clear(void);
//! Set filter coefficients.
/*!
An StkError can be thrown if either \e nb or \e na is less than
one, or if the a[0] coefficient is equal to zero. If a[0] is not
equal to 1, the filter coeffcients are normalized by a[0].
An StkError can be thrown if either of the coefficient vector
sizes is zero, or if the a[0] coefficient is equal to zero. If
a[0] is not equal to 1, the filter coeffcients are normalized by
a[0]. The internal state of the filter is cleared.
*/
void setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
void setCoefficients( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients );
//! Set numerator coefficients.
/*!
An StkError can be thrown if \e nb is less than one. Any
previously set denominator coefficients are left unaffected.
Note that the default constructor sets the single denominator
coefficient a[0] to 1.0.
An StkError can be thrown if coefficient vector is empty. Any
previously set denominator coefficients are left unaffected. Note
that the default constructor sets the single denominator
coefficient a[0] to 1.0. The internal state of the filter is
cleared.
*/
void setNumerator(int nb, MY_FLOAT *bCoefficients);
void setNumerator( std::vector<StkFloat> &bCoefficients );
//! Set denominator coefficients.
/*!
An StkError can be thrown if \e na is less than one or if the
a[0] coefficient is equal to zero. Previously set numerator
coefficients are unaffected unless a[0] is not equal to 1, in
which case all coeffcients are normalized by a[0]. Note that the
default constructor sets the single numerator coefficient b[0]
to 1.0.
An StkError can be thrown if the coefficient vector is empty or
if the a[0] coefficient is equal to zero. Previously set
numerator coefficients are unaffected unless a[0] is not equal to
1, in which case all coeffcients are normalized by a[0]. Note
that the default constructor sets the single numerator coefficient
b[0] to 1.0. The internal state of the filter is cleared.
*/
void setDenominator(int na, MY_FLOAT *aCoefficients);
void setDenominator( std::vector<StkFloat> &aCoefficients );
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
virtual void setGain(MY_FLOAT theGain);
virtual void setGain(StkFloat gain);
//! Return the current filter gain.
virtual MY_FLOAT getGain(void) const;
virtual StkFloat getGain(void) const;
//! Return the last computed output value.
virtual MY_FLOAT lastOut(void) const;
virtual StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
virtual MY_FLOAT tick(MY_FLOAT sample);
virtual StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT gain;
int nB;
int nA;
MY_FLOAT *b;
MY_FLOAT *a;
MY_FLOAT *outputs;
MY_FLOAT *inputs;
StkFloat gain_;
std::vector<StkFloat> b_;
std::vector<StkFloat> a_;
std::vector<StkFloat> outputs_;
std::vector<StkFloat> inputs_;
};

View File

@@ -18,15 +18,15 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__FLUTE_H)
#define __FLUTE_H
#ifndef STK_FLUTE_H
#define STK_FLUTE_H
#include "Instrmnt.h"
#include "JetTabl.h"
#include "JetTable.h"
#include "DelayL.h"
#include "OnePole.h"
#include "PoleZero.h"
@@ -38,7 +38,10 @@ class Flute : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Flute(MY_FLOAT lowestFrequency);
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Flute(StkFloat lowestFrequency);
//! Class destructor.
~Flute();
@@ -47,53 +50,65 @@ class Flute : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the reflection coefficient for the jet delay (-1.0 - 1.0).
void setJetReflection(MY_FLOAT coefficient);
void setJetReflection(StkFloat coefficient);
//! Set the reflection coefficient for the air column delay (-1.0 - 1.0).
void setEndReflection(MY_FLOAT coefficient);
void setEndReflection(StkFloat coefficient);
//! Set the length of the jet delay in terms of a ratio of jet delay to air column delay lengths.
void setJetDelay(MY_FLOAT aRatio);
void setJetDelay(StkFloat aRatio);
//! Apply breath velocity to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath velocity with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayL *jetDelay;
DelayL *boreDelay;
JetTabl *jetTable;
OnePole *filter;
PoleZero *dcBlock;
Noise *noise;
ADSR *adsr;
WaveLoop *vibrato;
long length;
MY_FLOAT lastFrequency;
MY_FLOAT maxPressure;
MY_FLOAT jetReflection;
MY_FLOAT endReflection;
MY_FLOAT noiseGain;
MY_FLOAT vibratoGain;
MY_FLOAT outputGain;
MY_FLOAT jetRatio;
DelayL jetDelay_;
DelayL boreDelay_;
JetTable jetTable_;
OnePole filter_;
PoleZero dcBlock_;
Noise noise_;
ADSR adsr_;
WaveLoop *vibrato_;
unsigned long length_;
StkFloat lastFrequency_;
StkFloat maxPressure_;
StkFloat jetReflection_;
StkFloat endReflection_;
StkFloat noiseGain_;
StkFloat vibratoGain_;
StkFloat outputGain_;
StkFloat jetRatio_;
};

View File

@@ -8,12 +8,12 @@
It provides methods for controlling the sweep
rate and target frequency.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__FORMSWEP_H)
#define __FORMSWEP_H
#ifndef STK_FORMSWEP_H
#define STK_FORMSWEP_H
#include "BiQuad.h"
@@ -39,13 +39,13 @@ class FormSwep : public BiQuad
the unit-circle (\e radius close to one), the narrower the
resulting resonance width.
*/
void setResonance(MY_FLOAT aFrequency, MY_FLOAT aRadius);
void setResonance(StkFloat frequency, StkFloat radius);
//! Set both the current and target resonance parameters.
void setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
void setStates(StkFloat frequency, StkFloat radius, StkFloat gain = 1.0);
//! Set target resonance parameters.
void setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
void setTargets(StkFloat frequency, StkFloat radius, StkFloat gain = 1.0);
//! Set the sweep rate (between 0.0 - 1.0).
/*!
@@ -56,7 +56,7 @@ class FormSwep : public BiQuad
target values. A sweep rate of 0.0 will produce no
change in resonance parameters.
*/
void setSweepRate(MY_FLOAT aRate);
void setSweepRate(StkFloat rate);
//! Set the sweep rate in terms of a time value in seconds.
/*!
@@ -64,29 +64,38 @@ class FormSwep : public BiQuad
given time for the formant parameters to reach
their target values.
*/
void setSweepTime(MY_FLOAT aTime);
void setSweepTime(StkFloat time);
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
bool dirty;
MY_FLOAT frequency;
MY_FLOAT radius;
MY_FLOAT startFrequency;
MY_FLOAT startRadius;
MY_FLOAT startGain;
MY_FLOAT targetFrequency;
MY_FLOAT targetRadius;
MY_FLOAT targetGain;
MY_FLOAT deltaFrequency;
MY_FLOAT deltaRadius;
MY_FLOAT deltaGain;
MY_FLOAT sweepState;
MY_FLOAT sweepRate;
bool dirty_;
StkFloat frequency_;
StkFloat radius_;
StkFloat startFrequency_;
StkFloat startRadius_;
StkFloat startGain_;
StkFloat targetFrequency_;
StkFloat targetRadius_;
StkFloat targetGain_;
StkFloat deltaFrequency_;
StkFloat deltaRadius_;
StkFloat deltaGain_;
StkFloat sweepState_;
StkFloat sweepRate_;
};

52
include/Function.h Normal file
View File

@@ -0,0 +1,52 @@
/***************************************************/
/*! \class Function
\brief STK abstract function parent class.
This class provides common functionality for STK classes which
implement tables or other types of input to output function
mappings.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#include "Stk.h"
#ifndef STK_FUNCTION_H
#define STK_FUNCTION_H
class Function : public Stk
{
public:
//! Class constructor.
Function();
//! Class destructor.
virtual ~Function();
//! Return the last output value.
virtual StkFloat lastOut() const { return lastOutput_; };
//! Abstract tick function ... must be implemented in subclasses.
virtual StkFloat tick( StkFloat input ) = 0;
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
StkFloat lastOutput_;
};
#endif

51
include/Generator.h Normal file
View File

@@ -0,0 +1,51 @@
/***************************************************/
/*! \class Generator
\brief STK abstract unit generator parent class.
This class provides common functionality for
STK unit generator source subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_GENERATOR_H
#define STK_GENERATOR_H
#include "Stk.h"
class Generator : public Stk
{
public:
//! Class constructor.
Generator();
//! Class destructor.
virtual ~Generator();
//! Return the last output value.
virtual StkFloat lastOut() const { return lastOutput_; };
//! Abstract tick function ... must be implemented in subclasses.
virtual StkFloat tick( void ) = 0;
//! Compute \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
StkFloat lastOutput_;
};
#endif

View File

@@ -24,12 +24,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__HEVYMETL_H)
#define __HEVYMETL_H
#ifndef STK_HEVYMETL_H
#define STK_HEVYMETL_H
#include "FM.h"
@@ -37,16 +37,31 @@ class HevyMetl : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
HevyMetl();
//! Class destructor.
~HevyMetl();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -5,15 +5,14 @@
This class provides a common interface for
all STK instruments.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__INSTRMNT_H)
#define __INSTRMNT_H
#ifndef STK_INSTRMNT_H
#define STK_INSTRMNT_H
#include "Stk.h"
#include <iostream>
class Instrmnt : public Stk
{
@@ -25,34 +24,43 @@ class Instrmnt : public Stk
virtual ~Instrmnt();
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) = 0;
virtual void noteOn(StkFloat frequency, StkFloat amplitude) = 0;
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude) = 0;
virtual void noteOff(StkFloat amplitude) = 0;
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Return the last output value.
MY_FLOAT lastOut() const;
StkFloat lastOut() const;
//! Return the last left output value.
MY_FLOAT lastOutLeft() const;
StkFloat lastOutLeft() const;
//! Return the last right output value.
MY_FLOAT lastOutRight() const;
StkFloat lastOutRight() const;
//! Compute one output sample.
virtual MY_FLOAT tick() = 0;
virtual StkFloat tick() = 0;
//! Computer \e vectorSize outputs and return them in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
virtual void controlChange(int number, StkFloat value);
protected:
MY_FLOAT lastOutput;
StkFloat lastOutput_;
};

View File

@@ -10,21 +10,21 @@
filters, and two decorrelation delay lines in
parallel at the output.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__JCREV_H)
#define __JCREV_H
#ifndef STK_JCREV_H
#define STK_JCREV_H
#include "Reverb.h"
#include "Effect.h"
#include "Delay.h"
class JCRev : public Reverb
class JCRev : public Effect
{
public:
//! Class constructor taking a T60 decay time argument.
JCRev(MY_FLOAT T60);
//! Class constructor taking a T60 decay time argument (one second default value).
JCRev( StkFloat T60 = 1.0 );
//! Class destructor.
~JCRev();
@@ -32,16 +32,31 @@ class JCRev : public Reverb
//! Reset and clear all internal state.
void clear();
//! Set the reverberation T60 decay time.
void setT60( StkFloat T60 );
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
Delay *allpassDelays[3];
Delay *combDelays[4];
Delay *outLeftDelay;
Delay *outRightDelay;
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[4];
Delay allpassDelays_[3];
Delay combDelays_[4];
Delay outLeftDelay_;
Delay outRightDelay_;
StkFloat allpassCoefficient_;
StkFloat combCoefficient_[4];
};

View File

@@ -1,44 +0,0 @@
/***************************************************/
/*! \class JetTabl
\brief STK jet table class.
This class implements a flue jet non-linear
function, computed by a polynomial calculation.
Contrary to the name, this is not a "table".
Consult Fletcher and Rossing, Karjalainen,
Cook, and others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__JETTABL_H)
#define __JETTABL_H
#include "Stk.h"
class JetTabl : public Stk
{
public:
//! Default constructor.
JetTabl();
//! Class destructor.
~JetTabl();
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the function value for \e input.
MY_FLOAT tick(MY_FLOAT input);
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
protected:
MY_FLOAT lastOutput;
};
#endif

49
include/JetTable.h Normal file
View File

@@ -0,0 +1,49 @@
/***************************************************/
/*! \class JetTable
\brief STK jet table class.
This class implements a flue jet non-linear
function, computed by a polynomial calculation.
Contrary to the name, this is not a "table".
Consult Fletcher and Rossing, Karjalainen,
Cook, and others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_JETTABL_H
#define STK_JETTABL_H
#include "Function.h"
class JetTable : public Function
{
public:
//! Default constructor.
JetTable();
//! Class destructor.
~JetTable();
//! Return the function value for \e input.
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
};
#endif

View File

@@ -23,12 +23,12 @@
- String Detuning = 1
- Microphone Position = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MANDOLIN_H)
#define __MANDOLIN_H
#ifndef STK_MANDOLIN_H
#define STK_MANDOLIN_H
#include "PluckTwo.h"
#include "WvIn.h"
@@ -37,35 +37,46 @@ class Mandolin : public PluckTwo
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Mandolin(MY_FLOAT lowestFrequency);
Mandolin(StkFloat lowestFrequency);
//! Class destructor.
virtual ~Mandolin();
~Mandolin();
//! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency.
void pluck(MY_FLOAT amplitude);
void pluck(StkFloat amplitude);
//! Pluck the strings with the given amplitude (0.0 - 1.0) and position (0.0 - 1.0).
void pluck(MY_FLOAT amplitude,MY_FLOAT position);
void pluck(StkFloat amplitude,StkFloat position);
//! Start a note with the given frequency and amplitude (0.0 - 1.0).
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Set the body size (a value of 1.0 produces the "default" size).
void setBodySize(MY_FLOAT size);
void setBodySize(StkFloat size);
//! Compute one output sample.
virtual MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
WvIn *soundfile[12];
MY_FLOAT directBody;
int mic;
long dampTime;
bool waveDone;
WvIn *soundfile_[12];
int mic_;
long dampTime_;
bool waveDone_;
};
#endif

View File

@@ -24,14 +24,14 @@
*/
/***************************************************/
#if !defined(__MESH2D_H)
#define __MESH2D_H
#ifndef STK_MESH2D_H
#define STK_MESH2D_H
#include "Instrmnt.h"
#include "OnePole.h"
#define NXMAX ((short)(12))
#define NYMAX ((short)(12))
const short NXMAX = 12;
const short NYMAX = 12;
class Mesh2D : public Instrmnt
{
@@ -52,54 +52,64 @@ class Mesh2D : public Instrmnt
void setNY(short lenY);
//! Set the x, y input position on a 0.0 - 1.0 scale.
void setInputPosition(MY_FLOAT xFactor, MY_FLOAT yFactor);
void setInputPosition(StkFloat xFactor, StkFloat yFactor);
//! Set the loss filters gains (0.0 - 1.0).
void setDecay(MY_FLOAT decayFactor);
void setDecay(StkFloat decayFactor);
//! Impulse the mesh with the given amplitude (frequency ignored).
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay) ... currently ignored.
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Calculate and return the signal energy stored in the mesh.
MY_FLOAT energy();
StkFloat energy();
//! Compute one output sample, without adding energy to the mesh.
MY_FLOAT tick();
StkFloat tick();
//! Input a sample to the mesh and compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
MY_FLOAT tick0();
MY_FLOAT tick1();
StkFloat tick0();
StkFloat tick1();
void clearMesh();
short NX, NY;
short xInput, yInput;
OnePole *filterX[NXMAX];
OnePole *filterY[NYMAX];
MY_FLOAT v[NXMAX-1][NYMAX-1]; // junction velocities
MY_FLOAT vxp[NXMAX][NYMAX]; // positive-x velocity wave
MY_FLOAT vxm[NXMAX][NYMAX]; // negative-x velocity wave
MY_FLOAT vyp[NXMAX][NYMAX]; // positive-y velocity wave
MY_FLOAT vym[NXMAX][NYMAX]; // negative-y velocity wave
short NX_, NY_;
short xInput_, yInput_;
OnePole filterX_[NXMAX];
OnePole filterY_[NYMAX];
StkFloat v_[NXMAX-1][NYMAX-1]; // junction velocities
StkFloat vxp_[NXMAX][NYMAX]; // positive-x velocity wave
StkFloat vxm_[NXMAX][NYMAX]; // negative-x velocity wave
StkFloat vyp_[NXMAX][NYMAX]; // positive-y velocity wave
StkFloat vym_[NXMAX][NYMAX]; // negative-y velocity wave
// Alternate buffers
MY_FLOAT vxp1[NXMAX][NYMAX]; // positive-x velocity wave
MY_FLOAT vxm1[NXMAX][NYMAX]; // negative-x velocity wave
MY_FLOAT vyp1[NXMAX][NYMAX]; // positive-y velocity wave
MY_FLOAT vym1[NXMAX][NYMAX]; // negative-y velocity wave
int counter; // time in samples
StkFloat vxp1_[NXMAX][NYMAX]; // positive-x velocity wave
StkFloat vxm1_[NXMAX][NYMAX]; // negative-x velocity wave
StkFloat vyp1_[NXMAX][NYMAX]; // positive-y velocity wave
StkFloat vym1_[NXMAX][NYMAX]; // negative-y velocity wave
int counter_; // time in samples
};
#endif

View File

@@ -2,146 +2,165 @@
/*! \class Messager
\brief STK input control message parser.
This class reads and parses control messages
from a variety of sources, such as a MIDI
port, scorefile, socket connection, or pipe.
MIDI messages are retrieved using the RtMidi
class. All other input sources (scorefile,
socket, or pipe) are assumed to provide SKINI
formatted messages.
This class reads and parses control messages from a variety of
sources, such as a scorefile, MIDI port, socket connection, or
stdin. MIDI messages are retrieved using the RtMidi class. All
other input sources (scorefile, socket, or stdin) are assumed to
provide SKINI formatted messages. This class can be compiled with
generic, non-realtime support, in which case only scorefile
reading is possible.
For each call to nextMessage(), the active
input sources are queried to see if a new
control message is available.
The various \e realtime message acquisition mechanisms (from MIDI,
socket, or stdin) take place asynchronously, filling the message
queue. A call to popMessage() will pop the next available control
message from the queue and return it via the referenced Message
structure. When a \e non-realtime scorefile is set, it is not
possible to start reading realtime input messages (from MIDI,
socket, or stdin). Likewise, it is not possible to read from a
scorefile when a realtime input mechanism is running.
This class is primarily for use in STK main()
event loops.
When MIDI input is started, input is also automatically read from
stdin. This allows for program termination via the terminal
window. An __SK_Exit_ message is pushed onto the stack whenever
an "exit" or "Exit" message is received from stdin or when all
socket connections close and no stdin thread is running.
One of the original goals in creating this
class was to simplify the message acquisition
process by removing all threads. If the
windoze select() function behaved just like
the unix one, that would have been possible.
Since it does not (it can't be used to poll
STDIN), I am using a thread to acquire
messages from STDIN, which sends these
messages via a socket connection to the
message socket server. Perhaps in the future,
it will be possible to simplify things.
This class is primarily for use in STK example programs but it is
generic enough to work in many other contexts.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MESSAGER_H)
#define __MESSSAGER_H
#ifndef STK_MESSAGER_H
#define STK_MESSAGER_H
#include "Stk.h"
#include "SKINI.h"
#include "Skini.h"
#include <queue>
#define MESSAGE_LENGTH 128
#define MAX_MESSAGES 25
#define STK_MIDI 0x0001
#define STK_PIPE 0x0002
#define STK_SOCKET 0x0004
const int DEFAULT_QUEUE_LIMIT = 200;
#if defined(__STK_REALTIME__)
#include "Mutex.h"
#include "Thread.h"
#include "Socket.h"
#include "RtMidi.h"
extern "C" THREAD_RETURN THREAD_TYPE stdinHandler(void * ptr);
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
#include <sys/types.h>
#include <sys/time.h>
#endif
extern "C" THREAD_RETURN THREAD_TYPE socketHandler(void * ptr);
#endif // __STK_REALTIME__
class Messager : public Stk
{
public:
//! Constructor performs initialization based on an input mask and an optional socket port.
/*!
The default constructor is set to read input from a SKINI
scorefile. The flags STK_MIDI, STK_PIPE, and STK_SOCKET can be
OR'ed together in any combination for multiple "realtime" input
source parsing. An optional socket port number can be specified
for use when the STK_SOCKET flag is set. For realtime input
types, an StkError can be thrown during instantiation.
*/
Messager(int inputMask = 0, int port = 2001);
// This structure is used to share data among the various realtime
// messager threads. It must be public.
struct MessagerData {
Skini skini;
std::queue<Skini::Message> queue;
unsigned int queueLimit;
int sources;
#if defined(__STK_REALTIME__)
Mutex mutex;
RtMidiIn *midi;
Socket *socket;
std::vector<int> fd;
fd_set mask;
#endif
// Default constructor.
MessagerData()
:queueLimit(0), sources(0) {}
};
//! Default constructor.
Messager();
//! Class destructor.
~Messager();
//! Check for a new input message and return the message type.
//! Pop the next message from the queue and write it to the referenced message structure.
/*!
Return type values greater than zero represent valid messages.
If an input scorefile has been completely read or all realtime
input sources have closed, a negative value is returned. If the
return type is zero, no valid messages are present.
Invalid messages (or an empty queue) are indicated by type
values of zero, in which case all other message structure values
are undefined. The user MUST verify the returned message type is
valid before reading other message values.
*/
long nextMessage(void);
void popMessage( Skini::Message& message );
//! Set the delta time (in samples) returned between valid realtime messages. This setting has no affect for scorefile messages.
void setRtDelta(long nSamples);
//! Push the referenced message onto the message stack.
void pushMessage( Skini::Message& message );
//! Return the current message "delta time" in samples.
long getDelta(void) const;
//! Specify a SKINI formatted scorefile from which messages should be read.
/*!
A return value of \c true indicates the call was successful. A
return value of \c false can occur if the file is not found,
cannot be opened, another file is currently still open, or if a
realtime input mechanism is running. Scorefile input is
considered to be a non-realtime control mechanism that cannot run
concurrently with realtime input.
*/
bool setScoreFile( const char* filename );
//! Return the current message type.
long getType() const;
#if defined(__STK_REALTIME__)
//! Initiate the "realtime" retreival from stdin of control messages into the queue.
/*!
This function initiates a thread for asynchronous retrieval of
SKINI formatted messages from stdin. A return value of \c true
indicates the call was successful. A return value of \c false can
occur if a scorefile is being read, a stdin thread is already
running, or a thread error occurs during startup. Stdin input is
considered to be a realtime control mechanism that cannot run
concurrently with non-realtime scorefile input.
*/
bool startStdInput();
//! Return the byte two value for the current message.
MY_FLOAT getByteTwo() const;
//! Start a socket server, accept connections, and read "realtime" control messages into the message queue.
/*!
This function creates a socket server on the optional port
(default = 2001) and starts a thread for asynchronous retrieval of
SKINI formatted messages from socket connections. A return value
of \c true indicates the call was successful. A return value of
\c false can occur if a scorefile is being read, a socket thread
is already running, or an error occurs during the socket server
or thread initialization stages. Socket input is considered to be
a realtime control mechanism that cannot run concurrently with
non-realtime scorefile input.
*/
bool startSocketInput( int port=2001 );
//! Return the byte three value for the current message.
MY_FLOAT getByteThree() const;
//! Start MIDI input, with optional device and port identifiers.
/*!
This function creates an RtMidiIn instance for MIDI input. The
RtMidiIn class invokes a local callback function to read incoming
messages into the queue. If \c port = -1, RtMidiIn will open a
virtual port to which other software applications can connect (OS
X and Linux only). A return value of \c true indicates the call
was successful. A return value of \c false can occur if a
scorefile is being read, MIDI input is already running, or an
error occurs during RtMidiIn construction. Midi input is
considered to be a realtime control mechanism that cannot run
concurrently with non-realtime scorefile input.
*/
bool startMidiInput( int port=0 );
//! Return the channel number for the current message.
long getChannel() const;
#endif
protected:
SKINI *skini;
long type;
long channel;
MY_FLOAT byte2;
MY_FLOAT byte3;
int sources;
long delta;
long rtDelta;
char message[MAX_MESSAGES][MESSAGE_LENGTH];
unsigned int messageIndex;
int nMessages;
MessagerData data_;
#if defined(__STK_REALTIME__)
// Check MIDI source for new messages.
bool midiMessage(void);
// Check socket sources for new messages.
bool socketMessage(void);
// Receive and parse socket data.
bool readSocket(int fd);
RtMidi *midi;
Thread *thread;
Socket *soket;
unsigned int nSockets;
fd_set mask;
int maxfd;
int pipefd;
int fd[16];
char error[256];
#endif // __STK_REALTIME__
Thread stdinThread_;
Thread socketThread_;
#endif
};
#endif // defined(__MESSAGER_H)
#endif

131
include/MidiFileIn.h Normal file
View File

@@ -0,0 +1,131 @@
/**********************************************************************/
/*! \class MidiFileIn
\brief A standard MIDI file reading/parsing class.
This class can be used to read events from a standard MIDI file.
Event bytes are copied to a C++ vector and must be subsequently
interpreted by the user. The function getNextMidiEvent() skips
meta and sysex events, returning only MIDI channel messages.
Event delta-times are returned in the form of "ticks" and a
function is provided to determine the current "seconds per tick".
Tempo changes are internally tracked by the class and reflected in
the values returned by the function getTickSeconds().
by Gary P. Scavone, 2003.
*/
/**********************************************************************/
#ifndef STK_MIDIFILEIN_H
#define STK_MIDIFILEIN_H
#include "Stk.h"
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
class MidiFileIn : public Stk
{
public:
//! Default constructor.
/*!
If an error occurs while opening or parsing the file header, an
StkError exception will be thrown.
*/
MidiFileIn( std::string fileName );
//! Class destructor.
~MidiFileIn();
//! Return the MIDI file format (0, 1, or 2).
int getFileFormat() const;
//! Return the number of tracks in the MIDI file.
unsigned int getNumberOfTracks() const;
//! Return the MIDI file division value from the file header.
/*!
Note that this value must be "parsed" in accordance with the
MIDI File Specification. In particular, if the MSB is set, the
file uses time-code representations for delta-time values.
*/
int getDivision() const;
//! Move the specified track event reader to the beginning of its track.
/*!
The relevant track tempo value is reset as well. If an invalid
track number is specified, an StkError exception will be thrown.
*/
void rewindTrack( unsigned int track = 0 );
//! Get the current value, in seconds, of delta-time ticks for the specified track.
/*!
This value can change as events are read (via "Set Tempo"
Meta-Events). Therefore, one should call this function after
every call to getNextEvent() or getNextMidiEvent(). If an
invalid track number is specified, an StkError exception will be
thrown.
*/
double getTickSeconds( unsigned int track = 0 );
//! Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks.
/*!
MIDI File events consist of a delta time and a sequence of event
bytes. This function returns the delta-time value and writes
the subsequent event bytes directly to the event vector. The
user must parse the event bytes in accordance with the MIDI File
Specification. All returned MIDI channel events are complete
... a status byte is provided even when running status is used
in the file. If the track has reached its end, no bytes will be
written and the event vector size will be zero. If an invalid
track number is specified or an error occurs while reading the
file, an StkError exception will be thrown.
*/
unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 );
//! Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks.
/*!
All returned MIDI events are complete ... a status byte is
provided even when running status is used in the file. Meta and
sysex events in the track are skipped though "Set Tempo" events
are properly parsed for use by the getTickSeconds() function.
If the track has reached its end, no bytes will be written and
the event vector size will be zero. If an invalid track number
is specified or an error occurs while reading the file, an
StkError exception will be thrown.
*/
unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 );
protected:
// This protected class function is used for reading variable-length
// MIDI file values. It is assumed that this function is called with
// the file read pointer positioned at the start of a
// variable-length value. The function returns true if the value is
// successfully parsed. Otherwise, it returns false.
bool readVariableLength( unsigned long *value );
std::ifstream file_;
unsigned int nTracks_;
int format_;
int division_;
bool usingTimeCode_;
std::vector<double> tickSeconds_;
std::vector<long> trackPointers_;
std::vector<long> trackOffsets_;
std::vector<long> trackLengths_;
std::vector<char> trackStatus_;
// This structure and the following variables are used to save and
// keep track of a format 1 tempo map (and the initial tickSeconds
// parameter for formats 0 and 2).
struct TempoChange {
unsigned long count;
double tickSeconds;
};
std::vector<TempoChange> tempoEvents_;
std::vector<unsigned long> trackCounters_;
std::vector<unsigned int> trackTempoIndex_;
};
#endif

View File

@@ -7,12 +7,12 @@
(non-sweeping BiQuad filters), where N is set
during instantiation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MODAL_H)
#define __MODAL_H
#ifndef STK_MODAL_H
#define STK_MODAL_H
#include "Instrmnt.h"
#include "Envelope.h"
@@ -24,7 +24,10 @@ class Modal : public Instrmnt
{
public:
//! Class constructor, taking the desired number of modes to create.
Modal( int modes = 4 );
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Modal( unsigned int modes = 4 );
//! Class destructor.
virtual ~Modal();
@@ -33,54 +36,67 @@ public:
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Set the ratio and radius for a specified mode filter.
void setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius);
void setRatioAndRadius(unsigned int modeIndex, StkFloat ratio, StkFloat radius);
//! Set the master gain.
void setMasterGain(MY_FLOAT aGain);
void setMasterGain(StkFloat aGain);
//! Set the direct gain.
void setDirectGain(MY_FLOAT aGain);
void setDirectGain(StkFloat aGain);
//! Set the gain for a specified mode filter.
void setModeGain(int modeIndex, MY_FLOAT gain);
void setModeGain(unsigned int modeIndex, StkFloat gain);
//! Initiate a strike with the given amplitude (0.0 - 1.0).
virtual void strike(MY_FLOAT amplitude);
virtual void strike(StkFloat amplitude);
//! Damp modes with a given decay factor (0.0 - 1.0).
void damp(MY_FLOAT amplitude);
void damp(StkFloat amplitude);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
virtual StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value) = 0;
virtual void controlChange(int number, StkFloat value) = 0;
protected:
Envelope *envelope;
WvIn *wave;
BiQuad **filters;
OnePole *onepole;
WaveLoop *vibrato;
int nModes;
MY_FLOAT vibratoGain;
MY_FLOAT masterGain;
MY_FLOAT directGain;
MY_FLOAT stickHardness;
MY_FLOAT strikePosition;
MY_FLOAT baseFrequency;
MY_FLOAT *ratios;
MY_FLOAT *radii;
Envelope envelope_;
WvIn *wave_;
BiQuad **filters_;
OnePole onepole_;
WaveLoop *vibrato_;
unsigned int nModes_;
std::vector<StkFloat> ratios_;
std::vector<StkFloat> radii_;
StkFloat vibratoGain_;
StkFloat masterGain_;
StkFloat directGain_;
StkFloat stickHardness_;
StkFloat strikePosition_;
StkFloat baseFrequency_;
};
#endif

View File

@@ -9,8 +9,9 @@
Control Change Numbers:
- Stick Hardness = 2
- Stick Position = 4
- Vibrato Gain = 11
- Vibrato Frequency = 7
- Vibrato Gain = 1
- Vibrato Frequency = 11
- Direct Stick Mix = 8
- Volume = 128
- Modal Presets = 16
- Marimba = 0
@@ -23,12 +24,12 @@
- Two Fixed = 7
- Clump = 8
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MODALBAR_H)
#define __MODALBAR_H
#ifndef STK_MODALBAR_H
#define STK_MODALBAR_H
#include "Modal.h"
@@ -42,19 +43,19 @@ public:
~ModalBar();
//! Set stick hardness (0.0 - 1.0).
void setStickHardness(MY_FLOAT hardness);
void setStickHardness(StkFloat hardness);
//! Set stick position (0.0 - 1.0).
void setStrikePosition(MY_FLOAT position);
void setStrikePosition(StkFloat position);
//! Select a bar preset (currently modulo 9).
void setPreset(int preset);
//! Set the modulation (vibrato) depth.
void setModulationDepth(MY_FLOAT mDepth);
void setModulationDepth(StkFloat mDepth);
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
};
#endif

View File

@@ -6,22 +6,25 @@
modulations to give a nice, natural human
modulation function.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MODULATE_H)
#define __MODULATE_H
#ifndef STK_MODULATE_H
#define STK_MODULATE_H
#include "Stk.h"
#include "Generator.h"
#include "WaveLoop.h"
#include "SubNoise.h"
#include "OnePole.h"
class Modulate : public Stk
class Modulate : public Generator
{
public:
//! Class constructor.
/*!
An StkError can be thrown if the rawwave path is incorrect.
*/
Modulate();
//! Class destructor.
@@ -31,30 +34,35 @@ class Modulate : public Stk
void reset();
//! Set the periodic (vibrato) rate or frequency in Hz.
void setVibratoRate(MY_FLOAT aRate);
void setVibratoRate(StkFloat rate);
//! Set the periodic (vibrato) gain.
void setVibratoGain(MY_FLOAT aGain);
void setVibratoGain(StkFloat gain);
//! Set the random modulation gain.
void setRandomGain(MY_FLOAT aGain);
void setRandomGain(StkFloat gain);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Return \e vectorSize outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Compute \e vectorSize outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Return the last computed output value.
MY_FLOAT lastOut() const;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
WaveLoop *vibrato;
SubNoise *noise;
OnePole *filter;
MY_FLOAT vibratoGain;
MY_FLOAT randomGain;
MY_FLOAT lastOutput;
WaveLoop *vibrato_;
SubNoise noise_;
OnePole filter_;
StkFloat vibratoGain_;
StkFloat randomGain_;
};

View File

@@ -14,12 +14,12 @@
- Vibrato Gain = 1
- Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__MOOG_H)
#define __MOOG_H
#ifndef STK_MOOG_H
#define STK_MOOG_H
#include "Sampler.h"
#include "FormSwep.h"
@@ -28,34 +28,49 @@ class Moog : public Sampler
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Moog();
//! Class destructor.
~Moog();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Set the modulation (vibrato) speed in Hz.
void setModulationSpeed(MY_FLOAT mSpeed);
void setModulationSpeed(StkFloat mSpeed);
//! Set the modulation (vibrato) depth.
void setModulationDepth(MY_FLOAT mDepth);
void setModulationDepth(StkFloat mDepth);
//! Compute one output sample.
virtual MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
FormSwep *filters[2];
MY_FLOAT modDepth;
MY_FLOAT filterQ;
MY_FLOAT filterRate;
FormSwep filters_[2];
StkFloat modDepth_;
StkFloat filterQ_;
StkFloat filterRate_;
};

70
include/Mutex.h Normal file
View File

@@ -0,0 +1,70 @@
/***************************************************/
/*! \class Mutex
\brief STK mutex class.
This class provides a uniform interface for
cross-platform mutex use. On Linux and IRIX
systems, the pthread library is used. Under
Windows, critical sections are used.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_MUTEX_H
#define STK_MUTEX_H
#include "Stk.h"
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
#include <pthread.h>
typedef pthread_mutex_t MUTEX;
typedef pthread_cond_t CONDITION;
#elif defined(__OS_WINDOWS__)
#include <windows.h>
#include <process.h>
typedef CRITICAL_SECTION MUTEX;
typedef HANDLE CONDITION;
#endif
class Mutex : public Stk
{
public:
//! Default constructor.
Mutex();
//! Class destructor.
~Mutex();
//! Lock the mutex.
void lock(void);
//! Unlock the mutex.
void unlock(void);
//! Wait indefinitely on the mutex condition variable.
/*!
The mutex must be locked before calling this function, and then
subsequently unlocked after this function returns.
*/
void wait(void);
//! Signal the condition variable.
/*!
The mutex must be locked before calling this function, and then
subsequently unlocked after this function returns.
*/
void signal(void);
protected:
MUTEX mutex_;
CONDITION condition_;
};
#endif

View File

@@ -12,21 +12,21 @@
filters in parallel with corresponding right
and left outputs.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__NREV_H)
#define __NREV_H
#ifndef STK_NREV_H
#define STK_NREV_H
#include "Reverb.h"
#include "Effect.h"
#include "Delay.h"
class NRev : public Reverb
class NRev : public Effect
{
public:
//! Class constructor taking a T60 decay time argument.
NRev(MY_FLOAT T60);
//! Class constructor taking a T60 decay time argument (one second default value).
NRev( StkFloat T60 = 1.0 );
//! Class destructor.
~NRev();
@@ -34,15 +34,30 @@ class NRev : public Reverb
//! Reset and clear all internal state.
void clear();
//! Set the reverberation T60 decay time.
void setT60( StkFloat T60 );
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
Delay *allpassDelays[8];
Delay *combDelays[6];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[6];
MY_FLOAT lowpassState;
Delay allpassDelays_[8];
Delay combDelays_[6];
StkFloat allpassCoefficient_;
StkFloat combCoefficient_[6];
StkFloat lowpassState_;
};

View File

@@ -6,16 +6,16 @@
C rand() function. The quality of the rand()
function varies from one OS to another.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__NOISE_H)
#define __NOISE_H
#ifndef STK_NOISE_H
#define STK_NOISE_H
#include "Stk.h"
#include "Generator.h"
class Noise : public Stk
class Noise : public Generator
{
public:
@@ -40,17 +40,21 @@ public:
void setSeed( unsigned int seed = 0 );
//! Return a random number between -1.0 and 1.0 using rand().
virtual MY_FLOAT tick();
virtual StkFloat tick();
//! Return \e vectorSize random numbers between -1.0 and 1.0 in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Compute \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Return the last computed value.
MY_FLOAT lastOut() const;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT lastOutput;
protected:
};

View File

@@ -8,12 +8,12 @@
the real axis of the z-plane while maintaining
a constant peak filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__ONEPOLE_H)
#define __ONEPOLE_H
#ifndef STK_ONEPOLE_H
#define STK_ONEPOLE_H
#include "Filter.h"
@@ -25,7 +25,7 @@ public:
OnePole();
//! Overloaded constructor which sets the pole position during instantiation.
OnePole(MY_FLOAT thePole);
OnePole(StkFloat thePole);
//! Class destructor.
~OnePole();
@@ -34,10 +34,10 @@ public:
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
void setA1(StkFloat a1);
//! Set the pole position in the z-plane.
/*!
@@ -47,26 +47,36 @@ public:
pole value produces a high-pass filter. This method does not
affect the filter \e gain value.
*/
void setPole(MY_FLOAT thePole);
void setPole(StkFloat thePole);
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -8,12 +8,12 @@
along the real axis of the z-plane while
maintaining a constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__ONEZERO_H)
#define __ONEZERO_H
#ifndef STK_ONEZERO_H
#define STK_ONEZERO_H
#include "Filter.h"
@@ -25,7 +25,7 @@ class OneZero : protected Filter
OneZero();
//! Overloaded constructor which sets the zero position during instantiation.
OneZero(MY_FLOAT theZero);
OneZero(StkFloat theZero);
//! Class destructor.
~OneZero();
@@ -34,10 +34,10 @@ class OneZero : protected Filter
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
void setB1(StkFloat b1);
//! Set the zero position in the z-plane.
/*!
@@ -47,26 +47,36 @@ class OneZero : protected Filter
negative zero value produces a low-pass filter. This method does
not affect the filter \e gain value.
*/
void setZero(MY_FLOAT theZero);
void setZero(StkFloat theZero);
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -10,21 +10,21 @@
two series allpass units and two parallel comb
filters.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PRCREV_H)
#define __PRCREV_H
#ifndef STK_PRCREV_H
#define STK_PRCREV_H
#include "Reverb.h"
#include "Effect.h"
#include "Delay.h"
class PRCRev : public Reverb
class PRCRev : public Effect
{
public:
//! Class constructor taking a T60 decay time argument.
PRCRev(MY_FLOAT T60);
//! Class constructor taking a T60 decay time argument (one second default value).
PRCRev( StkFloat T60 = 1.0 );
//! Class destructor.
~PRCRev();
@@ -32,14 +32,29 @@ public:
//! Reset and clear all internal state.
void clear();
//! Set the reverberation T60 decay time.
void setT60( StkFloat T60 );
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
Delay *allpassDelays[2];
Delay *combDelays[2];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[2];
Delay allpassDelays_[2];
Delay combDelays_[2];
StkFloat allpassCoefficient_;
StkFloat combCoefficient_[2];
};

View File

@@ -22,12 +22,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PERCFLUT_H)
#define __PERCFLUT_H
#ifndef STK_PERCFLUT_H
#define STK_PERCFLUT_H
#include "FM.h"
@@ -35,19 +35,34 @@ class PercFlut : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
PercFlut();
//! Class destructor.
~PercFlut();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -6,16 +6,16 @@
set of 32 static phoneme formant parameters
and provide access to those values.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PHONEMES_H)
#define __PHONEMES_H
#ifndef STK_PHONEMES_H
#define STK_PHONEMES_H
#include "Stk.h"
class Phonemes
class Phonemes : public Stk
{
public:
@@ -26,26 +26,25 @@ public:
static const char *name( unsigned int index );
//! Returns the voiced component gain for the given phoneme index (0-31).
static MY_FLOAT voiceGain( unsigned int index );
static StkFloat voiceGain( unsigned int index );
//! Returns the unvoiced component gain for the given phoneme index (0-31).
static MY_FLOAT noiseGain( unsigned int index );
static StkFloat noiseGain( unsigned int index );
//! Returns the formant frequency for the given phoneme index (0-31) and partial (0-3).
static MY_FLOAT formantFrequency( unsigned int index, unsigned int partial );
static StkFloat formantFrequency( unsigned int index, unsigned int partial );
//! Returns the formant radius for the given phoneme index (0-31) and partial (0-3).
static MY_FLOAT formantRadius( unsigned int index, unsigned int partial );
static StkFloat formantRadius( unsigned int index, unsigned int partial );
//! Returns the formant gain for the given phoneme index (0-31) and partial (0-3).
static MY_FLOAT formantGain( unsigned int index, unsigned int partial );
static StkFloat formantGain( unsigned int index, unsigned int partial );
private:
static const char phonemeNames[][4];
static const MY_FLOAT phonemeGains[][2];
static const MY_FLOAT phonemeParameters[][4][3];
static const StkFloat phonemeGains[][2];
static const StkFloat phonemeParameters[][4][3];
};
#endif

View File

@@ -5,17 +5,17 @@
This class implements a simple pitch shifter
using delay lines.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PITSHIFT_H)
#define __PITSHIFT_H
#ifndef STK_PITSHIFT_H
#define STK_PITSHIFT_H
#include "Stk.h"
#include "Effect.h"
#include "DelayL.h"
class PitShift : public Stk
class PitShift : public Effect
{
public:
//! Class constructor.
@@ -28,27 +28,30 @@ class PitShift : public Stk
void clear();
//! Set the pitch shift factor (1.0 produces no shift).
void setShift(MY_FLOAT shift);
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
void setEffectMix(MY_FLOAT mix);
//! Return the last output value.
MY_FLOAT lastOut() const;
void setShift(StkFloat shift);
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
DelayL *delayLine[2];
MY_FLOAT lastOutput;
MY_FLOAT delay[2];
MY_FLOAT env[2];
MY_FLOAT effectMix;
MY_FLOAT rate;
DelayL delayLine_[2];
StkFloat delay_[2];
StkFloat env_[2];
StkFloat rate_;
unsigned long delayLength;
unsigned long halfLength;
};

View File

@@ -14,12 +14,12 @@
use possibly subject to patents held by
Stanford University, Yamaha, and others.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PLUCKTWO_H)
#define __PLUCKTWO_H
#ifndef STK_PLUCKTWO_H
#define STK_PLUCKTWO_H
#include "Instrmnt.h"
#include "DelayL.h"
@@ -30,7 +30,7 @@ class PluckTwo : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
PluckTwo(MY_FLOAT lowestFrequency);
PluckTwo(StkFloat lowestFrequency);
//! Class destructor.
virtual ~PluckTwo();
@@ -39,16 +39,16 @@ class PluckTwo : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Detune the two strings by the given factor. A value of 1.0 produces unison strings.
void setDetune(MY_FLOAT detune);
void setDetune(StkFloat detune);
//! Efficient combined setting of frequency and detuning.
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
void setFreqAndDetune(StkFloat frequency, StkFloat detune);
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
void setPluckPosition(MY_FLOAT position);
void setPluckPosition(StkFloat position);
//! Set the base loop gain.
/*!
@@ -56,28 +56,41 @@ class PluckTwo : public Instrmnt
Because of high-frequency loop filter roll-off, higher
frequency settings have greater loop gains.
*/
void setBaseLoopGain(MY_FLOAT aGain);
void setBaseLoopGain(StkFloat aGain);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
virtual void noteOff(StkFloat amplitude);
//! Virtual (abstract) tick function is implemented by subclasses.
virtual MY_FLOAT tick() = 0;
virtual StkFloat tick() = 0;
protected:
DelayA *delayLine;
DelayA *delayLine2;
DelayL *combDelay;
OneZero *filter;
OneZero *filter2;
long length;
MY_FLOAT loopGain;
MY_FLOAT baseLoopGain;
MY_FLOAT lastFrequency;
MY_FLOAT lastLength;
MY_FLOAT detuning;
MY_FLOAT pluckAmplitude;
MY_FLOAT pluckPosition;
//! Computer \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
protected:
DelayA delayLine_;
DelayA delayLine2_;
DelayL combDelay_;
OneZero filter_;
OneZero filter2_;
unsigned long length_;
StkFloat loopGain_;
StkFloat baseLoopGain_;
StkFloat lastFrequency_;
StkFloat lastLength_;
StkFloat detuning_;
StkFloat pluckAmplitude_;
StkFloat pluckPosition_;
};

View File

@@ -13,12 +13,12 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__PLUCKED_H)
#define __PLUCKED_H
#ifndef STK_PLUCKED_H
#define STK_PLUCKED_H
#include "Instrmnt.h"
#include "DelayA.h"
@@ -30,7 +30,7 @@ class Plucked : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Plucked(MY_FLOAT lowestFrequency);
Plucked(StkFloat lowestFrequency);
//! Class destructor.
~Plucked();
@@ -39,27 +39,39 @@ class Plucked : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
virtual void setFrequency(StkFloat frequency);
//! Pluck the string with the given amplitude using the current frequency.
void pluck(MY_FLOAT amplitude);
void pluck(StkFloat amplitude);
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
virtual void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
virtual void noteOff(StkFloat amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
virtual StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
DelayA *delayLine;
OneZero *loopFilter;
OnePole *pickFilter;
Noise *noise;
long length;
MY_FLOAT loopGain;
DelayA delayLine_;
OneZero loopFilter_;
OnePole pickFilter_;
Noise noise_;
StkFloat loopGain_;
unsigned long length_;
};

View File

@@ -8,12 +8,12 @@
filter with a given coefficient. Another
method is provided to create a DC blocking filter.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__POLEZERO_H)
#define __POLEZERO_H
#ifndef STK_POLEZERO_H
#define STK_POLEZERO_H
#include "Filter.h"
@@ -31,13 +31,13 @@ class PoleZero : protected Filter
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
void setB1(StkFloat b1);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
void setA1(StkFloat a1);
//! Set the filter for allpass behavior using \e coefficient.
/*!
@@ -45,7 +45,7 @@ class PoleZero : protected Filter
which has unity gain at all frequencies. Note that the \e
coefficient magnitude must be less than one to maintain stability.
*/
void setAllpass(MY_FLOAT coefficient);
void setAllpass(StkFloat coefficient);
//! Create a DC blocking filter with the given pole position in the z-plane.
/*!
@@ -54,26 +54,36 @@ class PoleZero : protected Filter
close to one to minimize low-frequency attenuation.
*/
void setBlockZero(MY_FLOAT thePole = 0.99);
void setBlockZero(StkFloat thePole = 0.99);
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -1,5 +1,5 @@
/***************************************************/
/*! \class ReedTabl
/*! \class ReedTable
\brief STK reed table class.
This class implements a simple one breakpoint,
@@ -13,23 +13,23 @@
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__REEDTABL_H)
#define __REEDTABL_H
#ifndef STK_REEDTABLE_H
#define STK_REEDTABLE_H
#include "Stk.h"
#include "Function.h"
class ReedTabl : public Stk
class ReedTable : public Function
{
public:
//! Default constructor.
ReedTabl();
ReedTable();
//! Class destructor.
~ReedTabl();
~ReedTable();
//! Set the table offset value.
/*!
@@ -37,7 +37,7 @@ public:
of the initial reed tip opening (a greater offset
represents a smaller opening).
*/
void setOffset(MY_FLOAT aValue);
void setOffset(StkFloat offset);
//! Set the table slope value.
/*!
@@ -45,25 +45,30 @@ public:
stiffness (a greater slope represents a harder
reed).
*/
void setSlope(MY_FLOAT aValue);
//! Return the last output value.
MY_FLOAT lastOut() const;
void setSlope(StkFloat slope);
//! Return the function value for \e input.
/*!
The function input represents the differential
pressure across the reeds.
*/
MY_FLOAT tick(MY_FLOAT input);
StkFloat tick(StkFloat input);
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
MY_FLOAT offSet;
MY_FLOAT slope;
MY_FLOAT lastOutput;
StkFloat offset_;
StkFloat slope_;
};

View File

@@ -13,12 +13,12 @@
- Zero Radii = 1
- Envelope Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__RESONATE_H)
#define __RESONATE_H
#ifndef STK_RESONATE_H
#define STK_RESONATE_H
#include "Instrmnt.h"
#include "ADSR.h"
@@ -38,10 +38,10 @@ class Resonate : public Instrmnt
void clear();
//! Set the filter for a resonance at the given frequency (Hz) and radius.
void setResonance(MY_FLOAT frequency, MY_FLOAT radius);
void setResonance(StkFloat frequency, StkFloat radius);
//! Set the filter for a notch at the given frequency (Hz) and radius.
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
void setNotch(StkFloat frequency, StkFloat radius);
//! Set the filter zero coefficients for contant resonance gain.
void setEqualGainZeroes();
@@ -53,25 +53,37 @@ class Resonate : public Instrmnt
void keyOff();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
ADSR *adsr;
BiQuad *filter;
Noise *noise;
MY_FLOAT poleFrequency;
MY_FLOAT poleRadius;
MY_FLOAT zeroFrequency;
MY_FLOAT zeroRadius;
ADSR adsr_;
BiQuad filter_;
Noise noise_;
StkFloat poleFrequency_;
StkFloat poleRadius_;
StkFloat zeroFrequency_;
StkFloat zeroRadius_;
};

View File

@@ -1,58 +0,0 @@
/***************************************************/
/*! \class Reverb
\brief STK abstract reverberator parent class.
This class provides common functionality for
STK reverberator subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#include "Stk.h"
#if !defined(__REVERB_H)
#define __REVERB_H
class Reverb : public Stk
{
public:
//! Class constructor.
Reverb();
//! Class destructor.
virtual ~Reverb();
//! Reset and clear all internal state.
virtual void clear() = 0;
//! Set the mixture of input and "reverberated" levels in the output (0.0 = input only, 1.0 = reverb only).
void setEffectMix(MY_FLOAT mix);
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the last left output value.
MY_FLOAT lastOutLeft() const;
//! Return the last right output value.
MY_FLOAT lastOutRight() const;
//! Abstract tick function ... must be implemented in subclasses.
virtual MY_FLOAT tick(MY_FLOAT input) = 0;
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
protected:
// Returns true if argument value is prime.
bool isPrime(int number);
MY_FLOAT lastOutput[2];
MY_FLOAT effectMix;
};
#endif // defined(__REVERB_H)

View File

@@ -26,12 +26,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__RHODEY_H)
#define __RHODEY_H
#ifndef STK_RHODEY_H
#define STK_RHODEY_H
#include "FM.h"
@@ -39,19 +39,34 @@ class Rhodey : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Rhodey();
//! Class destructor.
~Rhodey();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -9,7 +9,7 @@
RtAudio WWW site: http://music.mcgill.ca/~gary/rtaudio/
RtAudio: a realtime audio i/o C++ class
RtAudio: realtime audio i/o C++ classes
Copyright (c) 2001-2004 Gary P. Scavone
Permission is hereby granted, free of charge, to any person
@@ -37,7 +37,7 @@
*/
/************************************************************************/
// RtAudio: Version 3.0.1, 22 March 2004
// RtAudio: Version 3.0.2, pre-release for STK 4.2.0
#ifndef __RTAUDIO_H
#define __RTAUDIO_H
@@ -127,17 +127,27 @@ class RtApi
{
public:
enum StreamState {
STREAM_STOPPED,
STREAM_RUNNING
};
RtApi();
virtual ~RtApi();
void openStream( int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RtAudioFormat format, int sampleRate,
int *bufferSize, int numberOfBuffers );
void openStream( int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RtAudioFormat format, int sampleRate,
int *bufferSize, int *numberOfBuffers );
virtual void setStreamCallback( RtAudioCallback callback, void *userData ) = 0;
virtual void cancelStreamCallback() = 0;
int getDeviceCount(void);
RtAudioDeviceInfo getDeviceInfo( int device );
char * const getStreamBuffer();
RtApi::StreamState getStreamState() const;
virtual void tickStream() = 0;
virtual void closeStream();
virtual void startStream() = 0;
@@ -158,9 +168,13 @@ protected:
UNINITIALIZED = -75
};
enum StreamState {
STREAM_STOPPED,
STREAM_RUNNING
// A protected structure used for buffer conversion.
struct ConvertInfo {
int channels;
int inJump, outJump;
RtAudioFormat inFormat, outFormat;
std::vector<int> inOffset;
std::vector<int> outOffset;
};
// A protected structure for audio streams.
@@ -183,10 +197,10 @@ protected:
RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
StreamMutex mutex;
CallbackInfo callbackInfo;
ConvertInfo convertInfo[2];
RtApiStream()
:apiHandle(0), userBuffer(0), deviceBuffer(0) {}
// mode(UNINITIALIZED), state(STREAM_STOPPED),
};
// A protected device structure for audio devices.
@@ -217,7 +231,7 @@ protected:
typedef float Float32;
typedef double Float64;
char message_[256];
char message_[1024];
int nDevices_;
std::vector<RtApiDevice> devices_;
RtApiStream stream_;
@@ -281,7 +295,7 @@ protected:
Protected method used to perform format, channel number, and/or interleaving
conversions between the user and device buffers.
*/
void convertStreamBuffer( StreamMode mode );
void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
//! Protected common method used to perform byte-swapping on buffers.
void byteSwapBuffer( char *buffer, int samples, RtAudioFormat format );
@@ -350,6 +364,20 @@ public:
RtAudioFormat format, int sampleRate,
int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED );
//! An overloaded constructor which opens a stream and also returns \c numberOfBuffers parameter via pointer argument.
/*!
See the previous constructor call for details. This overloaded
version differs only in that it takes a pointer argument for the
\c numberOfBuffers parameter and returns the value used by the
audio device (which may be different from that requested). Note
that the \c numberofBuffers parameter is not used with the Linux
Jack, Macintosh CoreAudio, and Windows ASIO APIs.
*/
RtAudio( int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RtAudioFormat format, int sampleRate,
int *bufferSize, int *numberOfBuffers, RtAudioApi api=UNSPECIFIED );
//! The destructor.
/*!
Stops and closes an open stream and devices and deallocates
@@ -389,6 +417,20 @@ public:
RtAudioFormat format, int sampleRate,
int *bufferSize, int numberOfBuffers );
//! A public method for opening a stream and also returning \c numberOfBuffers parameter via pointer argument.
/*!
See the previous function call for details. This overloaded
version differs only in that it takes a pointer argument for the
\c numberOfBuffers parameter and returns the value used by the
audio device (which may be different from that requested). Note
that the \c numberofBuffers parameter is not used with the Linux
Jack, Macintosh CoreAudio, and Windows ASIO APIs.
*/
void openStream( int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RtAudioFormat format, int sampleRate,
int *bufferSize, int *numberOfBuffers );
//! A public method which sets a user-defined callback function for a given stream.
/*!
This method assigns a callback function to a previously opened

View File

@@ -1,28 +1,35 @@
/***************************************************/
/*! \class RtDuplex
\brief STK realtime audio input/output class.
\brief STK realtime audio (blocking) input/output class.
This class provides a simplified interface to
RtAudio for realtime audio input/output. It
is also possible to achieve duplex operation
using separate RtWvIn and RtWvOut classes, but
this class ensures better input/output
syncronization.
may also be possible to achieve duplex
operation using separate RtWvIn and RtWvOut
classes, but this class ensures better
input/output synchronization.
Because this class makes use of RtAudio's
blocking input/output routines, its
performance is less robust on systems where
the audio API is callback-based (Macintosh
CoreAudio and Windows ASIO).
RtDuplex supports multi-channel data in
interleaved format. It is important to
distinguish the tick() methods, which output
single samples to all channels in a sample frame
and return samples produced by averaging across
sample frames, from the tickFrame() methods, which
take/return pointers to multi-channel sample frames.
single samples to all channels in a sample
frame and return samples produced by averaging
across sample frames, from the tickFrame()
methods, which take/return pointers to
multi-channel sample frames.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__RTDUPLEX_H)
#define __RTDUPLEX_H
#ifndef STK_RTDUPLEX_H
#define STK_RTDUPLEX_H
#include "Stk.h"
#include "RtAudio.h"
@@ -42,7 +49,7 @@ public:
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
RtDuplex(int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
RtDuplex(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
//! Class destructor.
~RtDuplex();
@@ -60,34 +67,53 @@ public:
void stop(void);
//! Return the average across the last output sample frame.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Output a single sample to all channels in a sample frame and return the average across one new input sample frame of data.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
MY_FLOAT tick(const MY_FLOAT sample);
StkFloat tick(const StkFloat sample);
//! Output each sample in \vector to all channels per frame and return averaged input sample frames of new data in \e vector.
//! Output each sample in \e vector to all channels per frame and return averaged input sample frames of new data in \e vector.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Output a channel of the StkFrames object to all channels and replace with averaged sample frames of input.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if an
error occurs during input/outpu or the \c channel argument is zero
or it is greater than the number of channels in the StkFrames
object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return a pointer to the last output sample frame.
const MY_FLOAT *lastFrame(void) const;
const StkFloat *lastFrame(void) const;
//! Output sample \e frames from \e frameVector and return new input frames in \e frameVector.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames = 1);
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames = 1);
//! Output the StkFrames data and replace with new input frames.
/*!
An StkError will be thrown if an error occurs during
input/output or if there is an incompatability between the number
of channels in the RtDuplex object and that in the StkFrames
object.
*/
StkFrames& tickFrame( StkFrames& frames );
protected:
RtAudio *audio_;
MY_FLOAT *data_;
MY_FLOAT *lastOutput_;
StkFloat *data_;
StkFloat *lastOutput_;
int bufferSize_;
bool stopped_;
long counter_;

View File

@@ -39,7 +39,7 @@ protected:
public:
//! The constructor.
RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type){}
RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
//! The destructor.
virtual ~RtError(void) {};

View File

@@ -1,80 +1,282 @@
/***************************************************/
/**********************************************************************/
/*! \class RtMidi
\brief STK realtime MIDI class.
\brief An abstract base class for realtime MIDI input/output.
At the moment, this object only handles MIDI
input, though MIDI output code can go here
when someone decides they need it (and writes
it).
This class implements some common functionality for the realtime
MIDI input/output subclasses RtMidiIn and RtMidiOut.
This object opens a MIDI input device and
parses MIDI messages into a MIDI buffer. Time
stamp info is converted to a delta-time
value. MIDI data is stored as MY_FLOAT to
conform with SKINI. System exclusive messages
are currently ignored.
RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/
An optional argument to the constructor can be
used to specify a device or card. When no
argument is given, a default device is opened.
If a device argument fails, a list of available
devices is printed to allow selection by the user.
RtMidi: realtime MIDI i/o C++ classes
Copyright (c) 2003-2004 Gary P. Scavone
This code is based in part on work of Perry
Cook (SGI), Paul Leonard (Linux), the
RoseGarden team (Linux), and Bill Putnam
(Windows).
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/***************************************************/
/**********************************************************************/
#if !defined(__RTMIDI_H)
#define __RTMIDI_H
// RtMidi: Version 1.0.2, 21 September 2004
#include "Stk.h"
#ifndef RTMIDI_H
#define RTMIDI_H
class RtMidi : public Stk
#include "RtError.h"
#include <string>
class RtMidi
{
protected:
RtMidi();
virtual ~RtMidi() {};
// A basic error reporting function for internal use in the RtMidi
// subclasses. The behavior of this function can be modified to
// suit specific needs.
void error( RtError::Type type );
virtual void openPort( unsigned int portNumber = 0 ) = 0;
void *apiData_;
bool connected_;
std::string errorString_;
};
/**********************************************************************/
/*! \class RtMidiIn
\brief A realtime MIDI input class.
This class provides a common, platform-independent API for
realtime MIDI input. It allows access to a single MIDI input
port. Incoming MIDI messages are either saved to a queue for
retrieval using the getMessage() function or immediately passed to
a user-specified callback function. Create multiple instances of
this class to connect to more than one MIDI device at the same
time. With the OS-X and Linux ALSA MIDI APIs, it is also possible
to open a virtual input port to which other MIDI software clients
can connect.
by Gary P. Scavone, 2003-2004.
*/
/**********************************************************************/
#include <vector>
#include <queue>
class RtMidiIn : public RtMidi
{
public:
//! Default constructor with optional device argument.
RtMidi(int device = 0);
//! Class destructor.
~RtMidi();
//! User callback function type definition.
typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
//! Print out the current message values.
void printMessage(void) const;
//! Check for and parse a new MIDI message in the queue, returning its type.
//! Default constructor.
/*!
If a new message is found, the return value is greater than zero.
An exception will be thrown if a MIDI system initialization error occurs.
*/
int nextMessage(void);
RtMidiIn();
//! Return the current message type.
int getType() const;
//! If a MIDI connection is still open, it will be closed by the destructor.
~RtMidiIn();
//! Return the current message channel value.
int getChannel() const;
//! Open a MIDI input connection.
/*!
An optional port number greater than 0 can be specified.
Otherwise, the default or first port found is opened.
*/
void openPort( unsigned int portNumber = 0 );
//! Return the current message byte two value.
MY_FLOAT getByteTwo() const;
//! Create a virtual input port to allow software connections (OS X and ALSA only).
/*!
This function creates a virtual MIDI input port to which other
software applications can connect. This type of functionality
is currently only supported by the Macintosh OS-X and Linux ALSA
APIs (the function does nothing for the other APIs).
*/
void openVirtualPort();
//! Return the current message byte three value.
MY_FLOAT getByteThree() const;
//! Set a callback function to be invoked for incoming MIDI messages.
/*!
The callback function will be called whenever an incoming MIDI
message is received. While not absolutely necessary, it is best
to set the callback function before opening a MIDI port to avoid
leaving some messages in the queue.
*/
void setCallback( RtMidiCallback callback, void *userData = 0 );
//! Return the current message delta time value in seconds.
MY_FLOAT getDeltaTime() const;
//! Cancel use of the current callback function (if one exists).
/*!
Subsequent incoming MIDI messages will be written to the queue
and can be retrieved with the \e getMessage function.
*/
void cancelCallback();
protected:
int messageType;
int channel;
float byteTwo;
float byteThree;
MY_FLOAT deltaTime;
int readIndex;
//! Close an open MIDI connection (if one exists).
void closePort( void );
//! Return the number of available MIDI input ports.
unsigned int getPortCount();
//! Return a string identifier for the specified MIDI input port number.
/*!
An exception is thrown if an invalid port specifier is provided.
*/
std::string getPortName( unsigned int portNumber = 0 );
//! Set the maximum number of MIDI messages to be saved in the queue.
/*!
If the queue size limit is reached, incoming messages will be
ignored. The default limit is 1024.
*/
void setQueueSizeLimit( unsigned int queueSize );
//! Specify whether certain MIDI message types should be queued or ignored during input.
/*!
By default, MIDI timing and active sensing messages are ignored
during message input because of their relative high data rates.
MIDI sysex messages are ignored by default as well. Variable
values of "true" imply that the respective message type will be
ignored.
*/
void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
/*!
This function returns immediately whether a new message is
available or not. A valid message is indicated by a non-zero
vector size. An exception is thrown if an error occurs during
message retrieval or an input connection was not previously
established.
*/
double getMessage( std::vector<unsigned char> *message );
// A MIDI structure used internally by the class to store incoming
// messages. Each message represents one and only one MIDI message.
struct MidiMessage {
std::vector<unsigned char> bytes;
double timeStamp;
// Default constructor.
MidiMessage()
:bytes(3), timeStamp(0.0) {}
};
// The RtMidiInData structure is used to pass private class data to
// the MIDI input handling function or thread.
struct RtMidiInData {
std::queue<MidiMessage> queue;
unsigned int queueLimit;
unsigned char ignoreFlags;
bool doInput;
bool firstMessage;
void *apiData;
bool usingCallback;
void *userCallback;
void *userData;
// Default constructor.
RtMidiInData()
: queueLimit(1024), ignoreFlags(7), doInput(false), firstMessage(true),
apiData(0), usingCallback(false), userCallback(0), userData(0) {}
};
private:
void initialize( void );
RtMidiInData inputData_;
};
/**********************************************************************/
/*! \class RtMidiOut
\brief A realtime MIDI output class.
This class provides a common, platform-independent API for MIDI
output. It allows one to probe available MIDI output ports, to
connect to one such port, and to send MIDI bytes immediately over
the connection. Create multiple instances of this class to
connect to more than one MIDI device at the same time.
by Gary P. Scavone, 2003-2004.
*/
/**********************************************************************/
class RtMidiOut : public RtMidi
{
public:
//! Default constructor.
/*!
An exception will be thrown if a MIDI system initialization error occurs.
*/
RtMidiOut();
//! The destructor closes any open MIDI connections.
~RtMidiOut();
//! Open a MIDI output connection.
/*!
An optional port number greater than 0 can be specified.
Otherwise, the default or first port found is opened. An
exception is thrown if an error occurs while attempting to make
the port connection.
*/
void openPort( unsigned int portNumber = 0 );
//! Close an open MIDI connection (if one exists).
void closePort();
//! Create a virtual output port to allow software connections (OS X and ALSA only).
/*!
This function creates a virtual MIDI output port to which other
software applications can connect. This type of functionality
is currently only supported by the Macintosh OS-X and Linux ALSA
APIs (the function does nothing with the other APIs). An
exception is thrown if an error occurs while attempting to create
the virtual port.
*/
void openVirtualPort();
//! Return the number of available MIDI output ports.
unsigned int getPortCount();
//! Return a string identifier for the specified MIDI port type and number.
/*!
An exception is thrown if an invalid port specifier is provided.
*/
std::string getPortName( unsigned int portNumber );
//! Immediately send a single message out an open MIDI output port.
/*!
An exception is thrown if an error occurs during output or an
output connection was not previously established.
*/
void sendMessage( std::vector<unsigned char> *message );
private:
void initialize( void );
};
#endif

View File

@@ -1,10 +1,14 @@
/***************************************************/
/*! \class RtWvIn
\brief STK realtime audio input class.
\brief STK realtime audio (blocking) input class.
This class provides a simplified interface to
RtAudio for realtime audio input. It is a
protected subclass of WvIn.
protected subclass of WvIn. Because this
class makes use of RtAudio's blocking output
routines, its performance is less robust on
systems where the audio API is callback-based
(Macintosh CoreAudio and Windows ASIO).
RtWvIn supports multi-channel data in
interleaved format. It is important to
@@ -15,14 +19,13 @@
For single-channel data, these methods return
equivalent values.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__RTWVIN_H)
#define __RTWVIN_H
#ifndef STK_RTWVIN_H
#define STK_RTWVIN_H
#include "Stk.h"
#include "WvIn.h"
#include "RtAudio.h"
@@ -41,7 +44,7 @@ public:
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
RtWvIn(int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
RtWvIn(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
//! Class destructor.
~RtWvIn();
@@ -59,34 +62,51 @@ public:
void stop(void);
//! Return the average across the last output sample frame.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Read out the average across one sample frame of data.
/*!
An StkError will be thrown if an error occurs during input.
*/
MY_FLOAT tick(void);
StkFloat tick(void);
//! Read out vectorSize averaged sample frames of data in \e vector.
/*!
An StkError will be thrown if an error occurs during input.
*/
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with averaged sample frames.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if an
error occurs during input or the \c channel argument is zero or it
is greater than the number of channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return a pointer to the last output sample frame.
const MY_FLOAT *lastFrame(void) const;
const StkFloat *lastFrame(void) const;
//! Return a pointer to the next sample frame of data.
/*!
An StkError will be thrown if an error occurs during input.
*/
const MY_FLOAT *tickFrame(void);
const StkFloat *tickFrame(void);
//! Read out sample \e frames of data to \e frameVector.
/*!
An StkError will be thrown if an error occurs during input.
*/
MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames);
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
//! Fill the StkFrames object with sample frames of data and return the same reference.
/*!
An StkError will be thrown if an error occurs during input or
there is an incompatability between the number of channels in the
RtWvIn object and that in the StkFrames object.
*/
StkFrames& tickFrame( StkFrames& frames );
protected:

View File

@@ -1,10 +1,14 @@
/***************************************************/
/*! \class RtWvOut
\brief STK realtime audio output class.
\brief STK realtime audio (blocking) output class.
This class provides a simplified interface to
RtAudio for realtime audio output. It is a
protected subclass of WvOut.
protected subclass of WvOut. Because this
class makes use of RtAudio's blocking output
routines, its performance is less robust on
systems where the audio API is callback-based
(Macintosh CoreAudio and Windows ASIO).
RtWvOut supports multi-channel data in
interleaved format. It is important to
@@ -14,16 +18,15 @@
takes a pointer to multi-channel sample
frame data.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__RTWVOUT_H)
#define __RTWVOUT_H
#ifndef STK_RTWVOUT_H
#define STK_RTWVOUT_H
#include "WvOut.h"
#include "RtAudio.h"
#include "Thread.h"
class RtWvOut : protected WvOut
{
@@ -41,7 +44,7 @@ class RtWvOut : protected WvOut
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
RtWvOut(unsigned int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
RtWvOut(unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
//! Class destructor.
~RtWvOut();
@@ -62,32 +65,50 @@ class RtWvOut : protected WvOut
unsigned long getFrames( void ) const;
//! Return the number of seconds of data output.
MY_FLOAT getTime( void ) const;
StkFloat getTime( void ) const;
//! Output a single sample to all channels in a sample frame.
/*!
An StkError will be thrown if an error occurs during output.
*/
void tick(const MY_FLOAT sample);
void tick( const StkFloat sample );
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
/*!
An StkError will be thrown if an error occurs during output.
*/
void tick(const MY_FLOAT *vector, unsigned int vectorSize);
void tick( const StkFloat *vector, unsigned int vectorSize );
//! Output a channel of the StkFrames object to all channels of the RtWvOut object.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if an
error occurs during output or the \c channel argument is zero or
it is greater than the number of channels in the StkFrames object.
*/
void tick( const StkFrames& frames, unsigned int channel = 1 );
//! Output the \e frameVector of sample frames of the given length.
/*!
An StkError will be thrown if an error occurs during output.
*/
void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
void tickFrame( const StkFloat *frameVector, unsigned int frames = 1 );
//! Output the StkFrames data to the RtWvOut object.
/*!
An StkError will be thrown if an error occurs during output or
if there is an incompatability between the number of channels in
the WvOut object and that in the StkFrames object.
*/
void tickFrame( const StkFrames& frames );
protected:
RtAudio *audio_;
RtAudio *audio_;
StkFloat *dataPtr_;
bool stopped_;
int bufferSize_;
};
#endif // defined(__RTWVOUT_H)
#endif

View File

@@ -1,127 +0,0 @@
/***************************************************/
/*! \class SKINI
\brief STK SKINI parsing class
This class parses SKINI formatted text
messages. It can be used to parse individual
messages or it can be passed an entire file.
The file specification is Perry's and his
alone, but it's all text so it shouldn't be to
hard to figure out.
SKINI (Synthesis toolKit Instrument Network
Interface) is like MIDI, but allows for
floating-point control changes, note numbers,
etc. The following example causes a sharp
middle C to be played with a velocity of 111.132:
\code
noteOn 60.01 111.13
\endcode
\sa \ref skini
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__SKINI_H)
#define __SKINI_H
#include "Stk.h"
#include <stdio.h>
class SKINI : public Stk
{
public:
//! Default constructor used for parsing messages received externally.
SKINI();
//! Overloaded constructor taking a SKINI formatted scorefile.
SKINI(char *fileName);
//! Class destructor
~SKINI();
//! Attempt to parse the given string, returning the message type.
/*!
A type value equal to zero indicates an invalid message.
*/
long parseThis(char* aString);
//! Parse the next message (if a file is loaded) and return the message type.
/*!
A negative value is returned when the file end is reached.
*/
long nextMessage();
//! Return the current message type.
long getType() const;
//! Return the current message channel value.
long getChannel() const;
//! Return the current message delta time value (in seconds).
MY_FLOAT getDelta() const;
//! Return the current message byte two value.
MY_FLOAT getByteTwo() const;
//! Return the current message byte three value.
MY_FLOAT getByteThree() const;
//! Return the current message byte two value (integer).
long getByteTwoInt() const;
//! Return the current message byte three value (integer).
long getByteThreeInt() const;
//! Return remainder string after parsing.
const char* getRemainderString();
//! Return the message type as a string.
const char* getMessageTypeString();
//! Return the SKINI type string for the given type value.
const char* whatsThisType(long type);
//! Return the SKINI controller string for the given controller number.
const char* whatsThisController(long number);
protected:
FILE *myFile;
long messageType;
char msgTypeString[64];
long channel;
MY_FLOAT deltaTime;
MY_FLOAT byteTwo;
MY_FLOAT byteThree;
long byteTwoInt;
long byteThreeInt;
char remainderString[1024];
char whatString[1024];
};
static const double Midi2Pitch[129] = {
8.18,8.66,9.18,9.72,10.30,10.91,11.56,12.25,
12.98,13.75,14.57,15.43,16.35,17.32,18.35,19.45,
20.60,21.83,23.12,24.50,25.96,27.50,29.14,30.87,
32.70,34.65,36.71,38.89,41.20,43.65,46.25,49.00,
51.91,55.00,58.27,61.74,65.41,69.30,73.42,77.78,
82.41,87.31,92.50,98.00,103.83,110.00,116.54,123.47,
130.81,138.59,146.83,155.56,164.81,174.61,185.00,196.00,
207.65,220.00,233.08,246.94,261.63,277.18,293.66,311.13,
329.63,349.23,369.99,392.00,415.30,440.00,466.16,493.88,
523.25,554.37,587.33,622.25,659.26,698.46,739.99,783.99,
830.61,880.00,932.33,987.77,1046.50,1108.73,1174.66,1244.51,
1318.51,1396.91,1479.98,1567.98,1661.22,1760.00,1864.66,1975.53,
2093.00,2217.46,2349.32,2489.02,2637.02,2793.83,2959.96,3135.96,
3322.44,3520.00,3729.31,3951.07,4186.01,4434.92,4698.64,4978.03,
5274.04,5587.65,5919.91,6271.93,6644.88,7040.00,7458.62,7902.13,
8372.02,8869.84,9397.27,9956.06,10548.08,11175.30,11839.82,12543.85,
13289.75};
#endif

View File

@@ -3,22 +3,25 @@
Definition of SKINI Message Types and Special Symbols
Synthesis toolKit Instrument Network Interface
These symbols should have the form __SK_<name>_
These symbols should have the form:
Where <name> is the string used in the SKINI stream.
\c __SK_<name>_
by Perry R. Cook, 1995 - 2002.
where <name> is the string used in the SKINI stream.
by Perry R. Cook, 1995 - 2004.
*/
/*********************************************************/
/***** MIDI COMPATIBLE MESSAGES *****/
/***** Status Bytes Have Channel=0 **/
#define NOPE -32767
#define YEP 1
#define SK_DBL -32766
#define SK_INT -32765
#define SK_STR -32764
#define __SK_Exit_ 999
#define NOPE -32767
#define YEP 1
#define SK_DBL -32766
#define SK_INT -32765
#define SK_STR -32764
/***** MIDI COMPATIBLE MESSAGES *****/
/*** (Status bytes for channel=0) ***/
#define __SK_NoteOff_ 128
#define __SK_NoteOn_ 144

View File

@@ -1,128 +1,128 @@
#include "SKINI.msg"
#define __SK_MaxMsgTypes_ 128
#define __SK_MaxMsgTypes_ 80
struct SKINISpec { char messageString[32];
struct SkiniSpec { char messageString[32];
long type;
long data2;
long data3;
};
/* SEE COMMENT BLOCK AT BOTTOM FOR FIELDS AND USES */
/* MessageString ,type, ch?, data2 , data3 */
/* SEE COMMENT BLOCK AT BOTTOM FOR FIELDS AND USES */
/* MessageString , type, data2, data3 */
struct SKINISpec skini_msgs[__SK_MaxMsgTypes_] =
struct SkiniSpec skini_msgs[__SK_MaxMsgTypes_] =
{
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
{"PolyPressure" , __SK_PolyPressure_, SK_DBL, SK_DBL},
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
{"ProgramChange" , __SK_ProgramChange_, SK_DBL, SK_DBL},
{"AfterTouch" , __SK_AfterTouch_, SK_DBL, NOPE},
{"ChannelPressure" ,__SK_ChannelPressure_, SK_DBL, NOPE},
{"PitchWheel" , __SK_PitchWheel_, SK_DBL, NOPE},
{"PitchBend" , __SK_PitchBend_, SK_DBL, NOPE},
{"PitchChange" , __SK_PitchChange_, SK_DBL, NOPE},
{"Clock" , __SK_Clock_, NOPE, NOPE},
{"Undefined" , 249, NOPE, NOPE},
{"SongStart" , __SK_SongStart_, NOPE, NOPE},
{"Continue" , __SK_Continue_, NOPE, NOPE},
{"SongStop" , __SK_SongStop_, NOPE, NOPE},
{"Undefined" , 253, NOPE, NOPE},
{"ActiveSensing" , __SK_ActiveSensing_, NOPE, NOPE},
{"SystemReset" , __SK_SystemReset_, NOPE, NOPE},
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
{"ModWheel" , __SK_ControlChange_, __SK_ModWheel_ , SK_DBL},
{"Modulation" , __SK_ControlChange_, __SK_Modulation_ , SK_DBL},
{"Breath" , __SK_ControlChange_, __SK_Breath_ , SK_DBL},
{"FootControl" , __SK_ControlChange_, __SK_FootControl_ , SK_DBL},
{"Portamento" , __SK_ControlChange_, __SK_Portamento_ , SK_DBL},
{"Balance" , __SK_ControlChange_, __SK_Balance_ , SK_DBL},
{"Pan" , __SK_ControlChange_, __SK_Pan_ , SK_DBL},
{"Sustain" , __SK_ControlChange_, __SK_Sustain_ , SK_DBL},
{"Damper" , __SK_ControlChange_, __SK_Damper_ , SK_DBL},
{"Expression" , __SK_ControlChange_, __SK_Expression_ , SK_DBL},
{"NoiseLevel" , __SK_ControlChange_, __SK_NoiseLevel_ , SK_DBL},
{"PickPosition" , __SK_ControlChange_, __SK_PickPosition_ , SK_DBL},
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL},
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL},
{"BodySize" , __SK_ControlChange_, __SK_BodySize_ , SK_DBL},
{"BowPressure" , __SK_ControlChange_, __SK_BowPressure_ , SK_DBL},
{"BowPosition" , __SK_ControlChange_, __SK_BowPosition_ , SK_DBL},
{"BowBeta" , __SK_ControlChange_, __SK_BowBeta_ , SK_DBL},
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
{"PolyPressure" , __SK_PolyPressure_, SK_DBL, SK_DBL},
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
{"ProgramChange" , __SK_ProgramChange_, SK_DBL, NOPE},
{"AfterTouch" , __SK_AfterTouch_, SK_DBL, NOPE},
{"ChannelPressure" ,__SK_ChannelPressure_, SK_DBL, NOPE},
{"PitchWheel" , __SK_PitchWheel_, SK_DBL, NOPE},
{"PitchBend" , __SK_PitchBend_, SK_DBL, NOPE},
{"PitchChange" , __SK_PitchChange_, SK_DBL, NOPE},
{"Clock" , __SK_Clock_, NOPE, NOPE},
{"Undefined" , 249, NOPE, NOPE},
{"SongStart" , __SK_SongStart_, NOPE, NOPE},
{"Continue" , __SK_Continue_, NOPE, NOPE},
{"SongStop" , __SK_SongStop_, NOPE, NOPE},
{"Undefined" , 253, NOPE, NOPE},
{"ActiveSensing" , __SK_ActiveSensing_, NOPE, NOPE},
{"SystemReset" , __SK_SystemReset_, NOPE, NOPE},
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
{"ModWheel" , __SK_ControlChange_, __SK_ModWheel_ , SK_DBL},
{"Modulation" , __SK_ControlChange_, __SK_Modulation_ , SK_DBL},
{"Breath" , __SK_ControlChange_, __SK_Breath_ , SK_DBL},
{"FootControl" , __SK_ControlChange_, __SK_FootControl_ , SK_DBL},
{"Portamento" , __SK_ControlChange_, __SK_Portamento_ , SK_DBL},
{"Balance" , __SK_ControlChange_, __SK_Balance_ , SK_DBL},
{"Pan" , __SK_ControlChange_, __SK_Pan_ , SK_DBL},
{"Sustain" , __SK_ControlChange_, __SK_Sustain_ , SK_DBL},
{"Damper" , __SK_ControlChange_, __SK_Damper_ , SK_DBL},
{"Expression" , __SK_ControlChange_, __SK_Expression_ , SK_DBL},
{"NoiseLevel" , __SK_ControlChange_, __SK_NoiseLevel_ , SK_DBL},
{"PickPosition" , __SK_ControlChange_, __SK_PickPosition_ , SK_DBL},
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL},
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL},
{"BodySize" , __SK_ControlChange_, __SK_BodySize_ , SK_DBL},
{"BowPressure" , __SK_ControlChange_, __SK_BowPressure_ , SK_DBL},
{"BowPosition" , __SK_ControlChange_, __SK_BowPosition_ , SK_DBL},
{"BowBeta" , __SK_ControlChange_, __SK_BowBeta_ , SK_DBL},
{"ReedStiffness" , __SK_ControlChange_, __SK_ReedStiffness_ , SK_DBL},
{"ReedRestPos" , __SK_ControlChange_, __SK_ReedRestPos_ , SK_DBL},
{"FluteEmbouchure" , __SK_ControlChange_, __SK_FluteEmbouchure_, SK_DBL},
{"LipTension" , __SK_ControlChange_, __SK_LipTension_ , SK_DBL},
{"StrikePosition" , __SK_ControlChange_, __SK_StrikePosition_, SK_DBL},
{"StickHardness" , __SK_ControlChange_, __SK_StickHardness_ , SK_DBL},
{"ReedStiffness" , __SK_ControlChange_, __SK_ReedStiffness_ , SK_DBL},
{"ReedRestPos" , __SK_ControlChange_, __SK_ReedRestPos_ , SK_DBL},
{"FluteEmbouchure" , __SK_ControlChange_, __SK_FluteEmbouchure_ , SK_DBL},
{"LipTension" , __SK_ControlChange_, __SK_LipTension_ , SK_DBL},
{"StrikePosition" , __SK_ControlChange_, __SK_StrikePosition_ , SK_DBL},
{"StickHardness" , __SK_ControlChange_, __SK_StickHardness_ , SK_DBL},
{"TrillDepth" , __SK_ControlChange_, __SK_TrillDepth_ , SK_DBL},
{"TrillSpeed" , __SK_ControlChange_, __SK_TrillSpeed_ , SK_DBL},
{"TrillDepth" , __SK_ControlChange_, __SK_TrillDepth_ , SK_DBL},
{"TrillSpeed" , __SK_ControlChange_, __SK_TrillSpeed_ , SK_DBL},
{"Strumming" , __SK_ControlChange_, __SK_Strumming_ , 127 },
{"NotStrumming" , __SK_ControlChange_, __SK_Strumming_ , 0 },
{"Strumming" , __SK_ControlChange_, __SK_Strumming_ , 127 },
{"NotStrumming" , __SK_ControlChange_, __SK_Strumming_ , 0 },
{"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL},
{"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL},
{"Chord" , __SK_Chord_ , SK_DBL , SK_STR },
{"ChordOff" , __SK_ChordOff_ , SK_DBL , NOPE },
{"Chord" , __SK_Chord_ , SK_DBL, SK_STR},
{"ChordOff" , __SK_ChordOff_ , SK_DBL, NOPE},
{"ShakerInst" , __SK_ControlChange_, __SK_ShakerInst_ , SK_DBL},
{"Maraca" , __SK_ControlChange_, __SK_ShakerInst_ , 0 },
{"Sekere" , __SK_ControlChange_, __SK_ShakerInst_ , 1 },
{"Cabasa" , __SK_ControlChange_, __SK_ShakerInst_ , 2 },
{"Bamboo" , __SK_ControlChange_, __SK_ShakerInst_ , 3 },
{"Waterdrp" , __SK_ControlChange_, __SK_ShakerInst_ , 4 },
{"Tambourn" , __SK_ControlChange_, __SK_ShakerInst_ , 5 },
{"Sleighbl" , __SK_ControlChange_, __SK_ShakerInst_ , 6 },
{"Guiro" , __SK_ControlChange_, __SK_ShakerInst_ , 7 },
{"ShakerInst" , __SK_ControlChange_, __SK_ShakerInst_ , SK_DBL},
{"Maraca" , __SK_ControlChange_, __SK_ShakerInst_ , 0 },
{"Sekere" , __SK_ControlChange_, __SK_ShakerInst_ , 1 },
{"Cabasa" , __SK_ControlChange_, __SK_ShakerInst_ , 2 },
{"Bamboo" , __SK_ControlChange_, __SK_ShakerInst_ , 3 },
{"Waterdrp" , __SK_ControlChange_, __SK_ShakerInst_ , 4 },
{"Tambourn" , __SK_ControlChange_, __SK_ShakerInst_ , 5 },
{"Sleighbl" , __SK_ControlChange_, __SK_ShakerInst_ , 6 },
{"Guiro" , __SK_ControlChange_, __SK_ShakerInst_ , 7 },
{"OpenFile" , 256, SK_STR , NOPE},
{"SetPath" , 257, SK_STR , NOPE},
{"OpenFile" , 256, SK_STR, NOPE},
{"SetPath" , 257, SK_STR, NOPE},
{"FilePath" , __SK_SINGER_FilePath_, SK_STR , NOPE},
{"Frequency" , __SK_SINGER_Frequency_, SK_STR , NOPE},
{"NoteName" , __SK_SINGER_NoteName_, SK_STR , NOPE},
{"VocalShape" , __SK_SINGER_Shape_ , SK_STR , NOPE},
{"Glottis" , __SK_SINGER_Glot_ , SK_STR , NOPE},
{"VoicedUnVoiced" , __SK_SINGER_VoicedUnVoiced_, SK_DBL , SK_STR},
{"Synthesize" , __SK_SINGER_Synthesize_, SK_STR , NOPE},
{"Silence" , __SK_SINGER_Silence_, SK_STR , NOPE},
{"VibratoAmt" , __SK_ControlChange_ ,__SK_SINGER_VibratoAmt_,SK_DBL},
{"RndVibAmt" , __SK_SINGER_RndVibAmt_ ,SK_STR, NOPE},
{"VibFreq" , __SK_ControlChange_ ,__SK_SINGER_VibFreq_ ,SK_DBL}
{"FilePath" , __SK_SINGER_FilePath_ , SK_STR, NOPE},
{"Frequency" , __SK_SINGER_Frequency_ , SK_STR, NOPE},
{"NoteName" , __SK_SINGER_NoteName_ , SK_STR, NOPE},
{"VocalShape" , __SK_SINGER_Shape_ , SK_STR, NOPE},
{"Glottis" , __SK_SINGER_Glot_ , SK_STR, NOPE},
{"VoicedUnVoiced" , __SK_SINGER_VoicedUnVoiced_, SK_DBL, SK_STR},
{"Synthesize" , __SK_SINGER_Synthesize_ , SK_STR, NOPE},
{"Silence" , __SK_SINGER_Silence_ , SK_STR, NOPE},
{"RndVibAmt" , __SK_SINGER_RndVibAmt_ , SK_STR, NOPE},
{"VibratoAmt" , __SK_ControlChange_ ,__SK_SINGER_VibratoAmt_,SK_DBL},
{"VibFreq" , __SK_ControlChange_ ,__SK_SINGER_VibFreq_ ,SK_DBL}
};
/** FORMAT: *************************************************************/
/* */
/* MessageStr$ ,type, data2, data3, */
/* MessageStr$ , type, data2, data3, */
/* */
/* type is the message type sent back from the SKINI line parser. */
/* data<n> is either */
/* NOPE : field not used, specifically, there aren't going */
/* to be any more fields on this line. So if there */
/* is is NOPE in data2, data3 won't even be checked */
/* is NOPE in data2, data3 won't even be checked */
/* SK_INT : byte (actually scanned as 32 bit signed integer) */
/* If it's a MIDI data field which is required to */
/* be an integer, like a controller number, it's */
/* 0-127. Otherwise) get creative with SK_INTs */
/* If it's a MIDI data field which is required to */
/* be an integer, like a controller number, it's */
/* 0-127. Otherwise, get creative with SK_INTs. */
/* SK_DBL : double precision floating point. SKINI uses these */
/* in the MIDI context for note numbers with micro */
/* tuning, velocities, controller values, etc. */
/* SK_STR : only valid in final field. This allows (nearly) */
/* arbitrary message types to be supported by simply */
/* scanning the string to EndOfLine and then passing */
/* it to a more intellegent handler. For example, */
/* it to a more intelligent handler. For example, */
/* MIDI SYSEX (system exclusive) messages of up to */
/* 256bytes can be read as space-delimited integers */
/* into the 1K SK_STR buffer. Longer bulk dumps, */
/* 256 bytes can be read as space-delimited integers */
/* into the SK_STR buffer. Longer bulk dumps, */
/* soundfiles, etc. should be handled as a new */
/* message type pointing to a FileName stored in the */
/* SK_STR field, or as a new type of multi-line */

View File

@@ -2,15 +2,15 @@
/*! \class Sampler
\brief STK sampling synthesis abstract base class.
This instrument contains up to 5 attack waves,
5 looped waves, and an ADSR envelope.
This instrument provides an ADSR envelope, a one-pole filter, and
structures for an arbitrary number of attack and loop waves.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SAMPLER_H)
#define __SAMPLER_H
#ifndef STK_SAMPLER_H
#define STK_SAMPLER_H
#include "Instrmnt.h"
#include "ADSR.h"
@@ -31,7 +31,7 @@ class Sampler : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency) = 0;
virtual void setFrequency(StkFloat frequency) = 0;
//! Initiate the envelopes with a key-on event and reset the attack waves.
void keyOn();
@@ -40,25 +40,36 @@ class Sampler : public Instrmnt
void keyOff();
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
virtual void noteOff(StkFloat amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
virtual StkFloat tick() = 0;
//! Computer \e vectorSize outputs and return them in \e vector.
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value) = 0;
virtual void controlChange(int number, StkFloat value) = 0;
protected:
ADSR *adsr;
WvIn *attacks[5];
WaveLoop *loops[5];
OnePole *filter;
MY_FLOAT baseFrequency;
MY_FLOAT attackRatios[5];
MY_FLOAT loopRatios[5];
MY_FLOAT attackGain;
MY_FLOAT loopGain;
int whichOne;
ADSR adsr_;
std::vector<WvIn *> attacks_;
std::vector<WaveLoop *> loops_;
OnePole filter_;
StkFloat baseFrequency_;
std::vector<StkFloat> attackRatios_;
std::vector<StkFloat> loopRatios_;
StkFloat attackGain_;
StkFloat loopGain_;
};

View File

@@ -31,16 +31,16 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SAXOFONY_H)
#define __SAXOFONY_H
#ifndef STK_SAXOFONY_H
#define STK_SAXOFONY_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "ReedTabl.h"
#include "ReedTable.h"
#include "OneZero.h"
#include "Envelope.h"
#include "Noise.h"
@@ -50,7 +50,10 @@ class Saxofony : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Saxofony(MY_FLOAT lowestFrequency);
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Saxofony(StkFloat lowestFrequency);
//! Class destructor.
~Saxofony();
@@ -59,41 +62,53 @@ class Saxofony : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the "blowing" position between the air column terminations (0.0 - 1.0).
void setBlowPosition(MY_FLOAT aPosition);
void setBlowPosition(StkFloat aPosition);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayL *delays[2];
ReedTabl *reedTable;
OneZero *filter;
Envelope *envelope;
Noise *noise;
WaveLoop *vibrato;
long length;
MY_FLOAT outputGain;
MY_FLOAT noiseGain;
MY_FLOAT vibratoGain;
MY_FLOAT position;
DelayL delays_[2];
ReedTable reedTable_;
OneZero filter_;
Envelope envelope_;
Noise noise_;
WaveLoop *vibrato_;
unsigned long length_;
StkFloat outputGain_;
StkFloat noiseGain_;
StkFloat vibratoGain_;
StkFloat position_;
};

View File

@@ -48,17 +48,17 @@
- Little Rocks = 21
- Tuned Bamboo Chimes = 22
by Perry R. Cook, 1996 - 1999.
by Perry R. Cook, 1996 - 2004.
*/
/***************************************************/
#if !defined(__SHAKERS_H)
#define __SHAKERS_H
#ifndef STK_SHAKERS_H
#define STK_SHAKERS_H
#include "Instrmnt.h"
#define MAX_FREQS 8
#define NUM_INSTR 24
const int MAX_FREQS = 8;
const int NUM_INSTR = 24;
class Shakers : public Instrmnt
{
@@ -74,54 +74,65 @@ class Shakers : public Instrmnt
Use the instrument numbers above, converted to frequency values
as if MIDI note numbers, to select a particular instrument.
*/
virtual void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
void noteOn(StkFloat instrument, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
int setupName(char* instr);
int setupNum(int inst);
int setFreqAndReson(int which, MY_FLOAT freq, MY_FLOAT reson);
void setDecays(MY_FLOAT sndDecay, MY_FLOAT sysDecay);
void setFinalZs(MY_FLOAT z0, MY_FLOAT z1, MY_FLOAT z2);
MY_FLOAT wuter_tick();
MY_FLOAT tbamb_tick();
MY_FLOAT ratchet_tick();
int setFreqAndReson(int which, StkFloat freq, StkFloat reson);
void setDecays(StkFloat sndDecay, StkFloat sysDecay);
void setFinalZs(StkFloat z0, StkFloat z1, StkFloat z2);
StkFloat wuter_tick();
StkFloat tbamb_tick();
StkFloat ratchet_tick();
int instType;
int ratchetPos, lastRatchetPos;
MY_FLOAT shakeEnergy;
MY_FLOAT inputs[MAX_FREQS];
MY_FLOAT outputs[MAX_FREQS][2];
MY_FLOAT coeffs[MAX_FREQS][2];
MY_FLOAT sndLevel;
MY_FLOAT baseGain;
MY_FLOAT gains[MAX_FREQS];
int nFreqs;
MY_FLOAT t_center_freqs[MAX_FREQS];
MY_FLOAT center_freqs[MAX_FREQS];
MY_FLOAT resons[MAX_FREQS];
MY_FLOAT freq_rand[MAX_FREQS];
int freqalloc[MAX_FREQS];
MY_FLOAT soundDecay;
MY_FLOAT systemDecay;
MY_FLOAT nObjects;
MY_FLOAT collLikely;
MY_FLOAT totalEnergy;
MY_FLOAT ratchet,ratchetDelta;
MY_FLOAT finalZ[3];
MY_FLOAT finalZCoeffs[3];
MY_FLOAT defObjs[NUM_INSTR];
MY_FLOAT defDecays[NUM_INSTR];
MY_FLOAT decayScale[NUM_INSTR];
int instType_;
int ratchetPos_, lastRatchetPos_;
StkFloat shakeEnergy_;
StkFloat inputs_[MAX_FREQS];
StkFloat outputs_[MAX_FREQS][2];
StkFloat coeffs_[MAX_FREQS][2];
StkFloat sndLevel_;
StkFloat baseGain_;
StkFloat gains_[MAX_FREQS];
int nFreqs_;
StkFloat t_center_freqs_[MAX_FREQS];
StkFloat center_freqs_[MAX_FREQS];
StkFloat resons_[MAX_FREQS];
StkFloat freq_rand_[MAX_FREQS];
int freqalloc_[MAX_FREQS];
StkFloat soundDecay_;
StkFloat systemDecay_;
StkFloat nObjects_;
StkFloat totalEnergy_;
StkFloat ratchet_, ratchetDelta_;
StkFloat finalZ_[3];
StkFloat finalZCoeffs_[3];
StkFloat defObjs_[NUM_INSTR];
StkFloat defDecays_[NUM_INSTR];
StkFloat decayScale_[NUM_INSTR];
};

View File

@@ -13,12 +13,12 @@
- Envelope Rate = 11
- Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SIMPLE_H)
#define __SIMPLE_H
#ifndef STK_SIMPLE_H
#define STK_SIMPLE_H
#include "Instrmnt.h"
#include "ADSR.h"
@@ -31,16 +31,19 @@ class Simple : public Instrmnt
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Simple();
//! Class destructor.
virtual ~Simple();
~Simple();
//! Clear internal states.
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Start envelope toward "on" target.
void keyOn();
@@ -49,25 +52,37 @@ class Simple : public Instrmnt
void keyOff();
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
ADSR *adsr;
WaveLoop *loop;
OnePole *filter;
BiQuad *biquad;
Noise *noise;
MY_FLOAT baseFrequency;
MY_FLOAT loopGain;
ADSR adsr_;
WaveLoop *loop_;
OnePole filter_;
BiQuad biquad_;
Noise noise_;
StkFloat baseFrequency_;
StkFloat loopGain_;
};

View File

@@ -9,26 +9,26 @@
from pitch shifting. It will be used as an
excitation source for other instruments.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SINGWAVE_H)
#define __SINGWAVE_H
#ifndef STK_SINGWAVE_H
#define STK_SINGWAVE_H
#include "WaveLoop.h"
#include "Modulate.h"
#include "Envelope.h"
class SingWave : public Stk
class SingWave : public Generator
{
public:
//! Class constructor taking filename argument.
/*!
An StkError will be thrown if the file is not found, its format is
unknown, or a read error occurs.
unknown, a read error occurs, or the rawwave path is incorrectly set.
*/
SingWave(const char *fileName, bool raw=FALSE);
SingWave( std::string fileName, bool raw=false);
//! Class destructor.
~SingWave();
@@ -40,28 +40,28 @@ class SingWave : public Stk
void normalize();
//! Normalize the file to a maximum of \e +- peak.
void normalize(MY_FLOAT peak);
void normalize(StkFloat peak);
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the vibrato frequency in Hz.
void setVibratoRate(MY_FLOAT aRate);
void setVibratoRate(StkFloat rate);
//! Set the vibrato gain.
void setVibratoGain(MY_FLOAT gain);
void setVibratoGain(StkFloat gain);
//! Set the random-ness amount.
void setRandomGain(MY_FLOAT gain);
void setRandomGain(StkFloat gain);
//! Set the sweep rate.
void setSweepRate(MY_FLOAT aRate);
void setSweepRate(StkFloat rate);
//! Set the gain rate.
void setGainRate(MY_FLOAT aRate);
void setGainRate(StkFloat rate);
//! Set the gain target value.
void setGainTarget(MY_FLOAT target);
void setGainTarget(StkFloat target);
//! Start a note.
void noteOn();
@@ -69,21 +69,29 @@ class SingWave : public Stk
//! Stop a note.
void noteOff();
//! Return the last output value.
MY_FLOAT lastOut();
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Compute \e vectorSize outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
WaveLoop *wave;
Modulate *modulator;
Envelope *envelope;
Envelope *pitchEnvelope;
MY_FLOAT rate;
MY_FLOAT sweepRate;
MY_FLOAT lastOutput;
WaveLoop *wave_;
Modulate *modulator_;
Envelope envelope_;
Envelope pitchEnvelope_;
StkFloat rate_;
StkFloat sweepRate_;
};

View File

@@ -13,12 +13,12 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SITAR_H)
#define __SITAR_H
#ifndef STK_SITAR_H
#define STK_SITAR_H
#include "Instrmnt.h"
#include "DelayA.h"
@@ -30,7 +30,7 @@ class Sitar : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Sitar(MY_FLOAT lowestFrequency);
Sitar( StkFloat lowestFrequency = 20 );
//! Class destructor.
~Sitar();
@@ -39,30 +39,42 @@ class Sitar : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Pluck the string with the given amplitude using the current frequency.
void pluck(MY_FLOAT amplitude);
void pluck(StkFloat amplitude);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
DelayA *delayLine;
OneZero *loopFilter;
Noise *noise;
ADSR *envelope;
long length;
MY_FLOAT loopGain;
MY_FLOAT amGain;
MY_FLOAT delay;
MY_FLOAT targetDelay;
DelayA delayLine_;
OneZero loopFilter_;
Noise noise_;
ADSR envelope_;
StkFloat loopGain_;
StkFloat amGain_;
StkFloat delay_;
StkFloat targetDelay_;
};

117
include/Skini.h Normal file
View File

@@ -0,0 +1,117 @@
/***************************************************/
/*! \class Skini
\brief STK SKINI parsing class
This class parses SKINI formatted text
messages. It can be used to parse individual
messages or it can be passed an entire file.
The SKINI specification is Perry's and his
alone, but it's all text so it shouldn't be too
hard to figure out.
SKINI (Synthesis toolKit Instrument Network
Interface) is like MIDI, but allows for
floating-point control changes, note numbers,
etc. The following example causes a sharp
middle C to be played with a velocity of 111.132:
\code
noteOn 60.01 111.132
\endcode
\sa \ref skini
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#ifndef STK_SKINI_H
#define STK_SKINI_H
#include "Stk.h"
#include <vector>
#include <string>
#include <fstream>
class Skini : public Stk
{
public:
//! A message structure to store and pass parsed SKINI messages.
struct Message {
long type; /*!< The message type, as defined in SKINI.msg. */
long channel; /*!< The message channel (not limited to 16!). */
StkFloat time; /*!< The message time stamp in seconds (delta or absolute). */
std::vector<StkFloat> floatValues; /*!< The message values read as floats (values are type-specific). */
std::vector<long> intValues; /*!< The message values read as ints (number and values are type-specific). */
std::string remainder; /*!< Any remaining message data, read as ascii text. */
// Default constructor.
Message()
:type(0), channel(0), time(0.0), floatValues(2), intValues(2) {}
};
//! Default constructor.
Skini();
//! Class destructor
~Skini();
//! Set a SKINI formatted file for reading.
/*!
If the file is successfully opened, this function returns \e
true. Otherwise, \e false is returned.
*/
bool setFile( std::string fileName );
//! Parse the next file message (if a file is loaded) and return the message type.
/*!
This function skips over lines in a file which cannot be
parsed. A type value equal to zero in the referenced message
structure (and the returned value) indicates the file end is
reached or no file is open for reading.
*/
long nextMessage( Skini::Message& message );
//! Attempt to parse the given string and returning the message type.
/*!
A type value equal to zero in the referenced message structure
indicates an invalid message.
*/
long parseString( std::string& line, Skini::Message& message );
//! Return the SKINI type string for the given type value.
static std::string whatsThisType(long type);
//! Return the SKINI controller string for the given controller number.
static std::string whatsThisController(long number);
protected:
void tokenize( const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters );
std::ifstream file_;
};
static const double Midi2Pitch[129] = {
8.18,8.66,9.18,9.72,10.30,10.91,11.56,12.25,
12.98,13.75,14.57,15.43,16.35,17.32,18.35,19.45,
20.60,21.83,23.12,24.50,25.96,27.50,29.14,30.87,
32.70,34.65,36.71,38.89,41.20,43.65,46.25,49.00,
51.91,55.00,58.27,61.74,65.41,69.30,73.42,77.78,
82.41,87.31,92.50,98.00,103.83,110.00,116.54,123.47,
130.81,138.59,146.83,155.56,164.81,174.61,185.00,196.00,
207.65,220.00,233.08,246.94,261.63,277.18,293.66,311.13,
329.63,349.23,369.99,392.00,415.30,440.00,466.16,493.88,
523.25,554.37,587.33,622.25,659.26,698.46,739.99,783.99,
830.61,880.00,932.33,987.77,1046.50,1108.73,1174.66,1244.51,
1318.51,1396.91,1479.98,1567.98,1661.22,1760.00,1864.66,1975.53,
2093.00,2217.46,2349.32,2489.02,2637.02,2793.83,2959.96,3135.96,
3322.44,3520.00,3729.31,3951.07,4186.01,4434.92,4698.64,4978.03,
5274.04,5587.65,5919.91,6271.93,6644.88,7040.00,7458.62,7902.13,
8372.02,8869.84,9397.27,9956.06,10548.08,11175.30,11839.82,12543.85,
13289.75};
#endif

View File

@@ -14,12 +14,12 @@
less than or equal to zero indicate a closed
or lost connection or the occurence of an error.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SOCKET_H)
#define __SOCKET_H
#ifndef STK_SOCKET_H
#define STK_SOCKET_H
#include "Stk.h"
@@ -56,7 +56,7 @@ class Socket : public Stk
void close( void );
//! Return the server/client socket descriptor.
int socket( void ) const;
int id( void ) const;
//! Return the server/client port number.
int port( void ) const;
@@ -76,7 +76,7 @@ class Socket : public Stk
//! Close the socket with the given descriptor.
static void close( int socket );
//! Returns TRUE is the socket descriptor is valid.
//! Returns true if the socket descriptor is valid.
static bool isValid( int socket );
//! Write a buffer over the socket connection. Returns the number of bytes written or -1 if an error occurs.
@@ -93,11 +93,10 @@ class Socket : public Stk
protected:
char msg[256];
int soket;
int poort;
bool server;
int soket_;
int port_;
bool server_;
};
#endif // defined(__SOCKET_H)
#endif // defined(STK_SOCKET_H)

View File

@@ -5,66 +5,67 @@
This class implements a spherical ball with
radius, mass, position, and velocity parameters.
by Perry R. Cook, 1995 - 2002.
by Perry R. Cook, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SPHERE_H)
#define __SPHERE_H
#ifndef STK_SPHERE_H
#define STK_SPHERE_H
#include "Stk.h"
#include "Vector3D.h"
class Sphere
class Sphere : public Stk
{
public:
//! Constructor taking an initial radius value.
Sphere(double initRadius);
Sphere(StkFloat radius = 1.0 );
//! Class destructor.
~Sphere();
//! Set the 3D center position of the sphere.
void setPosition(double anX, double aY, double aZ);
void setPosition(StkFloat x, StkFloat y, StkFloat z);
//! Set the 3D velocity of the sphere.
void setVelocity(double anX, double aY, double aZ);
void setVelocity(StkFloat x, StkFloat y, StkFloat z);
//! Set the radius of the sphere.
void setRadius(double aRadius);
void setRadius(StkFloat radius);
//! Set the mass of the sphere.
void setMass(double aMass);
void setMass(StkFloat mass);
//! Get the current position of the sphere as a 3D vector.
Vector3D* getPosition();
//! Get the relative position of the given point to the sphere as a 3D vector.
Vector3D* getRelativePosition(Vector3D *aPosition);
Vector3D* getRelativePosition(Vector3D *position);
//! Set the velcoity of the sphere as a 3D vector.
double getVelocity(Vector3D* aVelocity);
StkFloat getVelocity(Vector3D* velocity);
//! Returns the distance from the sphere boundary to the given position (< 0 if inside).
double isInside(Vector3D *aPosition);
StkFloat isInside(Vector3D *position);
//! Get the current sphere radius.
double getRadius();
StkFloat getRadius();
//! Get the current sphere mass.
double getMass();
StkFloat getMass();
//! Increase the current sphere velocity by the given 3D components.
void addVelocity(double anX, double aY, double aZ);
void addVelocity(StkFloat x, StkFloat y, StkFloat z);
//! Move the sphere for the given time increment.
void tick(double timeIncrement);
void tick(StkFloat timeIncrement);
private:
Vector3D *myPosition;
Vector3D *myVelocity;
Vector3D workingVector;
double myRadius;
double myMass;
Vector3D position_;
Vector3D velocity_;
Vector3D workingVector_;
StkFloat radius_;
StkFloat mass_;
};
#endif

View File

@@ -17,12 +17,12 @@
- String Sustain = 11
- String Stretch = 1
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__StifKarp_h)
#define __StifKarp_h
#ifndef STK_STIFKARP_H
#define STK_STIFKARP_H
#include "Instrmnt.h"
#include "DelayL.h"
@@ -35,7 +35,7 @@ class StifKarp : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
StifKarp(MY_FLOAT lowestFrequency);
StifKarp(StkFloat lowestFrequency);
//! Class destructor.
~StifKarp();
@@ -44,13 +44,13 @@ class StifKarp : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set the stretch "factor" of the string (0.0 - 1.0).
void setStretch(MY_FLOAT stretch);
void setStretch(StkFloat stretch);
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
void setPickupPosition(MY_FLOAT position);
void setPickupPosition(StkFloat position);
//! Set the base loop gain.
/*!
@@ -58,37 +58,50 @@ class StifKarp : public Instrmnt
Because of high-frequency loop filter roll-off, higher
frequency settings have greater loop gains.
*/
void setBaseLoopGain(MY_FLOAT aGain);
void setBaseLoopGain(StkFloat aGain);
//! Pluck the string with the given amplitude using the current frequency.
void pluck(MY_FLOAT amplitude);
void pluck(StkFloat amplitude);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
DelayA *delayLine;
DelayL *combDelay;
OneZero *filter;
Noise *noise;
BiQuad *biQuad[4];
long length;
MY_FLOAT loopGain;
MY_FLOAT baseLoopGain;
MY_FLOAT lastFrequency;
MY_FLOAT lastLength;
MY_FLOAT stretching;
MY_FLOAT pluckAmplitude;
MY_FLOAT pickupPosition;
DelayA delayLine_;
DelayL combDelay_;
OneZero filter_;
Noise noise_;
BiQuad biquad_[4];
unsigned long length_;
StkFloat loopGain_;
StkFloat baseLoopGain_;
StkFloat lastFrequency_;
StkFloat lastLength_;
StkFloat stretching_;
StkFloat pluckAmplitude_;
StkFloat pickupPosition_;
};

View File

@@ -8,30 +8,36 @@
this class provides error handling and
byte-swapping functions.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__STK_H)
#define __STK_H
#ifndef STK_STK_H
#define STK_STK_H
#include <string>
#include <iostream>
#include <sstream>
#include <valarray>
// Most data in STK is passed and calculated with the
// following user-definable floating-point type. You
// can change this to "float" if you prefer or perhaps
// a "long double" in the future.
typedef double MY_FLOAT;
typedef double StkFloat;
// The "MY_FLOAT" type was deprecated in STK
// versions higher than 4.1.3 and replaced with the variable
// "StkFloat".
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
typedef StkFloat MY_FLOAT;
#pragma deprecated(MY_FLOAT)
#elif defined(__GXX__)
typedef StkFloat MY_FLOAT __attribute__ ((deprecated));
#else
typedef StkFloat MY_FLOAT; // temporary
#endif
// The "MY_FLOAT" type will be deprecated in STK
// versions higher than 4.1.2 and replaced with the variable
// "StkFloat".
//typedef double StkFloat;
//#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
// #pragma deprecated(MY_FLOAT)
//#else
// typedef StkFloat MY_FLOAT __attribute__ ((deprecated));
//#endif
//! STK error handling class.
/*!
@@ -42,7 +48,8 @@ typedef double MY_FLOAT;
class StkError
{
public:
enum TYPE {
enum Type {
STATUS,
WARNING,
DEBUG_WARNING,
FUNCTION_ARGUMENT,
@@ -58,24 +65,27 @@ public:
};
protected:
char message[256];
TYPE type;
std::string message_;
Type type_;
public:
//! The constructor.
StkError(const char *p, TYPE tipe = StkError::UNSPECIFIED);
StkError(const std::string& message, Type type = StkError::UNSPECIFIED) : message_(message), type_(type) {}
//! The destructor.
virtual ~StkError(void);
virtual ~StkError(void) {};
//! Prints "thrown" error message to stdout.
virtual void printMessage(void);
//! Prints thrown error message to stderr.
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
//! Returns the "thrown" error message TYPE.
virtual const TYPE& getType(void) { return type; }
//! Returns the thrown error message type.
virtual const Type& getType(void) { return type_; }
//! Returns the "thrown" error message string.
virtual const char *getMessage(void) const { return message; }
//! Returns the thrown error message string.
virtual const std::string& getMessage(void) { return message_; }
//! Returns the thrown error message as a C string.
virtual const char *getMessageCString(void) { return message_.c_str(); }
};
@@ -83,15 +93,16 @@ class Stk
{
public:
typedef unsigned long STK_FORMAT;
static const STK_FORMAT STK_SINT8; /*!< -128 to +127 */
static const STK_FORMAT STK_SINT16; /*!< -32768 to +32767 */
static const STK_FORMAT STK_SINT32; /*!< -2147483648 to +2147483647. */
static const STK_FORMAT MY_FLOAT32; /*!< Normalized between plus/minus 1.0. */
static const STK_FORMAT MY_FLOAT64; /*!< Normalized between plus/minus 1.0. */
typedef unsigned long StkFormat;
static const StkFormat STK_SINT8; /*!< -128 to +127 */
static const StkFormat STK_SINT16; /*!< -32768 to +32767 */
static const StkFormat STK_SINT24; /*!< Upper 3 bytes of 32-bit signed integer. */
static const StkFormat STK_SINT32; /*!< -2147483648 to +2147483647. */
static const StkFormat STK_FLOAT32; /*!< Normalized between plus/minus 1.0. */
static const StkFormat STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */
//! Static method which returns the current STK sample rate.
static MY_FLOAT sampleRate(void);
static StkFloat sampleRate(void) { return srate_; }
//! Static method which sets the STK sample rate.
/*!
@@ -102,13 +113,13 @@ public:
is different from the default rate, it is imperative that it be
set \e BEFORE STK objects are instantiated.
*/
static void setSampleRate(MY_FLOAT newRate);
static void setSampleRate(StkFloat rate) { if (rate > 0.0) srate_ = rate; }
//! Static method which returns the current rawwave path.
static std::string rawwavePath(void);
static std::string rawwavePath(void) { return rawwavepath_; }
//! Static method which sets the STK rawwave path.
static void setRawwavePath(std::string newPath);
static void setRawwavePath(std::string path);
//! Static method which byte-swaps a 16-bit data type.
static void swap16(unsigned char *ptr);
@@ -122,41 +133,119 @@ public:
//! Static cross-platform method to sleep for a number of milliseconds.
static void sleep(unsigned long milliseconds);
//! Static function for error reporting and handling using c-strings.
static void handleError( const char *message, StkError::Type type );
//! Static function for error reporting and handling using c++ strings.
static void handleError( std::string message, StkError::Type type );
private:
static MY_FLOAT srate;
static std::string rawwavepath;
static StkFloat srate_;
static std::string rawwavepath_;
protected:
std::ostringstream errorString_;
//! Default constructor.
Stk(void);
//! Class destructor.
virtual ~Stk(void);
//! Function for error reporting and handling.
static void handleError( const char *message, StkError::TYPE type );
//! Internal function for error reporting which assumes message in \c errorString_ variable.
void handleError( StkError::Type type );
};
/***************************************************/
/*! \class StkFrames
\brief An STK class to handle vectorized audio data.
This class can hold single- or multi-channel audio data in either
interleaved or non-interleaved formats. The data type is always
StkFloat.
Possible future improvements in this class could include static
functions to inter- or de-interleave the data and to convert to
and return other data types.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
class StkFrames
{
public:
//! The default constructor initializes the frame data structure to size zero.
StkFrames( unsigned int nFrames = 0, unsigned int nChannels = 1, bool interleaved = true );
//! Overloaded constructor which initializes the frame data to the specified size with \c value.
StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels, bool interleaved = true );
//! Subscript operator which returns a reference to element \c n of self.
/*!
The result can be used as an lvalue . This reference is valid
until the resize function is called or the array is destroyed. The
index \c n must be between 0 and size less one. No range checking
is performed.
*/
StkFloat& operator[]( size_t n ) { return data_[n]; };
//! Subscript operator which returns the value at element \c n of self.
/*!
The index \c n must be between 0 and size less one. No range
checking is performed.
*/
StkFloat operator[]( size_t n ) const { return data_[n]; };
//! Returns the total number of audio samples represented by the object.
size_t size() const { return size_; };
//! Resize self to represent the specified number of channels and frames.
/*!
Changes the size of self based on the number of frames and
channels, and assigns \c value to every element.
*/
void resize( unsigned int nFrames, unsigned int nChannels = 1, StkFloat value = 0.0 );
//! Return the number of channels represented by the data.
unsigned int channels( void ) const { return nChannels_; };
//! Return the number of sample frames represented by the data.
unsigned int frames( void ) const { return nFrames_; };
//! Returns \c true if the data is in interleaved format, \c false if the data is non-interleaved.
bool interleaved( void ) const { return interleaved_; };
//! Set the flag to indicate whether the internal data is in interleaved (\c true) or non-interleaved (\c false) format.
void setInterleaved( bool isInterleaved ) { interleaved_ = isInterleaved; };
private:
std::valarray<StkFloat> data_;
unsigned int nFrames_;
unsigned int nChannels_;
size_t size_;
bool interleaved_;
};
// Here are a few other useful typedefs.
typedef signed short SINT16;
typedef signed int SINT32;
typedef float FLOAT32;
typedef double FLOAT64;
// Boolean values
#define FALSE 0
#define TRUE 1
// The default sampling rate.
#define SRATE (MY_FLOAT) 44100.0
const StkFloat SRATE = 44100.0;
// The default real-time audio input and output buffer size. If
// clicks are occuring in the input and/or output sound stream, a
// larger buffer size may help. Larger buffer sizes, however, produce
// more latency.
#define RT_BUFFER_SIZE 512
const unsigned int RT_BUFFER_SIZE = 512;
// The default rawwave path value is set with the preprocessor
// definition RAWWAVE_PATH. This can be specified as an argument to
@@ -171,10 +260,9 @@ typedef double FLOAT64;
#define RAWWAVE_PATH "../../rawwaves/"
#endif
#define PI (MY_FLOAT) 3.14159265359
#define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI)
#define ONE_OVER_128 (MY_FLOAT) 0.0078125
const StkFloat PI = 3.14159265359;
const StkFloat TWO_PI = 2 * PI;
const StkFloat ONE_OVER_128 = 0.0078125;
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
#define __OS_WINDOWS__

View File

@@ -6,12 +6,12 @@
using the C rand() function. The quality of the
rand() function varies from one OS to another.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__SUBNOISE_H)
#define __SUBNOISE_H
#ifndef STK_SUBNOISE_H
#define STK_SUBNOISE_H
#include "Noise.h"
@@ -32,11 +32,23 @@ class SubNoise : public Noise
void setRate(int subRate);
//! Return a sub-sampled random number between -1.0 and 1.0.
MY_FLOAT tick();
StkFloat tick();
//! Compute \e vectorSize outputs and return them in \e vector.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
int counter;
int rate;
int counter_;
int rate_;
};

View File

@@ -10,20 +10,24 @@
An StkError will be thrown if the table file
is not found.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TABLE_H)
#define __TABLE_H
#ifndef STK_TABLE_H
#define STK_TABLE_H
#include "Stk.h"
#include "Function.h"
class Table : public Stk
class Table : public Function
{
public:
//! Constructor loads the data from \e fileName.
Table(char *fileName);
//! The constructor loads the data from \e fileName.
/*!
An StkError will be thrown in the file cannot be found or
opened.
*/
Table( std::string fileName );
//! Class destructor.
~Table();
@@ -31,23 +35,28 @@ public:
//! Return the number of elements in the table.
long getLength() const;
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the table value at position \e index.
/*!
Linear interpolation is performed if \e index is
fractional.
*/
MY_FLOAT tick(MY_FLOAT index);
StkFloat tick(StkFloat index);
//! Take \e vectorSize index positions and return the corresponding table values in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
protected:
long length;
MY_FLOAT *data;
MY_FLOAT lastOutput;
long length_;
std::valarray<StkFloat> data_;
};

View File

@@ -20,18 +20,19 @@
for a single remote connection. The default
data type for the incoming stream is signed
16-bit integers, though any of the defined
STK_FORMATs are permissible.
StkFormats are permissible.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TCPWVIN_H)
#define __TCPWVIN_H
#ifndef STK_TCPWVIN_H
#define STK_TCPWVIN_H
#include "WvIn.h"
#include "Socket.h"
#include "Thread.h"
#include "Mutex.h"
typedef struct {
bool finished;
@@ -54,32 +55,49 @@ public:
/*!
An StkError will be thrown a socket error or an invalid function argument.
*/
void listen(unsigned int nChannels = 1, Stk::STK_FORMAT format = STK_SINT16);
void listen(unsigned int nChannels = 1, Stk::StkFormat format = STK_SINT16);
//! Returns TRUE is an input connection exists or input data remains in the queue.
//! Returns true is an input connection exists or input data remains in the queue.
/*!
This method will not return FALSE after an input connection has been closed until
This method will not return false after an input connection has been closed until
all buffered input data has been read out.
*/
bool isConnected(void);
//! Return the average across the last output sample frame.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Read out the average across one sample frame of data.
MY_FLOAT tick(void);
StkFloat tick(void);
//! Read out vectorSize averaged sample frames of data in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with averaged sample frames.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return a pointer to the last output sample frame.
const MY_FLOAT *lastFrame(void) const;
const StkFloat *lastFrame(void) const;
//! Return a pointer to the next sample frame of data.
const MY_FLOAT *tickFrame(void);
const StkFloat *tickFrame(void);
//! Read out sample \e frames of data to \e frameVector.
MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames);
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
//! Fill the StkFrames object with sample frames of data and return the same reference.
/*!
An StkError will be thrown if there is an incompatability
between the number of channels in the TcpWvIn object and that in
the StkFrames object.
*/
StkFrames& tickFrame( StkFrames& frames );
// Called by the thread routine to receive data via the socket connection
// and fill the socket buffer. This is not intended for general use but
@@ -94,19 +112,19 @@ protected:
// Read buffered socket data into the data buffer ... will block if none available.
int readData( void );
Socket *soket;
Thread *thread;
Mutex mutex;
char *buffer;
long bufferBytes;
long bytesFilled;
long writePoint;
long readPoint;
long counter;
int dataSize;
bool connected;
int fd;
thread_info threadInfo;
Socket *soket_;
Thread *thread_;
Mutex mutex_;
char *buffer_;
long bufferBytes_;
long bytesFilled_;
long writePoint_;
long readPoint_;
long counter_;
int dataSize_;
bool connected_;
int fd_;
thread_info threadInfo_;
};

View File

@@ -19,14 +19,14 @@
port and IP address of which must be specified
as constructor arguments. The default data
type is signed 16-bit integers but any of the
defined STK_FORMATs are permissible.
defined StkFormats are permissible.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TCPWVOUT_H)
#define __TCPWVOUT_H
#ifndef STK_TCPWVOUT_H
#define STK_TCPWVOUT_H
#include "WvOut.h"
#include "Socket.h"
@@ -41,7 +41,7 @@ class TcpWvOut : protected WvOut
/*!
An StkError is thrown if a socket error occurs or an invalid argument is specified.
*/
TcpWvOut(int port, const char *hostname = "localhost", unsigned int nChannels = 1, Stk::STK_FORMAT format = STK_SINT16);
TcpWvOut(int port, const char *hostname = "localhost", unsigned int nChannels = 1, Stk::StkFormat format = STK_SINT16);
//! Class destructor.
~TcpWvOut();
@@ -50,7 +50,7 @@ class TcpWvOut : protected WvOut
/*!
An StkError is thrown if a socket error occurs or an invalid argument is specified.
*/
void connect(int port, const char *hostname = "localhost", unsigned int nChannels = 1, Stk::STK_FORMAT format = STK_SINT16);
void connect(int port, const char *hostname = "localhost", unsigned int nChannels = 1, Stk::StkFormat format = STK_SINT16);
//! If a connection is open, write out remaining samples in the queue and then disconnect.
void disconnect(void);
@@ -59,35 +59,51 @@ class TcpWvOut : protected WvOut
unsigned long getFrames( void ) const;
//! Return the number of seconds of data output.
MY_FLOAT getTime( void ) const;
StkFloat getTime( void ) const;
//! Output a single sample to all channels in a sample frame.
/*!
An StkError is thrown if a socket write error occurs.
*/
void tick(MY_FLOAT sample);
void tick( const StkFloat sample );
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
/*!
An StkError is thrown if a socket write error occurs.
*/
void tick(const MY_FLOAT *vector, unsigned int vectorSize);
void tick( const StkFloat *vector, unsigned int vectorSize );
//! Output a channel of the StkFrames object to all channels of the TcpWvOut object.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if a
socket write error occurs or the \c channel argument is zero or it
is greater than the number of channels in the StkFrames object.
*/
void tick( const StkFrames& frames, unsigned int channel = 1 );
//! Output the \e frameVector of sample frames of the given length.
/*!
An StkError is thrown if a socket write error occurs.
*/
void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
void tickFrame( const StkFloat *frameVector, unsigned int frames = 1 );
//! Output the StkFrames data to the TcpWvOut object.
/*!
An StkError will be thrown if a socket write error occurs or if
there is an incompatability between the number of channels in the
TcpWvOut object and that in the StkFrames object.
*/
virtual void tickFrame( const StkFrames& frames );
protected:
// Write a buffer of length \e frames via the socket connection.
void writeData( unsigned long frames );
char msg[256];
char *buffer;
Socket *soket;
int dataSize;
char *buffer_;
Socket *soket_;
int dataSize_;
};
#endif // defined(__TCPWVOUT_H)
#endif

View File

@@ -2,17 +2,26 @@
/*! \class Thread
\brief STK thread class.
This class provides a uniform interface for
cross-platform threads. On unix systems,
the pthread library is used. Under Windows,
the C runtime threadex functions are used.
This class provides a uniform interface for cross-platform
threads. On unix systems, the pthread library is used. Under
Windows, the C runtime threadex functions are used.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
Each instance of the Thread class can be used to control a single
thread process. Routines are provided to signal cancelation
and/or joining with a thread, though it is not possible for this
class to know the running status of a thread once it is started.
For cross-platform compatability, thread functions should be
declared as follows:
THREAD_RETURN THREAD_TYPE thread_function(void *ptr)
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__THREAD_H)
#define __THREAD_H
#ifndef STK_THREAD_H
#define STK_THREAD_H
#include "Stk.h"
@@ -23,7 +32,6 @@
typedef pthread_t THREAD_HANDLE;
typedef void * THREAD_RETURN;
typedef void * (*THREAD_FUNCTION)(void *);
typedef pthread_mutex_t MUTEX;
#elif defined(__OS_WINDOWS__)
@@ -33,7 +41,6 @@
typedef unsigned long THREAD_HANDLE;
typedef unsigned THREAD_RETURN;
typedef unsigned (__stdcall *THREAD_FUNCTION)(void *);
typedef CRITICAL_SECTION MUTEX;
#endif
@@ -43,53 +50,45 @@ class Thread : public Stk
//! Default constructor.
Thread();
//! The class destructor waits indefinitely for the thread to end before returning.
//! The class destructor does not attempt to cancel or join a thread.
~Thread();
//! Begin execution of the thread \e routine. Upon success, TRUE is returned.
//! Begin execution of the thread \e routine. Upon success, true is returned.
/*!
The thread routine can be passed an argument via \e ptr. If
the thread cannot be created, the return value is FALSE.
A data pointer can be supplied to the thread routine via the
optional \e ptr argument. If the thread cannot be created, the
return value is false.
*/
bool start( THREAD_FUNCTION routine, void * ptr = NULL );
//! Wait the specified number of milliseconds for the thread to terminate. Return TRUE on success.
//! Signal cancellation of a thread routine, returning \e true on success.
/*!
If the specified time value is negative, the function will
block indefinitely. Otherwise, the function will block up to a
maximum of the specified time. A return value of FALSE indicates
the thread did not terminate within the specified time limit.
This function only signals thread cancellation. It does not
wait to verify actual routine termination. A \e true return value
only signifies that the cancellation signal was properly executed,
not thread cancellation. A thread routine may need to make use of
the testCancel() function to specify a cancellation point.
*/
bool wait( long milliseconds = -1 );
bool cancel(void);
//! Test for a thread cancellation request.
static void test(void);
//! Block the calling routine indefinitely until the thread terminates.
/*!
This function suspends execution of the calling routine until the thread has terminated. It will return immediately if the thread was already terminated. A \e true return value signifies successful termination. A \e false return value indicates a problem with the wait call.
*/
bool wait(void);
//! Create a cancellation point within a thread routine.
/*!
This function call checks for thread cancellation, allowing the
thread to be terminated if a cancellation request was previously
signaled.
*/
void testCancel(void);
protected:
THREAD_HANDLE thread;
THREAD_HANDLE thread_;
};
class Mutex : public Stk
{
public:
//! Default constructor.
Mutex();
//! Class destructor.
~Mutex();
//! Lock the mutex.
void lock(void);
//! Unlock the mutex.
void unlock(void);
protected:
MUTEX mutex;
};
#endif // defined(__THREAD_H)
#endif

View File

@@ -26,12 +26,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TUBEBELL_H)
#define __TUBEBELL_H
#ifndef STK_TUBEBELL_H
#define STK_TUBEBELL_H
#include "FM.h"
@@ -39,16 +39,31 @@ class TubeBell : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
TubeBell();
//! Class destructor.
~TubeBell();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -8,12 +8,12 @@
frequency response while maintaining a nearly
constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TWOPOLE_H)
#define __TWOPOLE_H
#ifndef STK_TWOPOLE_H
#define STK_TWOPOLE_H
#include "Filter.h"
@@ -31,13 +31,13 @@ class TwoPole : protected Filter
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
void setA1(StkFloat a1);
//! Set the a[2] coefficient value.
void setA2(MY_FLOAT a2);
void setA2(StkFloat a2);
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
/*!
@@ -53,26 +53,35 @@ class TwoPole : protected Filter
An unstable filter will result for \e radius >= 1.0. For a better
resonance filter, use a BiQuad filter. \sa BiQuad filter class
*/
void setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize = FALSE);
void setResonance(StkFloat frequency, StkFloat radius, bool normalize = false);
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -8,12 +8,12 @@
frequency response while maintaining a
constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__TWOZERO_H)
#define __TWOZERO_H
#ifndef STK_TWOZERO_H
#define STK_TWOZERO_H
#include "Filter.h"
@@ -30,13 +30,13 @@ class TwoZero : protected Filter
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
void setB0(StkFloat b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
void setB1(StkFloat b1);
//! Set the b[2] coefficient value.
void setB2(MY_FLOAT b2);
void setB2(StkFloat b2);
//! Sets the filter coefficients for a "notch" at \e frequency (in Hz).
/*!
@@ -49,26 +49,35 @@ class TwoZero : protected Filter
frequency. The closer the zeros are to the unit-circle (\e radius
close to or equal to one), the narrower the resulting notch width.
*/
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
void setNotch(StkFloat frequency, StkFloat radius);
//! Set the filter gain.
/*!
The gain is applied at the filter input and does not affect the
coefficient values. The default gain value is 1.0.
*/
void setGain(MY_FLOAT theGain);
void setGain(StkFloat gain);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
StkFloat getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
StkFloat lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT sample);
StkFloat tick(StkFloat sample);
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -4,50 +4,53 @@
This class implements a three-dimensional vector.
by Perry R. Cook, 1995 - 2002.
by Perry R. Cook, 1995 - 2004.
*/
/***************************************************/
#if !defined(__VECTOR3D_H)
#define __VECTOR3D_H
#ifndef STK_VECTOR3D_H
#define STK_VECTOR3D_H
class Vector3D {
#include "Stk.h"
class Vector3D : public Stk
{
public:
//! Default constructor taking optional initial X, Y, and Z values.
Vector3D(double initX=0.0, double initY=0.0, double initZ=0.0);
Vector3D(StkFloat initX=0.0, StkFloat initY=0.0, StkFloat initZ=0.0);
//! Class destructor.
~Vector3D();
//! Get the current X value.
double getX();
StkFloat getX();
//! Get the current Y value.
double getY();
StkFloat getY();
//! Get the current Z value.
double getZ();
StkFloat getZ();
//! Calculate the vector length.
double getLength();
StkFloat getLength();
//! Set the X, Y, and Z values simultaniously.
void setXYZ(double anX, double aY, double aZ);
void setXYZ(StkFloat x, StkFloat y, StkFloat z);
//! Set the X value.
void setX(double aval);
void setX(StkFloat x);
//! Set the Y value.
void setY(double aval);
void setY(StkFloat y);
//! Set the Z value.
void setZ(double aval);
void setZ(StkFloat z);
protected:
double myX;
double myY;
double myZ;
StkFloat myX_;
StkFloat myY_;
StkFloat myZ_;
};
#endif

View File

@@ -21,12 +21,12 @@
- Vibrato Gain = 1
- Loudness (Spectral Tilt) = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__VOICFORM_H)
#define __VOICFORM_H
#ifndef STK_VOICFORM_H
#define STK_VOICFORM_H
#include "Instrmnt.h"
#include "Envelope.h"
@@ -39,7 +39,10 @@
class VoicForm : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
VoicForm();
//! Class destructor.
@@ -49,22 +52,22 @@ class VoicForm : public Instrmnt
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Set instrument parameters for the given phoneme. Returns FALSE if phoneme not found.
//! Set instrument parameters for the given phoneme. Returns false if phoneme not found.
bool setPhoneme(const char* phoneme);
//! Set the voiced component gain.
void setVoiced(MY_FLOAT vGain);
void setVoiced(StkFloat vGain);
//! Set the unvoiced component gain.
void setUnVoiced(MY_FLOAT nGain);
void setUnVoiced(StkFloat nGain);
//! Set the sweep rate for a particular formant filter (0-3).
void setFilterSweepRate(int whichOne, MY_FLOAT rate);
void setFilterSweepRate(unsigned int whichOne, StkFloat rate);
//! Set voiced component pitch sweep rate.
void setPitchSweepRate(MY_FLOAT rate);
void setPitchSweepRate(StkFloat rate);
//! Start the voice.
void speak();
@@ -73,24 +76,36 @@ class VoicForm : public Instrmnt
void quiet();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
SingWave *voiced;
Noise *noise;
Envelope *noiseEnv;
FormSwep *filters[4];
OnePole *onepole;
OneZero *onezero;
SingWave *voiced_;
Noise noise_;
Envelope noiseEnv_;
FormSwep filters_[4];
OnePole onepole_;
OneZero onezero_;
};

View File

@@ -25,21 +25,21 @@
an ensemble. Alternately, control changes can
be sent to all voices on a given channel.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__VOICER_H)
#define __VOICER_H
#ifndef STK_VOICER_H
#define STK_VOICER_H
#include "Stk.h"
#include "Instrmnt.h"
#include <vector>
class Voicer : public Stk
{
public:
//! Class constructor taking the maximum number of instruments to control and an optional note decay time (in seconds).
Voicer( int maxInstruments, MY_FLOAT decayTime=0.2 );
//! Class constructor taking an optional note decay time (in seconds).
Voicer( StkFloat decayTime=0.2 );
//! Class destructor.
~Voicer();
@@ -68,81 +68,93 @@ public:
found for a specified non-zero channel value, the function returns
-1. The amplitude value should be in the range 0.0 - 128.0.
*/
long noteOn( MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel=0 );
long noteOn( StkFloat noteNumber, StkFloat amplitude, int channel=0 );
//! Send a noteOff to all voices having the given noteNumber and optional channel (default channel = 0).
/*!
The amplitude value should be in the range 0.0 - 128.0.
*/
void noteOff( MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel=0 );
void noteOff( StkFloat noteNumber, StkFloat amplitude, int channel=0 );
//! Send a noteOff to the voice with the given note tag.
/*!
The amplitude value should be in the range 0.0 - 128.0.
*/
void noteOff( long tag, MY_FLOAT amplitude );
void noteOff( long tag, StkFloat amplitude );
//! Send a frequency update message to all voices assigned to the optional channel argument (default channel = 0).
/*!
The \e noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range.
*/
void setFrequency( MY_FLOAT noteNumber, int channel=0 );
void setFrequency( StkFloat noteNumber, int channel=0 );
//! Send a frequency update message to the voice with the given note tag.
/*!
The \e noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range.
*/
void setFrequency( long tag, MY_FLOAT noteNumber );
void setFrequency( long tag, StkFloat noteNumber );
//! Send a pitchBend message to all voices assigned to the optional channel argument (default channel = 0).
void pitchBend( MY_FLOAT value, int channel=0 );
void pitchBend( StkFloat value, int channel=0 );
//! Send a pitchBend message to the voice with the given note tag.
void pitchBend( long tag, MY_FLOAT value );
void pitchBend( long tag, StkFloat value );
//! Send a controlChange to all instruments assigned to the optional channel argument (default channel = 0).
void controlChange( int number, MY_FLOAT value, int channel=0 );
void controlChange( int number, StkFloat value, int channel=0 );
//! Send a controlChange to the voice with the given note tag.
void controlChange( long tag, int number, MY_FLOAT value );
void controlChange( long tag, int number, StkFloat value );
//! Send a noteOff message to all existing voices.
void silence( void );
//! Mix the output for all sounding voices.
MY_FLOAT tick();
StkFloat tick();
//! Compute \e vectorSize output mixes and return them in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return the last output value.
MY_FLOAT lastOut() const;
StkFloat lastOut() const;
//! Return the last left output value.
MY_FLOAT lastOutLeft() const;
StkFloat lastOutLeft() const;
//! Return the last right output value.
MY_FLOAT lastOutRight() const;
StkFloat lastOutRight() const;
protected:
typedef struct {
struct Voice {
Instrmnt *instrument;
long tag;
MY_FLOAT noteNumber;
MY_FLOAT frequency;
StkFloat noteNumber;
StkFloat frequency;
int sounding;
int channel;
} Voice;
int nVoices;
int maxVoices;
Voice *voices;
long tags;
int muteTime;
MY_FLOAT lastOutput;
MY_FLOAT lastOutputLeft;
MY_FLOAT lastOutputRight;
// Default constructor.
Voice()
:instrument(0), tag(0), noteNumber(-1.0), frequency(0.0),
sounding(0), channel(0) {}
};
std::vector<Voice> voices_;
long tags_;
int muteTime_;
StkFloat lastOutput_;
StkFloat lastOutputLeft_;
StkFloat lastOutputRight_;
};
#endif

View File

@@ -14,21 +14,20 @@
For single-channel data, these methods return
equivalent values.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__WAVELOOP_H)
#define __WAVELOOP_H
#ifndef STK_WAVELOOP_H
#define STK_WAVELOOP_H
#include "WvIn.h"
#include <stdio.h>
class WaveLoop : public WvIn
{
public:
//! Class constructor.
WaveLoop( const char *fileName, bool raw = FALSE );
WaveLoop( std::string fileName, bool raw = false );
//! Class destructor.
virtual ~WaveLoop();
@@ -40,10 +39,10 @@ public:
corresponds to file cycles per second. The frequency can be
negative, in which case the loop is read in reverse order.
*/
void setFrequency(MY_FLOAT aFrequency);
void setFrequency(StkFloat frequency);
//! Increment the read pointer by \e aTime samples, modulo file size.
void addTime(MY_FLOAT aTime);
void addTime(StkFloat time);
//! Increment current read pointer by \e anAngle, relative to a looping frequency.
/*!
@@ -51,7 +50,7 @@ public:
size and the current Stk::sampleRate. The \e anAngle value
is a multiple of file size.
*/
void addPhase(MY_FLOAT anAngle);
void addPhase(StkFloat angle);
//! Add a phase offset to the current read pointer.
/*!
@@ -59,18 +58,33 @@ public:
size and the current Stk::sampleRate. The \e anAngle value
is a multiple of file size.
*/
void addPhaseOffset(MY_FLOAT anAngle);
void addPhaseOffset(StkFloat angle);
//! Return a pointer to the next sample frame of data.
const MY_FLOAT *tickFrame(void);
const StkFloat *tickFrame(void);
//! Read out sample \e frames of data to \e frameVector.
/*!
An StkError will be thrown if a file is read incrementally and a read error occurs.
*/
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
//! Fill the StkFrames object with sample frames of data and return the same reference.
/*!
An StkError will be thrown if a file is read incrementally and
a read error occurs or there is an incompatability between the
number of channels in the RtWvIn object and that in the StkFrames
object.
*/
StkFrames& tickFrame( StkFrames& frames );
protected:
// Read file data.
void readData(unsigned long index);
MY_FLOAT phaseOffset;
StkFloat phaseOffset_;
};
#endif // defined(__WAVELOOP_H)
#endif

View File

@@ -12,12 +12,12 @@
- Blowing Frequency Modulation = 2
- Volume = 128
by Perry R. Cook 1996 - 2002.
by Perry R. Cook 1996 - 2004.
*/
/***************************************************/
#if !defined(__WHISTLE_H)
#define __WHISTLE_H
#ifndef STK_WHISTLE_H
#define STK_WHISTLE_H
#include "Instrmnt.h"
#include "Sphere.h"
@@ -31,6 +31,9 @@ class Whistle : public Instrmnt
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Whistle();
//! Class destructor.
@@ -40,46 +43,58 @@ public:
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Apply breath velocity to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
void startBlowing(StkFloat amplitude, StkFloat rate);
//! Decrease breath velocity with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
void stopBlowing(StkFloat rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
void noteOff(StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
void controlChange(int number, StkFloat value);
protected:
Vector3D *tempVectorP;
Vector3D *tempVector;
OnePole onepole;
Noise noise;
Envelope envelope;
Sphere *can; // Declare a Spherical "can".
Sphere *pea, *bumper; // One spherical "pea", and a spherical "bumper".
WaveLoop *sine;
Vector3D *tempVectorP_;
Vector3D tempVector_;
OnePole onepole_;
Noise noise_;
Envelope envelope_;
Sphere can_; // Declare a Spherical "can".
Sphere pea_, bumper_; // One spherical "pea", and a spherical "bumper".
MY_FLOAT baseFrequency;
MY_FLOAT maxPressure;
MY_FLOAT noiseGain;
MY_FLOAT fippleFreqMod;
MY_FLOAT fippleGainMod;
MY_FLOAT blowFreqMod;
MY_FLOAT tickSize;
MY_FLOAT canLoss;
int subSample, subSampCount;
WaveLoop *sine_;
StkFloat baseFrequency_;
StkFloat noiseGain_;
StkFloat fippleFreqMod_;
StkFloat fippleGainMod_;
StkFloat blowFreqMod_;
StkFloat tickSize_;
StkFloat canLoss_;
int subSample_, subSampCount_;
};
#endif

View File

@@ -26,12 +26,12 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__WURLEY_H)
#define __WURLEY_H
#ifndef STK_WURLEY_H
#define STK_WURLEY_H
#include "FM.h"
@@ -39,19 +39,34 @@ class Wurley : public FM
{
public:
//! Class constructor.
/*!
An StkError will be thrown if the rawwave path is incorrectly set.
*/
Wurley();
//! Class destructor.
~Wurley();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
void setFrequency(StkFloat frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
void noteOn(StkFloat frequency, StkFloat amplitude);
//! Compute one output sample.
MY_FLOAT tick();
StkFloat tick();
//! Computer \e vectorSize outputs and return them in \e vector.
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if the \c
channel argument is zero or it is greater than the number of
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
};
#endif

View File

@@ -10,44 +10,49 @@
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.
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.
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.
When the end of a file is reached, subsequent
calls to the tick() functions return the data
values at the end of the file.
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.
Compressed data types are not supported. If using
MAT-files, data should be saved in an array with
each data channel filling a matrix row. The sample
rate for MAT-files is assumed to be 44100 Hz.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__WVIN_H)
#define __WVIN_H
#ifndef STK_WVIN_H
#define STK_WVIN_H
// Files larger than CHUNK_THRESHOLD will be copied into memory
// in CHUNK_SIZE increments, rather than completely loaded into
// a buffer at once.
#define CHUNK_THRESHOLD 5000000 // 5 Mb
#define CHUNK_SIZE 1024 // sample frames
const unsigned long CHUNK_THRESHOLD = 5000000; // 5 Mb
const long CHUNK_SIZE = 1024; // sample frames
#include "Stk.h"
#include <stdio.h>
class WvIn : public Stk
{
@@ -60,7 +65,7 @@ public:
An StkError will be thrown if the file is not found, its format is
unknown, or a read error occurs.
*/
WvIn( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE );
WvIn( std::string fileName, bool raw = false, bool doNormalize = true );
//! Class destructor.
virtual ~WvIn();
@@ -70,7 +75,7 @@ public:
An StkError will be thrown if the file is not found, its format is
unknown, or a read error occurs.
*/
void openFile( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE );
void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
//! If a file is open, close it.
void closeFile(void);
@@ -94,7 +99,7 @@ public:
(\e peak/maximum). For incrementally loaded files with floating-
point data types, direct scaling by \e peak is performed.
*/
void normalize(MY_FLOAT peak);
void normalize(StkFloat peak);
//! Return the file size in sample frames.
unsigned long getSize(void) const;
@@ -108,7 +113,7 @@ public:
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.
*/
MY_FLOAT getFileRate(void) const;
StkFloat getFileRate(void) const;
//! Query whether reading is complete.
bool isFinished(void) const;
@@ -117,10 +122,10 @@ public:
/*!
If the rate value is negative, the data is read in reverse order.
*/
void setRate(MY_FLOAT aRate);
void setRate(StkFloat aRate);
//! Increment the read pointer by \e aTime samples.
virtual void addTime(MY_FLOAT aTime);
virtual void addTime(StkFloat aTime);
//! Turn linear interpolation on/off.
/*!
@@ -132,34 +137,53 @@ public:
void setInterpolate(bool doInterpolate);
//! Return the average across the last output sample frame.
virtual MY_FLOAT lastOut(void) const;
virtual StkFloat lastOut(void) const;
//! 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.
*/
virtual MY_FLOAT tick(void);
virtual StkFloat tick(void);
//! Read out vectorSize averaged sample frames of data in \e vector.
/*!
An StkError will be thrown if a file is read incrementally and a read error occurs.
*/
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Fill a channel of the StkFrames object with averaged sample frames.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if a file
is read incrementally and a read error occurs or the \c channel
argument is zero or it is greater than the number of channels in
the StkFrames object.
*/
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return a pointer to the last output sample frame.
virtual const MY_FLOAT *lastFrame(void) const;
virtual const StkFloat *lastFrame(void) const;
//! 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.
*/
virtual const MY_FLOAT *tickFrame(void);
virtual const StkFloat *tickFrame(void);
//! Read out sample \e frames of data to \e frameVector.
/*!
An StkError will be thrown if a file is read incrementally and a read error occurs.
*/
virtual MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames);
virtual StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
//! Fill the StkFrames object with sample frames of data and return the same reference.
/*!
An StkError will be thrown if a file is read incrementally and
a read error occurs or if there is an incompatability between the
number of channels in the WvIn object and that in the StkFrames
object.
*/
virtual StkFrames& tickFrame( StkFrames& frames );
protected:
@@ -184,24 +208,23 @@ protected:
// Get MAT-file header information.
bool getMatInfo( const char *fileName );
char msg[256];
FILE *fd;
MY_FLOAT *data;
MY_FLOAT *lastOutput;
bool chunking;
bool finished;
bool interpolate;
bool byteswap;
unsigned long fileSize;
unsigned long bufferSize;
unsigned long dataOffset;
unsigned int channels;
long chunkPointer;
STK_FORMAT dataType;
MY_FLOAT fileRate;
MY_FLOAT gain;
MY_FLOAT time;
MY_FLOAT rate;
FILE *fd_;
StkFloat *data_;
StkFloat *lastOutputs_;
bool chunking_;
bool finished_;
bool interpolate_;
bool byteswap_;
unsigned long fileSize_;
unsigned long bufferSize_;
unsigned long dataOffset_;
unsigned int channels_;
long chunkPointer_;
StkFormat dataType_;
StkFloat fileRate_;
StkFloat gain_;
StkFloat time_;
StkFloat rate_;
};
#endif // defined(__WVIN_H)
#endif

View File

@@ -14,32 +14,31 @@
tickFrame() method, which takes a pointer
to multi-channel sample frame data.
WvOut currently supports WAV, AIFF, AIFC, 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. STK RAW files use 16-bit
integers by definition. MAT-files will always
be written as 64-bit floats. If a data type
specification does not match the specified file
type, the data type will automatically be
modified. Uncompressed data types are not
supported.
WvOut currently supports uncompressed WAV,
AIFF, AIFC, 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. STK RAW
files use 16-bit integers by definition.
MAT-files will always be written as 64-bit
floats. If a data type specification does not
match the specified file type, the data type
will automatically be modified. Compressed
data types are not supported.
Currently, WvOut is non-interpolating and the
output rate is always Stk::sampleRate().
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__WVOUT_H)
#define __WVOUT_H
#ifndef STK_WVOUT_H
#define STK_WVOUT_H
#include "Stk.h"
#include <stdio.h>
#define BUFFER_SIZE 1024 // sample frames
const unsigned long BUFFER_SIZE = 1024; // sample frames
class WvOut : public Stk
{
@@ -60,7 +59,7 @@ class WvOut : public Stk
/*!
An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
*/
WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::StkFormat format = STK_SINT16 );
//! Class destructor.
virtual ~WvOut();
@@ -70,7 +69,7 @@ class WvOut : public Stk
An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
*/
void openFile( const char *fileName, unsigned int nChannels = 1,
WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
WvOut::FILE_TYPE type = WVOUT_WAV, Stk::StkFormat format = STK_SINT16 );
//! If a file is open, write out samples in the queue and then close it.
void closeFile( void );
@@ -79,25 +78,48 @@ class WvOut : public Stk
unsigned long getFrames( void ) const;
//! Return the number of seconds of data output.
MY_FLOAT getTime( void ) const;
StkFloat getTime( void ) const;
//! Returns \c true if clipping has been detected during output since instantiation or the last reset.
bool getClipStatus( void ) { return clipping_; };
//! Reset the clipping status to \c false.
void resetClipStatus( void ) { clipping_ = false; };
//! Output a single sample to all channels in a sample frame.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tick(const MY_FLOAT sample);
virtual void tick(const StkFloat sample);
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
virtual void tick( const StkFloat *vector, unsigned int vectorSize );
//! Output a channel of the StkFrames object to all channels of the WvOut object.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if a file
write error occurs or the \c channel argument is zero or it is
greater than the number of channels in the StkFrames object.
*/
virtual void tick( const StkFrames& frames, unsigned int channel = 1 );
//! Output the \e frameVector of sample frames of the given length.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
virtual void tickFrame( const StkFloat *frameVector, unsigned int frames = 1);
//! Output the StkFrames data to the WvOut object.
/*!
An StkError will be thrown if a file write error occurs or if
there is an incompatability between the number of channels in the
WvOut object and that in the StkFrames object.
*/
virtual void tickFrame( const StkFrames& frames );
protected:
@@ -107,6 +129,9 @@ class WvOut : public Stk
// Write data to output file;
virtual void writeData( unsigned long frames );
// Check for sample clipping and clamp.
void clipTest( StkFloat& sample );
// Write STK RAW file header.
bool setRawFile( const char *fileName );
@@ -134,16 +159,16 @@ class WvOut : public Stk
// Close MAT-file, updating the header.
void closeMatFile( void );
char msg[256];
FILE *fd;
MY_FLOAT *data;
FILE_TYPE fileType;
STK_FORMAT dataType;
bool byteswap;
unsigned int channels;
unsigned long counter;
unsigned long totalCount;
FILE *fd_;
std::valarray<StkFloat> data_;
FILE_TYPE fileType_;
StkFormat dataType_;
unsigned int channels_;
unsigned long counter_;
unsigned long totalCount_;
bool byteswap_;
bool clipping_;
};
#endif // defined(__WVOUT_H)
#endif