mirror of
https://github.com/thestk/stk
synced 2026-04-19 22:16:54 +00:00
Version 3.2
This commit is contained in:
committed by
Stephen Sinclair
parent
4b6500d3de
commit
3f126af4e5
46
include/ADSR.h
Normal file
46
include/ADSR.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
30
include/AifWvIn.h
Normal file
30
include/AifWvIn.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
32
include/AifWvOut.h
Normal file
32
include/AifWvOut.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
23
include/BeeThree.h
Normal file
23
include/BeeThree.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/******************************************/
|
||||
/* HammondOid Organ Subclass */
|
||||
/* of Algorithm 8 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__BeeThree_h)
|
||||
#define __BeeThree_h
|
||||
|
||||
#include "FM4Alg8.h"
|
||||
|
||||
class BeeThree : public FM4Alg8
|
||||
{
|
||||
public:
|
||||
BeeThree();
|
||||
~BeeThree();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
MY_FLOAT tick();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
40
include/BiQuad.h
Normal file
40
include/BiQuad.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
57
include/BlowHole.h
Normal file
57
include/BlowHole.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/***********************************************/
|
||||
/*
|
||||
Waveguide reed model with a register hole
|
||||
and one tonehole
|
||||
|
||||
by Gary P. Scavone, 2000.
|
||||
*/
|
||||
/***********************************************/
|
||||
|
||||
#if !defined(__BlowHole_h)
|
||||
#define __BlowHole_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "OneZero.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "RawWvIn.h"
|
||||
|
||||
class BlowHole : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineL *delays;
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
PoleZero *tonehole;
|
||||
PoleZero *vent;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
RawWvIn *vibr;
|
||||
long length;
|
||||
MY_FLOAT scatter;
|
||||
MY_FLOAT th_coeff;
|
||||
MY_FLOAT r_th;
|
||||
MY_FLOAT rh_coeff;
|
||||
MY_FLOAT rh_gain;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT 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);
|
||||
};
|
||||
|
||||
#endif
|
||||
27
include/BowTabl.h
Normal file
27
include/BowTabl.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/***********************************************/
|
||||
/* 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
|
||||
56
include/Bowed.h
Normal file
56
include/Bowed.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/******************************************/
|
||||
/* 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 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Bowed_h)
|
||||
#define __Bowed_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineL.h"
|
||||
#include "BowTabl.h"
|
||||
#include "OnePole.h"
|
||||
#include "BiQuad.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "ADSR.h"
|
||||
|
||||
class Bowed : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineL *neckDelay;
|
||||
DLineL *bridgeDelay;
|
||||
BowTabl *bowTabl;
|
||||
OnePole *reflFilt;
|
||||
BiQuad *bodyFilt;
|
||||
RawWvIn *vibr;
|
||||
ADSR *adsr;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT baseDelay;
|
||||
MY_FLOAT vibrGain;
|
||||
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
|
||||
62
include/BowedBar.h
Normal file
62
include/BowedBar.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*********************************************/
|
||||
/* 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
|
||||
53
include/Brass.h
Normal file
53
include/Brass.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/******************************************/
|
||||
/* 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 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Brass_h)
|
||||
#define __Brass_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.h"
|
||||
#include "LipFilt.h"
|
||||
#include "DCBlock.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.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();
|
||||
};
|
||||
|
||||
#endif
|
||||
5
include/ByteSwap.h
Normal file
5
include/ByteSwap.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "Object.h"
|
||||
|
||||
void swap16(unsigned char *ptr);
|
||||
void swap32(unsigned char *ptr);
|
||||
void swap64(unsigned char *ptr);
|
||||
53
include/Clarinet.h
Normal file
53
include/Clarinet.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
119
include/Controller.h
Normal file
119
include/Controller.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/******************************************/
|
||||
/*
|
||||
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)
|
||||
26
include/DCBlock.h
Normal file
26
include/DCBlock.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
43
include/DLineA.h
Normal file
43
include/DLineA.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
45
include/DLineL.h
Normal file
45
include/DLineL.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
45
include/DLineN.h
Normal file
45
include/DLineN.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
|
||||
47
include/DrumSynt.h
Normal file
47
include/DrumSynt.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
41
include/Envelope.h
Normal file
41
include/Envelope.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
34
include/FIR.h
Normal file
34
include/FIR.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/********************************************/
|
||||
/*
|
||||
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
|
||||
30
include/FM4Alg3.h
Normal file
30
include/FM4Alg3.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
30
include/FM4Alg4.h
Normal file
30
include/FM4Alg4.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
33
include/FM4Alg5.h
Normal file
33
include/FM4Alg5.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
36
include/FM4Alg6.h
Normal file
36
include/FM4Alg6.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
34
include/FM4Alg8.h
Normal file
34
include/FM4Alg8.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
59
include/FM4Op.h
Normal file
59
include/FM4Op.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
24
include/FMVoices.h
Normal file
24
include/FMVoices.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/******************************************/
|
||||
/* Singing Voice Synthesis Subclass */
|
||||
/* of Algorithm 6 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1996 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__FMVoices_h)
|
||||
#define __FMVoices_h
|
||||
|
||||
#include "FM4Alg6.h"
|
||||
|
||||
class FMVoices : public FM4Alg6
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
||||
#endif
|
||||
28
include/Filter.h
Normal file
28
include/Filter.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
64
include/Flute.h
Normal file
64
include/Flute.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/******************************************/
|
||||
/* 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 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Flute_h)
|
||||
#define __Flute_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "JetTabl.h"
|
||||
#include "DLineL.h"
|
||||
#include "OnePole.h"
|
||||
#include "DCBlock.h"
|
||||
#include "Noise.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
|
||||
class Flute : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineL *jetDelay;
|
||||
DLineL *boreDelay;
|
||||
JetTabl *jetTable;
|
||||
OnePole *filter;
|
||||
DCBlock *dcBlock;
|
||||
Noise *noise;
|
||||
ADSR *adsr;
|
||||
RawWvIn *vibr;
|
||||
MY_FLOAT lastFreq;
|
||||
MY_FLOAT maxPressure;
|
||||
MY_FLOAT jetRefl;
|
||||
MY_FLOAT endRefl;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibrGain;
|
||||
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
|
||||
46
include/FormSwep.h
Normal file
46
include/FormSwep.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
22
include/HeavyMtl.h
Normal file
22
include/HeavyMtl.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
26
include/Instrmnt.h
Normal file
26
include/Instrmnt.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
52
include/JCRev.h
Normal file
52
include/JCRev.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*******************************************/
|
||||
/* 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. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__JCRev_h)
|
||||
#define __JCRev_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
27
include/JetTabl.h
Normal file
27
include/JetTabl.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/**********************************************/
|
||||
/* 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
|
||||
28
include/LipFilt.h
Normal file
28
include/LipFilt.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/************************************************/
|
||||
/* 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();
|
||||
};
|
||||
|
||||
44
include/Mandolin.h
Normal file
44
include/Mandolin.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/********************************************/
|
||||
/* 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. */
|
||||
/********************************************/
|
||||
|
||||
#if !defined(__Mandolin_h)
|
||||
#define __Mandolin_h
|
||||
|
||||
#include "Plucked2.h"
|
||||
#include "RawWvIn.h"
|
||||
|
||||
class Mandolin : public Plucked2
|
||||
{
|
||||
protected:
|
||||
RawWvIn *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();
|
||||
};
|
||||
|
||||
#endif
|
||||
37
include/MatWvIn.h
Normal file
37
include/MatWvIn.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
36
include/MatWvOut.h
Normal file
36
include/MatWvOut.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*******************************************/
|
||||
/* 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)
|
||||
55
include/Modal4.h
Normal file
55
include/Modal4.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
30
include/ModalBar.h
Normal file
30
include/ModalBar.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
ModalBar SubClass of Modal4 Instrument
|
||||
by Perry R. Cook, 1999-2000
|
||||
|
||||
Controls: CONTROL1 = stickHardness
|
||||
CONTROL2 = strikePosition
|
||||
CONTROL3 = Mode Presets
|
||||
*/
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__ModalBar_h)
|
||||
#define __ModalBar_h
|
||||
|
||||
#include "Modal4.h"
|
||||
|
||||
class ModalBar : public Modal4
|
||||
{
|
||||
private:
|
||||
public:
|
||||
ModalBar();
|
||||
~ModalBar();
|
||||
void setStickHardness(MY_FLOAT hardness);
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
void setModalPreset(int which);
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
};
|
||||
|
||||
#endif
|
||||
36
include/Modulatr.h
Normal file
36
include/Modulatr.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
34
include/Moog1.h
Normal file
34
include/Moog1.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
52
include/NRev.h
Normal file
52
include/NRev.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/******************************************/
|
||||
/* 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. */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__NRev_h)
|
||||
#define __NRev_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
23
include/Noise.h
Normal file
23
include/Noise.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
137
include/Object.h
Normal file
137
include/Object.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*********************************************/
|
||||
/* 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
|
||||
44
include/OnePole.h
Normal file
44
include/OnePole.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*******************************************/
|
||||
/*
|
||||
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
|
||||
35
include/OneZero.h
Normal file
35
include/OneZero.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
43
include/PRCRev.h
Normal file
43
include/PRCRev.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*******************************************/
|
||||
/* 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. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__PRCRev_h)
|
||||
#define __PRCRev_h
|
||||
|
||||
#include "Reverb.h"
|
||||
#include "DLineN.h"
|
||||
|
||||
class PRCRev : public Reverb
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
21
include/PercFlut.h
Normal file
21
include/PercFlut.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/******************************************/
|
||||
/* Percussive Flute Subclass */
|
||||
/* of Algorithm 4 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__PercFlut_h)
|
||||
#define __PercFlut_h
|
||||
|
||||
#include "FM4Alg4.h"
|
||||
|
||||
class PercFlut : public FM4Alg4
|
||||
{
|
||||
public:
|
||||
PercFlut();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
40
include/Plucked.h
Normal file
40
include/Plucked.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/******************************************/
|
||||
/* 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. */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Plucked_h)
|
||||
#define __Plucked_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.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();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
46
include/Plucked2.h
Normal file
46
include/Plucked2.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
32
include/PoleZero.h
Normal file
32
include/PoleZero.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
28
include/RawWvIn.h
Normal file
28
include/RawWvIn.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
29
include/RawWvOut.h
Normal file
29
include/RawWvOut.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*******************************************/
|
||||
/* 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)
|
||||
30
include/ReedTabl.h
Normal file
30
include/ReedTabl.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/**********************************************/
|
||||
/* 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
|
||||
32
include/Reverb.h
Normal file
32
include/Reverb.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/********************************************/
|
||||
/* Reverb Abstract Class, */
|
||||
/* by Tim Stilson, 1998 */
|
||||
/* */
|
||||
/* Integrated into STK by Gary Scavone */
|
||||
/* with T60 argument. */
|
||||
/********************************************/
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
#if !defined(__Reverb_h)
|
||||
#define __Reverb_h
|
||||
|
||||
class Reverb : public Object
|
||||
{
|
||||
public:
|
||||
Reverb();
|
||||
virtual ~Reverb();
|
||||
virtual MY_FLOAT tick(MY_FLOAT sample);
|
||||
virtual void setEffectMix(MY_FLOAT mix);
|
||||
int isprime(int val);
|
||||
};
|
||||
|
||||
#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.
|
||||
*/
|
||||
22
include/Rhodey.h
Normal file
22
include/Rhodey.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/******************************************/
|
||||
/* Fender Rhodes Electric Piano Subclass */
|
||||
/* of Algorithm 5 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Rhodey_h)
|
||||
#define __Rhodey_h
|
||||
|
||||
#include "FM4Alg5.h"
|
||||
|
||||
class Rhodey : public FM4Alg5
|
||||
{
|
||||
public:
|
||||
Rhodey();
|
||||
~Rhodey();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
155
include/RtAudio.h
Normal file
155
include/RtAudio.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/******************************************/
|
||||
/*
|
||||
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
|
||||
39
include/RtDuplex.h
Normal file
39
include/RtDuplex.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*******************************************/
|
||||
/* 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)
|
||||
66
include/RtMidi.h
Normal file
66
include/RtMidi.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/******************************************/
|
||||
/*
|
||||
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
|
||||
45
include/RtWvIn.h
Normal file
45
include/RtWvIn.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
36
include/RtWvOut.h
Normal file
36
include/RtWvOut.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*******************************************/
|
||||
/* 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)
|
||||
58
include/SKINI11.h
Normal file
58
include/SKINI11.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/******************************************/
|
||||
/* 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
|
||||
|
||||
|
||||
120
include/SKINI11.msg
Normal file
120
include/SKINI11.msg
Normal file
@@ -0,0 +1,120 @@
|
||||
/*************************************************************/
|
||||
/* */
|
||||
/* 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_
|
||||
|
||||
|
||||
29
include/SamplFlt.h
Normal file
29
include/SamplFlt.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
42
include/Sampler.h
Normal file
42
include/Sampler.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*******************************************/
|
||||
/* 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. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Sampler_h)
|
||||
#define __Sampler_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Sampler : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
RawWvIn *attacks[5];
|
||||
RawWvIn *loops[5];
|
||||
OnePole *filter;
|
||||
MY_FLOAT baseFreq;
|
||||
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
|
||||
77
include/Shakers.h
Normal file
77
include/Shakers.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/**********************************************************/
|
||||
/* 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) */
|
||||
/**********************************************************/
|
||||
|
||||
#if !defined(__Shakers_h)
|
||||
#define __Shakers_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
|
||||
#define MAX_FREQS 8
|
||||
#define NUM_INSTR 13
|
||||
|
||||
class Shakers : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
int instType;
|
||||
int setFreqAndReson(int which, MY_FLOAT freq, MY_FLOAT reson);
|
||||
int ratchetPos, lastRatchetPos;
|
||||
MY_FLOAT shakeEnergy;
|
||||
MY_FLOAT inputs[MAX_FREQS];
|
||||
MY_FLOAT outputs[MAX_FREQS][2];
|
||||
MY_FLOAT coeffs[MAX_FREQS][2];
|
||||
MY_FLOAT sndLevel;
|
||||
MY_FLOAT baseGain;
|
||||
MY_FLOAT gains[MAX_FREQS];
|
||||
int num_freqs;
|
||||
MY_FLOAT t_center_freqs[MAX_FREQS];
|
||||
MY_FLOAT center_freqs[MAX_FREQS];
|
||||
MY_FLOAT resons[MAX_FREQS];
|
||||
MY_FLOAT freq_rand[MAX_FREQS];
|
||||
int freqalloc[MAX_FREQS];
|
||||
MY_FLOAT soundDecay;
|
||||
MY_FLOAT systemDecay;
|
||||
MY_FLOAT num_objects;
|
||||
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
|
||||
44
include/Simple.h
Normal file
44
include/Simple.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*******************************************/
|
||||
/* 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 */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Simple_h)
|
||||
#define __Simple_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "OnePole.h"
|
||||
#include "TwoPole.h"
|
||||
#include "TwoZero.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Simple : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
RawWvIn *loop;
|
||||
OnePole *filter;
|
||||
TwoPole *bqpoles;
|
||||
TwoZero *bqzeroes;
|
||||
Noise *noise;
|
||||
MY_FLOAT baseFreq;
|
||||
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
|
||||
52
include/SingWave.h
Normal file
52
include/SingWave.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*******************************************/
|
||||
/* "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
|
||||
27
include/SndWvIn.h
Normal file
27
include/SndWvIn.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
29
include/SndWvOut.h
Normal file
29
include/SndWvOut.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/***********************************************/
|
||||
/*
|
||||
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)
|
||||
46
include/StkError.h
Normal file
46
include/StkError.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*************************************************/
|
||||
/*
|
||||
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
|
||||
40
include/StrmWvIn.h
Normal file
40
include/StrmWvIn.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/******************************************/
|
||||
/*
|
||||
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
|
||||
36
include/StrmWvOut.h
Normal file
36
include/StrmWvOut.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/******************************************/
|
||||
/*
|
||||
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)
|
||||
25
include/SubNoise.h
Normal file
25
include/SubNoise.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*******************************************/
|
||||
/* 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
|
||||
32
include/TablLook.h
Normal file
32
include/TablLook.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/********************************************/
|
||||
/* Table Lookup Class, */
|
||||
/* by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* This class loads a table of floating */
|
||||
/* point doubles, which are assumed to be */
|
||||
/* in big-endian format. Linear */
|
||||
/* interpolation is performed for */
|
||||
/* fractional lookup indexes. */
|
||||
/********************************************/
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
#if !defined(__TablLook_h)
|
||||
#define __TablLook_h
|
||||
|
||||
class TablLook : public Object
|
||||
{
|
||||
protected:
|
||||
long length;
|
||||
MY_FLOAT *data;
|
||||
MY_FLOAT lastOutput;
|
||||
public:
|
||||
TablLook(char *fileName);
|
||||
~TablLook();
|
||||
long getLength();
|
||||
MY_FLOAT tick(MY_FLOAT index);
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif // defined(__TablLook_h)
|
||||
21
include/TubeBell.h
Normal file
21
include/TubeBell.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/******************************************/
|
||||
/* Tubular Bell (Orch. Chime) Subclass */
|
||||
/* of Algorithm 5 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__TubeBell_h)
|
||||
#define __TubeBell_h
|
||||
|
||||
#include "FM4Alg5.h"
|
||||
|
||||
class TubeBell : public FM4Alg5
|
||||
{
|
||||
public:
|
||||
TubeBell();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
28
include/TwoPole.h
Normal file
28
include/TwoPole.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*******************************************/
|
||||
/* Two 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(__TwoPole_h)
|
||||
#define __TwoPole_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class TwoPole : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT poleCoeffs[2];
|
||||
public:
|
||||
TwoPole();
|
||||
~TwoPole();
|
||||
void clear();
|
||||
void setPoleCoeffs(MY_FLOAT *coeffs);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
void setFreqAndReson(MY_FLOAT freq, MY_FLOAT reson);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
27
include/TwoZero.h
Normal file
27
include/TwoZero.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*******************************************/
|
||||
/* Two Zero 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(__TwoZero_h)
|
||||
#define __TwoZero_h
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
class TwoZero : public Filter
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT zeroCoeffs[2];
|
||||
public:
|
||||
TwoZero();
|
||||
~TwoZero();
|
||||
void clear();
|
||||
void setZeroCoeffs(MY_FLOAT *coeffs);
|
||||
void setGain(MY_FLOAT aValue);
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
61
include/VoicForm.h
Normal file
61
include/VoicForm.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*******************************************/
|
||||
/* 4 Formant Synthesis Instrument */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* This instrument contains an excitation */
|
||||
/* singing wavetable (looping wave with */
|
||||
/* random and periodic vibrato, smoothing */
|
||||
/* on frequency, etc.), excitation noise, */
|
||||
/* and four sweepable complex resonances. */
|
||||
/* */
|
||||
/* Measured Formant data (from me) is */
|
||||
/* included, and enough data is there to */
|
||||
/* support either parallel or cascade */
|
||||
/* synthesis. In the floating point case */
|
||||
/* cascade synthesis is the most natural */
|
||||
/* so that's what you'll find here. */
|
||||
/* */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__VoicForm_h)
|
||||
#define __VoicForm_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
#include "SingWave.h"
|
||||
#include "FormSwep.h"
|
||||
#include "OnePole.h"
|
||||
#include "OneZero.h"
|
||||
|
||||
class VoicForm : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
SingWave *voiced;
|
||||
Noise *noise;
|
||||
Envelope *noiseEnv;
|
||||
FormSwep *filters[4];
|
||||
OnePole *onepole;
|
||||
OneZero *onezero;
|
||||
MY_FLOAT lastFreq;
|
||||
MY_FLOAT lastGain;
|
||||
public:
|
||||
VoicForm();
|
||||
~VoicForm();
|
||||
void clear();
|
||||
void setFreq(MY_FLOAT frequency);
|
||||
void setFormantAll(int whichOne, MY_FLOAT freq, MY_FLOAT reson, MY_FLOAT gain);
|
||||
int setPhoneme(char* phoneme);
|
||||
void setVoiced(MY_FLOAT vGain);
|
||||
void setUnVoiced(MY_FLOAT nGain);
|
||||
void setVoicedUnVoiced(MY_FLOAT vGain, MY_FLOAT nGain);
|
||||
void setFiltSweepRate(int whichOne,MY_FLOAT rate);
|
||||
void setPitchSweepRate(MY_FLOAT rate);
|
||||
void speak();
|
||||
void quiet();
|
||||
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
|
||||
70
include/VoicMang.h
Normal file
70
include/VoicMang.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/******************************************/
|
||||
/* Simple Voice Manager (Mangler) */
|
||||
/* for ToolKit96, 1996 Perry R. Cook */
|
||||
/* Princeton University */
|
||||
/* */
|
||||
/* Make one of these by telling it the */
|
||||
/* maximum number of voices you'll want, */
|
||||
/* and also what flavor instrument */
|
||||
/* group it will be mangling. Pipe SKINI*/
|
||||
/* messages into it and it will return */
|
||||
/* the mixed channel signal each tick. */
|
||||
/* For multi-channel (multi-timbral), */
|
||||
/* make one for each channel and mix */
|
||||
/* their outputs. */
|
||||
/* */
|
||||
/* Each note on returns a unique tag, */
|
||||
/* (credits to the NeXT MusicKit here), */
|
||||
/* so you can send control changes to */
|
||||
/* unique instances of instruments */
|
||||
/* within an ensemble. */
|
||||
/* */
|
||||
/* 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 SKINI09.txt for more information */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
#if !defined(__VoicMang_h)
|
||||
#define __VoicMang_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
|
||||
#define __VMang_MAX_ 8
|
||||
|
||||
class VoicMang : public Object
|
||||
{
|
||||
protected:
|
||||
char InstrumentType[16]; // Instrument Flavor
|
||||
int max_voices;
|
||||
long newTag; // Unique NoteOn tag counter
|
||||
Instrmnt *instrument[__VMang_MAX_]; // The actual Instruments
|
||||
long voicesOn[__VMang_MAX_]; // Tags of Sounding Notes
|
||||
int notesOn[__VMang_MAX_]; // Note Numbers On
|
||||
long mute_time; // Instrument time to shut up
|
||||
MY_FLOAT freqBases[__VMang_MAX_]; // Indiv. Pitch Bend Multipliers
|
||||
MY_FLOAT frequencies[__VMang_MAX_]; // Indiv. Sounding Frequencies
|
||||
MY_FLOAT pitch_bend; // Channel Pitch Bend Mult.
|
||||
public:
|
||||
VoicMang(int maxVoices, char *instrType);
|
||||
~VoicMang();
|
||||
long noteOnN(MY_FLOAT noteNum, MY_FLOAT amp);
|
||||
long noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
void noteOffT(long tag, MY_FLOAT amp);
|
||||
long noteOffN(int note_num, MY_FLOAT amp);
|
||||
long oldestVoice();
|
||||
void kill(long tag);
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChangeT(long tag, int number, MY_FLOAT value);
|
||||
void pitchBend(MY_FLOAT value);
|
||||
void pitchBendT(long tag, MY_FLOAT value);
|
||||
MY_FLOAT tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
28
include/WavWvIn.h
Normal file
28
include/WavWvIn.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*******************************************/
|
||||
/* WavWvIn Input Class, */
|
||||
/* by Gary P. Scavone, 2000 */
|
||||
/* */
|
||||
/* This object inherits from WvIn and is */
|
||||
/* used to open DOS/Windows .wav 16-bit */
|
||||
/* data (signed integer) files for */
|
||||
/* playback. */
|
||||
/* */
|
||||
/* .wav files are always little-endian. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__WavWvIn_h)
|
||||
#define __WavWvIn_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvIn.h"
|
||||
|
||||
class WavWvIn : public WvIn
|
||||
{
|
||||
public:
|
||||
WavWvIn(char *fileName, const char *mode);
|
||||
~WavWvIn();
|
||||
protected:
|
||||
void getData(long index);
|
||||
};
|
||||
|
||||
#endif
|
||||
28
include/WavWvOut.h
Normal file
28
include/WavWvOut.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*******************************************/
|
||||
/* Wave file Output Class, */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/* revised by Gary P. Scavone, 1999 */
|
||||
/* */
|
||||
/* This Object opens a DOS/Windows .wav */
|
||||
/* 16bit data (signed integers) file, and */
|
||||
/* poke buffers of samples into it. */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__WavWvOut_h)
|
||||
#define __WavWvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
class WavWvOut : public WvOut
|
||||
{
|
||||
protected:
|
||||
FILE *fd;
|
||||
public:
|
||||
WavWvOut(char *fileName, int chans = 1);
|
||||
~WavWvOut();
|
||||
void tick(MY_FLOAT sample);
|
||||
void mtick(MY_MULTI samples);
|
||||
};
|
||||
|
||||
#endif
|
||||
21
include/Wurley.h
Normal file
21
include/Wurley.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/******************************************/
|
||||
/* Wurlitzer Electric Piano Subclass */
|
||||
/* of Algorithm 5 (TX81Z) Subclass of */
|
||||
/* 4 Operator FM Synth */
|
||||
/* by Perry R. Cook, 1995-96 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Wurley_h)
|
||||
#define __Wurley_h
|
||||
|
||||
#include "FM4Alg5.h"
|
||||
|
||||
class Wurley : public FM4Alg5
|
||||
{
|
||||
public:
|
||||
Wurley();
|
||||
virtual void setFreq(MY_FLOAT frequency);
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
};
|
||||
|
||||
#endif
|
||||
81
include/WvIn.h
Normal file
81
include/WvIn.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/********************************************/
|
||||
/*
|
||||
Audio Data Input Base Class
|
||||
by Gary P. Scavone, 1999-2000
|
||||
|
||||
This class can handle multi-channel
|
||||
input. Multi-channel input is
|
||||
interleaved in the vector "data".
|
||||
Actual data input occurs in the
|
||||
subclasses of WvIn.
|
||||
|
||||
Currently, STK is only supporting a few data
|
||||
types (16-bit integer .snd, .wav, .raw, and
|
||||
.aif files and 64-bit double MAT-files). In
|
||||
order to support more formats AND to make the
|
||||
writing of subclasses easier, a format ENUM
|
||||
could be defined and a generalized getData()
|
||||
function written within this WvIn class. Then,
|
||||
most subclasses of WvIn would only have to
|
||||
setup the appropriate parameters and all
|
||||
other processing would happen here.
|
||||
*/
|
||||
/********************************************/
|
||||
|
||||
#if !defined(__WvIn_h)
|
||||
#define __WvIn_h
|
||||
|
||||
/* "Oneshot" files larger than MAX_FILE_LOAD_SIZE will be
|
||||
copied into memory in RT_BUFFER_SIZE chunks, rather than
|
||||
completely loaded into a buffer at instantiation.
|
||||
*/
|
||||
#define MAX_FILE_LOAD_SIZE 5000000
|
||||
|
||||
// Buffer size, in sample frames, when incrementally loading from disk
|
||||
#define LOAD_BUFFER_SIZE 1024
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
class WvIn : public Object
|
||||
{
|
||||
protected:
|
||||
long fileSize;
|
||||
long bufferSize;
|
||||
long readPointer;
|
||||
long dataOffset;
|
||||
int channels;
|
||||
int looping;
|
||||
int finished;
|
||||
int chunking;
|
||||
int interpolate;
|
||||
MY_FLOAT *data;
|
||||
MY_FLOAT time;
|
||||
MY_FLOAT rate;
|
||||
MY_FLOAT phaseOffset;
|
||||
MY_FLOAT *lastOutput;
|
||||
FILE *fd;
|
||||
virtual void getData(long index);
|
||||
public:
|
||||
WvIn();
|
||||
virtual ~WvIn();
|
||||
void reset();
|
||||
void normalize();
|
||||
void normalize(MY_FLOAT newPeak);
|
||||
virtual void setRate(MY_FLOAT aRate);
|
||||
void setFreq(MY_FLOAT aFreq);
|
||||
virtual void addTime(MY_FLOAT aTime);
|
||||
void addPhase(MY_FLOAT anAngle);
|
||||
void addPhaseOffset(MY_FLOAT anAngle);
|
||||
void setInterpolate(int anInterpStatus);
|
||||
virtual void setLooping(int aLoopStatus);
|
||||
long getSize();
|
||||
int isFinished();
|
||||
virtual int informTick();
|
||||
MY_FLOAT tick();
|
||||
MY_MULTI mtick();
|
||||
MY_FLOAT lastOut();
|
||||
MY_MULTI mlastOut();
|
||||
};
|
||||
|
||||
#endif // defined(__WvIn_h)
|
||||
43
include/WvOut.h
Normal file
43
include/WvOut.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/********************************************/
|
||||
/* WvOut Abstract Class, */
|
||||
/* by Tim Stilson, 1996 */
|
||||
/* revised by Gary P. Scavone, 1999-2000 */
|
||||
/* */
|
||||
/* This class can handle multi-channel */
|
||||
/* data via the mtick() method. */
|
||||
/* */
|
||||
/* Currently, WvOut and its subclasses are */
|
||||
/* non-interpolating. Thus, the output */
|
||||
/* rate is always SRATE (defined in */
|
||||
/* Object.h). A future upgrade could add */
|
||||
/* interpolation functionality to allow */
|
||||
/* output rates different than the STK */
|
||||
/* internal processing rate (SRATE). */
|
||||
/********************************************/
|
||||
|
||||
#if !defined(__WvOut_h)
|
||||
#define __WvOut_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
#define FILE_BUFFER_SIZE 1024
|
||||
|
||||
class WvOut : public Object
|
||||
{
|
||||
protected:
|
||||
INT16 *data;
|
||||
long data_length;
|
||||
long counter;
|
||||
long totalCount;
|
||||
int channels;
|
||||
public:
|
||||
WvOut();
|
||||
virtual ~WvOut();
|
||||
long getCounter();
|
||||
MY_FLOAT getTime();
|
||||
virtual void tick(MY_FLOAT sample) = 0;
|
||||
virtual void mtick(MY_MULTI samples) = 0;
|
||||
};
|
||||
|
||||
#endif // defined(__WvOut_h)
|
||||
41
include/mandplyr.h
Normal file
41
include/mandplyr.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/********************************************/
|
||||
/* MandPlyr Player Expert Object to control*/
|
||||
/* commuted dual plucked-string model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/********************************************/
|
||||
|
||||
#if !defined(__MandPlyr_h)
|
||||
#define __MandPlyr_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "VoicMang.h"
|
||||
#include "Noise.h"
|
||||
|
||||
#define NUM_STRINGS 4
|
||||
|
||||
class MandPlyr : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
VoicMang *strings;
|
||||
Noise *noise;
|
||||
short strumming;
|
||||
long strumRate;
|
||||
long strumCount;
|
||||
MY_FLOAT skill;
|
||||
short nums[NUM_STRINGS]; // For Now Integer Note Nums
|
||||
MY_FLOAT amps[NUM_STRINGS];
|
||||
long tags[NUM_STRINGS];
|
||||
public:
|
||||
MandPlyr();
|
||||
~MandPlyr();
|
||||
virtual void noteOnN(short num, MY_FLOAT amp);
|
||||
virtual void noteOffN(short num, MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
MY_FLOAT special_tick();
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual void playChord(MY_FLOAT amp, char* chordString);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
19
include/miditabl.h
Normal file
19
include/miditabl.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "Object.h"
|
||||
|
||||
double __MIDI_To_Pitch[128] = {
|
||||
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};
|
||||
189
include/phontabl.h
Normal file
189
include/phontabl.h
Normal file
@@ -0,0 +1,189 @@
|
||||
double phonGains[32][2] =
|
||||
{{1.0,0.0}, // eee
|
||||
{1.0,0.0}, // ihh
|
||||
{1.0,0.0}, // ehh
|
||||
{1.0,0.0}, // aaa
|
||||
|
||||
{1.0,0.0}, // ahh
|
||||
{1.0,0.0}, // aww
|
||||
{1.0,0.0}, // ohh
|
||||
{1.0,0.0}, // uhh
|
||||
|
||||
{1.0,0.0}, // uuu
|
||||
{1.0,0.0}, // ooo
|
||||
{1.0,0.0}, // rrr
|
||||
{1.0,0.0}, // lll
|
||||
|
||||
{1.0,0.0}, // mmm
|
||||
{1.0,0.0}, // nnn
|
||||
{1.0,0.0}, // nng
|
||||
{1.0,0.0}, // ngg
|
||||
|
||||
{0.0,1.0}, // fff
|
||||
{0.0,1.0}, // sss
|
||||
{0.0,1.0}, // thh
|
||||
{0.0,1.0}, // shh
|
||||
|
||||
{0.0,1.0}, // xxx
|
||||
{0.0,0.1}, // hee
|
||||
{0.0,0.1}, // hoo
|
||||
{0.0,0.1}, // hah
|
||||
|
||||
{1.0,0.1}, // bbb
|
||||
{1.0,0.1}, // ddd
|
||||
{1.0,0.1}, // jjj
|
||||
{1.0,0.1}, // ggg
|
||||
|
||||
{1.0,1.0}, // vvv
|
||||
{1.0,1.0}, // zzz
|
||||
{1.0,1.0}, // thz
|
||||
{1.0,1.0} // zhh
|
||||
};
|
||||
|
||||
double phonParams[32][4][3] =
|
||||
{{ { 273,0.996, 0}, // eee (beet)
|
||||
{2086,0.945, -16},
|
||||
{2754,0.979, -12},
|
||||
{3270,0.440, -17}},
|
||||
{ { 385,0.987, 10}, // ihh (bit)
|
||||
{2056,0.930, -20},
|
||||
{2587,0.890, -20},
|
||||
{3150,0.400, -20}},
|
||||
{ { 515,0.977, 10}, // ehh (bet)
|
||||
{1805,0.810, -10},
|
||||
{2526,0.875, -10},
|
||||
{3103,0.400, -13}},
|
||||
{ { 773,0.950, 10}, // aaa (bat)
|
||||
{1676,0.830, -6},
|
||||
{2380,0.880, -20},
|
||||
{3027,0.600, -20}},
|
||||
|
||||
{ { 770,0.950, 0}, // ahh (father)
|
||||
{1153,0.970, -9},
|
||||
{2450,0.780, -29},
|
||||
{3140,0.800, -39}},
|
||||
{ { 637,0.910, 0}, // aww (bought)
|
||||
{ 895,0.900, -3},
|
||||
{2556,0.950, -17},
|
||||
{3070,0.910, -20}},
|
||||
{ { 637,0.910, 0}, // ohh (bone) NOTE:: same as aww (bought)
|
||||
{ 895,0.900, -3},
|
||||
{2556,0.950, -17},
|
||||
{3070,0.910, -20}},
|
||||
{ { 561,0.965, 0}, // uhh (but)
|
||||
{1084,0.930, -10},
|
||||
{2541,0.930, -15},
|
||||
{3345,0.900, -20}},
|
||||
|
||||
{ { 515,0.976, 0}, // uuu (foot)
|
||||
{1031,0.950, -3},
|
||||
{2572,0.960, -11},
|
||||
{3345,0.960, -20}},
|
||||
{ { 349,0.986, -10}, // ooo (boot)
|
||||
{ 918,0.940, -20},
|
||||
{2350,0.960, -27},
|
||||
{2731,0.950, -33}},
|
||||
{ { 394,0.959, -10}, // rrr (bird)
|
||||
{1297,0.780, -16},
|
||||
{1441,0.980, -16},
|
||||
{2754,0.950, -40}},
|
||||
{ { 462,0.990, +5}, // lll (lull)
|
||||
{1200,0.640, -10},
|
||||
{2500,0.200, -20},
|
||||
{3000,0.100, -30}},
|
||||
|
||||
{ { 265,0.987, -10}, // mmm (mom)
|
||||
{1176,0.940, -22},
|
||||
{2352,0.970, -20},
|
||||
{3277,0.940, -31}},
|
||||
{ { 204,0.980, -10}, // nnn (nun)
|
||||
{1570,0.940, -15},
|
||||
{2481,0.980, -12},
|
||||
{3133,0.800, -30}},
|
||||
{ { 204,0.980, -10}, // nng (sang) NOTE:: same as nnn
|
||||
{1570,0.940, -15},
|
||||
{2481,0.980, -12},
|
||||
{3133,0.800, -30}},
|
||||
{ { 204,0.980, -10}, // ngg (bong) NOTE:: same as nnn
|
||||
{1570,0.940, -15},
|
||||
{2481,0.980, -12},
|
||||
{3133,0.800, -30}},
|
||||
|
||||
{ {1000,0.300, 0}, // fff
|
||||
{2800,0.860, -10},
|
||||
{7425,0.740, 0},
|
||||
{8140,0.860, 0}},
|
||||
{ {0,0.000, 0}, // sss
|
||||
{2000,0.700, -15},
|
||||
{5257,0.750, -3},
|
||||
{7171,0.840, 0}},
|
||||
{ { 100,0.900, 0}, // thh
|
||||
{4000,0.500, -20},
|
||||
{5500,0.500, -15},
|
||||
{8000,0.400, -20}},
|
||||
{ {2693,0.940, 0}, // shh
|
||||
{4000,0.720, -10},
|
||||
{6123,0.870, -10},
|
||||
{7755,0.750, -18}},
|
||||
|
||||
{ {1000,0.300, -10}, // xxx NOTE:: Not Really Done Yet
|
||||
{2800,0.860, -10},
|
||||
{7425,0.740, 0},
|
||||
{8140,0.860, 0}},
|
||||
{ { 273,0.996, -40}, // hee (beet) (noisy eee)
|
||||
{2086,0.945, -16},
|
||||
{2754,0.979, -12},
|
||||
{3270,0.440, -17}},
|
||||
{ { 349,0.986, -40}, // hoo (boot) (noisy ooo)
|
||||
{ 918,0.940, -10},
|
||||
{2350,0.960, -17},
|
||||
{2731,0.950, -23}},
|
||||
{ { 770,0.950, -40}, // hah (father) (noisy ahh)
|
||||
{1153,0.970, -3},
|
||||
{2450,0.780, -20},
|
||||
{3140,0.800, -32}},
|
||||
|
||||
{ {2000,0.700, -20}, // bbb NOTE:: Not Really Done Yet
|
||||
{5257,0.750, -15},
|
||||
{7171,0.840, -3},
|
||||
{9000,0.900, 0}},
|
||||
{ { 100,0.900, 0}, // ddd NOTE:: Not Really Done Yet
|
||||
{4000,0.500, -20},
|
||||
{5500,0.500, -15},
|
||||
{8000,0.400, -20}},
|
||||
{ {2693,0.940, 0}, // jjj NOTE:: Not Really Done Yet
|
||||
{4000,0.720, -10},
|
||||
{6123,0.870, -10},
|
||||
{7755,0.750, -18}},
|
||||
{ {2693,0.940, 0}, // ggg NOTE:: Not Really Done Yet
|
||||
{4000,0.720, -10},
|
||||
{6123,0.870, -10},
|
||||
{7755,0.750, -18}},
|
||||
|
||||
{ {2000,0.700, -20}, // vvv NOTE:: Not Really Done Yet
|
||||
{5257,0.750, -15},
|
||||
{7171,0.840, -3},
|
||||
{9000,0.900, 0}},
|
||||
{ { 100,0.900, 0}, // zzz NOTE:: Not Really Done Yet
|
||||
{4000,0.500, -20},
|
||||
{5500,0.500, -15},
|
||||
{8000,0.400, -20}},
|
||||
{ {2693,0.940, 0}, // thz NOTE:: Not Really Done Yet
|
||||
{4000,0.720, -10},
|
||||
{6123,0.870, -10},
|
||||
{7755,0.750, -18}},
|
||||
{ {2693,0.940, 0}, // zhh NOTE:: Not Really Done Yet
|
||||
{4000,0.720, -10},
|
||||
{6123,0.870, -10},
|
||||
{7755,0.750, -18}}
|
||||
};
|
||||
|
||||
char phonemes[32][4] =
|
||||
{"eee","ihh","ehh","aaa",
|
||||
"ahh","aww","ohh","uhh",
|
||||
"uuu","ooo","rrr","lll",
|
||||
"mmm","nnn","nng","ngg",
|
||||
"fff","sss","thh","shh",
|
||||
"xxx","hee","hoo","hah",
|
||||
"bbb","ddd","jjj","ggg",
|
||||
"vvv","zzz","thz","zhh"};
|
||||
Reference in New Issue
Block a user