mirror of
https://github.com/thestk/stk
synced 2026-01-19 15:41:52 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
134
include/ADSR.h
134
include/ADSR.h
@@ -1,46 +1,88 @@
|
||||
/*******************************************/
|
||||
/* ADSR Subclass of the Envelope Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This is the traditional ADSR (Attack */
|
||||
/* Decay, Sustain, Release) envelope. */
|
||||
/* It responds to simple KeyOn and KeyOff */
|
||||
/* messages, keeping track of it's state. */
|
||||
/* There are two tick (update value) */
|
||||
/* methods, one returns the value, and */
|
||||
/* other returns the state (0 = A, 1 = D, */
|
||||
/* 2 = S, 3 = R) */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__ADSR_h)
|
||||
#define __ADSR_h
|
||||
|
||||
#include "Envelope.h"
|
||||
|
||||
class ADSR : public Envelope
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT attackRate;
|
||||
MY_FLOAT decayRate;
|
||||
MY_FLOAT sustainLevel;
|
||||
MY_FLOAT releaseRate;
|
||||
public:
|
||||
ADSR();
|
||||
~ADSR();
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
void setAttackRate(MY_FLOAT aRate);
|
||||
void setDecayRate(MY_FLOAT aRate);
|
||||
void setSustainLevel(MY_FLOAT aLevel);
|
||||
void setReleaseRate(MY_FLOAT aRate);
|
||||
void setAttackTime(MY_FLOAT aTime);
|
||||
void setDecayTime(MY_FLOAT aTime);
|
||||
void setReleaseTime(MY_FLOAT aTime);
|
||||
void setAllTimes(MY_FLOAT attTime, MY_FLOAT decTime, MY_FLOAT susLevel, MY_FLOAT relTime);
|
||||
void setTarget(MY_FLOAT aTarget);
|
||||
void setValue(MY_FLOAT aValue);
|
||||
MY_FLOAT tick();
|
||||
int informTick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class ADSR
|
||||
\brief STK ADSR envelope class.
|
||||
|
||||
This Envelope subclass implements a
|
||||
traditional ADSR (Attack, Decay,
|
||||
Sustain, Release) envelope. It
|
||||
responds to simple keyOn and keyOff
|
||||
messages, keeping track of its state.
|
||||
The \e state = ADSR::DONE after the
|
||||
envelope value reaches 0.0 in the
|
||||
ADSR::RELEASE state.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ADSR_H)
|
||||
#define __ADSR_H
|
||||
|
||||
#include "Envelope.h"
|
||||
|
||||
class ADSR : public Envelope
|
||||
{
|
||||
public:
|
||||
|
||||
//! Envelope states.
|
||||
enum { ATTACK, DECAY, SUSTAIN, RELEASE, DONE };
|
||||
|
||||
//! Default constructor.
|
||||
ADSR(void);
|
||||
|
||||
//! Class destructor.
|
||||
~ADSR(void);
|
||||
|
||||
//! Set target = 1, state = \e ADSR::ATTACK.
|
||||
void keyOn(void);
|
||||
|
||||
//! Set target = 0, state = \e ADSR::RELEASE.
|
||||
void keyOff(void);
|
||||
|
||||
//! Set the attack rate.
|
||||
void setAttackRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the decay rate.
|
||||
void setDecayRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the sustain level.
|
||||
void setSustainLevel(MY_FLOAT aLevel);
|
||||
|
||||
//! Set the release rate.
|
||||
void setReleaseRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the attack rate based on a time duration.
|
||||
void setAttackTime(MY_FLOAT aTime);
|
||||
|
||||
//! Set the decay rate based on a time duration.
|
||||
void setDecayTime(MY_FLOAT aTime);
|
||||
|
||||
//! Set the release rate based on a time duration.
|
||||
void setReleaseTime(MY_FLOAT aTime);
|
||||
|
||||
//! 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 the target value.
|
||||
void setTarget(MY_FLOAT aTarget);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Return one envelope output value.
|
||||
MY_FLOAT tick(void);
|
||||
|
||||
//! Return \e vectorSize envelope outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
protected:
|
||||
MY_FLOAT attackRate;
|
||||
MY_FLOAT decayRate;
|
||||
MY_FLOAT sustainLevel;
|
||||
MY_FLOAT releaseRate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
AifWvIn Input Class,
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This object inherits from WvIn and is
|
||||
used to open Audio Interchange File
|
||||
Format files with 16-bit data (signed
|
||||
integer) for playback.
|
||||
|
||||
.aif files are always bif-endian.
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__AifWvIn_h)
|
||||
#define __AifWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class AifWvIn : public WvIn
|
||||
{
|
||||
public:
|
||||
AifWvIn(char *fileName, const char *mode);
|
||||
~AifWvIn();
|
||||
protected:
|
||||
void getData(long index);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
AifWvOut Output Class,
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This object inherits from WvOut and is
|
||||
used to write Audio Interchange File
|
||||
Format files with 16-bit data (signed
|
||||
integer).
|
||||
|
||||
.aif files are always bif-endian.
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__AifWvOut_h)
|
||||
#define __AifWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class AifWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
FILE *fd;
|
||||
public:
|
||||
AifWvOut(char *fileName, int chans = 1);
|
||||
~AifWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif
|
||||
108
include/BandedWG.h
Normal file
108
include/BandedWG.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/***************************************************/
|
||||
/*! \class BandedWG
|
||||
\brief Banded waveguide modeling class.
|
||||
|
||||
This class uses banded waveguide techniques to
|
||||
model a variety of sounds, including bowed
|
||||
bars, glasses, and bowls. For more
|
||||
information, see Essl, G. and Cook, P. "Banded
|
||||
Waveguides: Towards Physical Modelling of Bar
|
||||
Percussion Instruments", Proceedings of the
|
||||
1999 International Computer Music Conference.
|
||||
|
||||
Control Change Numbers:
|
||||
- Bow Pressure = 2
|
||||
- Bow Motion = 4
|
||||
- Strike Position = 8 (not implemented)
|
||||
- Vibrato Frequency = 11
|
||||
- Gain = 1
|
||||
- Bow Velocity = 128
|
||||
- Set Striking = 64
|
||||
- Instrument Presets = 16
|
||||
- Uniform Bar = 0
|
||||
- Tuned Bar = 1
|
||||
- Glass Harmonica = 2
|
||||
- Tibetan Bowl = 3
|
||||
|
||||
by Georg Essl, 1999 - 2002.
|
||||
Modified for Stk 4.0 by Gary Scavone.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BANDEDWG_H)
|
||||
#define __BANDEDWG_H
|
||||
|
||||
#define MAX_BANDED_MODES 17
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "Delay.h"
|
||||
#include "BowTabl.h"
|
||||
#include "ADSR.h"
|
||||
#include "BiQuad.h"
|
||||
|
||||
class BandedWG : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
BandedWG();
|
||||
|
||||
//! Class destructor.
|
||||
~BandedWG();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set strike position (0.0 - 1.0).
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
|
||||
//! Select a preset.
|
||||
void setPreset(int preset);
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
|
||||
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease bow velocity/breath pressure with given rate of decrease.
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
|
||||
//! Pluck the instrument with given amplitude.
|
||||
void pluck(MY_FLOAT amp);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
|
||||
bool doPluck;
|
||||
bool trackVelocity;
|
||||
int nModes;
|
||||
int presetModes;
|
||||
BowTabl *bowTabl;
|
||||
ADSR *adsr;
|
||||
BiQuad *bandpass;
|
||||
Delay *delay;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT modes[MAX_BANDED_MODES];
|
||||
MY_FLOAT freakency;
|
||||
MY_FLOAT baseGain;
|
||||
MY_FLOAT gains[MAX_BANDED_MODES];
|
||||
MY_FLOAT integrationConstant;
|
||||
MY_FLOAT bowVelocity;
|
||||
MY_FLOAT bowTarget;
|
||||
MY_FLOAT bowPosition;
|
||||
int strikePosition;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,23 +1,56 @@
|
||||
/******************************************/
|
||||
/* HammondOid Organ Subclass */
|
||||
/* of Algorithm 8 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class BeeThree
|
||||
\brief STK Hammond-oid organ FM synthesis instrument.
|
||||
|
||||
#if !defined(__BeeThree_h)
|
||||
#define __BeeThree_h
|
||||
This class implements a simple 4 operator
|
||||
topology, also referred to as algorithm 8 of
|
||||
the TX81Z.
|
||||
|
||||
#include "FM4Alg8.h"
|
||||
\code
|
||||
Algorithm 8 is :
|
||||
1 --.
|
||||
2 -\|
|
||||
+-> Out
|
||||
3 -/|
|
||||
4 --
|
||||
\endcode
|
||||
|
||||
class BeeThree : public FM4Alg8
|
||||
Control Change Numbers:
|
||||
- Operator 4 (feedback) Gain = 2
|
||||
- Operator 3 Gain = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BEETHREE_H)
|
||||
#define __BEETHREE_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
class BeeThree : public FM
|
||||
{
|
||||
public:
|
||||
BeeThree();
|
||||
~BeeThree();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
MY_FLOAT tick();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
public:
|
||||
//! Class constructor.
|
||||
BeeThree();
|
||||
|
||||
//! Class destructor.
|
||||
~BeeThree();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
140
include/BiQuad.h
140
include/BiQuad.h
@@ -1,40 +1,100 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
BiQuad (2-pole, 2-zero) Filter Class,
|
||||
by Perry R. Cook, 1995-96.
|
||||
Modified by Julius Smith, 2000:
|
||||
setA1,setA2,setB1,setB2
|
||||
|
||||
See books on filters to understand
|
||||
more about how this works. Nothing
|
||||
out of the ordinary in this version.
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__BiQuad_h)
|
||||
#define __BiQuad_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class BiQuad : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT poleCoeffs[2];
|
||||
MY_FLOAT zeroCoeffs[2];
|
||||
public:
|
||||
BiQuad();
|
||||
~BiQuad();
|
||||
void clear();
|
||||
void setA1(MY_FLOAT a1);
|
||||
void setA2(MY_FLOAT a2);
|
||||
void setB1(MY_FLOAT b1);
|
||||
void setB2(MY_FLOAT b2);
|
||||
void setPoleCoeffs(MY_FLOAT *coeffs);
|
||||
void setZeroCoeffs(MY_FLOAT *coeffs);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
void setFreqAndReson(MY_FLOAT freq, MY_FLOAT reson);
|
||||
void setEqualGainZeroes();
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class BiQuad
|
||||
\brief STK biquad (two-pole, two-zero) filter class.
|
||||
|
||||
This protected Filter subclass implements a
|
||||
two-pole, two-zero digital filter. A method
|
||||
is provided for creating a resonance in the
|
||||
frequency response while maintaining a constant
|
||||
filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BIQUAD_H)
|
||||
#define __BIQUAD_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class BiQuad : protected Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a second-order pass-through filter.
|
||||
BiQuad();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~BiQuad();
|
||||
|
||||
//! Clears all internal states of the filter.
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
|
||||
//! Set the b[2] coefficient value.
|
||||
void setB2(MY_FLOAT b2);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
|
||||
//! Set the a[2] coefficient value.
|
||||
void setA2(MY_FLOAT a2);
|
||||
|
||||
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
|
||||
/*!
|
||||
This method determines the filter coefficients corresponding to
|
||||
two complex-conjugate poles with the given \e frequency (in Hz)
|
||||
and \e radius from the z-plane origin. If \e normalize is true,
|
||||
the filter zeros are placed at z = 1, z = -1, and the coefficients
|
||||
are then normalized to produce a constant unity peak gain
|
||||
(independent of the filter \e gain parameter). The resulting
|
||||
filter frequency response has a resonance at the given \e
|
||||
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);
|
||||
|
||||
//! Set the filter coefficients for a notch at \e frequency (in Hz).
|
||||
/*!
|
||||
This method determines the filter coefficients corresponding to
|
||||
two complex-conjugate zeros with the given \e frequency (in Hz)
|
||||
and \e radius from the z-plane origin. No filter normalization
|
||||
is attempted.
|
||||
*/
|
||||
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
|
||||
//! Sets the filter zeroes for equal resonance gain.
|
||||
/*!
|
||||
When using the filter as a resonator, zeroes places at z = 1, z
|
||||
= -1 will result in a constant gain at resonance of 1 / (1 - R),
|
||||
where R is the pole radius setting.
|
||||
|
||||
*/
|
||||
void setEqualGainZeroes();
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
77
include/BlowBotl.h
Normal file
77
include/BlowBotl.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************/
|
||||
/*! \class BlowBotl
|
||||
\brief STK blown bottle instrument class.
|
||||
|
||||
This class implements a helmholtz resonator
|
||||
(biquad filter) with a polynomial jet
|
||||
excitation (a la Cook).
|
||||
|
||||
Control Change Numbers:
|
||||
- Noise Gain = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BOTTLE_H)
|
||||
#define __BOTTLE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "JetTabl.h"
|
||||
#include "BiQuad.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Noise.h"
|
||||
#include "ADSR.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class BlowBotl : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
BlowBotl();
|
||||
|
||||
//! Class destructor.
|
||||
~BlowBotl();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Apply breath velocity to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath velocity with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,35 +1,98 @@
|
||||
/***********************************************/
|
||||
/*
|
||||
Waveguide reed model with a register hole
|
||||
and one tonehole
|
||||
/***************************************************/
|
||||
/*! \class BlowHole
|
||||
\brief STK clarinet physical model with one
|
||||
register hole and one tonehole.
|
||||
|
||||
by Gary P. Scavone, 2000.
|
||||
This class is based on the clarinet model,
|
||||
with the addition of a two-port register hole
|
||||
and a three-port dynamic tonehole
|
||||
implementation, as discussed by Scavone and
|
||||
Cook (1998).
|
||||
|
||||
In this implementation, the distances between
|
||||
the reed/register hole and tonehole/bell are
|
||||
fixed. As a result, both the tonehole and
|
||||
register hole will have variable influence on
|
||||
the playing frequency, which is dependent on
|
||||
the length of the air column. In addition,
|
||||
the highest playing freqeuency is limited by
|
||||
these fixed lengths.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by Stanford
|
||||
University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Reed Stiffness = 2
|
||||
- Noise Gain = 4
|
||||
- Tonehole State = 11
|
||||
- Register State = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***********************************************/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BlowHole_h)
|
||||
#define __BlowHole_h
|
||||
#if !defined(__BLOWHOLE_H)
|
||||
#define __BLOWHOLE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "OneZero.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class BlowHole : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
BlowHole(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~BlowHole();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the tonehole state (0.0 = closed, 1.0 = fully open).
|
||||
void setTonehole(MY_FLOAT newValue);
|
||||
|
||||
//! Set the register hole state (0.0 = closed, 1.0 = fully open).
|
||||
void setVent(MY_FLOAT newValue);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
DLineL *delays;
|
||||
DelayL *delays[3];
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
PoleZero *tonehole;
|
||||
PoleZero *vent;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
RawWvIn *vibr;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT scatter;
|
||||
MY_FLOAT th_coeff;
|
||||
@@ -38,20 +101,8 @@ class BlowHole : public Instrmnt
|
||||
MY_FLOAT rh_gain;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibrGain;
|
||||
public:
|
||||
BlowHole(MY_FLOAT lowestFreq);
|
||||
~BlowHole();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void setTonehole(MY_FLOAT newValue);
|
||||
void setVent(MY_FLOAT newValue);
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
MY_FLOAT vibratoGain;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,27 +1,62 @@
|
||||
/***********************************************/
|
||||
/* Simple Bow Table Object, after Smith */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/***********************************************/
|
||||
|
||||
#if !defined(__BowTabl_h)
|
||||
#define __BowTabl_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class BowTabl : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT offSet;
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
BowTabl();
|
||||
~BowTabl();
|
||||
void setOffset(MY_FLOAT aValue);
|
||||
void setSlope(MY_FLOAT aValue);
|
||||
MY_FLOAT lookup(MY_FLOAT sample);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \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
|
||||
|
||||
106
include/Bowed.h
106
include/Bowed.h
@@ -1,56 +1,86 @@
|
||||
/******************************************/
|
||||
/* Bowed String model ala Smith */
|
||||
/* after McIntyre, Schumacher, Woodhouse */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* This is a waveguide model, and thus */
|
||||
/* relates to various Stanford Univ. */
|
||||
/* and possibly Yamaha and other patents.*/
|
||||
/* */
|
||||
/* Controls: CONTROL1 = bowPressure */
|
||||
/* CONTROL2 = bowPosition */
|
||||
/* CONTROL3 = vibrFreq */
|
||||
/* MOD_WHEEL= vibrGain */
|
||||
/* */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Bowed
|
||||
\brief STK bowed string instrument class.
|
||||
|
||||
#if !defined(__Bowed_h)
|
||||
#define __Bowed_h
|
||||
This class implements a bowed string model, a
|
||||
la Smith (1986), after McIntyre, Schumacher,
|
||||
Woodhouse (1983).
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Bow Pressure = 2
|
||||
- Bow Position = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BOWED_H)
|
||||
#define __BOWED_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "DelayL.h"
|
||||
#include "BowTabl.h"
|
||||
#include "OnePole.h"
|
||||
#include "BiQuad.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "ADSR.h"
|
||||
|
||||
class Bowed : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Bowed(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Bowed();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set vibrato gain.
|
||||
void setVibrato(MY_FLOAT gain);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
DLineL *neckDelay;
|
||||
DLineL *bridgeDelay;
|
||||
BowTabl *bowTabl;
|
||||
OnePole *reflFilt;
|
||||
BiQuad *bodyFilt;
|
||||
RawWvIn *vibr;
|
||||
DelayL *neckDelay;
|
||||
DelayL *bridgeDelay;
|
||||
BowTabl *bowTable;
|
||||
OnePole *stringFilter;
|
||||
BiQuad *bodyFilter;
|
||||
WaveLoop *vibrato;
|
||||
ADSR *adsr;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT baseDelay;
|
||||
MY_FLOAT vibrGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT betaRatio;
|
||||
public:
|
||||
Bowed(MY_FLOAT lowestFreq);
|
||||
~Bowed();
|
||||
void clear();
|
||||
void startBowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void setVibrato(MY_FLOAT amount);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*********************************************/
|
||||
/* Bowed Bar model */
|
||||
/* by Georg Essl, 1999 */
|
||||
/* For details refer to: */
|
||||
/* G.Essl, P.R.Cook: "Banded Waveguides: */
|
||||
/* Towards Physical Modelling of Bar */
|
||||
/* Percussion Instruments", ICMC'99 */
|
||||
/*********************************************/
|
||||
|
||||
#if !defined(__BowedBar_h)
|
||||
#define __BowedBar_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineN.h"
|
||||
#include "BowTabl.h"
|
||||
#include "ADSR.h"
|
||||
#include "BiQuad.h"
|
||||
|
||||
class BowedBar : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
BowTabl *bowTabl;
|
||||
ADSR *adsr;
|
||||
BiQuad *bandpass;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT modes[4];
|
||||
DLineN delay[4];
|
||||
int NR_MODES;
|
||||
float Zs[4][2];
|
||||
MY_FLOAT coeffs[4][2];
|
||||
float filtOut[4];
|
||||
float filtIn[4];
|
||||
MY_FLOAT filtGain[4];
|
||||
MY_FLOAT freq;
|
||||
int length;
|
||||
MY_FLOAT R;
|
||||
MY_FLOAT GAIN;
|
||||
MY_FLOAT gains[4];
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT velinput;
|
||||
MY_FLOAT integration_const;
|
||||
int trackVel;
|
||||
MY_FLOAT bowvel, bowTarg, bowPos, lastBowPos;
|
||||
int doPluck;
|
||||
|
||||
public:
|
||||
BowedBar();
|
||||
~BowedBar();
|
||||
void tuneBandPasses();
|
||||
void clear();
|
||||
void startBowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
void pluck(MY_FLOAT amp);
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
void noteOff(MY_FLOAT amp);
|
||||
void setFreq(MY_FLOAT frequency);
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
116
include/Brass.h
116
include/Brass.h
@@ -1,53 +1,83 @@
|
||||
/******************************************/
|
||||
/* Simple Brass Instrument Model ala */
|
||||
/* Cook (TBone, HosePlayer) */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* This is a waveguide model, and thus */
|
||||
/* relates to various Stanford Univ. */
|
||||
/* and possibly Yamaha and other patents.*/
|
||||
/* */
|
||||
/* Controls: CONTROL1 = lipTension */
|
||||
/* CONTROL2 = slideLength */
|
||||
/* CONTROL3 = vibFreq */
|
||||
/* MOD_WHEEL= vibAmt */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Brass
|
||||
\brief STK simple brass instrument class.
|
||||
|
||||
#if !defined(__Brass_h)
|
||||
#define __Brass_h
|
||||
This class implements a simple brass instrument
|
||||
waveguide model, a la Cook (TBone, HosePlayer).
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Lip Tension = 2
|
||||
- Slide Length = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BRASS_H)
|
||||
#define __BRASS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.h"
|
||||
#include "LipFilt.h"
|
||||
#include "DCBlock.h"
|
||||
#include "DelayA.h"
|
||||
#include "BiQuad.h"
|
||||
#include "PoleZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Brass: public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineA *delayLine;
|
||||
LipFilt *lipFilter;
|
||||
DCBlock *dcBlock;
|
||||
ADSR *adsr;
|
||||
RawWvIn *vibr;
|
||||
long length;
|
||||
MY_FLOAT lipTarget;
|
||||
MY_FLOAT slideTarget;
|
||||
MY_FLOAT vibrGain;
|
||||
MY_FLOAT maxPressure;
|
||||
public:
|
||||
Brass(MY_FLOAT lowestFreq);
|
||||
~Brass();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void setLip(MY_FLOAT frequency);
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual MY_FLOAT tick();
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Brass(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Brass();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the lips frequency.
|
||||
void setLip(MY_FLOAT frequency);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "Object.h"
|
||||
|
||||
void swap16(unsigned char *ptr);
|
||||
void swap32(unsigned char *ptr);
|
||||
void swap64(unsigned char *ptr);
|
||||
65
include/Chorus.h
Normal file
65
include/Chorus.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************/
|
||||
/*! \class Chorus
|
||||
\brief STK chorus effect class.
|
||||
|
||||
This class implements a chorus effect.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__CHORUS_H)
|
||||
#define __CHORUS_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "DelayL.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Chorus : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the longest desired delay length.
|
||||
Chorus(MY_FLOAT baseDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~Chorus();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set modulation depth.
|
||||
void setModDepth(MY_FLOAT 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;
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
protected:
|
||||
DelayL *delayLine[2];
|
||||
WaveLoop *mods[2];
|
||||
MY_FLOAT baseLength;
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT lastOutput[2];
|
||||
MY_FLOAT effectMix;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,53 +1,83 @@
|
||||
/******************************************/
|
||||
/* Clarinet model ala Smith */
|
||||
/* after McIntyre, Schumacher, Woodhouse */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* This is a waveguide model, and thus */
|
||||
/* relates to various Stanford Univ. */
|
||||
/* and possibly Yamaha and other patents.*/
|
||||
/* */
|
||||
/* Controls: CONTROL1 = reedStiffns */
|
||||
/* CONTROL2 = noiseGain */
|
||||
/* CONTROL3 = vibFreq */
|
||||
/* MOD_WHEEL= vibAmt */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Clarinet_h)
|
||||
#define __Clarinet_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "OneZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "RawWvIn.h"
|
||||
|
||||
class Clarinet : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineL *delayLine;
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
RawWvIn *vibr;
|
||||
long length;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibrGain;
|
||||
public:
|
||||
Clarinet(MY_FLOAT lowestFreq);
|
||||
~Clarinet();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Clarinet
|
||||
\brief STK clarinet physical model class.
|
||||
|
||||
This class implements a simple clarinet
|
||||
physical model, as discussed by Smith (1986),
|
||||
McIntyre, Schumacher, Woodhouse (1983), and
|
||||
others.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by Stanford
|
||||
University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Reed Stiffness = 2
|
||||
- Noise Gain = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__CLARINET_H)
|
||||
#define __CLARINET_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "OneZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Clarinet : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Clarinet(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Clarinet();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Controller Class,
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This object will accept control messages
|
||||
from a variety of sources, such as a MIDI
|
||||
port, scorefile, socket connection, or
|
||||
pipe. MIDI messages are retrieved with
|
||||
the RtMidi class. All other input sources
|
||||
(scorefile, socket, or pipe) are assumed
|
||||
to provide SKINI formatted messages.
|
||||
|
||||
For each call of getNextMessage(), the
|
||||
active input devices are queried to see
|
||||
if a new control message is available.
|
||||
Only one message per call is returned, so
|
||||
a subsequent call begins querying the
|
||||
next available device "after" the previously
|
||||
handled one.
|
||||
|
||||
This class is primarily for use in STK
|
||||
main() event loops.
|
||||
|
||||
One of my 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 are
|
||||
then sent via a socket connection to the message
|
||||
socket server. Perhaps in the future, I will be
|
||||
able to simplify things.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Controller_h)
|
||||
#define __Controller_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "SKINI11.h"
|
||||
|
||||
#if defined(__STK_REALTIME_)
|
||||
#include "RtMidi.h"
|
||||
#include "StkError.h"
|
||||
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
void *stdinHandler(void *);
|
||||
|
||||
#elif defined(__OS_Win_)
|
||||
#include <process.h>
|
||||
#include <winsock.h>
|
||||
|
||||
void stdinHandler(void *);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __STK_REALTIME
|
||||
|
||||
#define STK_MIDI 0x0001
|
||||
#define STK_PIPE 0x0002
|
||||
#define STK_SOCKET 0x0004
|
||||
#define STK_SCOREFILE 0x0008
|
||||
|
||||
#define MESSAGE_LENGTH 128
|
||||
#define MAX_MESSAGES 25
|
||||
#define STK_SOCKET_PORT 2001
|
||||
|
||||
class Controller : public Object
|
||||
{
|
||||
protected:
|
||||
int source;
|
||||
long default_ticks;
|
||||
int type;
|
||||
MY_FLOAT channel;
|
||||
MY_FLOAT byte2;
|
||||
MY_FLOAT byte3;
|
||||
char message[MAX_MESSAGES][MESSAGE_LENGTH];
|
||||
int msg_index;
|
||||
int num_messages;
|
||||
SKINI11 *score;
|
||||
|
||||
#if defined(__STK_REALTIME_)
|
||||
fd_set mask;
|
||||
int maxfd;
|
||||
int fd[16];
|
||||
int local_socket;
|
||||
RtMidi *midi_input;
|
||||
int parseSocketData(int fd);
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
pthread_t stdin_thread;
|
||||
#elif defined(__OS_Win_)
|
||||
unsigned long stdin_thread;
|
||||
#endif
|
||||
#endif // __STK_REALTIME
|
||||
|
||||
public:
|
||||
Controller(int inputMask);
|
||||
~Controller();
|
||||
void setDefaultTicks(long nSamples);
|
||||
int getNextMessage();
|
||||
int getType();
|
||||
MY_FLOAT getByte2();
|
||||
MY_FLOAT getByte3();
|
||||
MY_FLOAT getChannel();
|
||||
};
|
||||
|
||||
#endif // defined(__Controller_h)
|
||||
@@ -1,26 +0,0 @@
|
||||
/*******************************************/
|
||||
/* DC Blocking Filter */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* This guy is very helpful in, uh, */
|
||||
/* blocking DC. Needed because a simple */
|
||||
/* low-pass reflection filter allows DC */
|
||||
/* to build up inside recursive */
|
||||
/* structures. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__DCBlock_h)
|
||||
#define __DCBlock_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class DCBlock : public Filter
|
||||
{
|
||||
public:
|
||||
DCBlock();
|
||||
~DCBlock();
|
||||
void clear();
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
/*******************************************/
|
||||
/* AllPass Interpolating Delay Line */
|
||||
/* Object by Perry R. Cook 1995-96. */
|
||||
/* Revised by Gary P. Scavone, 1999. */
|
||||
/* */
|
||||
/* This one uses a delay line of maximum */
|
||||
/* length specified on creation, and */
|
||||
/* interpolates fractional length using */
|
||||
/* an all-pass filter. This version is */
|
||||
/* more efficient for computing static */
|
||||
/* length delay lines (alpha and coeff */
|
||||
/* are computed only when the length */
|
||||
/* is set, there probably is a more */
|
||||
/* efficient computational form if alpha */
|
||||
/* is changed often (each sample)). */
|
||||
/* */
|
||||
/*******************************************/
|
||||
|
||||
|
||||
#if !defined(__DLineA_h)
|
||||
#define __DLineA_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class DLineA : public Filter
|
||||
{
|
||||
protected:
|
||||
long inPoint;
|
||||
long outPoint;
|
||||
long length;
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT coeff;
|
||||
MY_FLOAT lastIn;
|
||||
public:
|
||||
DLineA();
|
||||
DLineA(long max_length);
|
||||
~DLineA();
|
||||
void clear();
|
||||
void setDelay(MY_FLOAT length);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
Linearly Interpolating Delay Line
|
||||
Object by Perry R. Cook 1995-96.
|
||||
Added methods by Julius Smith, 2000.
|
||||
|
||||
This one uses a delay line of maximum
|
||||
length specified on creation, and
|
||||
linearly interpolates fractional
|
||||
length. It is designed to be more
|
||||
efficient if the delay length is not
|
||||
changed very often.
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__DLineL_h)
|
||||
#define __DLineL_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class DLineL : public Filter
|
||||
{
|
||||
protected:
|
||||
long inPoint;
|
||||
long outPoint;
|
||||
long length;
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT omAlpha;
|
||||
MY_FLOAT currentDelay;
|
||||
public:
|
||||
DLineL();
|
||||
DLineL(long max_length);
|
||||
~DLineL();
|
||||
void clear();
|
||||
void setDelay(MY_FLOAT length);
|
||||
MY_FLOAT delay(void);
|
||||
MY_FLOAT energy(void);
|
||||
long currentInPoint(void);
|
||||
long currentOutPoint(void);
|
||||
MY_FLOAT contentsAt(int n);
|
||||
MY_FLOAT contentsAtNowMinus(int n);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
Non-Interpolating Delay Line
|
||||
Object by Perry R. Cook 1995-96.
|
||||
Revised by Gary Scavone, 1999.
|
||||
Added methods by Julius Smith, 2000.
|
||||
|
||||
This one uses either a delay line of
|
||||
maximum length specified on creation
|
||||
or a default length of 2047 samples.
|
||||
A non-interpolating delay line is
|
||||
typically used in non-time varying
|
||||
(reverb) applications.
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__DLineN_h)
|
||||
#define __DLineN_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class DLineN : public Filter
|
||||
{
|
||||
protected:
|
||||
long inPoint;
|
||||
long outPoint;
|
||||
long length;
|
||||
MY_FLOAT currentDelay;
|
||||
public:
|
||||
DLineN();
|
||||
DLineN(long max_length);
|
||||
~DLineN();
|
||||
void clear();
|
||||
void setDelay(MY_FLOAT length);
|
||||
MY_FLOAT energy(void);
|
||||
long currentInPoint(void);
|
||||
long currentOutPoint(void);
|
||||
MY_FLOAT contentsAt(int n);
|
||||
MY_FLOAT contentsAtNowMinus(int n);
|
||||
MY_FLOAT delay(void);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
77
include/Delay.h
Normal file
77
include/Delay.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************/
|
||||
/*! \class Delay
|
||||
\brief STK non-interpolating delay line class.
|
||||
|
||||
This protected Filter subclass implements
|
||||
a non-interpolating digital delay-line.
|
||||
A fixed maximum length of 4095 and a delay
|
||||
of zero is set using the default constructor.
|
||||
Alternatively, the delay and maximum length
|
||||
can be set during instantiation with an
|
||||
overloaded constructor.
|
||||
|
||||
A non-interpolating delay line is typically
|
||||
used in fixed delay-length applications, such
|
||||
as for reverberation.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DELAY_H)
|
||||
#define __DELAY_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class Delay : protected Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
|
||||
Delay();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
Delay(long theDelay, long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Delay();
|
||||
|
||||
//! Clears the internal state of the delay line.
|
||||
void clear();
|
||||
|
||||
//! Set the delay-line length.
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(long theDelay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
long getDelay(void) const;
|
||||
|
||||
//! Calculate and return the signal energy in the delay-line.
|
||||
MY_FLOAT energy(void) const;
|
||||
|
||||
//! Return the value at \e tapDelay samples from the delay-line input.
|
||||
/*!
|
||||
The valid range for \e tapDelay is 1 to the delay-line length.
|
||||
*/
|
||||
MY_FLOAT contentsAt(long tapDelay) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
virtual MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
protected:
|
||||
long inPoint;
|
||||
long outPoint;
|
||||
long length;
|
||||
MY_FLOAT delay;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
65
include/DelayA.h
Normal file
65
include/DelayA.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************/
|
||||
/*! \class DelayA
|
||||
\brief STK allpass interpolating delay line class.
|
||||
|
||||
This Delay subclass implements a fractional-
|
||||
length digital delay-line using a first-order
|
||||
allpass filter. A fixed maximum length
|
||||
of 4095 and a delay of 0.5 is set using the
|
||||
default constructor. Alternatively, the
|
||||
delay and maximum length can be set during
|
||||
instantiation with an overloaded constructor.
|
||||
|
||||
An allpass filter has unity magnitude gain but
|
||||
variable phase delay properties, making it useful
|
||||
in achieving fractional delays without affecting
|
||||
a signal's frequency magnitude response. In
|
||||
order to achieve a maximally flat phase delay
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DelayA_h)
|
||||
#define __DelayA_h
|
||||
|
||||
#include "Delay.h"
|
||||
|
||||
class DelayA : public Delay
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
|
||||
DelayA();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
|
||||
DelayA(MY_FLOAT theDelay, long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~DelayA();
|
||||
|
||||
//! Clears the internal state of the delay line.
|
||||
void clear();
|
||||
|
||||
//! Set the delay-line length
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0.5 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(MY_FLOAT theDelay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
MY_FLOAT getDelay(void);
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
|
||||
protected:
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT coeff;
|
||||
MY_FLOAT apInput;
|
||||
};
|
||||
|
||||
#endif
|
||||
61
include/DelayL.h
Normal file
61
include/DelayL.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************/
|
||||
/*! \class DelayL
|
||||
\brief STK linear interpolating delay line class.
|
||||
|
||||
This Delay subclass implements a fractional-
|
||||
length digital delay-line using first-order
|
||||
linear interpolation. A fixed maximum length
|
||||
of 4095 and a delay of zero is set using the
|
||||
default constructor. Alternatively, the
|
||||
delay and maximum length can be set during
|
||||
instantiation with an overloaded constructor.
|
||||
|
||||
Linear interpolation is an efficient technique
|
||||
for achieving fractional delay lengths, though
|
||||
it does introduce high-frequency signal
|
||||
attenuation to varying degrees depending on the
|
||||
fractional delay setting. The use of higher
|
||||
order Lagrange interpolators can typically
|
||||
improve (minimize) this attenuation characteristic.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DELAYL_H)
|
||||
#define __DELAYL_H
|
||||
|
||||
#include "Delay.h"
|
||||
|
||||
class DelayL : public Delay
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
|
||||
DelayL();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
|
||||
DelayL(MY_FLOAT theDelay, long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~DelayL();
|
||||
|
||||
//! Set the delay-line length.
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(MY_FLOAT theDelay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
MY_FLOAT getDelay(void) const;
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
|
||||
protected:
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT omAlpha;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
/*******************************************/
|
||||
/* Master Class for Drum Synthesizer */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* This instrument contains a bunch of */
|
||||
/* RawWvIn objects, run through a bunch */
|
||||
/* of one-pole filters. All the */
|
||||
/* corresponding rawwave files have been */
|
||||
/* sampled at 22050 Hz. Thus, if the */
|
||||
/* compile-time SRATE = 22050, then */
|
||||
/* no interpolation is used. Otherwise, */
|
||||
/* the rawwave data is appropriately */
|
||||
/* interpolated for the current SRATE. */
|
||||
/* You can specify the maximum Polyphony */
|
||||
/* (maximum number of simultaneous voices)*/
|
||||
/* in a #define in the .h file. */
|
||||
/* */
|
||||
/* Modified for RawWvIn class */
|
||||
/* by Gary P. Scavone (4/99) */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__DrumSynt_h)
|
||||
#define __DrumSynt_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define DRUM_NUMWAVES 11
|
||||
#define DRUM_POLYPHONY 4
|
||||
|
||||
class DrumSynt : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
RawWvIn *waves[DRUM_POLYPHONY];
|
||||
OnePole *filters[DRUM_POLYPHONY];
|
||||
int sounding[DRUM_POLYPHONY];
|
||||
int numSounding;
|
||||
public:
|
||||
DrumSynt();
|
||||
~DrumSynt();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
void noteOff(MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
59
include/Drummer.h
Normal file
59
include/Drummer.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************/
|
||||
/*! \class Drummer
|
||||
\brief STK drum sample player class.
|
||||
|
||||
This class implements a drum sampling
|
||||
synthesizer using WvIn objects and one-pole
|
||||
filters. The drum rawwave files are sampled
|
||||
at 22050 Hz, but will be appropriately
|
||||
interpolated for other sample rates. You can
|
||||
specify the maximum polyphony (maximum number
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DRUMMER_H)
|
||||
#define __DRUMMER_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "WvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define DRUM_NUMWAVES 11
|
||||
#define DRUM_POLYPHONY 4
|
||||
|
||||
class Drummer : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Drummer();
|
||||
|
||||
//! Class destructor.
|
||||
~Drummer();
|
||||
|
||||
//! 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.
|
||||
*/
|
||||
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
WvIn *waves[DRUM_POLYPHONY];
|
||||
OnePole *filters[DRUM_POLYPHONY];
|
||||
int sounding[DRUM_POLYPHONY];
|
||||
int nSounding;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
53
include/Echo.h
Normal file
53
include/Echo.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************/
|
||||
/*! \class Echo
|
||||
\brief STK echo effect class.
|
||||
|
||||
This class implements a echo effect.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ECHO_H)
|
||||
#define __ECHO_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class Echo : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the longest desired delay length.
|
||||
Echo(MY_FLOAT longestDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~Echo();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! 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;
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
protected:
|
||||
Delay *delayLine;
|
||||
long length;
|
||||
MY_FLOAT lastOutput;
|
||||
MY_FLOAT effectMix;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +1,68 @@
|
||||
/*******************************************/
|
||||
/* Envelope Class, Perry R. Cook, 1995-96 */
|
||||
/* This is the base class for envelopes. */
|
||||
/* This one is capable of ramping state */
|
||||
/* from where it is to a target value by */
|
||||
/* a rate. It also responds to simple */
|
||||
/* KeyOn and KeyOff messages, ramping to */
|
||||
/* 1.0 on keyon and to 0.0 on keyoff. */
|
||||
/* There are two tick (update value) */
|
||||
/* methods, one returns the value, and */
|
||||
/* other returns 0 if the envelope is at */
|
||||
/* the target value (the state bit). */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Envelope_h)
|
||||
#define __Envelope_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Envelope : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT value;
|
||||
MY_FLOAT target;
|
||||
MY_FLOAT rate;
|
||||
int state;
|
||||
public:
|
||||
Envelope();
|
||||
virtual ~Envelope();
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
void setRate(MY_FLOAT aRate);
|
||||
void setTime(MY_FLOAT aTime);
|
||||
void setTarget(MY_FLOAT aTarget);
|
||||
void setValue(MY_FLOAT aValue);
|
||||
MY_FLOAT tick();
|
||||
int informTick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Envelope
|
||||
\brief STK envelope base class.
|
||||
|
||||
This class implements a simple envelope
|
||||
generator which is capable of ramping to
|
||||
a target value by a specified \e rate.
|
||||
It also responds to simple \e keyOn and
|
||||
\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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ENVELOPE_H)
|
||||
#define __ENVELOPE_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Envelope : public Stk
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Envelope(void);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Envelope(void);
|
||||
|
||||
//! Set target = 1.
|
||||
virtual void keyOn(void);
|
||||
|
||||
//! Set target = 0.
|
||||
virtual void keyOff(void);
|
||||
|
||||
//! Set the \e rate.
|
||||
void setRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the \e rate based on a time duration.
|
||||
void setTime(MY_FLOAT aTime);
|
||||
|
||||
//! Set the target value.
|
||||
virtual void setTarget(MY_FLOAT aTarget);
|
||||
|
||||
//! Set current and target values to \e aValue.
|
||||
virtual void setValue(MY_FLOAT aValue);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Return \e vectorSize envelope outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
protected:
|
||||
MY_FLOAT value;
|
||||
MY_FLOAT target;
|
||||
MY_FLOAT rate;
|
||||
int state;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/********************************************/
|
||||
/*
|
||||
General Finite-Impulse-Response (FIR)
|
||||
Digital Filter Class
|
||||
by Julius Smith, 1997
|
||||
*/
|
||||
/********************************************/
|
||||
|
||||
#if !defined(__FIR_h)
|
||||
#define __FIR_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class FIR : public Object
|
||||
{
|
||||
protected:
|
||||
int length;
|
||||
MY_FLOAT *coeffs;
|
||||
MY_FLOAT *pastInputs;
|
||||
int piOffset;
|
||||
MY_FLOAT delay;
|
||||
public:
|
||||
FIR(int length);
|
||||
FIR(const char *filterFile);
|
||||
~FIR();
|
||||
void clear(void);
|
||||
void setCoeffs(MY_FLOAT *theCoeffs);
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
MY_FLOAT lastOutput;
|
||||
MY_FLOAT getDelay(MY_FLOAT freq);
|
||||
int getLength(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
103
include/FM.h
Normal file
103
include/FM.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************/
|
||||
/*! \class FM
|
||||
\brief STK abstract FM synthesis base class.
|
||||
|
||||
This class controls an arbitrary number of
|
||||
waves and envelopes, determined via a
|
||||
constructor argument.
|
||||
|
||||
Control Change Numbers:
|
||||
- Control One = 2
|
||||
- Control Two = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FM_H)
|
||||
#define __FM_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "TwoZero.h"
|
||||
|
||||
class FM : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the number of wave/envelope operators to control.
|
||||
FM( int operators = 4 );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~FM();
|
||||
|
||||
//! Reset and clear all wave and envelope states.
|
||||
void clear();
|
||||
|
||||
//! Load the rawwave filenames in waves.
|
||||
void loadWaves(const char **filenames);
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the frequency ratio for the specified wave.
|
||||
void setRatio(int waveIndex, MY_FLOAT ratio);
|
||||
|
||||
//! Set the gain for the specified wave.
|
||||
void setGain(int waveIndex, MY_FLOAT gain);
|
||||
|
||||
//! Set the modulation speed in Hz.
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
|
||||
//! Set the modulation depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
|
||||
//! Set the value of control1.
|
||||
void setControl1(MY_FLOAT cVal);
|
||||
|
||||
//! Set the value of control1.
|
||||
void setControl2(MY_FLOAT cVal);
|
||||
|
||||
//! Start envelopes toward "on" targets.
|
||||
void keyOn();
|
||||
|
||||
//! Start envelopes toward "off" targets.
|
||||
void keyOff();
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Pure virtual function ... must be defined in subclasses.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT 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];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
/******************************************/
|
||||
/* Algorithm 3 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* Alg 3 is : 4--\ */
|
||||
/* 3-->2-- + -->1-->Out */
|
||||
/* */
|
||||
/* Controls: control1 = total mod index */
|
||||
/* control2 = crossfade of two */
|
||||
/* modulators */
|
||||
/* control3 = LFO speed */
|
||||
/* modWheel = LFO amount */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FM4Alg3_h)
|
||||
#define __FM4Alg3_h
|
||||
|
||||
#include "FM4Op.h"
|
||||
|
||||
class FM4Alg3 : public FM4Op
|
||||
{
|
||||
public:
|
||||
FM4Alg3();
|
||||
virtual ~FM4Alg3();
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
/******************************************/
|
||||
/* Algorithm 4 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* Alg 4 is : 4->3--\ */
|
||||
/* 2-- + -->1-->Out */
|
||||
/* */
|
||||
/* Controls: control1 = total mod index */
|
||||
/* control2 = crossfade of two */
|
||||
/* modulators */
|
||||
/* control3 = LFO speed */
|
||||
/* modWheel = LFO amount */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FM4Alg4_h)
|
||||
#define __FM4Alg4_h
|
||||
|
||||
#include "FM4Op.h"
|
||||
|
||||
class FM4Alg4 : public FM4Op
|
||||
{
|
||||
public:
|
||||
FM4Alg4();
|
||||
virtual ~FM4Alg4();
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
/******************************************/
|
||||
/* Algorithm 5 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This connection topology is 2 simple */
|
||||
/* FM Pairs summed together, like: */
|
||||
/* */
|
||||
/* 1 -> 2 -\ */
|
||||
/* +-> Out */
|
||||
/* 3 -> 4 -/ */
|
||||
/* */
|
||||
/* Controls: control1 = mod index 1 */
|
||||
/* control2 = crossfade of two */
|
||||
/* outputs */
|
||||
/* control3 = LFO speed */
|
||||
/* modWheel = LFO amount */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FM4Alg5_h)
|
||||
#define __FM4Alg5_h
|
||||
|
||||
#include "FM4Op.h"
|
||||
|
||||
class FM4Alg5 : public FM4Op
|
||||
{
|
||||
public:
|
||||
FM4Alg5();
|
||||
virtual ~FM4Alg5();
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/******************************************/
|
||||
/* Algorithm 6 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This connection topology is three */
|
||||
/* Carriers and a common Modulator */
|
||||
/* */
|
||||
/* /->1 -\ */
|
||||
/* 4-|-->2 - +-> Out */
|
||||
/* \->3 -/ */
|
||||
/* */
|
||||
/* Controls: control1 = vowel */
|
||||
/* control2 = spectral tilt */
|
||||
/* control3 = LFO speed */
|
||||
/* modWheel = LFO amount */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FM4Alg6_h)
|
||||
#define __FM4Alg6_h
|
||||
|
||||
#include "FM4Op.h"
|
||||
|
||||
class FM4Alg6 : public FM4Op
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT tilt[3];
|
||||
MY_FLOAT mods[3];
|
||||
public:
|
||||
FM4Alg6();
|
||||
virtual ~FM4Alg6();
|
||||
MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/******************************************/
|
||||
/* Algorithm 8 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This connection topology is simple */
|
||||
/* Additive Synthesis, like: */
|
||||
/* */
|
||||
/* 1 --. */
|
||||
/* 2 -\| */
|
||||
/* +-> Out */
|
||||
/* 3 -/| */
|
||||
/* 4 -- */
|
||||
/* */
|
||||
/* Controls: control1 = op4 (fb) gain */
|
||||
/* control2 = op3 gain */
|
||||
/* control3 = LFO speed */
|
||||
/* modWheel = LFO amount */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FM4Alg8_h)
|
||||
#define __FM4Alg8_h
|
||||
|
||||
#include "FM4Op.h"
|
||||
|
||||
class FM4Alg8 : public FM4Op
|
||||
{
|
||||
public:
|
||||
FM4Alg8();
|
||||
virtual ~FM4Alg8();
|
||||
virtual MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
/*******************************************/
|
||||
/* Master Class for 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This instrument contains an 4 waves, */
|
||||
/* 4 envelopes, and various state vars. */
|
||||
/* */
|
||||
/* The basic Chowning/Stanford FM patent */
|
||||
/* expired April 1995, but there exist */
|
||||
/* follow-on patents, mostly assigned to */
|
||||
/* Yamaha. If you are of the type who */
|
||||
/* should worry about this (making money) */
|
||||
/* worry away. */
|
||||
/* */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__FM4Op_h)
|
||||
#define __FM4Op_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "TwoZero.h"
|
||||
|
||||
class FM4Op : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
ADSR *adsr[4];
|
||||
RawWvIn *waves[4];
|
||||
RawWvIn *vibWave;
|
||||
TwoZero *twozero;
|
||||
MY_FLOAT baseFreq;
|
||||
MY_FLOAT ratios[4];
|
||||
MY_FLOAT gains[4];
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT control1;
|
||||
MY_FLOAT control2;
|
||||
MY_FLOAT __FM4Op_gains[100];
|
||||
MY_FLOAT __FM4Op_susLevels[16];
|
||||
MY_FLOAT __FM4Op_attTimes[32];
|
||||
public:
|
||||
FM4Op();
|
||||
virtual ~FM4Op();
|
||||
void loadWaves(char* wave1, char* wave2, char* wave3, char* wave4);
|
||||
void clear();
|
||||
void setFreq(MY_FLOAT frequency);
|
||||
void setRatio(int whichOne, MY_FLOAT ratio);
|
||||
void setGain(int whichOne, MY_FLOAT gain);
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
void noteOff(MY_FLOAT amp);
|
||||
/* There's no tick() method here, because that depends on the algorithm */
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
void setControl1(MY_FLOAT cVal);
|
||||
void setControl2(MY_FLOAT cVal);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,24 +1,65 @@
|
||||
/******************************************/
|
||||
/* Singing Voice Synthesis Subclass */
|
||||
/* of Algorithm 6 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1996 */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class FMVoices
|
||||
\brief STK singing FM synthesis instrument.
|
||||
|
||||
#if !defined(__FMVoices_h)
|
||||
#define __FMVoices_h
|
||||
This class implements 3 carriers and a common
|
||||
modulator, also referred to as algorithm 6 of
|
||||
the TX81Z.
|
||||
|
||||
#include "FM4Alg6.h"
|
||||
\code
|
||||
Algorithm 6 is :
|
||||
/->1 -\
|
||||
4-|-->2 - +-> Out
|
||||
\->3 -/
|
||||
\endcode
|
||||
|
||||
class FMVoices : public FM4Alg6
|
||||
Control Change Numbers:
|
||||
- Vowel = 2
|
||||
- Spectral Tilt = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FMVOICES_H)
|
||||
#define __FMVOICES_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
class FMVoices : public FM
|
||||
{
|
||||
protected:
|
||||
int currentVowel;
|
||||
public:
|
||||
FMVoices();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
public:
|
||||
//! Class constructor.
|
||||
FMVoices();
|
||||
|
||||
//! Class destructor.
|
||||
~FMVoices();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
int currentVowel;
|
||||
MY_FLOAT tilt[3];
|
||||
MY_FLOAT mods[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
140
include/Filter.h
140
include/Filter.h
@@ -1,28 +1,112 @@
|
||||
/*******************************************/
|
||||
/* Filter Class, by Perry R. Cook, 1995-96*/
|
||||
/* This is the base class for all filters.*/
|
||||
/* To me, most anything is a filter, but */
|
||||
/* I'll be a little less general here, and*/
|
||||
/* define a filter as something which has */
|
||||
/* input(s), output(s), and gain. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Filter_h)
|
||||
#define __Filter_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Filter : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT gain;
|
||||
MY_FLOAT *outputs;
|
||||
MY_FLOAT *inputs;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
Filter();
|
||||
virtual ~Filter();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Filter
|
||||
\brief STK filter class.
|
||||
|
||||
This class implements a generic structure which
|
||||
can be used to create a wide range of filters.
|
||||
It can function independently or be subclassed
|
||||
to provide more specific controls based on a
|
||||
particular filter type.
|
||||
|
||||
In particular, this class implements the standard
|
||||
difference equation:
|
||||
|
||||
a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] -
|
||||
a[1]*y[n-1] - ... - a[na]*y[n-na]
|
||||
|
||||
If a[0] is not equal to 1, the filter coeffcients
|
||||
are normalized by a[0].
|
||||
|
||||
The \e gain parameter is applied at the filter
|
||||
input and does not affect the coefficient values.
|
||||
The default gain value is 1.0. This structure
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FILTER_H)
|
||||
#define __FILTER_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Filter : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor creates a zero-order pass-through "filter".
|
||||
Filter(void);
|
||||
|
||||
//! 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.
|
||||
*/
|
||||
Filter(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Filter(void);
|
||||
|
||||
//! Clears all internal states of the filter.
|
||||
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].
|
||||
*/
|
||||
void setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *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.
|
||||
*/
|
||||
void setNumerator(int nb, MY_FLOAT *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.
|
||||
*/
|
||||
void setDenominator(int na, MY_FLOAT *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);
|
||||
|
||||
//! Return the current filter gain.
|
||||
virtual MY_FLOAT getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
virtual MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
virtual MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
protected:
|
||||
MY_FLOAT gain;
|
||||
int nB;
|
||||
int nA;
|
||||
MY_FLOAT *b;
|
||||
MY_FLOAT *a;
|
||||
MY_FLOAT *outputs;
|
||||
MY_FLOAT *inputs;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
120
include/Flute.h
120
include/Flute.h
@@ -1,64 +1,100 @@
|
||||
/******************************************/
|
||||
/* WaveGuide Flute ala Karjalainen, */
|
||||
/* Smith, Waryznyk, etc. */
|
||||
/* with polynomial Jet ala Cook */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* This is a waveguide model, and thus */
|
||||
/* relates to various Stanford Univ. */
|
||||
/* and possibly Yamaha and other patents.*/
|
||||
/* */
|
||||
/* Controls: CONTROL1 = jetDelay */
|
||||
/* CONTROL2 = noiseGain */
|
||||
/* CONTROL3 = vibFreq */
|
||||
/* MOD_WHEEL= vibAmt */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Flute
|
||||
\brief STK flute physical model class.
|
||||
|
||||
#if !defined(__Flute_h)
|
||||
#define __Flute_h
|
||||
This class implements a simple flute
|
||||
physical model, as discussed by Karjalainen,
|
||||
Smith, Waryznyk, etc. The jet model uses
|
||||
a polynomial, a la Cook.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by Stanford
|
||||
University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Jet Delay = 2
|
||||
- Noise Gain = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FLUTE_H)
|
||||
#define __FLUTE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "JetTabl.h"
|
||||
#include "DLineL.h"
|
||||
#include "DelayL.h"
|
||||
#include "OnePole.h"
|
||||
#include "DCBlock.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Noise.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Flute : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Flute(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Flute();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the reflection coefficient for the jet delay (-1.0 - 1.0).
|
||||
void setJetReflection(MY_FLOAT coefficient);
|
||||
|
||||
//! Set the reflection coefficient for the air column delay (-1.0 - 1.0).
|
||||
void setEndReflection(MY_FLOAT 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);
|
||||
|
||||
//! Apply breath velocity to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath velocity with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
DLineL *jetDelay;
|
||||
DLineL *boreDelay;
|
||||
DelayL *jetDelay;
|
||||
DelayL *boreDelay;
|
||||
JetTabl *jetTable;
|
||||
OnePole *filter;
|
||||
DCBlock *dcBlock;
|
||||
PoleZero *dcBlock;
|
||||
Noise *noise;
|
||||
ADSR *adsr;
|
||||
RawWvIn *vibr;
|
||||
MY_FLOAT lastFreq;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT lastFrequency;
|
||||
MY_FLOAT maxPressure;
|
||||
MY_FLOAT jetRefl;
|
||||
MY_FLOAT endRefl;
|
||||
MY_FLOAT jetReflection;
|
||||
MY_FLOAT endReflection;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibrGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT jetRatio;
|
||||
public:
|
||||
Flute(MY_FLOAT lowestFreq);
|
||||
~Flute();
|
||||
void clear();
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
void setJetRefl(MY_FLOAT refl);
|
||||
void setEndRefl(MY_FLOAT refl);
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void setJetDelay(MY_FLOAT aLength);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,46 +1,93 @@
|
||||
/*******************************************/
|
||||
/* Sweepable Formant (2-pole) */
|
||||
/* Filter Class, by Perry R. Cook, 1995-96*/
|
||||
/* See books on filters to understand */
|
||||
/* more about how this works. Nothing */
|
||||
/* out of the ordinary in this version. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__FormSwep_h)
|
||||
#define __FormSwep_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class FormSwep : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT poleCoeffs[2];
|
||||
MY_FLOAT freq;
|
||||
MY_FLOAT reson;
|
||||
int dirty;
|
||||
MY_FLOAT targetFreq;
|
||||
MY_FLOAT targetReson;
|
||||
MY_FLOAT targetGain;
|
||||
MY_FLOAT currentFreq;
|
||||
MY_FLOAT currentReson;
|
||||
MY_FLOAT currentGain;
|
||||
MY_FLOAT deltaFreq;
|
||||
MY_FLOAT deltaReson;
|
||||
MY_FLOAT deltaGain;
|
||||
MY_FLOAT sweepState;
|
||||
MY_FLOAT sweepRate;
|
||||
public:
|
||||
FormSwep();
|
||||
~FormSwep();
|
||||
void clear();
|
||||
void setPoleCoeffs(MY_FLOAT *coeffs);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
void setFreqAndReson(MY_FLOAT aFreq, MY_FLOAT aReson);
|
||||
void setStates(MY_FLOAT aFreq, MY_FLOAT aReson, MY_FLOAT aGain);
|
||||
void setTargets(MY_FLOAT aFreq, MY_FLOAT aReson, MY_FLOAT aGain);
|
||||
void setSweepRate(MY_FLOAT aRate);
|
||||
void setSweepTime(MY_FLOAT aTime);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class FormSwep
|
||||
\brief STK sweepable formant filter class.
|
||||
|
||||
This public BiQuad filter subclass implements
|
||||
a formant (resonance) which can be "swept"
|
||||
over time from one frequency setting to another.
|
||||
It provides methods for controlling the sweep
|
||||
rate and target frequency.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FORMSWEP_H)
|
||||
#define __FORMSWEP_H
|
||||
|
||||
#include "BiQuad.h"
|
||||
|
||||
class FormSwep : public BiQuad
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a second-order pass-through filter.
|
||||
FormSwep();
|
||||
|
||||
//! Class destructor.
|
||||
~FormSwep();
|
||||
|
||||
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
|
||||
/*!
|
||||
This method determines the filter coefficients corresponding to
|
||||
two complex-conjugate poles with the given \e frequency (in Hz)
|
||||
and \e radius from the z-plane origin. The filter zeros are
|
||||
placed at z = 1, z = -1, and the coefficients are then normalized to
|
||||
produce a constant unity gain (independent of the filter \e gain
|
||||
parameter). The resulting filter frequency response has a
|
||||
resonance at the given \e 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 aFrequency, MY_FLOAT aRadius);
|
||||
|
||||
//! Set both the current and target resonance parameters.
|
||||
void setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
|
||||
|
||||
//! Set target resonance parameters.
|
||||
void setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
|
||||
|
||||
//! Set the sweep rate (between 0.0 - 1.0).
|
||||
/*!
|
||||
The formant parameters are varied in increments of the
|
||||
sweep rate between their current and target values.
|
||||
A sweep rate of 1.0 will produce an immediate change in
|
||||
resonance parameters from their current values to the
|
||||
target values. A sweep rate of 0.0 will produce no
|
||||
change in resonance parameters.
|
||||
*/
|
||||
void setSweepRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the sweep rate in terms of a time value in seconds.
|
||||
/*!
|
||||
This method adjusts the sweep rate based on a
|
||||
given time for the formant parameters to reach
|
||||
their target values.
|
||||
*/
|
||||
void setSweepTime(MY_FLOAT aTime);
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/******************************************/
|
||||
/* Heavy Metal Synth Subclass */
|
||||
/* of Algorithm 3 (TX81Z) Subclass of */
|
||||
/* 3 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__HeavyMtl_h)
|
||||
#define __HeavyMtl_h
|
||||
|
||||
#include "FM4Alg3.h"
|
||||
|
||||
class HeavyMtl : public FM4Alg3
|
||||
{
|
||||
public:
|
||||
HeavyMtl();
|
||||
~HeavyMtl();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
52
include/HevyMetl.h
Normal file
52
include/HevyMetl.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************/
|
||||
/*! \class HevyMetl
|
||||
\brief STK heavy metal FM synthesis instrument.
|
||||
|
||||
This class implements 3 cascade operators with
|
||||
feedback modulation, also referred to as
|
||||
algorithm 3 of the TX81Z.
|
||||
|
||||
\code
|
||||
Algorithm 3 is : 4--\
|
||||
3-->2-- + -->1-->Out
|
||||
\endcode
|
||||
|
||||
Control Change Numbers:
|
||||
- Total Modulator Index = 2
|
||||
- Modulator Crossfade = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__HEVYMETL_H)
|
||||
#define __HEVYMETL_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
class HevyMetl : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
HevyMetl();
|
||||
|
||||
//! Class destructor.
|
||||
~HevyMetl();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,26 +1,53 @@
|
||||
/******************************************/
|
||||
/* Instrument SuperClass for Toolkit96 */
|
||||
/* Perry R. Cook, Princeton University */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Instrmnt_h)
|
||||
#define __Instrmnt_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Instrmnt : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
Instrmnt();
|
||||
virtual ~Instrmnt();
|
||||
MY_FLOAT lastOut();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Instrmnt
|
||||
\brief STK instrument abstract base class.
|
||||
|
||||
This class provides a common interface for
|
||||
all STK instruments.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__INSTRMNT_H)
|
||||
#define __INSTRMNT_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <iostream.h>
|
||||
|
||||
class Instrmnt : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
Instrmnt();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Instrmnt();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) = 0;
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude) = 0;
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
/*******************************************/
|
||||
/* JVRev Reverb Subclass */
|
||||
/* by Tim Stilson, 1998 */
|
||||
/* based on CLM JCRev */
|
||||
/* Integrated into STK by Gary Scavone */
|
||||
/* */
|
||||
/* This is based on some of the famous */
|
||||
/* Stanford CCRMA reverbs (NRev, KipRev) */
|
||||
/* all based on the Chowning/Moorer/ */
|
||||
/* Schroeder reverberators, which use */
|
||||
/* networks of simple allpass and comb */
|
||||
/* delay filters. This particular */
|
||||
/* arrangement consists of 3 allpass */
|
||||
/* filters in series, followed by 4 comb */
|
||||
/* filters in parallel, an optional */
|
||||
/* lowpass filter, and two decorrelation */
|
||||
/* delay lines in parallel at the output. */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class JCRev
|
||||
\brief John Chowning's reverberator class.
|
||||
|
||||
#if !defined(__JCRev_h)
|
||||
#define __JCRev_h
|
||||
This class is derived from the CLM JCRev
|
||||
function, which is based on the use of
|
||||
networks of simple allpass and comb delay
|
||||
filters. This class implements three series
|
||||
allpass units, followed by four parallel comb
|
||||
filters, and two decorrelation delay lines in
|
||||
parallel at the output.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__JCREV_H)
|
||||
#define __JCREV_H
|
||||
|
||||
#include "Object.h"
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class JCRev : public Reverb
|
||||
{
|
||||
protected:
|
||||
DLineN *APdelayLine[3];
|
||||
DLineN *CdelayLine[4];
|
||||
DLineN *outLdelayLine;
|
||||
DLineN *outRdelayLine;
|
||||
MY_FLOAT allPassCoeff;
|
||||
MY_FLOAT combCoeff[4];
|
||||
MY_FLOAT combsum,combsum1,combsum2;
|
||||
MY_FLOAT lastOutL;
|
||||
MY_FLOAT lastOutR;
|
||||
MY_FLOAT effectMix;
|
||||
public:
|
||||
JCRev(MY_FLOAT T60);
|
||||
~JCRev();
|
||||
void clear();
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
MY_FLOAT lastOutput();
|
||||
MY_FLOAT lastOutputL();
|
||||
MY_FLOAT lastOutputR();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
public:
|
||||
// Class constructor taking a T60 decay time argument.
|
||||
JCRev(MY_FLOAT T60);
|
||||
|
||||
// Class destructor.
|
||||
~JCRev();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
|
||||
protected:
|
||||
Delay *allpassDelays[3];
|
||||
Delay *combDelays[4];
|
||||
Delay *outLeftDelay;
|
||||
Delay *outRightDelay;
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[4];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,27 +1,44 @@
|
||||
/**********************************************/
|
||||
/* Jet Table Object by Perry R. Cook, 1995-96 */
|
||||
/* Consult Fletcher and Rossing, Karjalainen, */
|
||||
/* Cook, more, for information. */
|
||||
/* This, as with many other of my "tables", */
|
||||
/* is not a table, but is computed by poly- */
|
||||
/* nomial calculation. */
|
||||
/**********************************************/
|
||||
|
||||
#if !defined(__JetTabl_h)
|
||||
#define __JetTabl_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class JetTabl : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
JetTabl();
|
||||
~JetTabl();
|
||||
MY_FLOAT lookup(MY_FLOAT deltaP);
|
||||
MY_FLOAT tick(MY_FLOAT deltaP);
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \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
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/************************************************/
|
||||
/* Lip Filter Object by Perry R. Cook, 1995-96 */
|
||||
/* The lip of the brass player has dynamics */
|
||||
/* which are controlled by the mass, spring */
|
||||
/* constant, and damping of the lip. This */
|
||||
/* filter simulates that behavior and the */
|
||||
/* transmission/reflection properties as */
|
||||
/* well. See Cook TBone and HosePlayer */
|
||||
/* instruments and articles. */
|
||||
/************************************************/
|
||||
|
||||
#include "Object.h"
|
||||
#include "BiQuad.h"
|
||||
|
||||
class LipFilt : public Object
|
||||
{
|
||||
protected:
|
||||
BiQuad *filter;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
LipFilt();
|
||||
~LipFilt();
|
||||
void clear();
|
||||
void setFreq(MY_FLOAT frequency);
|
||||
MY_FLOAT tick(MY_FLOAT mouthSample,MY_FLOAT boreSample);
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
@@ -1,44 +1,71 @@
|
||||
/********************************************/
|
||||
/* Commuted Mandolin Subclass of enhanced */
|
||||
/* dual plucked-string model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* Controls: CONTROL1 = bodySize */
|
||||
/* CONTROL2 = pluckPosition */
|
||||
/* CONTROL3 = loopGain */
|
||||
/* MOD_WHEEL= deTuning */
|
||||
/* */
|
||||
/* Note: Commuted Synthesis, as with many */
|
||||
/* other WaveGuide techniques, is covered */
|
||||
/* by patents, granted, pending, and/or */
|
||||
/* applied-for. All are assigned to the */
|
||||
/* Board of Trustees, Stanford University. */
|
||||
/* For information, contact the Office of */
|
||||
/* Technology Licensing, Stanford U. */
|
||||
/********************************************/
|
||||
/***************************************************/
|
||||
/*! \class Mandolin
|
||||
\brief STK mandolin instrument model class.
|
||||
|
||||
#if !defined(__Mandolin_h)
|
||||
#define __Mandolin_h
|
||||
This class inherits from PluckTwo and uses
|
||||
"commuted synthesis" techniques to model a
|
||||
mandolin instrument.
|
||||
|
||||
#include "Plucked2.h"
|
||||
#include "RawWvIn.h"
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
Commuted Synthesis, in particular, is covered
|
||||
by patents, granted, pending, and/or
|
||||
applied-for. All are assigned to the Board of
|
||||
Trustees, Stanford University. For
|
||||
information, contact the Office of Technology
|
||||
Licensing, Stanford University.
|
||||
|
||||
class Mandolin : public Plucked2
|
||||
Control Change Numbers:
|
||||
- Body Size = 2
|
||||
- Pluck Position = 4
|
||||
- String Sustain = 11
|
||||
- String Detuning = 1
|
||||
- Microphone Position = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MANDOLIN_H)
|
||||
#define __MANDOLIN_H
|
||||
|
||||
#include "PluckTwo.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class Mandolin : public PluckTwo
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Mandolin(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Mandolin();
|
||||
|
||||
//! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency.
|
||||
void pluck(MY_FLOAT 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);
|
||||
|
||||
//! Start a note with the given frequency and amplitude (0.0 - 1.0).
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Set the body size (a value of 1.0 produces the "default" size).
|
||||
void setBodySize(MY_FLOAT size);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
RawWvIn *soundfile[12];
|
||||
WvIn *soundfile[12];
|
||||
MY_FLOAT directBody;
|
||||
int mic;
|
||||
long dampTime;
|
||||
int waveDone;
|
||||
public:
|
||||
Mandolin(MY_FLOAT lowestFreq);
|
||||
virtual ~Mandolin();
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
void pluck(MY_FLOAT amplitude,MY_FLOAT position);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
void setBodySize(MY_FLOAT size);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual MY_FLOAT tick();
|
||||
bool waveDone;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*******************************************/
|
||||
/* MatWvIn Input Class, */
|
||||
/* by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* This object inherits from WvIn and is */
|
||||
/* used to open Matlab MAT-file data */
|
||||
/* (doubles) files for playback. In */
|
||||
/* order for this class to work, the */
|
||||
/* MAT-file must contain a single array */
|
||||
/* (matrix) of double-precision floating */
|
||||
/* point values (can be multi-channel). */
|
||||
/* It does not work for any other data */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* MAT-file data is either big- or */
|
||||
/* little-endian, which can be determined */
|
||||
/* from the header. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__MatWvIn_h)
|
||||
#define __MatWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class MatWvIn : public WvIn
|
||||
{
|
||||
public:
|
||||
MatWvIn(char *fileName, char *mode);
|
||||
~MatWvIn();
|
||||
protected:
|
||||
void getData(long index);
|
||||
int doSwap;
|
||||
int interleaved;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/*******************************************/
|
||||
/* Matlab MAT-file Output Class, */
|
||||
/* by Gary P. Scavone, 1999. */
|
||||
/* This object creates a Matlab MAT-file */
|
||||
/* structure with a numeric array */
|
||||
/* subelement and fills it with buffers */
|
||||
/* of samples (doubles). */
|
||||
/* */
|
||||
/* When originally created, the Matlab */
|
||||
/* MAT-file format was not public and I */
|
||||
/* had to reverse-engineer the format. */
|
||||
/* Matlab finally released the format in */
|
||||
/* the Spring of 1999, and this class was */
|
||||
/* updated to more closely adhere to */
|
||||
/* specifications. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__MatWvOut_h)
|
||||
#define __MatWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class MatWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
FILE *fd;
|
||||
double *matdata; /* not MY_FLOAT because MAT-file uses doubles */
|
||||
public:
|
||||
MatWvOut(char *infileName, int chans = 1);
|
||||
~MatWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif // defined(__MatWvOut_h)
|
||||
105
include/Mesh2D.h
Normal file
105
include/Mesh2D.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/***************************************************/
|
||||
/*! \class Mesh2D
|
||||
\brief Two-dimensional rectilinear waveguide mesh class.
|
||||
|
||||
This class implements a rectilinear,
|
||||
two-dimensional digital waveguide mesh
|
||||
structure. For details, see Van Duyne and
|
||||
Smith, "Physical Modeling with the 2-D Digital
|
||||
Waveguide Mesh", Proceedings of the 1993
|
||||
International Computer Music Conference.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by Stanford
|
||||
University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- X Dimension = 2
|
||||
- Y Dimension = 4
|
||||
- Mesh Decay = 11
|
||||
- X-Y Input Position = 1
|
||||
|
||||
by Julius Smith, 2000 - 2002.
|
||||
Revised by Gary Scavone for STK, 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MESH2D_H)
|
||||
#define __MESH2D_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define NXMAX ((short)(12))
|
||||
#define NYMAX ((short)(12))
|
||||
|
||||
class Mesh2D : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the x and y dimensions in samples.
|
||||
Mesh2D(short nX, short nY);
|
||||
|
||||
//! Class destructor.
|
||||
~Mesh2D();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the x dimension size in samples.
|
||||
void setNX(short lenX);
|
||||
|
||||
//! Set the y dimension size in samples.
|
||||
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);
|
||||
|
||||
//! Set the loss filters gains (0.0 - 1.0).
|
||||
void setDecay(MY_FLOAT decayFactor);
|
||||
|
||||
//! Impulse the mesh with the given amplitude (frequency ignored).
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay) ... currently ignored.
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Calculate and return the signal energy stored in the mesh.
|
||||
MY_FLOAT energy();
|
||||
|
||||
//! Compute one output sample, without adding energy to the mesh.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Input a sample to the mesh and compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
|
||||
MY_FLOAT tick0();
|
||||
MY_FLOAT 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
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
147
include/Messager.h
Normal file
147
include/Messager.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/***************************************************/
|
||||
/*! \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.
|
||||
|
||||
For each call to nextMessage(), the active
|
||||
input sources are queried to see if a new
|
||||
control message is available.
|
||||
|
||||
This class is primarily for use in STK main()
|
||||
event loops.
|
||||
|
||||
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.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MESSAGER_H)
|
||||
#define __MESSSAGER_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "SKINI.h"
|
||||
|
||||
#define MESSAGE_LENGTH 128
|
||||
#define MAX_MESSAGES 25
|
||||
|
||||
#if defined(__STK_REALTIME__)
|
||||
|
||||
#include "Thread.h"
|
||||
#include "Socket.h"
|
||||
#include "RtMidi.h"
|
||||
|
||||
#define STK_MIDI 0x0001
|
||||
#define STK_PIPE 0x0002
|
||||
#define STK_SOCKET 0x0004
|
||||
|
||||
extern "C" THREAD_RETURN THREAD_TYPE stdinHandler(void * ptr);
|
||||
|
||||
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__))
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#endif // __STK_REALTIME__
|
||||
|
||||
class Messager : public Stk
|
||||
{
|
||||
public:
|
||||
//! Constructor performs initialization based on an input mask.
|
||||
/*!
|
||||
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. For realtime input types, an StkError can be
|
||||
thrown during instantiation.
|
||||
*/
|
||||
Messager(int inputMask = 0);
|
||||
|
||||
//! Class destructor.
|
||||
~Messager();
|
||||
|
||||
//! Check for a new input message and return the message type.
|
||||
/*!
|
||||
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.
|
||||
*/
|
||||
long nextMessage(void);
|
||||
|
||||
//! Set the delta time (in samples) returned between valid realtime messages. This setting has no affect for scorefile messages.
|
||||
void setRtDelta(long nSamples);
|
||||
|
||||
//! Return the current message "delta time" in samples.
|
||||
long getDelta(void) const;
|
||||
|
||||
//! Return the current message type.
|
||||
long getType() const;
|
||||
|
||||
//! Return the byte two value for the current message.
|
||||
MY_FLOAT getByteTwo() const;
|
||||
|
||||
//! Return the byte three value for the current message.
|
||||
MY_FLOAT getByteThree() const;
|
||||
|
||||
//! Return the channel number for the current message.
|
||||
long getChannel() const;
|
||||
|
||||
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;
|
||||
|
||||
#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__
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__MESSAGER_H)
|
||||
86
include/Modal.h
Normal file
86
include/Modal.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************/
|
||||
/*! \class Modal
|
||||
\brief STK resonance model instrument.
|
||||
|
||||
This class contains an excitation wavetable,
|
||||
an envelope, an oscillator, and N resonances
|
||||
(non-sweeping BiQuad filters), where N is set
|
||||
during instantiation.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MODAL_H)
|
||||
#define __MODAL_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "Envelope.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "BiQuad.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Modal : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the desired number of modes to create.
|
||||
Modal( int modes = 4 );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Modal();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the ratio and radius for a specified mode filter.
|
||||
void setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius);
|
||||
|
||||
//! Set the master gain.
|
||||
void setMasterGain(MY_FLOAT aGain);
|
||||
|
||||
//! Set the direct gain.
|
||||
void setDirectGain(MY_FLOAT aGain);
|
||||
|
||||
//! Set the gain for a specified mode filter.
|
||||
void setModeGain(int modeIndex, MY_FLOAT gain);
|
||||
|
||||
//! Initiate a strike with the given amplitude (0.0 - 1.0).
|
||||
virtual void strike(MY_FLOAT amplitude);
|
||||
|
||||
//! Damp modes with a given decay factor (0.0 - 1.0).
|
||||
void damp(MY_FLOAT amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
Four Resonance Modal Synthesis Instrument
|
||||
by Perry R. Cook, 1995-2000
|
||||
|
||||
This instrument contains an excitation
|
||||
wavetable, an envelope, an oscillator,
|
||||
and four resonances (Non-Sweeping BiQuad
|
||||
Filters).
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Modal4_h)
|
||||
#define __Modal4_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "Envelope.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "BiQuad.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Modal4 : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
Envelope *envelope;
|
||||
RawWvIn *wave;
|
||||
BiQuad *filters[4];
|
||||
OnePole *onepole;
|
||||
RawWvIn *vibr;
|
||||
MY_FLOAT vibrGain;
|
||||
MY_FLOAT masterGain;
|
||||
MY_FLOAT directGain;
|
||||
MY_FLOAT stickHardness;
|
||||
MY_FLOAT strikePosition;
|
||||
MY_FLOAT baseFreq;
|
||||
MY_FLOAT ratios[4];
|
||||
MY_FLOAT resons[4];
|
||||
public:
|
||||
Modal4();
|
||||
virtual ~Modal4();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void setRatioAndReson(int whichOne, MY_FLOAT ratio, MY_FLOAT reson);
|
||||
void setMasterGain(MY_FLOAT aGain);
|
||||
void setDirectGain(MY_FLOAT aGain);
|
||||
void setFiltGain(int whichOne, MY_FLOAT gain);
|
||||
virtual void strike(MY_FLOAT amplitude);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
void damp(MY_FLOAT amplitude);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,30 +1,60 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
ModalBar SubClass of Modal4 Instrument
|
||||
by Perry R. Cook, 1999-2000
|
||||
/***************************************************/
|
||||
/*! \class ModalBar
|
||||
\brief STK resonant bar instrument class.
|
||||
|
||||
Controls: CONTROL1 = stickHardness
|
||||
CONTROL2 = strikePosition
|
||||
CONTROL3 = Mode Presets
|
||||
This class implements a number of different
|
||||
struck bar instruments. It inherits from the
|
||||
Modal class.
|
||||
|
||||
Control Change Numbers:
|
||||
- Stick Hardness = 2
|
||||
- Stick Position = 4
|
||||
- Vibrato Gain = 11
|
||||
- Vibrato Frequency = 7
|
||||
- Volume = 128
|
||||
- Modal Presets = 16
|
||||
- Marimba = 0
|
||||
- Vibraphone = 1
|
||||
- Agogo = 2
|
||||
- Wood1 = 3
|
||||
- Reso = 4
|
||||
- Wood2 = 5
|
||||
- Beats = 6
|
||||
- Two Fixed = 7
|
||||
- Clump = 8
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ModalBar_h)
|
||||
#define __ModalBar_h
|
||||
#if !defined(__MODALBAR_H)
|
||||
#define __MODALBAR_H
|
||||
|
||||
#include "Modal4.h"
|
||||
#include "Modal.h"
|
||||
|
||||
class ModalBar : public Modal4
|
||||
class ModalBar : public Modal
|
||||
{
|
||||
private:
|
||||
public:
|
||||
//! Class constructor.
|
||||
ModalBar();
|
||||
|
||||
//! Class destructor.
|
||||
~ModalBar();
|
||||
|
||||
//! Set stick hardness (0.0 - 1.0).
|
||||
void setStickHardness(MY_FLOAT hardness);
|
||||
|
||||
//! Set stick position (0.0 - 1.0).
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
void setModalPreset(int which);
|
||||
|
||||
//! Select a bar preset (currently modulo 9).
|
||||
void setPreset(int preset);
|
||||
|
||||
//! Set the modulation (vibrato) depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
61
include/Modulate.h
Normal file
61
include/Modulate.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************/
|
||||
/*! \class Modulate
|
||||
\brief STK periodic/random modulator.
|
||||
|
||||
This class combines random and periodic
|
||||
modulations to give a nice, natural human
|
||||
modulation function.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MODULATE_H)
|
||||
#define __MODULATE_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "SubNoise.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Modulate : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Modulate();
|
||||
|
||||
//! Class destructor.
|
||||
~Modulate();
|
||||
|
||||
//! Reset internal state.
|
||||
void reset();
|
||||
|
||||
//! Set the periodic (vibrato) rate or frequency in Hz.
|
||||
void setVibratoRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the periodic (vibrato) gain.
|
||||
void setVibratoGain(MY_FLOAT aGain);
|
||||
|
||||
//! Set the random modulation gain.
|
||||
void setRandomGain(MY_FLOAT aGain);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Return \e vectorSize outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
protected:
|
||||
WaveLoop *vibrato;
|
||||
SubNoise *noise;
|
||||
OnePole *filter;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT randomGain;
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/*******************************************/
|
||||
/* Modulator Class, Perry R. Cook, 1995-96*/
|
||||
/* This Object combines random and */
|
||||
/* periodic modulations to give a nice */
|
||||
/* natural human modulation function. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Modulatr_h)
|
||||
#define __Modulatr_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "SubNoise.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Modulatr : public Object
|
||||
{
|
||||
protected:
|
||||
RawWvIn *vibwave;
|
||||
SubNoise *noise;
|
||||
OnePole *onepole;
|
||||
MY_FLOAT vibAmt;
|
||||
MY_FLOAT rndAmt;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
Modulatr();
|
||||
~Modulatr();
|
||||
void reset();
|
||||
void setVibFreq(MY_FLOAT vibFreq);
|
||||
void setVibAmt(MY_FLOAT vibAmount);
|
||||
void setRndAmt(MY_FLOAT rndAmount);
|
||||
MY_FLOAT tick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
62
include/Moog.h
Normal file
62
include/Moog.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************/
|
||||
/*! \class Moog
|
||||
\brief STK moog-like swept filter sampling synthesis class.
|
||||
|
||||
This instrument uses one attack wave, one
|
||||
looped wave, and an ADSR envelope (inherited
|
||||
from the Sampler class) and adds two sweepable
|
||||
formant (FormSwep) filters.
|
||||
|
||||
Control Change Numbers:
|
||||
- Filter Q = 2
|
||||
- Filter Sweep Rate = 4
|
||||
- Vibrato Frequency = 11
|
||||
- Vibrato Gain = 1
|
||||
- Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MOOG_H)
|
||||
#define __MOOG_H
|
||||
|
||||
#include "Sampler.h"
|
||||
#include "FormSwep.h"
|
||||
|
||||
class Moog : public Sampler
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Moog();
|
||||
|
||||
//! Class destructor.
|
||||
~Moog();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Set the modulation (vibrato) speed in Hz.
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
|
||||
//! Set the modulation (vibrato) depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
FormSwep *filters[2];
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT filterQ;
|
||||
MY_FLOAT filterRate;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/******************************************/
|
||||
/* Moog1 Subclass of */
|
||||
/* Sampling Synthesizer Class */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* */
|
||||
/* Controls: CONTROL1 = filterQ */
|
||||
/* CONTROL2 = filterRate */
|
||||
/* CONTROL3 = vibFreq */
|
||||
/* MOD_WHEEL= vibAmt */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Moog1_h)
|
||||
#define __Moog1_h
|
||||
|
||||
#include "SamplFlt.h"
|
||||
|
||||
class Moog1 : public SamplFlt
|
||||
{
|
||||
private:
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT filterQ;
|
||||
MY_FLOAT filterRate;
|
||||
public:
|
||||
Moog1();
|
||||
~Moog1();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,51 +1,49 @@
|
||||
/******************************************/
|
||||
/* NRev Reverb Subclass */
|
||||
/* by Tim Stilson, 1998 */
|
||||
/* based on CLM NRev */
|
||||
/* Integrated into STK by Gary Scavone */
|
||||
/* */
|
||||
/* This is based on some of the famous */
|
||||
/* Stanford CCRMA reverbs (NRev, KipRev) */
|
||||
/* all based on the the Chowning/Moorer/ */
|
||||
/* Schroeder reverberators, which use */
|
||||
/* networks of simple allpass and comb */
|
||||
/* delay filters. This particular */
|
||||
/* arrangement consists of 6 comb */
|
||||
/* filters in parallel, followed by 3 */
|
||||
/* allpass filters, a lowpass filter, */
|
||||
/* and another allpass in series, */
|
||||
/* followed by two allpass filters in */
|
||||
/* parallel with corresponding right and */
|
||||
/* left outputs. */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class NRev
|
||||
\brief CCRMA's NRev reverberator class.
|
||||
|
||||
#if !defined(__NRev_h)
|
||||
#define __NRev_h
|
||||
This class is derived from the CLM NRev
|
||||
function, which is based on the use of
|
||||
networks of simple allpass and comb delay
|
||||
filters. This particular arrangement consists
|
||||
of 6 comb filters in parallel, followed by 3
|
||||
allpass filters, a lowpass filter, and another
|
||||
allpass in series, followed by two allpass
|
||||
filters in parallel with corresponding right
|
||||
and left outputs.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__NREV_H)
|
||||
#define __NREV_H
|
||||
|
||||
#include "Object.h"
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class NRev : public Reverb
|
||||
{
|
||||
protected:
|
||||
DLineN *APdelayLine[8];
|
||||
DLineN *CdelayLine[6];
|
||||
MY_FLOAT allPassCoeff;
|
||||
MY_FLOAT combCoef[6];
|
||||
MY_FLOAT lpLastout;
|
||||
MY_FLOAT lastOutL;
|
||||
MY_FLOAT lastOutR;
|
||||
MY_FLOAT effectMix;
|
||||
public:
|
||||
NRev(MY_FLOAT T60);
|
||||
~NRev();
|
||||
void clear();
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
MY_FLOAT lastOutput();
|
||||
MY_FLOAT lastOutputL();
|
||||
MY_FLOAT lastOutputR();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
public:
|
||||
// Class constructor taking a T60 decay time argument.
|
||||
NRev(MY_FLOAT T60);
|
||||
|
||||
// Class destructor.
|
||||
~NRev();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
|
||||
protected:
|
||||
Delay *allpassDelays[8];
|
||||
Delay *combDelays[6];
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[6];
|
||||
MY_FLOAT lowpassState;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,23 +1,43 @@
|
||||
/*******************************************/
|
||||
/* Noise Generator Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* White noise as often as you like. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Noise_h)
|
||||
#define __Noise_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Noise : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
Noise();
|
||||
virtual ~Noise();
|
||||
MY_FLOAT tick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Noise
|
||||
\brief STK noise generator.
|
||||
|
||||
Generic random number generation 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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__NOISE_H)
|
||||
#define __NOISE_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Noise : public Stk
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Noise();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Noise();
|
||||
|
||||
//! Return a random number between -1.0 and 1.0 using rand().
|
||||
virtual MY_FLOAT 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);
|
||||
|
||||
//! Return the last computed value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
protected:
|
||||
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
137
include/Object.h
137
include/Object.h
@@ -1,137 +0,0 @@
|
||||
/*********************************************/
|
||||
/* Object Class, by Perry R. Cook, 1995-99 */
|
||||
/* */
|
||||
/* This is mostly here for compatibility */
|
||||
/* with Objective C. We'll also stick */
|
||||
/* global defines here, so everyone will */
|
||||
/* see them. */
|
||||
/*********************************************/
|
||||
|
||||
#if !defined(__Object_h)
|
||||
#define __Object_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
Object();
|
||||
virtual ~Object();
|
||||
};
|
||||
|
||||
/* The OS type definitions are made in the Makefile */
|
||||
|
||||
#if defined(__OS_NeXT_) /* For NeXTStep - Black or White Hardware */
|
||||
#define RANDLIMIT 2147483647
|
||||
#elif defined(__OS_IRIX_) /* For SGI */
|
||||
#define __STK_REALTIME_
|
||||
#define RANDLIMIT 2147483647
|
||||
#elif defined(__OS_Linux_) /* For Linux */
|
||||
#define __STK_REALTIME_
|
||||
#define __OSS_API_ /* Use OSS API */
|
||||
// #define __MIDIATOR_ /* Use special MIDIator support */
|
||||
// #define __ALSA_API_ /* Use ALSA API */
|
||||
#define __LITTLE_ENDIAN__
|
||||
#define RANDLIMIT 2147483647
|
||||
#elif defined(__OS_Win_) /* For WindowsXX or NT */
|
||||
#define __STK_REALTIME_
|
||||
#define __LITTLE_ENDIAN__
|
||||
#define RANDLIMIT 32767
|
||||
#endif
|
||||
|
||||
/*
|
||||
Real-time audio input and output buffer size. If clicks
|
||||
are occuring in the input or output sound stream, a
|
||||
larger buffer size may help. Larger buffer sizes, however,
|
||||
produce more latency between input and output.
|
||||
*/
|
||||
#define RT_BUFFER_SIZE 256
|
||||
|
||||
/*
|
||||
The following definition is concatenated to the beginning
|
||||
of all references to rawwave files in the various STK core
|
||||
classes (ex. Clarinet.cpp). If you wish to move the
|
||||
rawwaves directory to a different location in your file
|
||||
system, you will need to set this path definition
|
||||
appropriately. The current definition is a relative reference
|
||||
that will work "out of the box" for the STK distribution.
|
||||
*/
|
||||
#define RAWWAVE_PATH "../../"
|
||||
|
||||
/* Sampling Rate */
|
||||
#define SRATE (MY_FLOAT) 22050.0
|
||||
|
||||
/* Other SRATE derived defines */
|
||||
#define SRATE_OVER_TWO (MY_FLOAT) (SRATE / 2)
|
||||
#define ONE_OVER_SRATE (MY_FLOAT) (1 / SRATE)
|
||||
#define TWO_PI_OVER_SRATE (MY_FLOAT) (2 * PI / SRATE)
|
||||
|
||||
/* Yer Basic Trigonometric constants */
|
||||
#if !defined(PI)
|
||||
#define PI (MY_FLOAT) 3.14159265359
|
||||
#endif
|
||||
#define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI)
|
||||
#define ONE_OVER_TWO_PI (MY_FLOAT) (1.0 / PI)
|
||||
#define SQRT_TWO 1.414213562
|
||||
|
||||
/* Useful random number generator values */
|
||||
#define ONE_OVER_RANDLIMIT (1.0/RANDLIMIT)
|
||||
#define RANDLIMIT_OVER_TWO (int)(RANDLIMIT/2)
|
||||
|
||||
/* FPU Underflow Limit
|
||||
* The IEEE specification doesn't call for automatic
|
||||
* zeroing of floating-point values when they reach
|
||||
* their numerical limits. Instead, most processors
|
||||
* switch to a much more computation-intensive mode
|
||||
* when a FPU underflow occurs. We set a lower limit
|
||||
* here for our own (not so efficient) checks. Here's
|
||||
* a useful macro for limiting MY_FLOATs. At this time,
|
||||
* no FPU underflow checks are being performed.
|
||||
*/
|
||||
#define FPU_UFLOW_LIMIT 0.0000000001
|
||||
#define LIMIT_MY_FLOAT(j) ((((j)<(MY_FLOAT)FPU_UFLOW_LIMIT)&&((j)>(MY_FLOAT)-FPU_UFLOW_LIMIT))?(MY_FLOAT)0.0:(j))
|
||||
|
||||
/* States for Envelopes, etc. */
|
||||
#define ATTACK 0
|
||||
#define DECAY 1
|
||||
#define SUSTAIN 2
|
||||
#define RELEASE 3
|
||||
|
||||
/* Machine dependent stuff, possibly useful for optimization.
|
||||
* For example, changing double to float here increases
|
||||
* performance (speed) by a whopping 4-6% on 486-flavor machines.
|
||||
* BUT!! a change from float to double here increases speed by
|
||||
* 30% or so on SGI machines.
|
||||
*/
|
||||
#define MY_FLOAT double
|
||||
//#define MY_FLOAT float
|
||||
|
||||
/* MY_MULTI is just a pointer to MY_FLOAT. This type is used
|
||||
* to pass multichannel data back and forth within STK.
|
||||
*/
|
||||
typedef MY_FLOAT *MY_MULTI;
|
||||
|
||||
/* INT16 is just that ... a 16-bit signed integer. */
|
||||
typedef signed short INT16;
|
||||
|
||||
/* INT32 is just that ... a 32-bit signed integer. */
|
||||
typedef int INT32;
|
||||
|
||||
/* Boolean values */
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/* Debugging define, causes massive printf's to come out.
|
||||
* Also enables timing calculations in WaveOut class, other stuff.
|
||||
* Uncomment to enable.
|
||||
*/
|
||||
//#define _debug_ 1
|
||||
|
||||
/* MIDI definitions */
|
||||
#define NORM_7 (MY_FLOAT) 0.0078125 /* this is 1/128 */
|
||||
|
||||
#endif
|
||||
@@ -1,44 +1,72 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
One Pole Filter Class,
|
||||
by Perry R. Cook, 1995-96.
|
||||
Added methods by Julius Smith, 2000.
|
||||
|
||||
The parameter gain is an additional
|
||||
gain parameter applied to the filter
|
||||
on top of the normalization that takes
|
||||
place automatically. So the net max
|
||||
gain through the system equals the
|
||||
value of gain. sgain is the combina-
|
||||
tion of gain and the normalization
|
||||
parameter, so if you set the poleCoeff
|
||||
to alpha, sgain is always set to
|
||||
gain * (1.0 - fabs(alpha)).
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__OnePole_h)
|
||||
#define __OnePole_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class OnePole : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT poleCoeff;
|
||||
MY_FLOAT sgain;
|
||||
public:
|
||||
OnePole();
|
||||
OnePole(MY_FLOAT thePole);
|
||||
~OnePole();
|
||||
void clear();
|
||||
void setB0(MY_FLOAT aValue); /* set numerator b0 in b0/(1+a1/z) */
|
||||
void setNum(MY_FLOAT *values);
|
||||
void setA1(MY_FLOAT aValue); /* set denominator a1 in b0/(1+a1/z) */
|
||||
void setDen(MY_FLOAT *values);
|
||||
void setPole(MY_FLOAT aValue);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class OnePole
|
||||
\brief STK one-pole filter class.
|
||||
|
||||
This protected Filter subclass implements
|
||||
a one-pole digital filter. A method is
|
||||
provided for setting the pole position along
|
||||
the real axis of the z-plane while maintaining
|
||||
a constant peak filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ONEPOLE_H)
|
||||
#define __ONEPOLE_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class OnePole : protected Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a first-order low-pass filter.
|
||||
OnePole();
|
||||
|
||||
//! Overloaded constructor which sets the pole position during instantiation.
|
||||
OnePole(MY_FLOAT thePole);
|
||||
|
||||
//! Class destructor.
|
||||
~OnePole();
|
||||
|
||||
//! Clears the internal state of the filter.
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
|
||||
//! Set the pole position in the z-plane.
|
||||
/*!
|
||||
This method sets the pole position along the real-axis of the
|
||||
z-plane and normalizes the coefficients for a maximum gain of one.
|
||||
A positive pole value produces a low-pass filter, while a negative
|
||||
pole value produces a high-pass filter. This method does not
|
||||
affect the filter \e gain value.
|
||||
*/
|
||||
void setPole(MY_FLOAT 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);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,35 +1,72 @@
|
||||
/*******************************************/
|
||||
/* One Zero Filter Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* The parameter gain is an additional */
|
||||
/* gain parameter applied to the filter */
|
||||
/* on top of the normalization that takes */
|
||||
/* place automatically. So the net max */
|
||||
/* gain through the system equals the */
|
||||
/* value of gain. sgain is the combina- */
|
||||
/* tion of gain and the normalization */
|
||||
/* parameter, so if you set the poleCoeff */
|
||||
/* to alpha, sgain is always set to */
|
||||
/* gain / (1.0 - fabs(alpha)). */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__OneZero_h)
|
||||
#define __OneZero_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class OneZero : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT zeroCoeff;
|
||||
MY_FLOAT sgain;
|
||||
public:
|
||||
OneZero();
|
||||
~OneZero();
|
||||
void clear();
|
||||
void setGain(MY_FLOAT aValue);
|
||||
void setCoeff(MY_FLOAT aValue);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class OneZero
|
||||
\brief STK one-zero filter class.
|
||||
|
||||
This protected Filter subclass implements
|
||||
a one-zero digital filter. A method is
|
||||
provided for setting the zero position
|
||||
along the real axis of the z-plane while
|
||||
maintaining a constant filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ONEZERO_H)
|
||||
#define __ONEZERO_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class OneZero : protected Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a first-order low-pass filter.
|
||||
OneZero();
|
||||
|
||||
//! Overloaded constructor which sets the zero position during instantiation.
|
||||
OneZero(MY_FLOAT theZero);
|
||||
|
||||
//! Class destructor.
|
||||
~OneZero();
|
||||
|
||||
//! Clears the internal state of the filter.
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
|
||||
//! Set the zero position in the z-plane.
|
||||
/*!
|
||||
This method sets the zero position along the real-axis of the
|
||||
z-plane and normalizes the coefficients for a maximum gain of one.
|
||||
A positive zero value produces a high-pass filter, while a
|
||||
negative zero value produces a low-pass filter. This method does
|
||||
not affect the filter \e gain value.
|
||||
*/
|
||||
void setZero(MY_FLOAT 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);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,42 +1,46 @@
|
||||
/*******************************************/
|
||||
/* PRCRev, a simple reverb unit */
|
||||
/* by Perry Cook, 1996. */
|
||||
/* Incorporated into the Reverb superclass */
|
||||
/* by Gary Scavone, 1998. */
|
||||
/* */
|
||||
/* This is based on some of the famous */
|
||||
/* Stanford CCRMA reverbs (NRev, KipRev) */
|
||||
/* all based on the the Chowning/Moorer/ */
|
||||
/* Schroeder reverberators, which use */
|
||||
/* networks of simple allpass and comb */
|
||||
/* delay filters. */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class PRCRev
|
||||
\brief Perry's simple reverberator class.
|
||||
|
||||
#if !defined(__PRCRev_h)
|
||||
#define __PRCRev_h
|
||||
This class is based on some of the famous
|
||||
Stanford/CCRMA reverbs (NRev, KipRev), which
|
||||
were based on the Chowning/Moorer/Schroeder
|
||||
reverberators using networks of simple allpass
|
||||
and comb delay filters. This class implements
|
||||
two series allpass units and two parallel comb
|
||||
filters.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PRCREV_H)
|
||||
#define __PRCREV_H
|
||||
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class PRCRev : public Reverb
|
||||
{
|
||||
public:
|
||||
// Class constructor taking a T60 decay time argument.
|
||||
PRCRev(MY_FLOAT T60);
|
||||
|
||||
// Class destructor.
|
||||
~PRCRev();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
|
||||
protected:
|
||||
DLineN *APdelayLine[2];
|
||||
DLineN *CdelayLine[2];
|
||||
MY_FLOAT allPassCoeff;
|
||||
MY_FLOAT combCoeff[2];
|
||||
MY_FLOAT lastOutL;
|
||||
MY_FLOAT lastOutR;
|
||||
MY_FLOAT effectMix;
|
||||
public:
|
||||
PRCRev(MY_FLOAT T60);
|
||||
~PRCRev();
|
||||
void clear();
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
MY_FLOAT lastOutput();
|
||||
MY_FLOAT lastOutputL();
|
||||
MY_FLOAT lastOutputR();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
Delay *allpassDelays[2];
|
||||
Delay *combDelays[2];
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[2];
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,21 +1,53 @@
|
||||
/******************************************/
|
||||
/* Percussive Flute Subclass */
|
||||
/* of Algorithm 4 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class PercFlut
|
||||
\brief STK percussive flute FM synthesis instrument.
|
||||
|
||||
#if !defined(__PercFlut_h)
|
||||
#define __PercFlut_h
|
||||
This class implements algorithm 4 of the TX81Z.
|
||||
|
||||
#include "FM4Alg4.h"
|
||||
\code
|
||||
Algorithm 4 is : 4->3--\
|
||||
2-- + -->1-->Out
|
||||
\endcode
|
||||
|
||||
class PercFlut : public FM4Alg4
|
||||
Control Change Numbers:
|
||||
- Total Modulator Index = 2
|
||||
- Modulator Crossfade = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PERCFLUT_H)
|
||||
#define __PERCFLUT_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
class PercFlut : public FM
|
||||
{
|
||||
public:
|
||||
PercFlut();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
public:
|
||||
//! Class constructor.
|
||||
PercFlut();
|
||||
|
||||
//! Class destructor.
|
||||
~PercFlut();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
56
include/PitShift.h
Normal file
56
include/PitShift.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************/
|
||||
/*! \class PitShift
|
||||
\brief STK simple pitch shifter effect class.
|
||||
|
||||
This class implements a simple pitch shifter
|
||||
using delay lines.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PITSHIFT_H)
|
||||
#define __PITSHIFT_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "DelayL.h"
|
||||
|
||||
class PitShift : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
PitShift();
|
||||
|
||||
//! Class destructor.
|
||||
~PitShift();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
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;
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
|
||||
protected:
|
||||
Delay *delayLine[2];
|
||||
MY_FLOAT lastOutput;
|
||||
MY_FLOAT delay[2];
|
||||
MY_FLOAT env[2];
|
||||
MY_FLOAT effectMix;
|
||||
MY_FLOAT rate;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
84
include/PluckTwo.h
Normal file
84
include/PluckTwo.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************/
|
||||
/*! \class PluckTwo
|
||||
\brief STK enhanced plucked string model class.
|
||||
|
||||
This class implements an enhanced two-string,
|
||||
plucked physical model, a la Jaffe-Smith,
|
||||
Smith, and others.
|
||||
|
||||
PluckTwo is an abstract class, with no excitation
|
||||
specified. Therefore, it can't be directly
|
||||
instantiated.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PLUCKTWO_H)
|
||||
#define __PLUCKTWO_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
|
||||
class PluckTwo : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
PluckTwo(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~PluckTwo();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Detune the two strings by the given factor. A value of 1.0 produces unison strings.
|
||||
void setDetune(MY_FLOAT detune);
|
||||
|
||||
//! Efficient combined setting of frequency and detuning.
|
||||
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
|
||||
|
||||
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
|
||||
void setPluckPosition(MY_FLOAT position);
|
||||
|
||||
//! Set the base loop gain.
|
||||
/*!
|
||||
The actual loop gain is set according to the frequency.
|
||||
Because of high-frequency loop filter roll-off, higher
|
||||
frequency settings have greater loop gains.
|
||||
*/
|
||||
void setBaseLoopGain(MY_FLOAT aGain);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Virtual (abstract) tick function is implemented by subclasses.
|
||||
virtual MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,39 +1,66 @@
|
||||
/******************************************/
|
||||
/* Karplus-Strong plucked string model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* There exist at least two patents, */
|
||||
/* assigned to Stanford, bearing the */
|
||||
/* names of Karplus and/or Strong. */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Plucked
|
||||
\brief STK plucked string model class.
|
||||
|
||||
#if !defined(__Plucked_h)
|
||||
#define __Plucked_h
|
||||
This class implements a simple plucked string
|
||||
physical model based on the Karplus-Strong
|
||||
algorithm.
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.h"
|
||||
#include "OneZero.h"
|
||||
#include "OnePole.h"
|
||||
#include "Noise.h"
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
There exist at least two patents, assigned to
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PLUCKED_H)
|
||||
#define __PLUCKED_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "OnePole.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Plucked : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineA *delayLine;
|
||||
OneZero *loopFilt;
|
||||
OnePole *pickFilt;
|
||||
Noise *noise;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
public:
|
||||
Plucked(MY_FLOAT lowestFreq);
|
||||
~Plucked();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Plucked(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Plucked();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
OneZero *loopFilter;
|
||||
OnePole *pickFilter;
|
||||
Noise *noise;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/******************************************/
|
||||
/* Enhanced (Jaffe-Smith, Smith, others) */
|
||||
/* Karplus-Strong plucked model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* This is the super-class, with no */
|
||||
/* excitation specified. So this one by */
|
||||
/* itself doesn't make any sound. */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Plucked2_h)
|
||||
#define __Plucked2_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "DLineA.h"
|
||||
#include "OneZero.h"
|
||||
|
||||
class Plucked2 : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineA *delayLine;
|
||||
DLineA *delayLine2;
|
||||
DLineL *combDelay;
|
||||
OneZero *filter;
|
||||
OneZero *filter2;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
MY_FLOAT baseLoopGain;
|
||||
MY_FLOAT lastFreq;
|
||||
MY_FLOAT lastLength;
|
||||
MY_FLOAT detuning;
|
||||
MY_FLOAT pluckAmp;
|
||||
MY_FLOAT pluckPos;
|
||||
public:
|
||||
Plucked2(MY_FLOAT lowestFreq);
|
||||
virtual ~Plucked2();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void setDetune(MY_FLOAT detune);
|
||||
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
|
||||
void setPluckPos(MY_FLOAT position);
|
||||
void setBaseLoopGain(MY_FLOAT aGain);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,32 +1,79 @@
|
||||
/*******************************************/
|
||||
/* PoleZero (1-pole, 1-zero) Filter Class */
|
||||
/* by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* See books on filters to understand */
|
||||
/* more about how this works. Nothing */
|
||||
/* out of the ordinary in this version. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__PoleZero_h)
|
||||
#define __PoleZero_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class PoleZero : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT a1Coeff;
|
||||
MY_FLOAT b0Coeff;
|
||||
MY_FLOAT b1Coeff;
|
||||
public:
|
||||
PoleZero();
|
||||
~PoleZero();
|
||||
void clear();
|
||||
void setA1(MY_FLOAT coeff);
|
||||
void setB0(MY_FLOAT coeff);
|
||||
void setB1(MY_FLOAT coeff);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class PoleZero
|
||||
\brief STK one-pole, one-zero filter class.
|
||||
|
||||
This protected Filter subclass implements
|
||||
a one-pole, one-zero digital filter. A
|
||||
method is provided for creating an allpass
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__POLEZERO_H)
|
||||
#define __POLEZERO_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class PoleZero : protected Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor creates a first-order pass-through filter.
|
||||
PoleZero();
|
||||
|
||||
//! Class destructor.
|
||||
~PoleZero();
|
||||
|
||||
//! Clears the internal states of the filter.
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
|
||||
//! Set the filter for allpass behavior using \e coefficient.
|
||||
/*!
|
||||
This method uses \e coefficient to create an allpass 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);
|
||||
|
||||
//! Create a DC blocking filter with the given pole position in the z-plane.
|
||||
/*!
|
||||
This method sets the given pole position, together with a zero
|
||||
at z=1, to create a DC blocking filter. \e thePole should be
|
||||
close to one to minimize low-frequency attenuation.
|
||||
|
||||
*/
|
||||
void setBlockZero(MY_FLOAT 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);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT 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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*******************************************/
|
||||
/* RawWvIn Input Class, */
|
||||
/* by Gary P. Scavone, 2000 */
|
||||
/* */
|
||||
/* This object inherits from WvIn and is */
|
||||
/* used to open raw 16-bit data (signed */
|
||||
/* integer) files for playback. */
|
||||
/* */
|
||||
/* STK RawWave files are assumed to be */
|
||||
/* big-endian. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__RawWvIn_h)
|
||||
#define __RawWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class RawWvIn : public WvIn
|
||||
{
|
||||
public:
|
||||
RawWvIn(char *fileName, const char *mode);
|
||||
~RawWvIn();
|
||||
protected:
|
||||
void getData(long index);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
/*******************************************/
|
||||
/* RawWvOut Output Class */
|
||||
/* by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* This object spits samples into a raw */
|
||||
/* 16-bit data (signed integer) file. */
|
||||
/* */
|
||||
/* STK RawWave files are assumed to be */
|
||||
/* monaural and big-endian. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__RawWvOut_h)
|
||||
#define __RawWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class RawWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
FILE *fd;
|
||||
public:
|
||||
RawWvOut(char *fileName, int chans = 1);
|
||||
~RawWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif // defined(__RawWvOut_h)
|
||||
@@ -1,30 +1,70 @@
|
||||
/**********************************************/
|
||||
/* One break point linear reed table object */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* Consult McIntyre, Schumacher, & Woodhouse */
|
||||
/* Smith, Hirschman, Cook, Scavone, */
|
||||
/* more for information. */
|
||||
/**********************************************/
|
||||
|
||||
#if !defined(__ReedTabl_h)
|
||||
#define __ReedTabl_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class ReedTabl : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT offSet;
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
ReedTabl();
|
||||
~ReedTabl();
|
||||
void setOffset(MY_FLOAT aValue);
|
||||
void setSlope(MY_FLOAT aValue);
|
||||
MY_FLOAT lookup(MY_FLOAT deltaP);
|
||||
MY_FLOAT tick(MY_FLOAT deltaP);
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class ReedTabl
|
||||
\brief STK reed table class.
|
||||
|
||||
This class implements a simple one breakpoint,
|
||||
non-linear reed function, as described by
|
||||
Smith (1986). This function is based on a
|
||||
memoryless non-linear spring model of the reed
|
||||
(the reed mass is ignored) which saturates when
|
||||
the reed collides with the mouthpiece facing.
|
||||
|
||||
See McIntyre, Schumacher, & Woodhouse (1983),
|
||||
Smith (1986), Hirschman, Cook, Scavone, and
|
||||
others for more information.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__REEDTABL_H)
|
||||
#define __REEDTABL_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class ReedTabl : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
ReedTabl();
|
||||
|
||||
//! Class destructor.
|
||||
~ReedTabl();
|
||||
|
||||
//! Set the table offset value.
|
||||
/*!
|
||||
The table offset roughly corresponds to the size
|
||||
of the initial reed tip opening (a greater offset
|
||||
represents a smaller opening).
|
||||
*/
|
||||
void setOffset(MY_FLOAT aValue);
|
||||
|
||||
//! Set the table slope value.
|
||||
/*!
|
||||
The table slope roughly corresponds to the reed
|
||||
stiffness (a greater slope represents a harder
|
||||
reed).
|
||||
*/
|
||||
void setSlope(MY_FLOAT aValue);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the function value for \e input.
|
||||
/*!
|
||||
The function input represents the differential
|
||||
pressure across the reeds.
|
||||
*/
|
||||
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 offSet;
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
78
include/Resonate.h
Normal file
78
include/Resonate.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************/
|
||||
/*! \class Resonate
|
||||
\brief STK noise driven formant filter.
|
||||
|
||||
This instrument contains a noise source, which
|
||||
excites a biquad resonance filter, with volume
|
||||
controlled by an ADSR.
|
||||
|
||||
Control Change Numbers:
|
||||
- Resonance Frequency (0-Nyquist) = 2
|
||||
- Pole Radii = 4
|
||||
- Notch Frequency (0-Nyquist) = 11
|
||||
- Zero Radii = 1
|
||||
- Envelope Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RESONATE_H)
|
||||
#define __RESONATE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "BiQuad.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Resonate : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Resonate();
|
||||
|
||||
//! Class destructor.
|
||||
~Resonate();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the filter for a resonance at the given frequency (Hz) and radius.
|
||||
void setResonance(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
|
||||
//! Set the filter for a notch at the given frequency (Hz) and radius.
|
||||
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
|
||||
//! Set the filter zero coefficients for contant resonance gain.
|
||||
void setEqualGainZeroes();
|
||||
|
||||
//! Initiate the envelope with a key-on event.
|
||||
void keyOn();
|
||||
|
||||
//! Signal a key-off event to the envelope.
|
||||
void keyOff();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
BiQuad *filter;
|
||||
Noise *noise;
|
||||
MY_FLOAT poleFrequency;
|
||||
MY_FLOAT poleRadius;
|
||||
MY_FLOAT zeroFrequency;
|
||||
MY_FLOAT zeroRadius;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,32 +1,58 @@
|
||||
/********************************************/
|
||||
/* Reverb Abstract Class, */
|
||||
/* by Tim Stilson, 1998 */
|
||||
/* */
|
||||
/* Integrated into STK by Gary Scavone */
|
||||
/* with T60 argument. */
|
||||
/********************************************/
|
||||
/***************************************************/
|
||||
/*! \class Reverb
|
||||
\brief STK abstract reverberator parent class.
|
||||
|
||||
#include "Object.h"
|
||||
This class provides common functionality for
|
||||
STK reverberator subclasses.
|
||||
|
||||
#if !defined(__Reverb_h)
|
||||
#define __Reverb_h
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
class Reverb : public Object
|
||||
#include "Stk.h"
|
||||
|
||||
#if !defined(__REVERB_H)
|
||||
#define __REVERB_H
|
||||
|
||||
class Reverb : public Stk
|
||||
{
|
||||
public:
|
||||
Reverb();
|
||||
virtual ~Reverb();
|
||||
virtual MY_FLOAT tick(MY_FLOAT sample);
|
||||
virtual void setEffectMix(MY_FLOAT mix);
|
||||
int isprime(int val);
|
||||
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)
|
||||
#endif // defined(__REVERB_H)
|
||||
|
||||
/* CLM also had JLRev and JLLRev variations on the JCRev: JLRev had
|
||||
longer combs and alpasses, JLLRev further placed the comb coefs
|
||||
closer to 1.0. In my modified testMono.cpp, I allowed for a
|
||||
"JLRev" argument, though JLRev.cpp/.h doesn't exist, testMono
|
||||
simply uses a JCRev but passes a longer base comb length. I also
|
||||
have comments in JCRev.cpp for the JLLRev coefs.
|
||||
*/
|
||||
|
||||
@@ -1,22 +1,57 @@
|
||||
/******************************************/
|
||||
/* Fender Rhodes Electric Piano Subclass */
|
||||
/* of Algorithm 5 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Rhodey
|
||||
\brief STK Fender Rhodes electric piano FM
|
||||
synthesis instrument.
|
||||
|
||||
#if !defined(__Rhodey_h)
|
||||
#define __Rhodey_h
|
||||
This class implements two simple FM Pairs
|
||||
summed together, also referred to as algorithm
|
||||
5 of the TX81Z.
|
||||
|
||||
#include "FM4Alg5.h"
|
||||
\code
|
||||
Algorithm 5 is : 4->3--\
|
||||
+ --> Out
|
||||
2->1--/
|
||||
\endcode
|
||||
|
||||
class Rhodey : public FM4Alg5
|
||||
Control Change Numbers:
|
||||
- Modulator Index One = 2
|
||||
- Crossfade of Outputs = 4
|
||||
- LFO Speed = 11
|
||||
- LFO Depth = 1
|
||||
- ADSR 2 & 4 Target = 128
|
||||
|
||||
The basic Chowning/Stanford FM patent expired
|
||||
in 1995, but there exist follow-on patents,
|
||||
mostly assigned to Yamaha. If you are of the
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RHODEY_H)
|
||||
#define __RHODEY_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
class Rhodey : public FM
|
||||
{
|
||||
public:
|
||||
Rhodey();
|
||||
~Rhodey();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
public:
|
||||
//! Class constructor.
|
||||
Rhodey();
|
||||
|
||||
//! Class destructor.
|
||||
~Rhodey();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,155 +1,434 @@
|
||||
/******************************************/
|
||||
/*
|
||||
RtAudio.cpp
|
||||
Realtime Sound I/O Object for STK
|
||||
by Gary P. Scavone, 1998-2000.
|
||||
|
||||
The sound output sections of this object
|
||||
were originally based in part on code by
|
||||
Doug Scott (SGI), Tim Stilson (Linux),
|
||||
Bill Putnam (Win Wav), and R. Marsanyi
|
||||
(DirectSound). The latest DirectSound
|
||||
code was re-written by Dave Chisholm at
|
||||
CCRMA.
|
||||
|
||||
This object provides a standard API
|
||||
across all platforms for STK realtime
|
||||
audio input/output. Multi-channel
|
||||
support is supported when provided by
|
||||
the soundcard.
|
||||
|
||||
Only 16-bit integer input/output
|
||||
routines are written for the moment
|
||||
though it would be simple to overload
|
||||
the methods for other data types.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__RtAudio_h)
|
||||
#define __RtAudio_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
#if defined(__OS_IRIX_)
|
||||
#include <dmedia/audio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#elif defined(__ALSA_API_)
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/asoundlib.h>
|
||||
|
||||
#elif defined(__OSS_API_)
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/soundcard.h>
|
||||
#include <errno.h>
|
||||
|
||||
#elif defined(__OS_Win_)
|
||||
#include <windows.h>
|
||||
#include <dsound.h>
|
||||
#include <winsock.h>
|
||||
#include "mmsystem.h"
|
||||
|
||||
// this is how often we check for new audio input (milliseconds)
|
||||
#define TIMER_PERIOD 20
|
||||
// the resolution which we tell windows we are willing to tolerate (milliseconds)
|
||||
#define TIMER_RESOLUTION 5
|
||||
// in seconds, doesn't have a real effect on latency
|
||||
#define DS_CAPTURE_BUFFER_SIZE 2
|
||||
// this controls the inherent latency of the output ... more fragments produce
|
||||
// a more stable, though slower, response
|
||||
#define NUM_FRAGMENTS 10
|
||||
#define MAX_DEVICES 10
|
||||
|
||||
typedef struct DeviceInfo {
|
||||
LPGUID guid;
|
||||
char* description;
|
||||
char* moduleName;
|
||||
} DeviceInfo;
|
||||
|
||||
#endif
|
||||
|
||||
class RtAudio : public Object
|
||||
{
|
||||
protected:
|
||||
#if (defined(__STK_REALTIME_) && defined(__OS_IRIX_))
|
||||
int stk_chans;
|
||||
ALport audio_port_in;
|
||||
ALport audio_port_out;
|
||||
|
||||
#elif (defined(__STK_REALTIME_) && defined(__OSS_API_))
|
||||
int audio_fd;
|
||||
|
||||
#elif (defined(__STK_REALTIME_) && defined(__ALSA_API_))
|
||||
snd_pcm_t *ohandle;
|
||||
snd_pcm_t *ihandle;
|
||||
int stk_chans; // the number of channels we want to use
|
||||
int dev_ichans; // the number of input channels the device needs
|
||||
int dev_ochans; // the number of output channels the device needs
|
||||
int ifragsize;
|
||||
int ofragsize;
|
||||
int bytes_per_sample;
|
||||
unsigned int direction;
|
||||
unsigned char *outbuf;
|
||||
unsigned char *inbuf;
|
||||
|
||||
#elif (defined(__STK_REALTIME_) && defined(__OS_Win_) )
|
||||
|
||||
DeviceInfo devices[MAX_DEVICES];
|
||||
int numDevices;
|
||||
char errormsg[256];
|
||||
long inputBufferSize;
|
||||
BYTE *inputBuffer;
|
||||
UINT nextRecordRead, nextRecordWrite;
|
||||
MY_FLOAT sampleRate;
|
||||
|
||||
//these are the variable relating to direct sound output
|
||||
LPDIRECTSOUND directSoundObject;
|
||||
LPDIRECTSOUNDBUFFER directSoundBuffer;
|
||||
DWORD directSoundBufferSize;
|
||||
UINT nextWritePos;
|
||||
|
||||
//direct sound input
|
||||
LPDIRECTSOUNDCAPTURE directSoundCaptureObject;
|
||||
LPDIRECTSOUNDCAPTUREBUFFER directSoundCaptureBuffer;
|
||||
DWORD directSoundCaptureBufferSize;
|
||||
|
||||
// our periodic function will set this flag if something goes wrong
|
||||
bool internalError;
|
||||
bool playing, recording;
|
||||
UINT timerID;
|
||||
|
||||
static void CALLBACK PeriodicCallbackFn(UINT uID, UINT uMsg, DWORD dwUser,
|
||||
DWORD dw1, DWORD dw2);
|
||||
static bool CALLBACK SoundDeviceEnumCallback(LPGUID lpguid,
|
||||
LPCSTR lpcstrDescription,
|
||||
LPCSTR lpcstrModule,
|
||||
LPVOID lpContext);
|
||||
|
||||
void addDevice(LPGUID guid, char* description, char* moduleName);
|
||||
void getInputSamples();
|
||||
static char* getErrorMessage(int code);
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
RtAudio(int channels, MY_FLOAT srate, const char *mode, int device = -1);
|
||||
~RtAudio();
|
||||
int playBuffer(INT16 *buf, int bufsize);
|
||||
int recordBuffer(INT16 *buf, int bufsize);
|
||||
|
||||
#if (defined(__STK_REALTIME_) && defined(__OS_Win_) )
|
||||
// Sets the pointer to its own internal buffer, returning
|
||||
// amount of data available ... slightly more efficient.
|
||||
int recordBuffer(INT16**);
|
||||
void stopPlay();
|
||||
void startPlay();
|
||||
void stopRecord();
|
||||
void startRecord();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
/******************************************/
|
||||
/*
|
||||
RtAudio - realtime sound I/O C++ class
|
||||
by Gary P. Scavone, 2001-2002.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__RTAUDIO_H)
|
||||
#define __RTAUDIO_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#if defined(__LINUX_ALSA__)
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define THREAD_TYPE
|
||||
typedef snd_pcm_t *AUDIO_HANDLE;
|
||||
typedef int DEVICE_ID;
|
||||
typedef pthread_t THREAD_HANDLE;
|
||||
typedef pthread_mutex_t MUTEX;
|
||||
|
||||
#elif defined(__LINUX_OSS__)
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define THREAD_TYPE
|
||||
typedef int AUDIO_HANDLE;
|
||||
typedef int DEVICE_ID;
|
||||
typedef pthread_t THREAD_HANDLE;
|
||||
typedef pthread_mutex_t MUTEX;
|
||||
|
||||
#elif defined(__WINDOWS_DS__)
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
// The following struct is used to hold the extra variables
|
||||
// specific to the DirectSound implementation.
|
||||
typedef struct {
|
||||
void * object;
|
||||
void * buffer;
|
||||
UINT bufferPointer;
|
||||
} AUDIO_HANDLE;
|
||||
|
||||
#define THREAD_TYPE __stdcall
|
||||
typedef LPGUID DEVICE_ID;
|
||||
typedef unsigned long THREAD_HANDLE;
|
||||
typedef CRITICAL_SECTION MUTEX;
|
||||
|
||||
#elif defined(__IRIX_AL__)
|
||||
#include <dmedia/audio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define THREAD_TYPE
|
||||
typedef ALport AUDIO_HANDLE;
|
||||
typedef int DEVICE_ID;
|
||||
typedef pthread_t THREAD_HANDLE;
|
||||
typedef pthread_mutex_t MUTEX;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// *************************************************** //
|
||||
//
|
||||
// RtError class declaration.
|
||||
//
|
||||
// *************************************************** //
|
||||
|
||||
class RtError
|
||||
{
|
||||
public:
|
||||
enum TYPE {
|
||||
WARNING,
|
||||
DEBUG_WARNING,
|
||||
UNSPECIFIED,
|
||||
NO_DEVICES_FOUND,
|
||||
INVALID_DEVICE,
|
||||
INVALID_STREAM,
|
||||
MEMORY_ERROR,
|
||||
INVALID_PARAMETER,
|
||||
DRIVER_ERROR,
|
||||
SYSTEM_ERROR,
|
||||
THREAD_ERROR
|
||||
};
|
||||
|
||||
protected:
|
||||
char error_message[256];
|
||||
TYPE type;
|
||||
|
||||
public:
|
||||
//! The constructor.
|
||||
RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED);
|
||||
|
||||
//! The destructor.
|
||||
virtual ~RtError(void);
|
||||
|
||||
//! Prints "thrown" error message to stdout.
|
||||
virtual void printMessage(void);
|
||||
|
||||
//! Returns the "thrown" error message TYPE.
|
||||
virtual const TYPE& getType(void) { return type; }
|
||||
|
||||
//! Returns the "thrown" error message string.
|
||||
virtual const char *getMessage(void) { return error_message; }
|
||||
};
|
||||
|
||||
|
||||
// *************************************************** //
|
||||
//
|
||||
// RtAudio class declaration.
|
||||
//
|
||||
// *************************************************** //
|
||||
|
||||
class RtAudio
|
||||
{
|
||||
public:
|
||||
|
||||
// Support for signed integers and floats. Audio data fed to/from
|
||||
// the tickStream() routine is assumed to ALWAYS be in host
|
||||
// byte order. The internal routines will automatically take care of
|
||||
// any necessary byte-swapping between the host format and the
|
||||
// soundcard. Thus, endian-ness is not a concern in the following
|
||||
// format definitions.
|
||||
typedef unsigned long RTAUDIO_FORMAT;
|
||||
static const RTAUDIO_FORMAT RTAUDIO_SINT8;
|
||||
static const RTAUDIO_FORMAT RTAUDIO_SINT16;
|
||||
static const RTAUDIO_FORMAT RTAUDIO_SINT24; /*!< Upper 3 bytes of 32-bit integer. */
|
||||
static const RTAUDIO_FORMAT RTAUDIO_SINT32;
|
||||
static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; /*!< Normalized between plus/minus 1.0. */
|
||||
static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; /*!< Normalized between plus/minus 1.0. */
|
||||
|
||||
//static const int MAX_SAMPLE_RATES = 14;
|
||||
enum { MAX_SAMPLE_RATES = 14 };
|
||||
|
||||
typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData);
|
||||
|
||||
typedef struct {
|
||||
char name[128];
|
||||
DEVICE_ID id[2]; /*!< No value reported by getDeviceInfo(). */
|
||||
bool probed; /*!< true if the device capabilities were successfully probed. */
|
||||
int maxOutputChannels;
|
||||
int maxInputChannels;
|
||||
int maxDuplexChannels;
|
||||
int minOutputChannels;
|
||||
int minInputChannels;
|
||||
int minDuplexChannels;
|
||||
bool hasDuplexSupport; /*!< true if device supports duplex mode. */
|
||||
int nSampleRates; /*!< Number of discrete rates or -1 if range supported. */
|
||||
int sampleRates[MAX_SAMPLE_RATES]; /*!< Supported rates or (min, max) if range. */
|
||||
RTAUDIO_FORMAT nativeFormats; /*!< Bit mask of supported data formats. */
|
||||
} RTAUDIO_DEVICE;
|
||||
|
||||
//! The default constructor.
|
||||
/*!
|
||||
Probes the system to make sure at least one audio
|
||||
input/output device is available and determines
|
||||
the api-specific identifier for each device found.
|
||||
An RtError error can be thrown if no devices are
|
||||
found or if a memory allocation error occurs.
|
||||
*/
|
||||
RtAudio();
|
||||
|
||||
//! A constructor which can be used to open a stream during instantiation.
|
||||
/*!
|
||||
The specified output and/or input device identifiers correspond
|
||||
to those enumerated via the getDeviceInfo() method. If device =
|
||||
0, the default or first available devices meeting the given
|
||||
parameters is selected. If an output or input channel value is
|
||||
zero, the corresponding device value is ignored. When a stream is
|
||||
successfully opened, its identifier is returned via the "streamId"
|
||||
pointer. An RtError can be thrown if no devices are found
|
||||
for the given parameters, if a memory allocation error occurs, or
|
||||
if a driver error occurs. \sa openStream()
|
||||
*/
|
||||
RtAudio(int *streamId,
|
||||
int outputDevice, int outputChannels,
|
||||
int inputDevice, int inputChannels,
|
||||
RTAUDIO_FORMAT format, int sampleRate,
|
||||
int *bufferSize, int numberOfBuffers);
|
||||
|
||||
//! The destructor.
|
||||
/*!
|
||||
Stops and closes any open streams and devices and deallocates
|
||||
buffer and structure memory.
|
||||
*/
|
||||
~RtAudio();
|
||||
|
||||
//! A public method for opening a stream with the specified parameters.
|
||||
/*!
|
||||
If successful, the opened stream ID is returned. Otherwise, an
|
||||
RtError is thrown.
|
||||
|
||||
\param outputDevice: If equal to 0, the default or first device
|
||||
found meeting the given parameters is opened. Otherwise, the
|
||||
device number should correspond to one of those enumerated via
|
||||
the getDeviceInfo() method.
|
||||
\param outputChannels: The desired number of output channels. If
|
||||
equal to zero, the outputDevice identifier is ignored.
|
||||
\param inputDevice: If equal to 0, the default or first device
|
||||
found meeting the given parameters is opened. Otherwise, the
|
||||
device number should correspond to one of those enumerated via
|
||||
the getDeviceInfo() method.
|
||||
\param inputChannels: The desired number of input channels. If
|
||||
equal to zero, the inputDevice identifier is ignored.
|
||||
\param format: An RTAUDIO_FORMAT specifying the desired sample data format.
|
||||
\param sampleRate: The desired sample rate (sample frames per second).
|
||||
\param *bufferSize: A pointer value indicating the desired internal buffer
|
||||
size in sample frames. The actual value used by the device is
|
||||
returned via the same pointer. A value of zero can be specified,
|
||||
in which case the lowest allowable value is determined.
|
||||
\param numberOfBuffers: A value which can be used to help control device
|
||||
latency. More buffers typically result in more robust performance,
|
||||
though at a cost of greater latency. A value of zero can be
|
||||
specified, in which case the lowest allowable value is used.
|
||||
*/
|
||||
int openStream(int outputDevice, int outputChannels,
|
||||
int inputDevice, int inputChannels,
|
||||
RTAUDIO_FORMAT 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 specific,
|
||||
previously opened stream for non-blocking stream functionality. A
|
||||
separate process is initiated, though the user function is called
|
||||
only when the stream is "running" (between calls to the
|
||||
startStream() and stopStream() methods, respectively). The
|
||||
callback process remains active for the duration of the stream and
|
||||
is automatically shutdown when the stream is closed (via the
|
||||
closeStream() method or by object destruction). The callback
|
||||
process can also be shutdown and the user function de-referenced
|
||||
through an explicit call to the cancelStreamCallback() method.
|
||||
Note that a single stream can use only blocking or callback
|
||||
functionality at the same time, though it is possible to alternate
|
||||
modes on the same stream through the use of the
|
||||
setStreamCallback() and cancelStreamCallback() methods (the
|
||||
blocking tickStream() method can be used before a callback is set
|
||||
and/or after a callback is cancelled). An RtError will be
|
||||
thrown for an invalid device argument.
|
||||
*/
|
||||
void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData);
|
||||
|
||||
//! A public method which cancels a callback process and function for a given stream.
|
||||
/*!
|
||||
This method shuts down a callback process and de-references the
|
||||
user function for a specific stream. Callback functionality can
|
||||
subsequently be restarted on the stream via the
|
||||
setStreamCallback() method. An RtError will be thrown for an
|
||||
invalid device argument.
|
||||
*/
|
||||
void cancelStreamCallback(int streamId);
|
||||
|
||||
//! A public method which returns the number of audio devices found.
|
||||
int getDeviceCount(void);
|
||||
|
||||
//! Fill a user-supplied RTAUDIO_DEVICE structure for a specified device.
|
||||
/*!
|
||||
Any device between 0 and getDeviceCount()-1 is valid. If a
|
||||
device is busy or otherwise unavailable, the structure member
|
||||
"probed" has a value of "false". The system default input and
|
||||
output devices are referenced by device identifier = 0. On
|
||||
systems which allow dynamic default device settings, the default
|
||||
devices are not identified by name (specific device enumerations
|
||||
are assigned device identifiers > 0). An RtError will be
|
||||
thrown for an invalid device argument.
|
||||
*/
|
||||
void getDeviceInfo(int device, RTAUDIO_DEVICE *info);
|
||||
|
||||
//! A public method which returns a pointer to the buffer for an open stream.
|
||||
/*!
|
||||
The user should fill and/or read the buffer data in interleaved format
|
||||
and then call the tickStream() method. An RtError will be
|
||||
thrown for an invalid stream identifier.
|
||||
*/
|
||||
char * const getStreamBuffer(int streamId);
|
||||
|
||||
//! Public method used to trigger processing of input/output data for a stream.
|
||||
/*!
|
||||
This method blocks until all buffer data is read/written. An
|
||||
RtError will be thrown for an invalid stream identifier or if
|
||||
a driver error occurs.
|
||||
*/
|
||||
void tickStream(int streamId);
|
||||
|
||||
//! Public method which closes a stream and frees any associated buffers.
|
||||
/*!
|
||||
If an invalid stream identifier is specified, this method
|
||||
issues a warning and returns (an RtError is not thrown).
|
||||
*/
|
||||
void closeStream(int streamId);
|
||||
|
||||
//! Public method which starts a stream.
|
||||
/*!
|
||||
An RtError will be thrown for an invalid stream identifier
|
||||
or if a driver error occurs.
|
||||
*/
|
||||
void startStream(int streamId);
|
||||
|
||||
//! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
|
||||
/*!
|
||||
An RtError will be thrown for an invalid stream identifier
|
||||
or if a driver error occurs.
|
||||
*/
|
||||
void stopStream(int streamId);
|
||||
|
||||
//! Stop a stream, discarding any samples remaining in the input/output queue.
|
||||
/*!
|
||||
An RtError will be thrown for an invalid stream identifier
|
||||
or if a driver error occurs.
|
||||
*/
|
||||
void abortStream(int streamId);
|
||||
|
||||
//! Queries a stream to determine whether a call to the tickStream() method will block.
|
||||
/*!
|
||||
A return value of 0 indicates that the stream will NOT block. A positive
|
||||
return value indicates the number of sample frames that cannot yet be
|
||||
processed without blocking.
|
||||
*/
|
||||
int streamWillBlock(int streamId);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES];
|
||||
|
||||
enum { FAILURE, SUCCESS };
|
||||
|
||||
enum STREAM_MODE {
|
||||
PLAYBACK,
|
||||
RECORD,
|
||||
DUPLEX,
|
||||
UNINITIALIZED = -75
|
||||
};
|
||||
|
||||
enum STREAM_STATE {
|
||||
STREAM_STOPPED,
|
||||
STREAM_RUNNING
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int device[2]; // Playback and record, respectively.
|
||||
STREAM_MODE mode; // PLAYBACK, RECORD, or DUPLEX.
|
||||
AUDIO_HANDLE handle[2]; // Playback and record handles, respectively.
|
||||
STREAM_STATE state; // STOPPED or RUNNING
|
||||
char *userBuffer;
|
||||
char *deviceBuffer;
|
||||
bool doConvertBuffer[2]; // Playback and record, respectively.
|
||||
bool deInterleave[2]; // Playback and record, respectively.
|
||||
bool doByteSwap[2]; // Playback and record, respectively.
|
||||
int sampleRate;
|
||||
int bufferSize;
|
||||
int nBuffers;
|
||||
int nUserChannels[2]; // Playback and record, respectively.
|
||||
int nDeviceChannels[2]; // Playback and record channels, respectively.
|
||||
RTAUDIO_FORMAT userFormat;
|
||||
RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively.
|
||||
bool usingCallback;
|
||||
THREAD_HANDLE thread;
|
||||
MUTEX mutex;
|
||||
RTAUDIO_CALLBACK callback;
|
||||
void *userData;
|
||||
} RTAUDIO_STREAM;
|
||||
|
||||
typedef signed short INT16;
|
||||
typedef signed int INT32;
|
||||
typedef float FLOAT32;
|
||||
typedef double FLOAT64;
|
||||
|
||||
char message[256];
|
||||
int nDevices;
|
||||
RTAUDIO_DEVICE *devices;
|
||||
|
||||
std::map<int, void *> streams;
|
||||
|
||||
//! Private error method to allow global control over error handling.
|
||||
void error(RtError::TYPE type);
|
||||
|
||||
/*!
|
||||
Private method to count the system audio devices, allocate the
|
||||
RTAUDIO_DEVICE structures, and probe the device capabilities.
|
||||
*/
|
||||
void initialize(void);
|
||||
|
||||
//! Private method to clear an RTAUDIO_DEVICE structure.
|
||||
void clearDeviceInfo(RTAUDIO_DEVICE *info);
|
||||
|
||||
/*!
|
||||
Private method which attempts to fill an RTAUDIO_DEVICE
|
||||
structure for a given device. If an error is encountered during
|
||||
the probe, a "warning" message is reported and the value of
|
||||
"probed" remains false (no exception is thrown). A successful
|
||||
probe is indicated by probed = true.
|
||||
*/
|
||||
void probeDeviceInfo(RTAUDIO_DEVICE *info);
|
||||
|
||||
/*!
|
||||
Private method which attempts to open a device with the given parameters.
|
||||
If an error is encountered during the probe, a "warning" message is
|
||||
reported and FAILURE is returned (no exception is thrown). A
|
||||
successful probe is indicated by a return value of SUCCESS.
|
||||
*/
|
||||
bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream,
|
||||
STREAM_MODE mode, int channels,
|
||||
int sampleRate, RTAUDIO_FORMAT format,
|
||||
int *bufferSize, int numberOfBuffers);
|
||||
|
||||
/*!
|
||||
Private common method used to check validity of a user-passed
|
||||
stream ID. When the ID is valid, this method returns a pointer to
|
||||
an RTAUDIO_STREAM structure (in the form of a void pointer).
|
||||
Otherwise, an "invalid identifier" exception is thrown.
|
||||
*/
|
||||
void *verifyStream(int streamId);
|
||||
|
||||
/*!
|
||||
Private method used to perform format, channel number, and/or interleaving
|
||||
conversions between the user and device buffers.
|
||||
*/
|
||||
void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode);
|
||||
|
||||
//! Private method used to perform byte-swapping on buffers.
|
||||
void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format);
|
||||
|
||||
//! Private method which returns the number of bytes for a given format.
|
||||
int formatBytes(RTAUDIO_FORMAT format);
|
||||
};
|
||||
|
||||
// Uncomment the following definition to have extra information spewed to stderr.
|
||||
//#define RTAUDIO_DEBUG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,39 +1,99 @@
|
||||
/*******************************************/
|
||||
/* Real-Time Duplex Input/Output Class, */
|
||||
/* by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* This object opens the sound i/o */
|
||||
/* device, reads buffers in from it, and */
|
||||
/* pokes buffers of samples out to it. */
|
||||
/* */
|
||||
/* At the moment, duplex mode is possible */
|
||||
/* only on Linux (OSS), IRIX, and */
|
||||
/* Windows95/98 platforms. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__RtDuplex_h)
|
||||
#define __RtDuplex_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
class RtDuplex : public Object
|
||||
{
|
||||
protected:
|
||||
RtAudio *sound_dev;
|
||||
INT16 *indata;
|
||||
INT16 *outdata;
|
||||
long data_length;
|
||||
long readCounter;
|
||||
long writeCounter;
|
||||
int channels;
|
||||
MY_FLOAT gain;
|
||||
MY_FLOAT *insamples;
|
||||
public:
|
||||
RtDuplex(int chans = 1, MY_FLOAT srate = SRATE, int device = -1);
|
||||
~RtDuplex();
|
||||
MY_FLOAT tick(MY_FLOAT outsample);
|
||||
MY_MULTI mtick(MY_MULTI outsamples);
|
||||
};
|
||||
|
||||
#endif // defined(__RtDuplex_h)
|
||||
/***************************************************/
|
||||
/*! \class RtDuplex
|
||||
\brief STK realtime audio 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.
|
||||
|
||||
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.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTDUPLEX_H)
|
||||
#define __RTDUPLEX_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
class RtDuplex : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
/*!
|
||||
The \e device argument is passed to RtAudio during
|
||||
instantiation. The default value (zero) will select the default
|
||||
device on your system or the first device found meeting the
|
||||
specified parameters. On systems with multiple
|
||||
soundcards/devices, values greater than zero can be specified in
|
||||
accordance with the order that the devices are enumerated by the
|
||||
underlying audio API. The default buffer size of RT_BUFFER_SIZE
|
||||
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);
|
||||
|
||||
//! Class destructor.
|
||||
~RtDuplex();
|
||||
|
||||
//! Start the audio input/output stream.
|
||||
/*!
|
||||
The stream is started automatically, if necessary, when a tick() or tickFrame method is called.
|
||||
*/
|
||||
void start(void);
|
||||
|
||||
//! Stop the audio input/output stream.
|
||||
/*!
|
||||
It may be necessary to use this method to avoid audio overflow/underflow problems if you wish to temporarily stop the audio stream.
|
||||
*/
|
||||
void stop(void);
|
||||
|
||||
//! Return the average across the last output sample frame.
|
||||
MY_FLOAT 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);
|
||||
|
||||
//! Output each sample in \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);
|
||||
|
||||
//! Return a pointer to the last output sample frame.
|
||||
const MY_FLOAT *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);
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
MY_FLOAT *data;
|
||||
MY_FLOAT *lastOutput;
|
||||
int bufferSize;
|
||||
bool stopped;
|
||||
int stream;
|
||||
long counter;
|
||||
unsigned int channels;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
146
include/RtMidi.h
146
include/RtMidi.h
@@ -1,66 +1,80 @@
|
||||
/******************************************/
|
||||
/*
|
||||
RtMidi.cpp
|
||||
Realtime MIDI I/O Object for STK,
|
||||
by Gary P. Scavone, 1998-2000.
|
||||
Based in part on code by Perry
|
||||
Cook (SGI), Paul Leonard (Linux),
|
||||
the RoseGarden team (Linux), and
|
||||
Bill Putnam (Win95/NT).
|
||||
|
||||
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 object opens a MIDI input device
|
||||
and parses MIDI messages into a MIDI
|
||||
buffer. Time stamp info is converted
|
||||
to deltaTime. MIDI data is stored as
|
||||
MY_FLOAT to conform with SKINI.
|
||||
|
||||
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 or a list of available
|
||||
devices is printed to allow selection
|
||||
by the user.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__RtMidi_h)
|
||||
#define __RtMidi_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
class RtMidi : public Object
|
||||
{
|
||||
protected:
|
||||
int messageType;
|
||||
int channel;
|
||||
float byteTwo;
|
||||
float byteThree;
|
||||
MY_FLOAT deltaTime;
|
||||
public:
|
||||
RtMidi(int device = -1);
|
||||
~RtMidi();
|
||||
void printMessage();
|
||||
int nextMessage();
|
||||
int getType();
|
||||
int getChannel();
|
||||
MY_FLOAT getByteTwo();
|
||||
MY_FLOAT getByteThree();
|
||||
MY_FLOAT getDeltaTime();
|
||||
};
|
||||
|
||||
#if defined(__OS_Win_)
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
static void CALLBACK midiInputCallback( HMIDIOUT hmin, UINT inputStatus,
|
||||
DWORD instancePtr, DWORD midiMessage, DWORD timestamp);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class RtMidi
|
||||
\brief STK realtime MIDI class.
|
||||
|
||||
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 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.
|
||||
|
||||
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.
|
||||
|
||||
This code is based in part on work of Perry
|
||||
Cook (SGI), Paul Leonard (Linux), the
|
||||
RoseGarden team (Linux), and Bill Putnam
|
||||
(Windows).
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTMIDI_H)
|
||||
#define __RTMIDI_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class RtMidi : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor with optional device argument.
|
||||
RtMidi(int device = 0);
|
||||
|
||||
//! Class destructor.
|
||||
~RtMidi();
|
||||
|
||||
//! Print out the current message values.
|
||||
void printMessage(void) const;
|
||||
|
||||
//! Check for and parse a new MIDI message in the queue, returning its type.
|
||||
/*!
|
||||
If a new message is found, the return value is greater than zero.
|
||||
*/
|
||||
int nextMessage(void);
|
||||
|
||||
//! Return the current message type.
|
||||
int getType() const;
|
||||
|
||||
//! Return the current message channel value.
|
||||
int getChannel() 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 delta time value in seconds.
|
||||
MY_FLOAT getDeltaTime() const;
|
||||
|
||||
protected:
|
||||
int messageType;
|
||||
int channel;
|
||||
float byteTwo;
|
||||
float byteThree;
|
||||
MY_FLOAT deltaTime;
|
||||
int readIndex;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
145
include/RtWvIn.h
145
include/RtWvIn.h
@@ -1,45 +1,100 @@
|
||||
/*******************************************/
|
||||
/* RtWvIn Input Class, */
|
||||
/* by Gary P. Scavone, 1999-2000 */
|
||||
/* */
|
||||
/* This object inherits from WvIn and is */
|
||||
/* used to read in realtime 16-bit data */
|
||||
/* from a computer's audio port. */
|
||||
/* */
|
||||
/* NOTE: This object is NOT intended for */
|
||||
/* use in achieving simultaneous realtime */
|
||||
/* audio input/output (together with */
|
||||
/* RtWvOut). Under certain circumstances */
|
||||
/* such a scheme is possible, though you */
|
||||
/* should definitely know what you are */
|
||||
/* doing before trying. For safer "full- */
|
||||
/* duplex" operation, use the RtDuplex */
|
||||
/* class. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__RtWvIn_h)
|
||||
#define __RtWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "RtAudio.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class RtWvIn : public WvIn
|
||||
{
|
||||
protected:
|
||||
RtAudio *sound_dev;
|
||||
INT16 *rtdata;
|
||||
INT16 *lastSamples;
|
||||
MY_FLOAT gain;
|
||||
void getData(long index);
|
||||
public:
|
||||
RtWvIn(int chans = 1, MY_FLOAT srate = SRATE, int device = -1);
|
||||
~RtWvIn();
|
||||
void setRate(MY_FLOAT aRate);
|
||||
void addTime(MY_FLOAT aTime);
|
||||
void setLooping(int aLoopStatus);
|
||||
long getSize();
|
||||
int informTick();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class RtWvIn
|
||||
\brief STK realtime audio input class.
|
||||
|
||||
This class provides a simplified interface to
|
||||
RtAudio for realtime audio input. It is a
|
||||
protected subclass of WvIn.
|
||||
|
||||
RtWvIn 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.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTWVIN_H)
|
||||
#define __RTWVIN_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "WvIn.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
class RtWvIn : protected WvIn
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
/*!
|
||||
The \e device argument is passed to RtAudio during
|
||||
instantiation. The default value (zero) will select the default
|
||||
device on your system or the first device found meeting the
|
||||
specified parameters. On systems with multiple
|
||||
soundcards/devices, values greater than zero can be specified in
|
||||
accordance with the order that the devices are enumerated by the
|
||||
underlying audio API. The default buffer size of RT_BUFFER_SIZE
|
||||
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);
|
||||
|
||||
//! Class destructor.
|
||||
~RtWvIn();
|
||||
|
||||
//! Start the audio input stream.
|
||||
/*!
|
||||
The stream is started automatically, if necessary, when a tick() or tickFrame method is called.
|
||||
*/
|
||||
void start(void);
|
||||
|
||||
//! Stop the audio input stream.
|
||||
/*!
|
||||
It may be necessary to use this method to avoid audio underflow problems if you wish to temporarily stop audio input.
|
||||
*/
|
||||
void stop(void);
|
||||
|
||||
//! Return the average across the last output sample frame.
|
||||
MY_FLOAT 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);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Return a pointer to the last output sample frame.
|
||||
const MY_FLOAT *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);
|
||||
|
||||
//! 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);
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
bool stopped;
|
||||
int stream;
|
||||
long counter;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,36 +1,92 @@
|
||||
/*******************************************/
|
||||
/* Real-Time Audio Output Class, */
|
||||
/* by Perry R. Cook, 1996 */
|
||||
/* Revised by Gary P. Scavone, 2000 */
|
||||
/* */
|
||||
/* This object opens a realtime soundout */
|
||||
/* device, and pokes buffers of samples */
|
||||
/* into it. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__RtWvOut_h)
|
||||
#define __RtWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
class RtWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
RtAudio *sound_dev;
|
||||
public:
|
||||
RtWvOut(int chans = 1, int device = -1);
|
||||
~RtWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
|
||||
#if (defined(__OS_Win_) )
|
||||
void stopPlay();
|
||||
void startPlay();
|
||||
void stopRecord();
|
||||
void startRecord();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // defined(__RtWvOut_h)
|
||||
/***************************************************/
|
||||
/*! \class RtWvOut
|
||||
\brief STK realtime audio output class.
|
||||
|
||||
This class provides a simplified interface to
|
||||
RtAudio for realtime audio output. It is a
|
||||
protected subclass of WvOut.
|
||||
|
||||
RtWvOut 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, from the tickFrame() method, which
|
||||
takes a pointer to multi-channel sample
|
||||
frame data.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTWVOUT_H)
|
||||
#define __RTWVOUT_H
|
||||
|
||||
#include "WvOut.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
class RtWvOut : protected WvOut
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
/*!
|
||||
The \e device argument is passed to RtAudio during
|
||||
instantiation. The default value (zero) will select the default
|
||||
device on your system or the first device found meeting the
|
||||
specified parameters. On systems with multiple
|
||||
soundcards/devices, values greater than zero can be specified in
|
||||
accordance with the order that the devices are enumerated by the
|
||||
underlying audio API. The default buffer size of RT_BUFFER_SIZE
|
||||
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 );
|
||||
|
||||
//! Class destructor.
|
||||
~RtWvOut();
|
||||
|
||||
//! Start the audio output stream.
|
||||
/*!
|
||||
The stream is started automatically, if necessary, when a tick() or tickFrame method is called.
|
||||
*/
|
||||
void start(void);
|
||||
|
||||
//! Stop the audio output stream.
|
||||
/*!
|
||||
It may be necessary to use this method to avoid undesireable audio buffer cycling if you wish to temporarily stop audio output.
|
||||
*/
|
||||
void stop(void);
|
||||
|
||||
//! Return the number of sample frames output.
|
||||
unsigned long getFrames( void ) const;
|
||||
|
||||
//! Return the number of seconds of data output.
|
||||
MY_FLOAT 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);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! 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);
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
bool stopped;
|
||||
int stream;
|
||||
int bufferSize;
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__RTWVOUT_H)
|
||||
|
||||
127
include/SKINI.h
Normal file
127
include/SKINI.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/***************************************************/
|
||||
/*! \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
|
||||
|
||||
|
||||
@@ -1,120 +1,123 @@
|
||||
/*************************************************************/
|
||||
/* */
|
||||
/* DEFINITION of SKINI Message Types and Special Symbols */
|
||||
/* Synthesis toolKit Instrument Network Interface */
|
||||
/* */
|
||||
/* These symbols should have the form __SK_<name>_ */
|
||||
/* */
|
||||
/* Where <name> is the string used in the SKINI stream */
|
||||
/*************************************************************/
|
||||
|
||||
/***** MIDI COMPATIBLE MESSAGES ***/
|
||||
/***** STATUS BYTES Have Chan=0 **/
|
||||
|
||||
#define NOPE -32767
|
||||
#define YEP 1
|
||||
#define SK_DBL -32766
|
||||
#define SK_INT -32765
|
||||
#define SK_STR -32764
|
||||
|
||||
#define __SK_NoteOff_ 128
|
||||
#define __SK_NoteOn_ 144
|
||||
#define __SK_PolyPressure_ 160
|
||||
#define __SK_ControlChange_ 176
|
||||
#define __SK_ProgramChange_ 192
|
||||
#define __SK_AfterTouch_ 208
|
||||
#define __SK_ChannelPressure_ __SK_AfterTouch_
|
||||
#define __SK_PitchWheel_ 224
|
||||
#define __SK_PitchBend_ __SK_PitchWheel_
|
||||
|
||||
#define __SK_Clock_ 248
|
||||
#define __SK_SongStart_ 250
|
||||
#define __SK_Continue_ 251
|
||||
#define __SK_SongStop_ 252
|
||||
#define __SK_ActiveSensing_ 254
|
||||
#define __SK_SystemReset_ 255
|
||||
|
||||
#define __SK_Volume_ 7
|
||||
#define __SK_ModWheel_ 1
|
||||
#define __SK_Modulation_ __SK_ModWheel_
|
||||
#define __SK_Breath_ 2
|
||||
#define __SK_FootControl_ 4
|
||||
#define __SK_Portamento_ 65
|
||||
#define __SK_Balance_ 8
|
||||
#define __SK_Pan_ 10
|
||||
#define __SK_Sustain_ 64
|
||||
#define __SK_Damper_ __SK_Sustain_
|
||||
#define __SK_Expression_ 11
|
||||
|
||||
#define __SK_AfterTouch_Cont_ 128
|
||||
#define __SK_ModFrequency_ __SK_Expression_
|
||||
|
||||
#define __SK_ProphesyRibbon_ 16
|
||||
#define __SK_ProphesyWheelUp_ 2
|
||||
#define __SK_ProphesyWheelDown_ 3
|
||||
#define __SK_ProphesyPedal_ 18
|
||||
#define __SK_ProphesyKnob1_ 21
|
||||
#define __SK_ProphesyKnob2_ 22
|
||||
|
||||
/*** Instrument Family Specific **/
|
||||
|
||||
#define __SK_NoiseLevel_ __SK_FootControl_
|
||||
|
||||
#define __SK_PickPosition_ __SK_FootControl_
|
||||
#define __SK_StringDamping_ __SK_Expression_
|
||||
#define __SK_StringDetune_ __SK_ModWheel_
|
||||
#define __SK_BodySize_ __SK_Breath_
|
||||
#define __SK_BowPressure_ __SK_Breath_
|
||||
#define __SK_BowPosition_ __SK_PickPosition_
|
||||
#define __SK_BowBeta_ __SK_BowPosition_
|
||||
|
||||
#define __SK_ReedStiffness_ __SK_Breath_
|
||||
#define __SK_ReedRestPos_ __SK_FootControl_
|
||||
|
||||
#define __SK_FluteEmbouchure_ __SK_Breath_
|
||||
#define __SK_JetDelay_ __SK_FluteEmbouchure_
|
||||
|
||||
#define __SK_LipTension_ __SK_Breath_
|
||||
#define __SK_SlideLength_ __SK_FootControl_
|
||||
|
||||
#define __SK_StrikePosition_ __SK_PickPosition_
|
||||
#define __SK_StickHardness_ __SK_Breath_
|
||||
|
||||
#define __SK_TrillDepth_ 1051
|
||||
#define __SK_TrillSpeed_ 1052
|
||||
#define __SK_StrumSpeed_ __SK_TrillSpeed_
|
||||
#define __SK_RollSpeed_ __SK_TrillSpeed_
|
||||
|
||||
#define __SK_FilterQ_ __SK_Breath_
|
||||
#define __SK_FilterFreq_ 1062
|
||||
#define __SK_FilterSweepRate_ __SK_FootControl_
|
||||
|
||||
#define __SK_ShakerInst_ 1071
|
||||
#define __SK_ShakerEnergy_ __SK_Breath_
|
||||
#define __SK_ShakerDamping_ __SK_ModFrequency_
|
||||
#define __SK_ShakerNumObjects_ __SK_FootControl_
|
||||
|
||||
#define __SK_Strumming_ 1090
|
||||
#define __SK_NotStrumming_ 1091
|
||||
#define __SK_Trilling_ 1092
|
||||
#define __SK_NotTrilling_ 1093
|
||||
#define __SK_Rolling_ __SK_Strumming_
|
||||
#define __SK_NotRolling_ __SK_NotStrumming_
|
||||
|
||||
#define __SK_PlayerSkill_ 2001
|
||||
#define __SK_Chord_ 2002
|
||||
#define __SK_ChordOff_ 2003
|
||||
|
||||
#define __SK_SINGER_FilePath_ 3000
|
||||
#define __SK_SINGER_Frequency_ 3001
|
||||
#define __SK_SINGER_NoteName_ 3002
|
||||
#define __SK_SINGER_Shape_ 3003
|
||||
#define __SK_SINGER_Glot_ 3004
|
||||
#define __SK_SINGER_VoicedUnVoiced_ 3005
|
||||
#define __SK_SINGER_Synthesize_ 3006
|
||||
#define __SK_SINGER_Silence_ 3007
|
||||
#define __SK_SINGER_VibratoAmt_ __SK_ModWheel_
|
||||
#define __SK_SINGER_RndVibAmt_ 3008
|
||||
#define __SK_SINGER_VibFreq_ __SK_Expression_
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
/*
|
||||
Definition of SKINI Message Types and Special Symbols
|
||||
Synthesis toolKit Instrument Network Interface
|
||||
|
||||
These symbols should have the form __SK_<name>_
|
||||
|
||||
Where <name> is the string used in the SKINI stream.
|
||||
|
||||
by Perry R. Cook, 1995 - 2002.
|
||||
*/
|
||||
/*********************************************************/
|
||||
|
||||
/***** 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_NoteOff_ 128
|
||||
#define __SK_NoteOn_ 144
|
||||
#define __SK_PolyPressure_ 160
|
||||
#define __SK_ControlChange_ 176
|
||||
#define __SK_ProgramChange_ 192
|
||||
#define __SK_AfterTouch_ 208
|
||||
#define __SK_ChannelPressure_ __SK_AfterTouch_
|
||||
#define __SK_PitchWheel_ 224
|
||||
#define __SK_PitchBend_ __SK_PitchWheel_
|
||||
|
||||
#define __SK_Clock_ 248
|
||||
#define __SK_SongStart_ 250
|
||||
#define __SK_Continue_ 251
|
||||
#define __SK_SongStop_ 252
|
||||
#define __SK_ActiveSensing_ 254
|
||||
#define __SK_SystemReset_ 255
|
||||
|
||||
#define __SK_Volume_ 7
|
||||
#define __SK_ModWheel_ 1
|
||||
#define __SK_Modulation_ __SK_ModWheel_
|
||||
#define __SK_Breath_ 2
|
||||
#define __SK_FootControl_ 4
|
||||
#define __SK_Portamento_ 65
|
||||
#define __SK_Balance_ 8
|
||||
#define __SK_Pan_ 10
|
||||
#define __SK_Sustain_ 64
|
||||
#define __SK_Damper_ __SK_Sustain_
|
||||
#define __SK_Expression_ 11
|
||||
|
||||
#define __SK_AfterTouch_Cont_ 128
|
||||
#define __SK_ModFrequency_ __SK_Expression_
|
||||
|
||||
#define __SK_ProphesyRibbon_ 16
|
||||
#define __SK_ProphesyWheelUp_ 2
|
||||
#define __SK_ProphesyWheelDown_ 3
|
||||
#define __SK_ProphesyPedal_ 18
|
||||
#define __SK_ProphesyKnob1_ 21
|
||||
#define __SK_ProphesyKnob2_ 22
|
||||
|
||||
/*** Instrument Family Specific ***/
|
||||
|
||||
#define __SK_NoiseLevel_ __SK_FootControl_
|
||||
|
||||
#define __SK_PickPosition_ __SK_FootControl_
|
||||
#define __SK_StringDamping_ __SK_Expression_
|
||||
#define __SK_StringDetune_ __SK_ModWheel_
|
||||
#define __SK_BodySize_ __SK_Breath_
|
||||
#define __SK_BowPressure_ __SK_Breath_
|
||||
#define __SK_BowPosition_ __SK_PickPosition_
|
||||
#define __SK_BowBeta_ __SK_BowPosition_
|
||||
|
||||
#define __SK_ReedStiffness_ __SK_Breath_
|
||||
#define __SK_ReedRestPos_ __SK_FootControl_
|
||||
|
||||
#define __SK_FluteEmbouchure_ __SK_Breath_
|
||||
#define __SK_JetDelay_ __SK_FluteEmbouchure_
|
||||
|
||||
#define __SK_LipTension_ __SK_Breath_
|
||||
#define __SK_SlideLength_ __SK_FootControl_
|
||||
|
||||
#define __SK_StrikePosition_ __SK_PickPosition_
|
||||
#define __SK_StickHardness_ __SK_Breath_
|
||||
|
||||
#define __SK_TrillDepth_ 1051
|
||||
#define __SK_TrillSpeed_ 1052
|
||||
#define __SK_StrumSpeed_ __SK_TrillSpeed_
|
||||
#define __SK_RollSpeed_ __SK_TrillSpeed_
|
||||
|
||||
#define __SK_FilterQ_ __SK_Breath_
|
||||
#define __SK_FilterFreq_ 1062
|
||||
#define __SK_FilterSweepRate_ __SK_FootControl_
|
||||
|
||||
#define __SK_ShakerInst_ 1071
|
||||
#define __SK_ShakerEnergy_ __SK_Breath_
|
||||
#define __SK_ShakerDamping_ __SK_ModFrequency_
|
||||
#define __SK_ShakerNumObjects_ __SK_FootControl_
|
||||
|
||||
#define __SK_Strumming_ 1090
|
||||
#define __SK_NotStrumming_ 1091
|
||||
#define __SK_Trilling_ 1092
|
||||
#define __SK_NotTrilling_ 1093
|
||||
#define __SK_Rolling_ __SK_Strumming_
|
||||
#define __SK_NotRolling_ __SK_NotStrumming_
|
||||
|
||||
#define __SK_PlayerSkill_ 2001
|
||||
#define __SK_Chord_ 2002
|
||||
#define __SK_ChordOff_ 2003
|
||||
|
||||
#define __SK_SINGER_FilePath_ 3000
|
||||
#define __SK_SINGER_Frequency_ 3001
|
||||
#define __SK_SINGER_NoteName_ 3002
|
||||
#define __SK_SINGER_Shape_ 3003
|
||||
#define __SK_SINGER_Glot_ 3004
|
||||
#define __SK_SINGER_VoicedUnVoiced_ 3005
|
||||
#define __SK_SINGER_Synthesize_ 3006
|
||||
#define __SK_SINGER_Silence_ 3007
|
||||
#define __SK_SINGER_VibratoAmt_ __SK_ModWheel_
|
||||
#define __SK_SINGER_RndVibAmt_ 3008
|
||||
#define __SK_SINGER_VibFreq_ __SK_Expression_
|
||||
|
||||
|
||||
130
include/SKINI.tbl
Normal file
130
include/SKINI.tbl
Normal file
@@ -0,0 +1,130 @@
|
||||
|
||||
#include "SKINI.msg"
|
||||
|
||||
#define __SK_MaxMsgTypes_ 128
|
||||
|
||||
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 */
|
||||
|
||||
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},
|
||||
|
||||
{"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},
|
||||
|
||||
{"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 },
|
||||
|
||||
{"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL},
|
||||
|
||||
{"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 },
|
||||
|
||||
{"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}
|
||||
};
|
||||
|
||||
|
||||
/** FORMAT: *************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
/* 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 */
|
||||
/* 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, */
|
||||
/* 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, */
|
||||
/* 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 */
|
||||
/* message. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
@@ -1,58 +0,0 @@
|
||||
/******************************************/
|
||||
/* 3rd generation SKINI Text File Reader */
|
||||
/* Class, by Perry R. Cook, 1999 */
|
||||
/* This Object can open a SKINI File */
|
||||
/* and parse it. The file spec is mine */
|
||||
/* and mine alone, but it's all text so */
|
||||
/* that should help you figuring it out. */
|
||||
/* */
|
||||
/* SKINI (Synthesis toolKit Instrument */
|
||||
/* Network Interface) is like MIDI, but */
|
||||
/* allows for floating point control */
|
||||
/* changes, note numbers, etc. Example: */
|
||||
/* noteOn 60.01 111.132 plays a sharp */
|
||||
/* middle C with a velocity of 111.132 */
|
||||
/* See SKINI.txt for more information */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__SKINI11_h)
|
||||
#define __SKINI11_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class SKINI11 : public Object
|
||||
{
|
||||
protected:
|
||||
FILE *myFile;
|
||||
int messageType;
|
||||
char msgTypeString[64];
|
||||
int channel;
|
||||
MY_FLOAT deltaTime;
|
||||
MY_FLOAT byteTwo;
|
||||
MY_FLOAT byteThree;
|
||||
long byteTwoInt;
|
||||
long byteThreeInt;
|
||||
char remainderString[1024];
|
||||
public:
|
||||
SKINI11(char *fileName);
|
||||
SKINI11();
|
||||
~SKINI11();
|
||||
long parseThis(char* aString);
|
||||
long nextMessage();
|
||||
long getType();
|
||||
long getChannel();
|
||||
MY_FLOAT getDelta();
|
||||
MY_FLOAT getByteTwo();
|
||||
MY_FLOAT getByteThree();
|
||||
long getByteTwoInt();
|
||||
long getByteThreeInt();
|
||||
char* getRemainderString();
|
||||
char* getMessageTypeString();
|
||||
char* whatsThisType(long type);
|
||||
char* whatsThisController(long type);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*******************************************/
|
||||
/* Swept Filter SubClass of Sampling */
|
||||
/* Synthesizer, by Perry R. Cook, 1995-96*/
|
||||
/* This instrument inherits up to 5 */
|
||||
/* attack waves, 5 looped waves, an ADSR */
|
||||
/* envelope, and adds a 4 pole swept */
|
||||
/* filter. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__SamplFlt_h)
|
||||
#define __SamplFlt_h
|
||||
|
||||
#include "Sampler.h"
|
||||
#include "FormSwep.h"
|
||||
#include "TwoZero.h"
|
||||
|
||||
class SamplFlt : public Sampler
|
||||
{
|
||||
protected:
|
||||
FormSwep *filters[2];
|
||||
TwoZero *twozeroes[2];
|
||||
public:
|
||||
SamplFlt();
|
||||
virtual ~SamplFlt();
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,42 +1,65 @@
|
||||
/*******************************************/
|
||||
/* Master Class for Sampling Synthesizer */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This instrument contains up to 5 */
|
||||
/* attack waves, 5 looped waves, and */
|
||||
/* an ADSR envelope. */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Sampler
|
||||
\brief STK sampling synthesis abstract base class.
|
||||
|
||||
#if !defined(__Sampler_h)
|
||||
#define __Sampler_h
|
||||
This instrument contains up to 5 attack waves,
|
||||
5 looped waves, and an ADSR envelope.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SAMPLER_H)
|
||||
#define __SAMPLER_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Sampler : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
Sampler();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Sampler();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency) = 0;
|
||||
|
||||
//! Initiate the envelopes with a key-on event and reset the attack waves.
|
||||
void keyOn();
|
||||
|
||||
//! Signal a key-off event to the envelopes.
|
||||
void keyOff();
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value) = 0;
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
RawWvIn *attacks[5];
|
||||
RawWvIn *loops[5];
|
||||
WvIn *attacks[5];
|
||||
WaveLoop *loops[5];
|
||||
OnePole *filter;
|
||||
MY_FLOAT baseFreq;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT attackRatios[5];
|
||||
MY_FLOAT loopRatios[5];
|
||||
MY_FLOAT attackGain;
|
||||
MY_FLOAT loopGain;
|
||||
int whichOne;
|
||||
public:
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
100
include/Saxofony.h
Normal file
100
include/Saxofony.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************/
|
||||
/*! \class Saxofony
|
||||
\brief STK faux conical bore reed instrument class.
|
||||
|
||||
This class implements a "hybrid" digital
|
||||
waveguide instrument that can generate a
|
||||
variety of wind-like sounds. It has also been
|
||||
referred to as the "blowed string" model. The
|
||||
waveguide section is essentially that of a
|
||||
string, with one rigid and one lossy
|
||||
termination. The non-linear function is a
|
||||
reed table. The string can be "blown" at any
|
||||
point between the terminations, though just as
|
||||
with strings, it is impossible to excite the
|
||||
system at either end. If the excitation is
|
||||
placed at the string mid-point, the sound is
|
||||
that of a clarinet. At points closer to the
|
||||
"bridge", the sound is closer to that of a
|
||||
saxophone. See Scavone (2002) for more details.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by Stanford
|
||||
University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Reed Stiffness = 2
|
||||
- Reed Aperture = 26
|
||||
- Noise Gain = 4
|
||||
- Blow Position = 11
|
||||
- Vibrato Frequency = 29
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SAXOFONY_H)
|
||||
#define __SAXOFONY_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "OneZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Saxofony : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Saxofony(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Saxofony();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the "blowing" position between the air column terminations (0.0 - 1.0).
|
||||
void setBlowPosition(MY_FLOAT aPosition);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,39 +1,102 @@
|
||||
/**********************************************************/
|
||||
/* PhISEM (Physically Informed Stochastic Event Modeling */
|
||||
/* by Perry R. Cook, Princeton, February 1997 */
|
||||
/* */
|
||||
/* Meta-model that simulates all of: */
|
||||
/* Maraca Simulation by Perry R. Cook, Princeton, 1996-7 */
|
||||
/* Sekere Simulation by Perry R. Cook, Princeton, 1996-7 */
|
||||
/* Cabasa Simulation by Perry R. Cook, Princeton, 1996-7 */
|
||||
/* Bamboo Windchime Simulation, by Perry R. Cook, 1996-7 */
|
||||
/* Water Drops Simulation, by Perry R. Cook, 1996-7 */
|
||||
/* Tambourine Simulation, by Perry R. Cook, 1996-7 */
|
||||
/* Sleighbells Simulation, by Perry R. Cook, 1996-7 */
|
||||
/* Guiro Simulation, by Perry R. Cook, 1996-7 */
|
||||
/* */
|
||||
/**********************************************************/
|
||||
/* PhOLIES (Physically-Oriented Library of */
|
||||
/* Imitated Environmental Sounds), Perry Cook, 1997-9 */
|
||||
/* Stix1 (walking on brittle sticks) */
|
||||
/* Crunch1 (like new fallen snow, or not) */
|
||||
/* Wrench (basic socket wrench, friend of guiro) */
|
||||
/* Sandpapr (sandpaper) */
|
||||
/**********************************************************/
|
||||
/***************************************************/
|
||||
/*! \class Shakers
|
||||
\brief PhISEM and PhOLIES class.
|
||||
|
||||
#if !defined(__Shakers_h)
|
||||
#define __Shakers_h
|
||||
PhISEM (Physically Informed Stochastic Event
|
||||
Modeling) is an algorithmic approach for
|
||||
simulating collisions of multiple independent
|
||||
sound producing objects. This class is a
|
||||
meta-model that can simulate a Maraca, Sekere,
|
||||
Cabasa, Bamboo Wind Chimes, Water Drops,
|
||||
Tambourine, Sleighbells, and a Guiro.
|
||||
|
||||
PhOLIES (Physically-Oriented Library of
|
||||
Imitated Environmental Sounds) is a similar
|
||||
approach for the synthesis of environmental
|
||||
sounds. This class implements simulations of
|
||||
breaking sticks, crunchy snow (or not), a
|
||||
wrench, sandpaper, and more.
|
||||
|
||||
Control Change Numbers:
|
||||
- Shake Energy = 2
|
||||
- System Decay = 4
|
||||
- Number Of Objects = 11
|
||||
- Resonance Frequency = 1
|
||||
- Shake Energy = 128
|
||||
- Instrument Selection = 1071
|
||||
- Maraca = 0
|
||||
- Cabasa = 1
|
||||
- Sekere = 2
|
||||
- Guiro = 3
|
||||
- Water Drops = 4
|
||||
- Bamboo Chimes = 5
|
||||
- Tambourine = 6
|
||||
- Sleigh Bells = 7
|
||||
- Sticks = 8
|
||||
- Crunch = 9
|
||||
- Wrench = 10
|
||||
- Sand Paper = 11
|
||||
- Coke Can = 12
|
||||
- Next Mug = 13
|
||||
- Penny + Mug = 14
|
||||
- Nickle + Mug = 15
|
||||
- Dime + Mug = 16
|
||||
- Quarter + Mug = 17
|
||||
- Franc + Mug = 18
|
||||
- Peso + Mug = 19
|
||||
- Big Rocks = 20
|
||||
- Little Rocks = 21
|
||||
- Tuned Bamboo Chimes = 22
|
||||
|
||||
by Perry R. Cook, 1996 - 1999.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SHAKERS_H)
|
||||
#define __SHAKERS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
|
||||
#define MAX_FREQS 8
|
||||
#define NUM_INSTR 13
|
||||
#define NUM_INSTR 24
|
||||
|
||||
class Shakers : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
int instType;
|
||||
public:
|
||||
//! Class constructor.
|
||||
Shakers();
|
||||
|
||||
//! Class destructor.
|
||||
~Shakers();
|
||||
|
||||
//! Start a note with the given instrument and amplitude.
|
||||
/*!
|
||||
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);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT 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 instType;
|
||||
int ratchetPos, lastRatchetPos;
|
||||
MY_FLOAT shakeEnergy;
|
||||
MY_FLOAT inputs[MAX_FREQS];
|
||||
@@ -42,7 +105,7 @@ class Shakers : public Instrmnt
|
||||
MY_FLOAT sndLevel;
|
||||
MY_FLOAT baseGain;
|
||||
MY_FLOAT gains[MAX_FREQS];
|
||||
int num_freqs;
|
||||
int nFreqs;
|
||||
MY_FLOAT t_center_freqs[MAX_FREQS];
|
||||
MY_FLOAT center_freqs[MAX_FREQS];
|
||||
MY_FLOAT resons[MAX_FREQS];
|
||||
@@ -50,28 +113,16 @@ class Shakers : public Instrmnt
|
||||
int freqalloc[MAX_FREQS];
|
||||
MY_FLOAT soundDecay;
|
||||
MY_FLOAT systemDecay;
|
||||
MY_FLOAT num_objects;
|
||||
MY_FLOAT nObjects;
|
||||
MY_FLOAT collLikely;
|
||||
MY_FLOAT totalEnergy;
|
||||
MY_FLOAT ratchet,ratchetDelta;
|
||||
MY_FLOAT finalZ[3];
|
||||
MY_FLOAT finalZCoeffs[3];
|
||||
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 ratchet_tick();
|
||||
MY_FLOAT defObjs[NUM_INSTR];
|
||||
MY_FLOAT defDecays[NUM_INSTR];
|
||||
MY_FLOAT decayScale[NUM_INSTR];
|
||||
public:
|
||||
Shakers();
|
||||
~Shakers();
|
||||
int setupName(char* instr);
|
||||
int setupNum(int inst);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amp);
|
||||
MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,44 +1,74 @@
|
||||
/*******************************************/
|
||||
/* Master Class for Simple Instrument */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This instrument contains 1 looped */
|
||||
/* wave, 1 noise source, 1 biquad filter */
|
||||
/* 1 one-pole filter, and 1 ADSR envelope */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Simple
|
||||
\brief STK wavetable/noise instrument.
|
||||
|
||||
#if !defined(__Simple_h)
|
||||
#define __Simple_h
|
||||
This class combines a looped wave, a
|
||||
noise source, a biquad resonance filter,
|
||||
a one-pole filter, and an ADSR envelope
|
||||
to create some interesting sounds.
|
||||
|
||||
Control Change Numbers:
|
||||
- Filter Pole Position = 2
|
||||
- Noise/Pitched Cross-Fade = 4
|
||||
- Envelope Rate = 11
|
||||
- Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SIMPLE_H)
|
||||
#define __SIMPLE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "OnePole.h"
|
||||
#include "TwoPole.h"
|
||||
#include "TwoZero.h"
|
||||
#include "BiQuad.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Simple : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Simple();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Simple();
|
||||
|
||||
//! Clear internal states.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Start envelope toward "on" target.
|
||||
void keyOn();
|
||||
|
||||
//! Start envelope toward "off" target.
|
||||
void keyOff();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
RawWvIn *loop;
|
||||
WaveLoop *loop;
|
||||
OnePole *filter;
|
||||
TwoPole *bqpoles;
|
||||
TwoZero *bqzeroes;
|
||||
BiQuad *biquad;
|
||||
Noise *noise;
|
||||
MY_FLOAT baseFreq;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT loopGain;
|
||||
public:
|
||||
Simple();
|
||||
virtual ~Simple();
|
||||
void clear();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
virtual MY_FLOAT tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*******************************************/
|
||||
/* "Singing" Looped Soundfile Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This Object contains all that's needed */
|
||||
/* to make a pitched musical sound, like */
|
||||
/* a simple voice or violin. In general, */
|
||||
/* it will not be used alone (because of */
|
||||
/* of munchinification effects from pitch */
|
||||
/* shifting. It will be used as an */
|
||||
/* excitation source for other instruments*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__SingWave_h)
|
||||
#define __SingWave_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "Modulatr.h"
|
||||
#include "Envelope.h"
|
||||
#include "StkError.h"
|
||||
|
||||
class SingWave : public Object
|
||||
{
|
||||
protected:
|
||||
Modulatr *modulator;
|
||||
Envelope *envelope;
|
||||
Envelope *pitchEnvelope;
|
||||
long length;
|
||||
MY_FLOAT *data;
|
||||
MY_FLOAT rate;
|
||||
MY_FLOAT sweepRate;
|
||||
MY_FLOAT mytime;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
SingWave(char *fileName);
|
||||
~SingWave();
|
||||
void reset();
|
||||
void normalize();
|
||||
void normalize(MY_FLOAT newPeak);
|
||||
void setFreq(MY_FLOAT aFreq);
|
||||
void setVibFreq(MY_FLOAT vibFreq);
|
||||
void setVibAmt(MY_FLOAT vibAmt);
|
||||
void setRndAmt(MY_FLOAT rndVib);
|
||||
void setSweepRate(MY_FLOAT swpRate);
|
||||
void setGainRate(MY_FLOAT gainRate);
|
||||
void setGainTarget(MY_FLOAT aTarget);
|
||||
void noteOn();
|
||||
void noteOff();
|
||||
MY_FLOAT tick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
70
include/Sitar.h
Normal file
70
include/Sitar.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************/
|
||||
/*! \class Sitar
|
||||
\brief STK sitar string model class.
|
||||
|
||||
This class implements a sitar plucked string
|
||||
physical model based on the Karplus-Strong
|
||||
algorithm.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
There exist at least two patents, assigned to
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SITAR_H)
|
||||
#define __SITAR_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "Noise.h"
|
||||
#include "ADSR.h"
|
||||
|
||||
class Sitar : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Sitar(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Sitar();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
OneZero *loopFilter;
|
||||
Noise *noise;
|
||||
ADSR *envelope;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
MY_FLOAT amGain;
|
||||
MY_FLOAT delay;
|
||||
MY_FLOAT targetDelay;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*******************************************/
|
||||
/* SndWvIn Input Class, */
|
||||
/* by Gary P. Scavone, 2000 */
|
||||
/* */
|
||||
/* This object inherits from WvIn and is */
|
||||
/* used to open NeXT/Sun .snd 16-bit data */
|
||||
/* (signed integer) files for playback. */
|
||||
/* */
|
||||
/* .snd files are always big-endian. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__SndWvIn_h)
|
||||
#define __SndWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class SndWvIn : public WvIn
|
||||
{
|
||||
public:
|
||||
SndWvIn(char *fileName, const char *mode);
|
||||
~SndWvIn();
|
||||
protected:
|
||||
void getData(long index);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
/***********************************************/
|
||||
/*
|
||||
NeXT (.snd) and Sun (.au) Soundfile Output Class
|
||||
by Perry R. Cook, 1996
|
||||
Revised by Gary P. Scavone, 1999-2000
|
||||
|
||||
This one opens a NeXT .snd file, and
|
||||
even knows how to byte-swap!
|
||||
*/
|
||||
/***********************************************/
|
||||
|
||||
#if !defined(__SndWvOut_h)
|
||||
#define __SndWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class SndWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
FILE *fd;
|
||||
public:
|
||||
SndWvOut(char *fileName, int chans = 1);
|
||||
~SndWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif // defined(__SndWvOut_h)
|
||||
103
include/Socket.h
Normal file
103
include/Socket.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************/
|
||||
/*! \class Socket
|
||||
\brief STK TCP socket client/server class.
|
||||
|
||||
This class provides a uniform cross-platform
|
||||
TCP socket client or socket server interface.
|
||||
Methods are provided for reading or writing
|
||||
data buffers to/from connections. This class
|
||||
also provides a number of static functions for
|
||||
use with external socket descriptors.
|
||||
|
||||
The user is responsible for checking the values
|
||||
returned by the read/write methods. Values
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SOCKET_H)
|
||||
#define __SOCKET_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Socket : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor which creates a local socket server on port 2006 (or the specified port number).
|
||||
/*!
|
||||
An StkError will be thrown if a socket error occurs during instantiation.
|
||||
*/
|
||||
Socket( int port = 2006 );
|
||||
|
||||
//! Class constructor which creates a socket client connection to the specified host and port.
|
||||
/*!
|
||||
An StkError will be thrown if a socket error occurs during instantiation.
|
||||
*/
|
||||
Socket( int port, const char *hostname );
|
||||
|
||||
//! The class destructor closes the socket instance, breaking any existing connections.
|
||||
~Socket();
|
||||
|
||||
//! Connect a socket client to the specified host and port and returns the resulting socket descriptor.
|
||||
/*!
|
||||
This method is valid for socket clients only. If it is called for
|
||||
a socket server, -1 is returned. If the socket client is already
|
||||
connected, that connection is terminated and a new connection is
|
||||
attempted. Server connections are made using the accept() method.
|
||||
An StkError will be thrown if a socket error occurs during
|
||||
instantiation. \sa accept
|
||||
*/
|
||||
int connect( int port, const char *hostname = "localhost" );
|
||||
|
||||
//! Close this socket.
|
||||
void close( void );
|
||||
|
||||
//! Return the server/client socket descriptor.
|
||||
int socket( void ) const;
|
||||
|
||||
//! Return the server/client port number.
|
||||
int port( void ) const;
|
||||
|
||||
//! If this is a socket server, extract the first pending connection request from the queue and create a new connection, returning the descriptor for the accepted socket.
|
||||
/*!
|
||||
If no connection requests are pending and the socket has not
|
||||
been set non-blocking, this function will block until a connection
|
||||
is present. If an error occurs or this is a socket client, -1 is
|
||||
returned.
|
||||
*/
|
||||
int accept( void );
|
||||
|
||||
//! If enable = false, the socket is set to non-blocking mode. When first created, sockets are by default in blocking mode.
|
||||
static void setBlocking( int socket, bool enable );
|
||||
|
||||
//! Close the socket with the given descriptor.
|
||||
static void close( int socket );
|
||||
|
||||
//! Returns TRUE is 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.
|
||||
int writeBuffer(const void *buffer, long bufferSize, int flags = 0);
|
||||
|
||||
//! Write a buffer via the specified socket. Returns the number of bytes written or -1 if an error occurs.
|
||||
static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags );
|
||||
|
||||
//! Read a buffer from the socket connection, up to length \e bufferSize. Returns the number of bytes read or -1 if an error occurs.
|
||||
int readBuffer(void *buffer, long bufferSize, int flags = 0);
|
||||
|
||||
//! Read a buffer via the specified socket. Returns the number of bytes read or -1 if an error occurs.
|
||||
static int readBuffer(int socket, void *buffer, long bufferSize, int flags );
|
||||
|
||||
protected:
|
||||
|
||||
char msg[256];
|
||||
int soket;
|
||||
int poort;
|
||||
bool server;
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__SOCKET_H)
|
||||
95
include/StifKarp.h
Normal file
95
include/StifKarp.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/***************************************************/
|
||||
/*! \class StifKarp
|
||||
\brief STK plucked stiff string instrument.
|
||||
|
||||
This class implements a simple plucked string
|
||||
algorithm (Karplus Strong) with enhancements
|
||||
(Jaffe-Smith, Smith, and others), including
|
||||
string stiffness and pluck position controls.
|
||||
The stiffness is modeled with allpass filters.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
|
||||
Control Change Numbers:
|
||||
- Pickup Position = 4
|
||||
- String Sustain = 11
|
||||
- String Stretch = 1
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__StifKarp_h)
|
||||
#define __StifKarp_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "Noise.h"
|
||||
#include "BiQuad.h"
|
||||
|
||||
class StifKarp : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
StifKarp(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~StifKarp();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the stretch "factor" of the string (0.0 - 1.0).
|
||||
void setStretch(MY_FLOAT stretch);
|
||||
|
||||
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
|
||||
void setPickupPosition(MY_FLOAT position);
|
||||
|
||||
//! Set the base loop gain.
|
||||
/*!
|
||||
The actual loop gain is set according to the frequency.
|
||||
Because of high-frequency loop filter roll-off, higher
|
||||
frequency settings have greater loop gains.
|
||||
*/
|
||||
void setBaseLoopGain(MY_FLOAT aGain);
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT 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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
168
include/Stk.h
Normal file
168
include/Stk.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/***************************************************/
|
||||
/*! \class Stk
|
||||
\brief STK base class
|
||||
|
||||
Nearly all STK classes inherit from this class.
|
||||
The global sample rate can be queried and
|
||||
modified via Stk. In addition, this class
|
||||
provides error handling and byte-swapping
|
||||
functions.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__STK_H)
|
||||
#define __STK_H
|
||||
|
||||
// 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;
|
||||
|
||||
//! STK error handling class.
|
||||
/*!
|
||||
This is a fairly abstract exception handling class. There could
|
||||
be sub-classes to take care of more specific error conditions ... or
|
||||
not.
|
||||
*/
|
||||
class StkError
|
||||
{
|
||||
public:
|
||||
enum TYPE {
|
||||
WARNING,
|
||||
DEBUG_WARNING,
|
||||
FUNCTION_ARGUMENT,
|
||||
FILE_NOT_FOUND,
|
||||
FILE_UNKNOWN_FORMAT,
|
||||
FILE_ERROR,
|
||||
PROCESS_THREAD,
|
||||
PROCESS_SOCKET,
|
||||
PROCESS_SOCKET_IPADDR,
|
||||
AUDIO_SYSTEM,
|
||||
MIDI_SYSTEM,
|
||||
UNSPECIFIED
|
||||
};
|
||||
|
||||
protected:
|
||||
char message[256];
|
||||
TYPE type;
|
||||
|
||||
public:
|
||||
//! The constructor.
|
||||
StkError(const char *p, TYPE tipe = StkError::UNSPECIFIED);
|
||||
|
||||
//! The destructor.
|
||||
virtual ~StkError(void);
|
||||
|
||||
//! Prints "thrown" error message to stdout.
|
||||
virtual void printMessage(void);
|
||||
|
||||
//! 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; }
|
||||
};
|
||||
|
||||
|
||||
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 STK_FLOAT32; /*!< Normalized between plus/minus 1.0. */
|
||||
static const STK_FORMAT STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */
|
||||
|
||||
//! Static method which returns the current STK sample rate.
|
||||
static MY_FLOAT sampleRate(void);
|
||||
|
||||
//! Static method which sets the STK sample rate.
|
||||
/*!
|
||||
The sample rate set using this method is queried by all STK
|
||||
classes which depend on its value. It is initialized to the
|
||||
default SRATE set in Stk.h. Many STK classes use the sample rate
|
||||
during instantiation. Therefore, if you wish to use a rate which
|
||||
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 method which byte-swaps a 16-bit data type.
|
||||
static void swap16(unsigned char *ptr);
|
||||
|
||||
//! Static method which byte-swaps a 32-bit data type.
|
||||
static void swap32(unsigned char *ptr);
|
||||
|
||||
//! Static method which byte-swaps a 64-bit data type.
|
||||
static void swap64(unsigned char *ptr);
|
||||
|
||||
//! Static cross-platform method to sleep for a number of milliseconds.
|
||||
static void sleep(unsigned long milliseconds);
|
||||
|
||||
private:
|
||||
static MY_FLOAT srate;
|
||||
|
||||
protected:
|
||||
|
||||
//! Default constructor.
|
||||
Stk(void);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Stk(void);
|
||||
|
||||
//! Function for error reporting and handling.
|
||||
static void handleError( const char *message, StkError::TYPE type );
|
||||
|
||||
};
|
||||
|
||||
// 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) 22050.0
|
||||
|
||||
// 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
|
||||
|
||||
// The RAWWAVE_PATH definition is concatenated to the beginning of all
|
||||
// references to rawwave files in the various STK core classes
|
||||
// (ex. Clarinet.cpp). If you wish to move the rawwaves directory to
|
||||
// a different location in your file system, you will need to set this
|
||||
// path definition appropriately. The current definition is a
|
||||
// relative reference that will work "out of the box" for the STK
|
||||
// distribution.
|
||||
#define RAWWAVE_PATH "../../"
|
||||
|
||||
#define PI (MY_FLOAT) 3.14159265359
|
||||
#define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI)
|
||||
|
||||
#define ONE_OVER_128 (MY_FLOAT) 0.0078125
|
||||
|
||||
#if defined(__WINDOWS_DS__)
|
||||
#define __OS_WINDOWS__
|
||||
#define __STK_REALTIME__
|
||||
#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__)
|
||||
#define __OS_LINUX__
|
||||
#define __STK_REALTIME__
|
||||
#elif defined(__IRIX_AL__)
|
||||
#define __OS_IRIX__
|
||||
#define __STK_REALTIME__
|
||||
#endif
|
||||
|
||||
//#define _STK_DEBUG_
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
/*************************************************/
|
||||
/*
|
||||
STK Error Handling Class
|
||||
by Gary P. Scavone, 2000.
|
||||
|
||||
This is a fairly abstract exception handling
|
||||
class. There could be sub-classes to take
|
||||
care of more specific error conditions ... or not.
|
||||
*/
|
||||
/*************************************************/
|
||||
|
||||
#if !defined(__StkError_h)
|
||||
#define __StkError_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class StkError : public Object
|
||||
{
|
||||
public:
|
||||
enum TYPE { UNSPECIFIED,
|
||||
FUNCTION_SYNTAX,
|
||||
FILE_NOT_FOUND,
|
||||
FILE_ERROR,
|
||||
PROCESS_THREAD,
|
||||
PROCESS_SOCKET,
|
||||
PROCESS_SOCKET_IPADDR,
|
||||
SOUNDCARD_NOT_FOUND,
|
||||
SOUNDCARD_CAPS,
|
||||
SOUNDCARD_CONTROL,
|
||||
MIDICARD_NOT_FOUND,
|
||||
MIDICARD_CAPS,
|
||||
MIDICARD_CONTROL
|
||||
};
|
||||
|
||||
protected:
|
||||
char errormsg[256];
|
||||
TYPE type;
|
||||
|
||||
public:
|
||||
StkError(const char *p, TYPE tipe = StkError::UNSPECIFIED);
|
||||
virtual ~StkError(void);
|
||||
virtual void printMessage(void);
|
||||
virtual const TYPE& getType(void) { return type; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
/******************************************/
|
||||
/*
|
||||
StrmWvIn Audio Input Class,
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This object inherits from WvIn and is used
|
||||
to accept 16-bit data (signed integer) via
|
||||
a socket connection (streamed audio).
|
||||
Streamed data must be in big-endian format,
|
||||
which conforms to network byte ordering.
|
||||
|
||||
This class starts a socket server, which
|
||||
waits for a remote connection. Actual data
|
||||
reading and buffering takes place in a thread.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__StrmWvIn_h)
|
||||
#define __StrmWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class StrmWvIn : public WvIn
|
||||
{
|
||||
protected:
|
||||
INT16 *strmdata;
|
||||
INT16 *lastSamples;
|
||||
void getData(long index);
|
||||
public:
|
||||
StrmWvIn(int chans = 1, MY_FLOAT srate = SRATE);
|
||||
~StrmWvIn();
|
||||
void setRate(MY_FLOAT aRate);
|
||||
void addTime(MY_FLOAT aTime);
|
||||
void setLooping(int aLoopStatus);
|
||||
long getSize();
|
||||
int informTick();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/******************************************/
|
||||
/*
|
||||
StrmWvOut Audio Output Class,
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This object inherits from WvOut and is used
|
||||
to send 16-bit data (signed integer) via
|
||||
a socket connection (streamed audio).
|
||||
Streamed data must be in big-endian format,
|
||||
which conforms to network byte ordering.
|
||||
|
||||
This class connects to a socket server, the
|
||||
port and IP address of which must be specified
|
||||
as constructor arguments. Actual data writing
|
||||
and buffering takes place in a thread.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__StrmWvOut_h)
|
||||
#define __StrmWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class StrmWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
int local_socket;
|
||||
public:
|
||||
StrmWvOut(int port, const char *hostname = "localhost", int chans = 1);
|
||||
~StrmWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif // defined(__StrmWvOut_h)
|
||||
@@ -1,25 +1,43 @@
|
||||
/*******************************************/
|
||||
/* SubSampled Noise Generator Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* White noise as often as you like. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__SubNoise_h)
|
||||
#define __SubNoise_h
|
||||
|
||||
#include "Noise.h"
|
||||
|
||||
class SubNoise : public Noise
|
||||
{
|
||||
protected:
|
||||
int counter;
|
||||
int howOften;
|
||||
public:
|
||||
SubNoise();
|
||||
~SubNoise();
|
||||
SubNoise(int subSample);
|
||||
void setHowOften(int howOft);
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class SubNoise
|
||||
\brief STK sub-sampled noise generator.
|
||||
|
||||
Generates a new random number every "rate" ticks
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SUBNOISE_H)
|
||||
#define __SUBNOISE_H
|
||||
|
||||
#include "Noise.h"
|
||||
|
||||
class SubNoise : public Noise
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor sets sub-sample rate to 16.
|
||||
SubNoise(int subRate = 16);
|
||||
|
||||
//! Class destructor.
|
||||
~SubNoise();
|
||||
|
||||
//! Return the current sub-sampling rate.
|
||||
int subRate(void) const;
|
||||
|
||||
//! Set the sub-sampling rate.
|
||||
void setRate(int subRate);
|
||||
|
||||
//! Return a sub-sampled random number between -1.0 and 1.0.
|
||||
MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
int counter;
|
||||
int rate;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user