mirror of
https://github.com/thestk/stk
synced 2026-04-19 14:06:55 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
102
projects/ragamatic/Drone.cpp
Normal file
102
projects/ragamatic/Drone.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/***************************************************/
|
||||
/*! \class Drone
|
||||
\brief STK "drone" plucked string model.
|
||||
|
||||
This class implements a simple plucked string
|
||||
physical model based on the Karplus-Strong
|
||||
algorithm.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
There exist at least two patents, assigned to
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Drone.h"
|
||||
|
||||
Drone :: Drone(MY_FLOAT lowestFrequency)
|
||||
{
|
||||
length = (long) (Stk::sampleRate() / lowestFrequency + 1);
|
||||
loopGain = (MY_FLOAT) 0.999;
|
||||
delayLine = new DelayA( (MY_FLOAT)(length / 2.0), length );
|
||||
loopFilter = new OneZero;
|
||||
noise = new Noise;
|
||||
envelope = new ADSR();
|
||||
envelope->setAllTimes(2.0, 0.5, 0.0, 0.5);
|
||||
this->clear();
|
||||
}
|
||||
|
||||
Drone :: ~Drone()
|
||||
{
|
||||
delete delayLine;
|
||||
delete loopFilter;
|
||||
delete envelope;
|
||||
delete noise;
|
||||
}
|
||||
|
||||
void Drone :: clear()
|
||||
{
|
||||
delayLine->clear();
|
||||
loopFilter->clear();
|
||||
}
|
||||
|
||||
void Drone :: setFrequency(MY_FLOAT frequency)
|
||||
{
|
||||
MY_FLOAT freakency = frequency;
|
||||
if ( frequency <= 0.0 ) {
|
||||
cerr << "Drone: setFrequency parameter is less than or equal to zero!" << endl;
|
||||
freakency = 220.0;
|
||||
}
|
||||
|
||||
// Delay = length - approximate filter delay.
|
||||
MY_FLOAT delay = (Stk::sampleRate() / freakency) - (MY_FLOAT) 0.5;
|
||||
if (delay <= 0.0) delay = 0.3;
|
||||
else if (delay > length) delay = length;
|
||||
delayLine->setDelay(delay);
|
||||
loopGain = 0.997 + (freakency * 0.000002);
|
||||
if ( loopGain >= 1.0 ) loopGain = (MY_FLOAT) 0.99999;
|
||||
}
|
||||
|
||||
void Drone :: pluck(MY_FLOAT amplitude)
|
||||
{
|
||||
envelope->keyOn();
|
||||
}
|
||||
|
||||
void Drone :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude)
|
||||
{
|
||||
this->setFrequency(frequency);
|
||||
this->pluck(amplitude);
|
||||
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "Drone: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Drone :: noteOff(MY_FLOAT amplitude)
|
||||
{
|
||||
loopGain = (MY_FLOAT) 1.0 - amplitude;
|
||||
if ( loopGain < 0.0 ) {
|
||||
cerr << "Drone: noteOff amplitude greater than 1.0!" << endl;
|
||||
loopGain = 0.0;
|
||||
}
|
||||
else if ( loopGain > 1.0 ) {
|
||||
cerr << "Drone: noteOff amplitude less than or zero!" << endl;
|
||||
loopGain = (MY_FLOAT) 0.99999;
|
||||
}
|
||||
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "Drone: NoteOff amplitude = " << amplitude << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
MY_FLOAT Drone :: tick()
|
||||
{
|
||||
// Here's the whole inner loop of the instrument!!
|
||||
lastOutput = delayLine->tick( loopFilter->tick( delayLine->lastOut() * loopGain ) + (0.005 * envelope->tick() * noise->tick()));
|
||||
return lastOutput;
|
||||
}
|
||||
67
projects/ragamatic/Drone.h
Normal file
67
projects/ragamatic/Drone.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************/
|
||||
/*! \class Drone
|
||||
\brief STK "drone" plucked string model.
|
||||
|
||||
This class implements a simple plucked string
|
||||
physical model based on the Karplus-Strong
|
||||
algorithm.
|
||||
|
||||
This is a digital waveguide model, making its
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
There exist at least two patents, assigned to
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DRONE_H)
|
||||
#define __DRONE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Drone : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Drone(MY_FLOAT lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Drone();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
OneZero *loopFilter;
|
||||
ADSR *envelope;
|
||||
Noise *noise;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
wish < tcl/TCLRaga.tcl | ragamat -ip
|
||||
@@ -9,26 +9,26 @@ OS = $(shell uname)
|
||||
# the core STK classes.
|
||||
STK_PATH = ../../src/
|
||||
|
||||
O_FILES = Object.o Envelope.o ADSR.o Noise.o \
|
||||
Filter.o DLineA.o DLineL.o DLineN.o \
|
||||
OnePole.o OneZero.o DCBlock.o SKINI11.o \
|
||||
ByteSwap.o Tabla.o Instrmnt.o Sitar1.o \
|
||||
StrDrone.o VoicDrum.o WvOut.o WvIn.o RawWvIn.o \
|
||||
O_FILES = Stk.o Envelope.o ADSR.o Noise.o \
|
||||
Filter.o DelayA.o Delay.o \
|
||||
OnePole.o OneZero.o SKINI.o \
|
||||
Tabla.o Instrmnt.o Sitar.o \
|
||||
Drone.o VoicDrum.o WvOut.o WvIn.o \
|
||||
RtAudio.o RtWvOut.o RtMidi.o Reverb.o \
|
||||
JCRev.o Controller.o StkError.o
|
||||
JCRev.o Messager.o Socket.o Thread.o
|
||||
|
||||
RM = /bin/rm
|
||||
|
||||
ifeq ($(OS),IRIX) # These are for SGI
|
||||
INSTR = ragamat
|
||||
CC = CC -O2 -D__OS_IRIX_ # -g -fullwarn -D__SGI_CC__
|
||||
CC = CC -O2 -D__IRIX_AL__ # -g -fullwarn -D__SGI_CC__
|
||||
LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm -lpthread
|
||||
INCLUDE = -I../../include
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Linux) # These are for Linux
|
||||
INSTR = ragamat
|
||||
CC = g++ -O3 -Wall -D__OS_Linux_ # -g
|
||||
CC = g++ -O3 -Wall -D__LINUX_OSS__ -D__LITTLE_ENDIAN__ # -g
|
||||
LIBRARY = -lpthread -lm #-lasound
|
||||
INCLUDE = -I../../include
|
||||
endif
|
||||
@@ -56,11 +56,8 @@ strip :
|
||||
Tabla.o: Tabla.cpp
|
||||
$(CC) $(INCLUDE) -c Tabla.cpp
|
||||
|
||||
Sitar1.o: Sitar1.cpp
|
||||
$(CC) $(INCLUDE) -c Sitar1.cpp
|
||||
|
||||
StrDrone.o: StrDrone.cpp
|
||||
$(CC) $(INCLUDE) -c StrDrone.cpp
|
||||
Drone.o: Drone.cpp
|
||||
$(CC) $(INCLUDE) -c Drone.cpp
|
||||
|
||||
VoicDrum.o: VoicDrum.cpp
|
||||
$(CC) $(INCLUDE) -c VoicDrum.cpp
|
||||
@@ -4,21 +4,21 @@
|
||||
# the core STK classes.
|
||||
STK_PATH = ../../src/
|
||||
|
||||
O_FILES = $(STK_PATH)Object.o $(STK_PATH)Envelope.o $(STK_PATH)ADSR.o \
|
||||
$(STK_PATH)Filter.o $(STK_PATH)DLineL.o $(STK_PATH)DLineN.o \
|
||||
$(STK_PATH)ByteSwap.o $(STK_PATH)Noise.o $(STK_PATH)OnePole.o \
|
||||
$(STK_PATH)OneZero.o $(STK_PATH)DCBlock.o $(STK_PATH)SKINI11.o \
|
||||
$(STK_PATH)Instrmnt.o $(STK_PATH)WvIn.o $(STK_PATH)RawWvIn.o \
|
||||
$(STK_PATH)DLineA.o $(STK_PATH)Reverb.o $(STK_PATH)JCRev.o \
|
||||
O_FILES = $(STK_PATH)Stk.o $(STK_PATH)Envelope.o $(STK_PATH)ADSR.o \
|
||||
$(STK_PATH)Filter.o $(STK_PATH)DelayA.o $(STK_PATH)Delay.o \
|
||||
$(STK_PATH)Noise.o $(STK_PATH)OnePole.o $(STK_PATH)OneZero.o \
|
||||
$(STK_PATH)SKINI.o $(STK_PATH)Instrmnt.o $(STK_PATH)WvIn.o \
|
||||
$(STK_PATH)Sitar.o $(STK_PATH)Reverb.o $(STK_PATH)JCRev.o \
|
||||
$(STK_PATH)WvOut.o $(STK_PATH)RtAudio.o $(STK_PATH)RtMidi.o \
|
||||
$(STK_PATH)RtWvOut.o $(STK_PATH)StkError.o $(STK_PATH)Controller.o
|
||||
$(STK_PATH)RtWvOut.o $(STK_PATH)Messager.o $(STK_PATH)Socket.o \
|
||||
$(STK_PATH)Thread.o
|
||||
|
||||
O_LOCAL_FILES = Tabla.o Sitar1.o StrDrone.o VoicDrum.o
|
||||
O_LOCAL_FILES = Tabla.o Drone.o VoicDrum.o
|
||||
|
||||
RM = /bin/rm
|
||||
|
||||
INSTR = ragamat
|
||||
CC = CC -O2 -D__OS_IRIX_ # -g -fullwarn -D__SGI_CC__
|
||||
CC = CC -O2 -D__IRIX_AL__ # -g -fullwarn -D__SGI_CC__
|
||||
LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm -lpthread
|
||||
INCLUDE = -I../../include/
|
||||
|
||||
@@ -47,11 +47,8 @@ strip :
|
||||
Tabla.o: Tabla.cpp
|
||||
$(CC) $(INCLUDE) -c Tabla.cpp
|
||||
|
||||
Sitar1.o: Sitar1.cpp
|
||||
$(CC) $(INCLUDE) -c Sitar1.cpp
|
||||
|
||||
StrDrone.o: StrDrone.cpp
|
||||
$(CC) $(INCLUDE) -c StrDrone.cpp
|
||||
Drone.o: Drone.cpp
|
||||
$(CC) $(INCLUDE) -c Drone.cpp
|
||||
|
||||
VoicDrum.o: VoicDrum.cpp
|
||||
$(CC) $(INCLUDE) -c VoicDrum.cpp
|
||||
|
||||
@@ -11,13 +11,13 @@ In the RagaMatic directory, type:
|
||||
|
||||
to compile and then
|
||||
|
||||
> GUIRaga
|
||||
> Raga.bat
|
||||
|
||||
to have fun and achieve inner peace.
|
||||
|
||||
If you ask me, I think this band needs a flute player too. If you like, team up and see if you can add the flute model to the project. This requires adding a few files to the Makefile, a few lines to the ragamat.cpp file (including how the flute player should play, etc.), and another slider to the TCL script to control the flute's contributions. This might only run on the fastest machines once you've added the flute.
|
||||
|
||||
Since latency isn't much of an issue in raga-land, you might bump up the RT_BUFFER_SIZE in Object.h to something around 1024, depending on the speed of your machine. If you don't have the GNU makefile utilities on your system, take a look at one of the system-specific makefiles (example: Makefile.sgi) in the syntmono directory to see what changes you need to make.
|
||||
Since latency isn't much of an issue in raga-land, you might bump up the RT_BUFFER_SIZE in Stk.h to something around 1024, depending on the speed of your machine. If you don't have the GNU makefile utilities on your system, take a look at one of the system-specific makefiles (example: Makefile.sgi) in the syntmono directory to see what changes you need to make.
|
||||
|
||||
All is Bliss...
|
||||
All is Bliss...
|
||||
|
||||
1
projects/ragamatic/Raga.bat
Executable file
1
projects/ragamatic/Raga.bat
Executable file
@@ -0,0 +1 @@
|
||||
wish < tcl/Raga.tcl | ragamat -ip
|
||||
@@ -1,100 +0,0 @@
|
||||
/******************************************/
|
||||
/* Karplus-Strong Sitar1 string model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* There exist at least two patents, */
|
||||
/* assigned to Stanford, bearing the */
|
||||
/* names of Karplus and/or Strong. */
|
||||
/******************************************/
|
||||
|
||||
#include "Sitar1.h"
|
||||
|
||||
Sitar1 :: Sitar1(MY_FLOAT lowestFreq)
|
||||
{
|
||||
length = (long) (SRATE / lowestFreq + 1);
|
||||
loopGain = (MY_FLOAT) 0.999;
|
||||
loopFilt = new OneZero();
|
||||
loopFilt->setCoeff(0.01);
|
||||
delayLine = new DLineA(length);
|
||||
delay = length/2;
|
||||
delayTarg = delay;
|
||||
envelope = new ADSR();
|
||||
noise = new Noise;
|
||||
envelope->setAllTimes(0.001,0.04,0.0,0.5);
|
||||
this->clear();
|
||||
}
|
||||
|
||||
Sitar1 :: ~Sitar1()
|
||||
{
|
||||
delete loopFilt;
|
||||
delete delayLine;
|
||||
delete envelope;
|
||||
delete noise;
|
||||
}
|
||||
|
||||
void Sitar1 :: clear()
|
||||
{
|
||||
loopFilt->clear();
|
||||
delayLine->clear();
|
||||
}
|
||||
|
||||
void Sitar1 :: setFreq(MY_FLOAT frequency)
|
||||
{
|
||||
delayTarg = (SRATE / frequency);
|
||||
delay = delayTarg * (1.0 + (0.05 * noise->tick()));
|
||||
delayLine->setDelay(delay);
|
||||
loopGain = (MY_FLOAT) 0.995 + (frequency * (MY_FLOAT) 0.000001);
|
||||
if (loopGain>1.0) loopGain = (MY_FLOAT) 0.9995;
|
||||
}
|
||||
|
||||
void Sitar1 :: pluck(MY_FLOAT amplitude)
|
||||
{
|
||||
envelope->keyOn();
|
||||
}
|
||||
|
||||
void Sitar1 :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
|
||||
{
|
||||
this->setFreq(freq);
|
||||
this->pluck(amp);
|
||||
amPluck = 0.05 * amp;
|
||||
#if defined(_debug_)
|
||||
printf("Sitar1 : NoteOn: Freq=%lf Amp=%lf\n",freq,amp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Sitar1 :: noteOff(MY_FLOAT amp)
|
||||
{
|
||||
loopGain = (MY_FLOAT) 1.0 - amp;
|
||||
#if defined(_debug_)
|
||||
printf("Sitar1 : NoteOff: Amp=%lf\n",amp);
|
||||
#endif
|
||||
}
|
||||
|
||||
MY_FLOAT Sitar1 :: tick()
|
||||
{
|
||||
MY_FLOAT temp;
|
||||
|
||||
temp = delayLine->lastOut();
|
||||
if (fabs(temp) > 1.0) {
|
||||
loopGain = 0.1;
|
||||
this->noteOff(0.9);
|
||||
delay = delayTarg;
|
||||
delayLine->setDelay(delay);
|
||||
}
|
||||
|
||||
temp *= loopGain;
|
||||
|
||||
if (fabs(delayTarg - delay) > 0.001) {
|
||||
if (delayTarg < delay)
|
||||
delay *= 0.99999;
|
||||
else
|
||||
delay *= 1.00001;
|
||||
delayLine->setDelay(delay);
|
||||
}
|
||||
|
||||
lastOutput = delayLine->tick(loopFilt->tick(temp)
|
||||
+ (amPluck * envelope->tick() * noise->tick()));
|
||||
|
||||
return lastOutput;
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/******************************************/
|
||||
/* Karplus-Strong Sitar1 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(__Sitar1_h)
|
||||
#define __Sitar1_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.h"
|
||||
#include "OneZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Sitar1 : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineA *delayLine;
|
||||
OneZero *loopFilt;
|
||||
ADSR *envelope;
|
||||
Noise *noise;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
MY_FLOAT amPluck;
|
||||
MY_FLOAT delay;
|
||||
MY_FLOAT delayTarg;
|
||||
public:
|
||||
Sitar1(MY_FLOAT lowestFreq);
|
||||
~Sitar1();
|
||||
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
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/******************************************/
|
||||
/* Karplus-Strong StrDrone string model */
|
||||
/* by Perry Cook, 1995-96 */
|
||||
/* */
|
||||
/* There exist at least two patents, */
|
||||
/* assigned to Stanford, bearing the */
|
||||
/* names of Karplus and/or Strong. */
|
||||
/******************************************/
|
||||
|
||||
#include "StrDrone.h"
|
||||
|
||||
StrDrone :: StrDrone(MY_FLOAT lowestFreq)
|
||||
{
|
||||
length = (long) (SRATE / lowestFreq + 1);
|
||||
loopGain = (MY_FLOAT) 0.999;
|
||||
loopFilt = new OneZero();
|
||||
delayLine = new DLineA(length);
|
||||
envelope = new ADSR();
|
||||
noise = new Noise;
|
||||
envelope->setAllTimes(2.0,0.5,0.0,0.5);
|
||||
this->clear();
|
||||
}
|
||||
|
||||
StrDrone :: ~StrDrone()
|
||||
{
|
||||
delete loopFilt;
|
||||
delete delayLine;
|
||||
delete envelope;
|
||||
delete noise;
|
||||
}
|
||||
|
||||
void StrDrone :: clear()
|
||||
{
|
||||
loopFilt->clear();
|
||||
delayLine->clear();
|
||||
}
|
||||
|
||||
void StrDrone :: setFreq(MY_FLOAT frequency)
|
||||
{
|
||||
MY_FLOAT delay;
|
||||
delay = (SRATE / frequency);
|
||||
delayLine->setDelay(delay - 0.5);
|
||||
loopGain = (MY_FLOAT) 0.997 + (frequency * (MY_FLOAT) 0.000002);
|
||||
if (loopGain>1.0) loopGain = (MY_FLOAT) 0.99999;
|
||||
}
|
||||
|
||||
void StrDrone :: pluck(MY_FLOAT amplitude)
|
||||
{
|
||||
envelope->keyOn();
|
||||
}
|
||||
|
||||
void StrDrone :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
|
||||
{
|
||||
this->setFreq(freq);
|
||||
this->pluck(amp);
|
||||
#if defined(_debug_)
|
||||
printf("StrDrone : NoteOn: Freq=%lf Amp=%lf\n",freq,amp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void StrDrone :: noteOff(MY_FLOAT amp)
|
||||
{
|
||||
loopGain = (MY_FLOAT) 1.0 - amp;
|
||||
#if defined(_debug_)
|
||||
printf("StrDrone : NoteOff: Amp=%lf\n",amp);
|
||||
#endif
|
||||
}
|
||||
|
||||
MY_FLOAT StrDrone :: tick()
|
||||
{
|
||||
/* check this out */
|
||||
/* here's the whole inner loop of the instrument!! */
|
||||
lastOutput = delayLine->tick(loopFilt->tick((delayLine->lastOut() * loopGain))
|
||||
+ (0.005 * envelope->tick() * noise->tick()));
|
||||
return lastOutput;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/******************************************/
|
||||
/* Karplus-Strong StrDrone 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(__StrDrone_h)
|
||||
#define __StrDrone_h
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DLineA.h"
|
||||
#include "OneZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class StrDrone : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
DLineA *delayLine;
|
||||
ADSR *envelope;
|
||||
Noise *noise;
|
||||
OneZero *loopFilt;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
public:
|
||||
StrDrone(MY_FLOAT lowestFreq);
|
||||
~StrDrone();
|
||||
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
|
||||
|
||||
@@ -1,144 +1,147 @@
|
||||
/*******************************************/
|
||||
/* 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) */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Tabla
|
||||
\brief STK tabla drum class.
|
||||
|
||||
This class implements a drum sampling
|
||||
synthesizer using WvIn objects and one-pole
|
||||
filters. The drum rawwave files are sampled
|
||||
at 22050 Hz, but will be appropriately
|
||||
interpolated for other sample rates. You can
|
||||
specify the maximum polyphony (maximum number
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Tabla.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
Tabla :: Tabla() : Instrmnt()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<TABLA_POLYPHONY;i++) {
|
||||
for (int i=0; i<TABLA_POLYPHONY; i++) {
|
||||
filters[i] = new OnePole;
|
||||
sounding[i] = -1;
|
||||
}
|
||||
/* This counts the number of sounding voices */
|
||||
numSounding = 0;
|
||||
|
||||
/* Print warning about aliasing if SRATE < 22050 */
|
||||
if (SRATE < 22050) {
|
||||
printf("\nWarning: Tabla is designed for sampling rates of\n");
|
||||
printf("22050 Hz or greater. You will likely encounter aliasing\n");
|
||||
printf("at the current sampling rate of %.0f Hz.\n\n", SRATE);
|
||||
}
|
||||
// This counts the number of sounding voices.
|
||||
nSounding = 0;
|
||||
}
|
||||
|
||||
Tabla :: ~Tabla()
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<numSounding-1; i++ ) delete waves[i];
|
||||
for ( i=0; i<nSounding-1; i++ ) delete waves[i];
|
||||
for ( i=0; i<TABLA_POLYPHONY; i++ ) delete filters[i];
|
||||
}
|
||||
|
||||
void Tabla :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
|
||||
void Tabla :: noteOn(MY_FLOAT instrument, MY_FLOAT amplitude)
|
||||
{
|
||||
int i, notDone;
|
||||
int noteNum;
|
||||
int vel;
|
||||
char tempString[64];
|
||||
RawWvIn *tempWv;
|
||||
OnePole *tempFilt;
|
||||
char waveNames[TABLA_NUMWAVES][16] = {
|
||||
"Drdak2.raw",
|
||||
"Drdak3.raw",
|
||||
"Drdak4.raw",
|
||||
"Drddak1.raw",
|
||||
"Drdee1.raw",
|
||||
"Drdee2.raw",
|
||||
"Drdoo1.raw",
|
||||
"Drdoo2.raw",
|
||||
"Drdoo3.raw",
|
||||
"Drjun1.raw",
|
||||
"Drjun2.raw",
|
||||
"DrDoi1.raw",
|
||||
"DrDoi2.raw",
|
||||
"DrTak1.raw",
|
||||
"DrTak2.raw"
|
||||
};
|
||||
|
||||
noteNum = (int) freq;
|
||||
vel = (int) (amp * 127);
|
||||
|
||||
#if defined(_debug_)
|
||||
printf("NoteOn: %i vel=%i\n",noteNum,vel);
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "Tabla: NoteOn instrument = " << instrument << ", amplitude = " << amplitude << endl;
|
||||
#endif
|
||||
|
||||
notDone = -1;
|
||||
for (i=0;i<TABLA_POLYPHONY;i++) { /* Check first to see */
|
||||
if (sounding[i] == noteNum) notDone = i; /* if there's already */
|
||||
} /* one like this sounding */
|
||||
MY_FLOAT gain = amplitude;
|
||||
if ( amplitude > 1.0 ) {
|
||||
cerr << "Tabla: noteOn amplitude parameter is greater than 1.0!" << endl;
|
||||
gain = 1.0;
|
||||
}
|
||||
else if ( amplitude < 0.0 ) {
|
||||
cerr << "Tabla: noteOn amplitude parameter is less than 0.0!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (notDone<0) { /* If not, then */
|
||||
if (numSounding == TABLA_POLYPHONY) { /* If we're already */
|
||||
delete waves[0]; /* at max polyphony, */
|
||||
filters[0]->clear(); /* then */
|
||||
tempWv = waves[0];
|
||||
tempFilt = filters[0];
|
||||
for (i=0;i<TABLA_POLYPHONY-1;i++) { /* preempt oldest */
|
||||
waves[i] = waves[i+1]; /* voice and */
|
||||
filters[i] = filters[i+1]; /* ripple all down */
|
||||
static char tablaWaves[TABLA_NUMWAVES][16] =
|
||||
{ "Drdak2.raw",
|
||||
"Drdak3.raw",
|
||||
"Drdak4.raw",
|
||||
"Drddak1.raw",
|
||||
"Drdee1.raw",
|
||||
"Drdee2.raw",
|
||||
"Drdoo1.raw",
|
||||
"Drdoo2.raw",
|
||||
"Drdoo3.raw",
|
||||
"Drjun1.raw",
|
||||
"Drjun2.raw",
|
||||
"DrDoi1.raw",
|
||||
"DrDoi2.raw",
|
||||
"DrTak1.raw",
|
||||
"DrTak2.raw"
|
||||
};
|
||||
|
||||
int noteNum = ((int) instrument) % 16;
|
||||
|
||||
// Check first to see if there's already one like this sounding.
|
||||
int i, waveIndex = -1;
|
||||
for (i=0; i<TABLA_POLYPHONY; i++) {
|
||||
if (sounding[i] == noteNum) waveIndex = i;
|
||||
}
|
||||
|
||||
if ( waveIndex >= 0 ) {
|
||||
// Reset this sound.
|
||||
waves[waveIndex]->reset();
|
||||
filters[waveIndex]->setPole((MY_FLOAT) 0.999 - (gain * 0.6));
|
||||
filters[waveIndex]->setGain(gain);
|
||||
}
|
||||
else {
|
||||
if (nSounding == TABLA_POLYPHONY) {
|
||||
// If we're already at maximum polyphony, then preempt the oldest voice.
|
||||
delete waves[0];
|
||||
filters[0]->clear();
|
||||
WvIn *tempWv = waves[0];
|
||||
OnePole *tempFilt = filters[0];
|
||||
// Re-order the list.
|
||||
for (i=0; i<TABLA_POLYPHONY-1; i++) {
|
||||
waves[i] = waves[i+1];
|
||||
filters[i] = filters[i+1];
|
||||
}
|
||||
waves[TABLA_POLYPHONY-1] = tempWv;
|
||||
filters[TABLA_POLYPHONY-1] = tempFilt;
|
||||
} else {
|
||||
numSounding += 1; /* otherwise just add one */
|
||||
}
|
||||
else
|
||||
nSounding += 1;
|
||||
|
||||
sounding[numSounding-1] = noteNum; /* allocate new wave */
|
||||
strcpy(tempString,"rawwaves/");
|
||||
strcat(tempString,waveNames[noteNum]);
|
||||
waves[numSounding-1] = new RawWvIn(tempString, "oneshot");
|
||||
if (SRATE != 22050) {
|
||||
waves[numSounding-1]->setRate((MY_FLOAT) (22050.0/SRATE));
|
||||
}
|
||||
waves[numSounding-1]->normalize((MY_FLOAT) 0.4);
|
||||
filters[numSounding-1]->setPole((MY_FLOAT) 0.999 - ((MY_FLOAT) vel * NORM_7 * 0.6));
|
||||
filters[numSounding-1]->setGain(vel / (MY_FLOAT) 128.0);
|
||||
}
|
||||
else {
|
||||
waves[notDone]->reset();
|
||||
filters[notDone]->setPole((MY_FLOAT) 0.999 - ((MY_FLOAT) vel * NORM_7 * 0.6));
|
||||
filters[notDone]->setGain(vel / (MY_FLOAT) 128.0);
|
||||
sounding[nSounding-1] = noteNum;
|
||||
// Concatenate the STK RAWWAVE_PATH to the rawwave file
|
||||
char path[128];
|
||||
strcpy(path, "rawwaves/");
|
||||
strcat(path, tablaWaves[noteNum]);
|
||||
waves[nSounding-1] = new WvIn(path, TRUE);
|
||||
waves[nSounding-1]->normalize(0.4);
|
||||
filters[nSounding-1]->setPole((MY_FLOAT) 0.999 - (gain * 0.6) );
|
||||
filters[nSounding-1]->setGain( gain );
|
||||
}
|
||||
|
||||
#if defined(_debug_)
|
||||
printf("Number Sounding = %i\n",numSounding);
|
||||
for (i=0;i<numSounding;i++) printf(" %i ",sounding[i]);
|
||||
printf("\n");
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "Number Sounding = " << nSounding << endl;
|
||||
for (i=0; i<nSounding; i++) cerr << sounding[i] << " ";
|
||||
cerr << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tabla :: noteOff(MY_FLOAT amplitude)
|
||||
{
|
||||
// Set all sounding wave filter gains low.
|
||||
int i = 0;
|
||||
while(i < nSounding) {
|
||||
filters[i++]->setGain( amplitude * 0.01 );
|
||||
}
|
||||
}
|
||||
|
||||
MY_FLOAT Tabla :: tick()
|
||||
{
|
||||
int j, i = 0;
|
||||
MY_FLOAT output = 0.0;
|
||||
OnePole *tempFilt;
|
||||
|
||||
while (i < numSounding) {
|
||||
output += filters[i]->tick(waves[i]->lastOut());
|
||||
if (waves[i]->informTick() == 1) {
|
||||
int j, i = 0;
|
||||
while (i < nSounding) {
|
||||
if ( waves[i]->isFinished() ) {
|
||||
delete waves[i];
|
||||
tempFilt = filters[i];
|
||||
|
||||
for (j=i;j<numSounding-1;j++) {
|
||||
// Re-order the list.
|
||||
for (j=i; j<nSounding-1; j++) {
|
||||
sounding[j] = sounding[j+1];
|
||||
waves[j] = waves[j+1];
|
||||
filters[j] = filters[j+1];
|
||||
@@ -146,10 +149,13 @@ MY_FLOAT Tabla :: tick()
|
||||
filters[j] = tempFilt;
|
||||
filters[j]->clear();
|
||||
sounding[j] = -1;
|
||||
numSounding -= 1;
|
||||
nSounding -= 1;
|
||||
i -= 1;
|
||||
}
|
||||
else
|
||||
output += filters[i]->tick( waves[i]->tick() );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
/*******************************************/
|
||||
/* 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) */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class Tabla
|
||||
\brief STK tabla drum class.
|
||||
|
||||
#if !defined(__Tabla_h)
|
||||
#define __Tabla_h
|
||||
This class implements a drum sampling
|
||||
synthesizer using WvIn objects and one-pole
|
||||
filters. The drum rawwave files are sampled
|
||||
at 22050 Hz, but will be appropriately
|
||||
interpolated for other sample rates. You can
|
||||
specify the maximum polyphony (maximum number
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__TABLA_H)
|
||||
#define __TABLA_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define TABLA_NUMWAVES 15
|
||||
@@ -31,16 +27,28 @@
|
||||
|
||||
class Tabla : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
RawWvIn *waves[TABLA_POLYPHONY];
|
||||
OnePole *filters[TABLA_POLYPHONY];
|
||||
int sounding[TABLA_POLYPHONY];
|
||||
int numSounding;
|
||||
public:
|
||||
public:
|
||||
//! Class constructor.
|
||||
Tabla();
|
||||
|
||||
//! Class destructor.
|
||||
~Tabla();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Start a note with the given drum type and amplitude.
|
||||
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
WvIn *waves[TABLA_POLYPHONY];
|
||||
OnePole *filters[TABLA_POLYPHONY];
|
||||
int sounding[TABLA_POLYPHONY];
|
||||
int nSounding;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +1,61 @@
|
||||
/*******************************************/
|
||||
/* 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) */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class VoicDrum
|
||||
\brief STK vocal drum sample player class.
|
||||
|
||||
This class implements a drum sampling
|
||||
synthesizer using WvIn objects and one-pole
|
||||
filters. The drum rawwave files are sampled
|
||||
at 22050 Hz, but will be appropriately
|
||||
interpolated for other sample rates. You can
|
||||
specify the maximum polyphony (maximum number
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "VoicDrum.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
VoicDrum :: VoicDrum() : Instrmnt()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<DRUM_POLYPHONY;i++) {
|
||||
for (int i=0; i<VOICE_POLYPHONY; i++) {
|
||||
filters[i] = new OnePole;
|
||||
sounding[i] = -1;
|
||||
}
|
||||
/* This counts the number of sounding voices */
|
||||
numSounding = 0;
|
||||
|
||||
/* Print warning about aliasing if SRATE < 22050 */
|
||||
if (SRATE < 22050) {
|
||||
printf("\nWarning: VoicDrum is designed for sampling rates of\n");
|
||||
printf("22050 Hz or greater. You will likely encounter aliasing\n");
|
||||
printf("at the current sampling rate of %.0f Hz.\n\n", SRATE);
|
||||
}
|
||||
// This counts the number of sounding voices.
|
||||
nSounding = 0;
|
||||
}
|
||||
|
||||
VoicDrum :: ~VoicDrum()
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<numSounding-1; i++ ) delete waves[i];
|
||||
for ( i=0; i<DRUM_POLYPHONY; i++ ) delete filters[i];
|
||||
for ( i=0; i<nSounding-1; i++ ) delete waves[i];
|
||||
for ( i=0; i<VOICE_POLYPHONY; i++ ) delete filters[i];
|
||||
}
|
||||
|
||||
void VoicDrum :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
|
||||
void VoicDrum :: noteOn(MY_FLOAT instrument, MY_FLOAT amplitude)
|
||||
{
|
||||
int i, notDone;
|
||||
int noteNum;
|
||||
int vel;
|
||||
char tempString[64];
|
||||
RawWvIn *tempWv;
|
||||
OnePole *tempFilt;
|
||||
char waveNames[DRUM_NUMWAVES][16] = {
|
||||
"tak2.raw",
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "VoicDrum: NoteOn instrument = " << instrument << ", amplitude = " << amplitude << endl;
|
||||
#endif
|
||||
|
||||
MY_FLOAT gain = amplitude;
|
||||
if ( amplitude > 1.0 ) {
|
||||
cerr << "VoicDrum: noteOn amplitude parameter is greater than 1.0!" << endl;
|
||||
gain = 1.0;
|
||||
}
|
||||
else if ( amplitude < 0.0 ) {
|
||||
cerr << "VoicDrum: noteOn amplitude parameter is less than 0.0!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
char voiceNames[VOICE_NUMWAVES][11] =
|
||||
{
|
||||
"tak2.raw",
|
||||
"tak1.raw",
|
||||
"bee1.raw",
|
||||
"dee1.raw",
|
||||
@@ -68,74 +66,79 @@ void VoicDrum :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
|
||||
"jun2.raw",
|
||||
"tak3.raw",
|
||||
"tak4.raw"
|
||||
};
|
||||
};
|
||||
|
||||
/* Yes I know, this is tres kludgey */
|
||||
noteNum = (int)freq;
|
||||
vel = (int) (amp * 127);
|
||||
int noteNum = ((int) instrument) % 11;
|
||||
|
||||
#if defined(_debug_)
|
||||
printf("NoteOn: %i vel=%i\n",noteNum,vel);
|
||||
#endif
|
||||
// Check first to see if there's already one like this sounding.
|
||||
int i, waveIndex = -1;
|
||||
for (i=0; i<VOICE_POLYPHONY; i++) {
|
||||
if (sounding[i] == noteNum) waveIndex = i;
|
||||
}
|
||||
|
||||
notDone = -1;
|
||||
for (i=0;i<DRUM_POLYPHONY;i++) { /* Check first to see */
|
||||
if (sounding[i] == noteNum) notDone = i; /* if there's already */
|
||||
} /* one like this sounding */
|
||||
|
||||
if (notDone<0) { /* If not, then */
|
||||
if (numSounding == DRUM_POLYPHONY) { /* If we're already */
|
||||
delete waves[0]; /* at max polyphony, */
|
||||
filters[0]->clear(); /* then */
|
||||
tempWv = waves[0];
|
||||
tempFilt = filters[0];
|
||||
for (i=0;i<DRUM_POLYPHONY-1;i++) { /* preempt oldest */
|
||||
waves[i] = waves[i+1]; /* voice and */
|
||||
filters[i] = filters[i+1]; /* ripple all down */
|
||||
}
|
||||
waves[DRUM_POLYPHONY-1] = tempWv;
|
||||
filters[DRUM_POLYPHONY-1] = tempFilt;
|
||||
} else {
|
||||
numSounding += 1; /* otherwise just add one */
|
||||
}
|
||||
|
||||
sounding[numSounding-1] = noteNum; /* allocate new wave */
|
||||
strcpy(tempString,"rawwaves/");
|
||||
strcat(tempString,waveNames[noteNum]);
|
||||
waves[numSounding-1] = new RawWvIn(tempString, "oneshot");
|
||||
if (SRATE != 22050) {
|
||||
waves[numSounding-1]->setRate((MY_FLOAT) (22050.0/SRATE));
|
||||
}
|
||||
waves[numSounding-1]->normalize((MY_FLOAT) 0.4);
|
||||
filters[numSounding-1]->setPole((MY_FLOAT) 0.999 - ((MY_FLOAT) vel * NORM_7 * 0.6));
|
||||
filters[numSounding-1]->setGain(vel / (MY_FLOAT) 128.0);
|
||||
if ( waveIndex >= 0 ) {
|
||||
// Reset this sound.
|
||||
waves[waveIndex]->reset();
|
||||
filters[waveIndex]->setPole((MY_FLOAT) 0.999 - (gain * 0.6));
|
||||
filters[waveIndex]->setGain(gain);
|
||||
}
|
||||
else {
|
||||
waves[notDone]->reset();
|
||||
filters[notDone]->setPole((MY_FLOAT) 0.999 - ((MY_FLOAT) vel * NORM_7 * 0.6));
|
||||
filters[notDone]->setGain(vel / (MY_FLOAT) 128.0);
|
||||
if (nSounding == VOICE_POLYPHONY) {
|
||||
// If we're already at maximum polyphony, then preempt the oldest voice.
|
||||
delete waves[0];
|
||||
filters[0]->clear();
|
||||
WvIn *tempWv = waves[0];
|
||||
OnePole *tempFilt = filters[0];
|
||||
// Re-order the list.
|
||||
for (i=0; i<VOICE_POLYPHONY-1; i++) {
|
||||
waves[i] = waves[i+1];
|
||||
filters[i] = filters[i+1];
|
||||
}
|
||||
waves[VOICE_POLYPHONY-1] = tempWv;
|
||||
filters[VOICE_POLYPHONY-1] = tempFilt;
|
||||
}
|
||||
else
|
||||
nSounding += 1;
|
||||
|
||||
sounding[nSounding-1] = noteNum;
|
||||
// Concatenate the STK RAWWAVE_PATH to the rawwave file
|
||||
char path[128];
|
||||
strcpy(path, "rawwaves/");
|
||||
strcat(path, voiceNames[noteNum]);
|
||||
waves[nSounding-1] = new WvIn(path, TRUE);
|
||||
waves[nSounding-1]->normalize(0.4);
|
||||
filters[nSounding-1]->setPole((MY_FLOAT) 0.999 - (gain * 0.6) );
|
||||
filters[nSounding-1]->setGain( gain );
|
||||
}
|
||||
|
||||
#if defined(_debug_)
|
||||
printf("Number Sounding = %i\n",numSounding);
|
||||
for (i=0;i<numSounding;i++) printf(" %i ",sounding[i]);
|
||||
printf("\n");
|
||||
#if defined(_STK_DEBUG_)
|
||||
cerr << "Number Sounding = " << nSounding << endl;
|
||||
for (i=0; i<nSounding; i++) cerr << sounding[i] << " ";
|
||||
cerr << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoicDrum :: noteOff(MY_FLOAT amplitude)
|
||||
{
|
||||
// Set all sounding wave filter gains low.
|
||||
int i = 0;
|
||||
while(i < nSounding) {
|
||||
filters[i++]->setGain( amplitude * 0.01 );
|
||||
}
|
||||
}
|
||||
|
||||
MY_FLOAT VoicDrum :: tick()
|
||||
{
|
||||
int j, i = 0;
|
||||
MY_FLOAT output = 0.0;
|
||||
OnePole *tempFilt;
|
||||
|
||||
while (i < numSounding) {
|
||||
output += filters[i]->tick(waves[i]->lastOut());
|
||||
if (waves[i]->informTick() == 1) {
|
||||
int j, i = 0;
|
||||
while (i < nSounding) {
|
||||
if ( waves[i]->isFinished() ) {
|
||||
delete waves[i];
|
||||
tempFilt = filters[i];
|
||||
|
||||
for (j=i;j<numSounding-1;j++) {
|
||||
// Re-order the list.
|
||||
for (j=i; j<nSounding-1; j++) {
|
||||
sounding[j] = sounding[j+1];
|
||||
waves[j] = waves[j+1];
|
||||
filters[j] = filters[j+1];
|
||||
@@ -143,10 +146,13 @@ MY_FLOAT VoicDrum :: tick()
|
||||
filters[j] = tempFilt;
|
||||
filters[j]->clear();
|
||||
sounding[j] = -1;
|
||||
numSounding -= 1;
|
||||
nSounding -= 1;
|
||||
i -= 1;
|
||||
}
|
||||
else
|
||||
output += filters[i]->tick( waves[i]->tick() );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -1,46 +1,54 @@
|
||||
/*******************************************/
|
||||
/* 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) */
|
||||
/*******************************************/
|
||||
/***************************************************/
|
||||
/*! \class VoicDrum
|
||||
\brief STK vocal drum sample player class.
|
||||
|
||||
#if !defined(__VoicDrum_h)
|
||||
#define __VoicDrum_h
|
||||
This class implements a drum sampling
|
||||
synthesizer using WvIn objects and one-pole
|
||||
filters. The drum rawwave files are sampled
|
||||
at 22050 Hz, but will be appropriately
|
||||
interpolated for other sample rates. You can
|
||||
specify the maximum polyphony (maximum number
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__VOICDRUM_H)
|
||||
#define __VOICDRUM_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "RawWvIn.h"
|
||||
#include "WvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define DRUM_NUMWAVES 11
|
||||
#define DRUM_POLYPHONY 4
|
||||
#define VOICE_NUMWAVES 11
|
||||
#define VOICE_POLYPHONY 4
|
||||
|
||||
class VoicDrum : public Instrmnt
|
||||
{
|
||||
protected:
|
||||
RawWvIn *waves[DRUM_POLYPHONY];
|
||||
OnePole *filters[DRUM_POLYPHONY];
|
||||
int sounding[DRUM_POLYPHONY];
|
||||
int numSounding;
|
||||
public:
|
||||
public:
|
||||
//! Class constructor.
|
||||
VoicDrum();
|
||||
|
||||
//! Class destructor.
|
||||
~VoicDrum();
|
||||
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
//! Start a note with the given drum type and amplitude.
|
||||
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
|
||||
protected:
|
||||
WvIn *waves[VOICE_POLYPHONY];
|
||||
OnePole *filters[VOICE_POLYPHONY];
|
||||
int sounding[VOICE_POLYPHONY];
|
||||
int nSounding;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,31 +1,21 @@
|
||||
/************** Test Main Program Individual Voice *********************/
|
||||
|
||||
#include "RtWvOut.h"
|
||||
#include "SKINI11.msg"
|
||||
#include "SKINI.msg"
|
||||
#include "Instrmnt.h"
|
||||
#include "Reverb.h"
|
||||
#include "JCRev.h"
|
||||
#include "StrDrone.h"
|
||||
#include "Sitar1.h"
|
||||
#include "Drone.h"
|
||||
#include "Sitar.h"
|
||||
#include "Tabla.h"
|
||||
#include "VoicDrum.h"
|
||||
#include "miditabl.h"
|
||||
|
||||
#define RATE_NORM (MY_FLOAT) (22050.0/SRATE)
|
||||
|
||||
// The input control handler.
|
||||
#include "Controller.h"
|
||||
#include "Messager.h"
|
||||
|
||||
// Return random float between 0.0 and max
|
||||
MY_FLOAT float_random(MY_FLOAT max) {
|
||||
MY_FLOAT temp;
|
||||
#if defined(__OS_Win_) /* For Windoze */
|
||||
temp = (MY_FLOAT) (rand() * max);
|
||||
temp *= ONE_OVER_RANDLIMIT;
|
||||
#else /* This is for unix */
|
||||
temp = (MY_FLOAT) (random() * max);
|
||||
temp *= ONE_OVER_RANDLIMIT;
|
||||
#endif
|
||||
MY_FLOAT float_random(MY_FLOAT max) // Return random float between 0.0 and max
|
||||
{
|
||||
MY_FLOAT temp = (MY_FLOAT) (max * rand() / (RAND_MAX + 1.0) );
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -40,13 +30,21 @@ void usage(void) {
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
long i, nTicks;
|
||||
int type;
|
||||
MY_FLOAT byte2, byte3, temp;
|
||||
MY_FLOAT outSamples[2];
|
||||
int controlMask = 0;
|
||||
bool done;
|
||||
MY_FLOAT reverbTime = 4.0; /* in seconds */
|
||||
RtWvOut *output;
|
||||
Instrmnt *drones[3];
|
||||
Instrmnt *sitar;
|
||||
Instrmnt *voicDrums;
|
||||
Instrmnt *tabla;
|
||||
Reverb *reverbs[2];
|
||||
SKINI *score;
|
||||
Messager *messager;
|
||||
MY_FLOAT t60 = 4.0; // in seconds
|
||||
|
||||
// If you want to change the default sample rate (set in Stk.h), do
|
||||
// it before instantiating any objects!!
|
||||
Stk::setSampleRate( 22050.0 );
|
||||
|
||||
MY_FLOAT drone_prob = 0.01, note_prob = 0.0;
|
||||
MY_FLOAT drum_prob = 0.0, voic_prob = 0.0;
|
||||
MY_FLOAT droneFreqs[3] = {55.0,82.5,220.0};
|
||||
@@ -58,17 +56,10 @@ int main(int argc,char *argv[])
|
||||
{52, 54, 55, 57, 59, 60, 63, 64, 66, 67, 71, 72}};
|
||||
int ragaDown[2][13] = {{57, 60, 62, 64, 65, 67, 69, 71, 72, 76, 79, 81},
|
||||
{48, 52, 53, 55, 57, 59, 60, 64, 66, 68, 70, 72}};
|
||||
RtWvOut *output;
|
||||
Instrmnt *drones[3];
|
||||
Instrmnt *sitar;
|
||||
Instrmnt *voicDrums;
|
||||
Instrmnt *drums;
|
||||
Reverb *reverbs[2];
|
||||
SKINI11 *score;
|
||||
Controller *controller;
|
||||
|
||||
if (argc != 2) usage();
|
||||
|
||||
int controlMask = 0;
|
||||
if (!strcmp(argv[1],"-is") )
|
||||
controlMask |= STK_SOCKET;
|
||||
else if (!strcmp(argv[1],"-ip") )
|
||||
@@ -80,22 +71,21 @@ int main(int argc,char *argv[])
|
||||
output = new RtWvOut(2);
|
||||
|
||||
// Instantiate the input message controller.
|
||||
controller = new Controller( controlMask );
|
||||
messager = new Messager( controlMask );
|
||||
}
|
||||
catch (StkError& m) {
|
||||
m.printMessage();
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
drones[0] = new StrDrone(50.0);
|
||||
drones[1] = new StrDrone(50.0);
|
||||
drones[2] = new StrDrone(50.0);
|
||||
sitar = new Sitar1(50.0);
|
||||
drones[0] = new Drone(50.0);
|
||||
drones[1] = new Drone(50.0);
|
||||
drones[2] = new Drone(50.0);
|
||||
sitar = new Sitar(50.0);
|
||||
voicDrums = new VoicDrum();
|
||||
drums = new Tabla();
|
||||
tabla = new Tabla();
|
||||
|
||||
score = new SKINI11();
|
||||
reverbs[0] = new JCRev(reverbTime);
|
||||
score = new SKINI();
|
||||
reverbs[0] = new JCRev(t60);
|
||||
reverbs[0]->setEffectMix(0.5);
|
||||
reverbs[1] = new JCRev(2.0);
|
||||
reverbs[1]->setEffectMix(0.2);
|
||||
@@ -104,41 +94,47 @@ int main(int argc,char *argv[])
|
||||
drones[1]->noteOn(droneFreqs[1],0.1);
|
||||
drones[2]->noteOn(droneFreqs[2],0.1);
|
||||
|
||||
for (i=0;i<SRATE;i++) { /* warm everybody up a little */
|
||||
int i;
|
||||
MY_FLOAT outSamples[2];
|
||||
for (i=0;i<Stk::sampleRate();i++) { /* warm everybody up a little */
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
|
||||
// The runtime loop begins here:
|
||||
done = FALSE;
|
||||
MY_FLOAT rateScaler = 22050.0 / Stk::sampleRate();
|
||||
int nTicks, type;
|
||||
MY_FLOAT temp, byte2, byte3;
|
||||
while (!done) {
|
||||
|
||||
nTicks = controller->getNextMessage();
|
||||
|
||||
if (nTicks == -1)
|
||||
type = messager->nextMessage();
|
||||
if (type < 0)
|
||||
done = TRUE;
|
||||
|
||||
nTicks = messager->getDelta();
|
||||
|
||||
for (i=0; i<nTicks; i++) {
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick()
|
||||
+ sitar->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick() + 0.5 * voicDrums->tick()
|
||||
+ 0.5 * drums->tick());
|
||||
+ 0.5 * tabla->tick());
|
||||
// mix a little left to right and back
|
||||
temp = outSamples[0];
|
||||
outSamples[0] += 0.3 * outSamples[1];
|
||||
outSamples[1] += 0.3 * temp;
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
|
||||
counter -= 1;
|
||||
if (counter == 0) {
|
||||
counter = (int) (tempo / RATE_NORM);
|
||||
counter = (int) (tempo / rateScaler);
|
||||
if (float_random(1.0) < drone_prob)
|
||||
drones[0]->noteOn(droneFreqs[0],0.1);
|
||||
drones[0]->noteOn(droneFreqs[0], 0.1);
|
||||
if (float_random(1.0) < drone_prob)
|
||||
drones[1]->noteOn(droneFreqs[1],0.1);
|
||||
drones[1]->noteOn(droneFreqs[1], 0.1);
|
||||
if (float_random(1.0) < drone_prob)
|
||||
drones[2]->noteOn(droneFreqs[2],0.1);
|
||||
drones[2]->noteOn(droneFreqs[2], 0.1);
|
||||
if (float_random(1.0) < note_prob) {
|
||||
if ((temp = float_random(1.0)) < 0.1)
|
||||
ragaStep = 0;
|
||||
@@ -152,46 +148,45 @@ int main(int argc,char *argv[])
|
||||
if (ragaPoint > 11)
|
||||
ragaPoint = 11;
|
||||
if (ragaStep > 0)
|
||||
sitar->noteOn(__MIDI_To_Pitch[ragaUp[key][ragaPoint]],
|
||||
sitar->noteOn(Midi2Pitch[ragaUp[key][ragaPoint]],
|
||||
0.05 + float_random(0.3));
|
||||
else
|
||||
sitar->noteOn(__MIDI_To_Pitch[ragaDown[key][ragaPoint]],
|
||||
sitar->noteOn(Midi2Pitch[ragaDown[key][ragaPoint]],
|
||||
0.05 + float_random(0.3));
|
||||
}
|
||||
if (float_random(1.0) < voic_prob) {
|
||||
voicNote = (int) float_random(11);
|
||||
voicDrums->noteOn(voicNote, 0.3 + (0.4 * drum_prob) +
|
||||
float_random(0.9 * voic_prob));
|
||||
float_random(0.3 * voic_prob));
|
||||
}
|
||||
if (float_random(1.0) < drum_prob) {
|
||||
voicNote = (int) float_random(TABLA_NUMWAVES);
|
||||
drums->noteOn(voicNote, 0.2 + (0.2 * drum_prob) +
|
||||
float_random(0.7 * drum_prob));
|
||||
tabla->noteOn(voicNote, 0.2 + (0.2 * drum_prob) +
|
||||
float_random(0.6 * drum_prob));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type = controller->getType();
|
||||
if (type > 0) {
|
||||
if ( type > 0 ) {
|
||||
// parse the input control message
|
||||
|
||||
byte2 = controller->getByte2();
|
||||
byte3 = controller->getByte3();
|
||||
byte2 = messager->getByteTwo();
|
||||
byte3 = messager->getByteThree();
|
||||
|
||||
switch(type) {
|
||||
|
||||
case __SK_ControlChange_:
|
||||
if (byte2 == 1) {
|
||||
drone_prob = byte3 * NORM_7;
|
||||
drone_prob = byte3 * ONE_OVER_128;
|
||||
}
|
||||
else if (byte2 == 2) {
|
||||
note_prob = byte3 * NORM_7;
|
||||
note_prob = byte3 * ONE_OVER_128;
|
||||
}
|
||||
else if (byte2 == 4) {
|
||||
voic_prob = byte3 * NORM_7;
|
||||
voic_prob = byte3 * ONE_OVER_128;
|
||||
}
|
||||
else if (byte2 == 11) {
|
||||
drum_prob = byte3 * NORM_7;
|
||||
drum_prob = byte3 * ONE_OVER_128;
|
||||
}
|
||||
else if (byte2 == 7) {
|
||||
tempo = (int) (11025 - (byte3 * 70));
|
||||
@@ -214,38 +209,40 @@ int main(int argc,char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
nTicks = (long) (t60 * Stk::sampleRate());
|
||||
|
||||
printf("What Need Have I for This?\n");
|
||||
drones[1]->noteOn(droneFreqs[1],0.1);
|
||||
for (i=0; i<reverbTime*SRATE; i++) { // Calm down a little
|
||||
for (i=0; i<nTicks; i++) { // Calm down a little
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
printf("What Need Have I for This?\n");
|
||||
drones[2]->noteOn(droneFreqs[2],0.1);
|
||||
for (i=0; i<reverbTime*SRATE; i++) { // and a little more
|
||||
for (i=0; i<nTicks; i++) { // and a little more
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
printf("RagaMatic finished ... \n");
|
||||
drones[0]->noteOn(droneFreqs[0],0.1);
|
||||
for (i=0; i<reverbTime*SRATE; i++) { // almost ready to think about ending
|
||||
for (i=0; i<nTicks; i++) { // almost ready to think about ending
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
printf("All is Bliss ...\n");
|
||||
for (i=0; i<reverbTime*SRATE; i++) { // nearly finished now
|
||||
for (i=0; i<nTicks; i++) { // nearly finished now
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
printf("All is Bliss ...\n");
|
||||
for (i=0; i<reverbTime*SRATE; i++) { // all is bliss....
|
||||
for (i=0; i<nTicks; i++) { // all is bliss....
|
||||
outSamples[0] = reverbs[0]->tick(drones[0]->tick() + drones[2]->tick());
|
||||
outSamples[1] = reverbs[1]->tick(1.5 * drones[1]->tick());
|
||||
output->mtick(outSamples);
|
||||
output->tickFrame(outSamples);
|
||||
}
|
||||
|
||||
delete output;
|
||||
@@ -254,11 +251,11 @@ int main(int argc,char *argv[])
|
||||
delete drones[1];
|
||||
delete drones[2];
|
||||
delete sitar;
|
||||
delete drums;
|
||||
delete tabla;
|
||||
delete voicDrums;
|
||||
delete reverbs[0];
|
||||
delete reverbs[1];
|
||||
delete controller;
|
||||
delete messager;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
104
projects/ragamatic/ragamat.dsp
Executable file → Normal file
104
projects/ragamatic/ragamat.dsp
Executable file → Normal file
@@ -38,11 +38,11 @@ RSC=rc.exe
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Intermediate_Dir "release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__OS_Win_" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -62,11 +62,11 @@ LINK32=link.exe
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Intermediate_Dir "debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__OS_Win_" /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -92,43 +92,35 @@ SOURCE=..\..\include\ADSR.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\ByteSwap.cpp
|
||||
SOURCE=..\..\src\Delay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\ByteSwap.h
|
||||
SOURCE=..\..\include\Delay.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Controller.cpp
|
||||
SOURCE=..\..\src\DelayA.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Controller.h
|
||||
SOURCE=..\..\include\DelayA.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\DLineA.cpp
|
||||
SOURCE=..\..\src\DelayL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\DLineA.h
|
||||
SOURCE=..\..\include\DelayL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\DLineL.cpp
|
||||
SOURCE=.\Drone.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\DLineL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\DLineN.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\DLineN.h
|
||||
SOURCE=.\Drone.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -164,6 +156,14 @@ SOURCE=..\..\include\JCRev.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Messager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Messager.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Noise.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -172,22 +172,6 @@ SOURCE=..\..\include\Noise.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\NRev.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\NRev.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Object.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Object.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\OnePole.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -204,26 +188,10 @@ SOURCE=..\..\include\OneZero.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\PRCRev.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\PRCRev.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ragamat.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\RawWvIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\RawWvIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Reverb.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -256,35 +224,35 @@ SOURCE=..\..\include\RtWvOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sitar1.cpp
|
||||
SOURCE=..\..\src\Sitar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sitar1.h
|
||||
SOURCE=..\..\include\Sitar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\SKINI11.cpp
|
||||
SOURCE=..\..\src\SKINI.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\SKINI11.h
|
||||
SOURCE=..\..\include\SKINI.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\StkError.cpp
|
||||
SOURCE=..\..\src\Socket.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\StkError.h
|
||||
SOURCE=..\..\include\Socket.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StrDrone.cpp
|
||||
SOURCE=..\..\src\Stk.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StrDrone.h
|
||||
SOURCE=..\..\include\Stk.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -296,6 +264,14 @@ SOURCE=.\Tabla.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Thread.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Thread.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VoicDrum.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -304,6 +280,14 @@ SOURCE=.\VoicDrum.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\WaveLoop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\WaveLoop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\WvIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
0
projects/ragamatic/ragamatic.dsw
Executable file → Normal file
0
projects/ragamatic/ragamatic.dsw
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,55 +0,0 @@
|
||||
/**********************************************/
|
||||
/** Utility to make various functions **/
|
||||
/** like exponential and log gain curves. **/
|
||||
/** **/
|
||||
/** Included here: **/
|
||||
/** Yamaha TX81Z curves for master gain, **/
|
||||
/** Envelope Rates (in normalized units), **/
|
||||
/** envelope sustain level, and more.... **/
|
||||
/**********************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void main()
|
||||
{
|
||||
int i,j;
|
||||
double temp;
|
||||
double data[128];
|
||||
|
||||
/*************** TX81Z Master Gain *************/
|
||||
for (i=0;i<100;i++) {
|
||||
data[i] = pow(2.0,-(99-i)/10.0);
|
||||
}
|
||||
data[0] = 0.0;
|
||||
printf("double __FM4Op_gains[99] = {");
|
||||
for (i=0;i<100;i++) {
|
||||
if (i%8 == 0) printf("\n");
|
||||
printf("%lf,",data[i]);
|
||||
}
|
||||
printf("};\n");
|
||||
/*************** TX81Z Sustain Level ***********/
|
||||
for (i=0;i<16;i++) {
|
||||
data[i] = pow(2.0,-(15-i)/2.0);
|
||||
}
|
||||
data[0] = 0.0;
|
||||
printf("double __FM4Op_susLevels[16] = {");
|
||||
for (i=0;i<16;i++) {
|
||||
if (i%8 == 0) printf("\n");
|
||||
printf("%lf,",data[i]);
|
||||
}
|
||||
printf("};\n");
|
||||
/****************** Attack Rate ***************/
|
||||
for (i=0;i<32;i++) {
|
||||
data[i] = 6.0 * pow(5.7,-(i-1)/5.0);
|
||||
}
|
||||
printf("double __FM4Op_attTimes[16] = {");
|
||||
for (i=0;i<32;i++) {
|
||||
if (i%8 == 0) printf("\n");
|
||||
printf("%lf,",data[i]);
|
||||
}
|
||||
printf("};\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/**********************************************/
|
||||
/** Utility to make various functions **/
|
||||
/** like exponential and log gain curves. **/
|
||||
/** Specifically for direct MIDI parameter **/
|
||||
/** conversions. **/
|
||||
/** Included here: **/
|
||||
/** A440 Referenced Equal Tempered Pitches **/
|
||||
/** as a function of MIDI note number. **/
|
||||
/** **/
|
||||
/**********************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void main()
|
||||
{
|
||||
int i,j;
|
||||
double temp;
|
||||
double data[128];
|
||||
|
||||
/********* Pitch as fn. of MIDI Note **********/
|
||||
|
||||
printf("double __MIDI_To_Pitch[128] = {");
|
||||
for (i=0;i<128;i++) {
|
||||
if (i%8 == 0) printf("\n");
|
||||
temp = 220.0 * pow(2.0,((double) i - 57) / 12.0);
|
||||
printf("%.2lf,",temp);
|
||||
}
|
||||
printf("};\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/**********************************************/
|
||||
/** Utility to make various flavors of **/
|
||||
/** sine wave (rectified, etc), and **/
|
||||
/** other commonly needed waveforms, like **/
|
||||
/** triangles, ramps, etc. **/
|
||||
/** The files generated are all 16 bit **/
|
||||
/** linear signed integer, of length **/
|
||||
/** as defined by LENGTH below **/
|
||||
/**********************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define LENGTH 256
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
void main()
|
||||
{
|
||||
int i,j;
|
||||
double temp;
|
||||
short data[LENGTH + 2];
|
||||
FILE *fd;
|
||||
|
||||
/////////// Yer Basic TX81Z Waves, Including Sine ///////////
|
||||
fd = fopen("halfwave.raw","wb");
|
||||
for (i=0;i<LENGTH/2;i++)
|
||||
data[i] = 32767 * sin(i * 2 * PI / (double) LENGTH);
|
||||
for (i=LENGTH/2;i<LENGTH;i++)
|
||||
data[i] = 0;
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("sinewave.raw","wb");
|
||||
for (i=LENGTH/2;i<LENGTH;i++)
|
||||
data[i] = 32767 * sin(i * 2 * PI / (double) LENGTH);
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("sineblnk.raw","wb");
|
||||
for (i=0;i<LENGTH/2;i++)
|
||||
data[i] = data[2*i];
|
||||
for (i=LENGTH/2;i<LENGTH;i++)
|
||||
data[i] = 0;
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("fwavblnk.raw","wb");
|
||||
for (i=0;i<LENGTH/4;i++)
|
||||
data[i+LENGTH/4] = data[i];
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("snglpeak.raw","wb");
|
||||
for (i=0;i<=LENGTH/4;i++)
|
||||
data[i] = 32767 * (1.0 - cos(i * 2 * PI / (double) LENGTH));
|
||||
for (i=0;i<=LENGTH/4;i++)
|
||||
data[LENGTH/2-i] = data[i];
|
||||
for (i=LENGTH/2;i<LENGTH;i++)
|
||||
data[i] = 0;
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("twopeaks.raw","wb");
|
||||
for (i=0;i<=LENGTH/2;i++) {
|
||||
data[LENGTH/2+i] = -data[i];
|
||||
}
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("peksblnk.raw","wb");
|
||||
for (i=0;i<=LENGTH/2;i++)
|
||||
data[i] = data[i*2];
|
||||
for (i=LENGTH/2;i<LENGTH;i++)
|
||||
data[i] = 0;
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("ppksblnk.raw","wb");
|
||||
for (i=0;i<=LENGTH/4;i++)
|
||||
data[i+LENGTH/4] = data[i];
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
/////////// Impulses of various bandwidth ///////////
|
||||
fd = fopen("impuls10.raw","wb");
|
||||
for (i=0;i<LENGTH;i++) {
|
||||
temp = 0.0;
|
||||
for (j=1;j<=10;j++)
|
||||
temp += cos(i * j * 2 * PI / (double) LENGTH);
|
||||
data[i] = 32767 / 10.0 * temp;
|
||||
}
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("impuls20.raw","wb");
|
||||
for (i=0;i<LENGTH;i++) {
|
||||
temp = 0.0;
|
||||
for (j=1;j<=20;j++)
|
||||
temp += cos(i * j * 2 * PI / (double) LENGTH);
|
||||
data[i] = 32767 / 20.0 * temp;
|
||||
}
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
fd = fopen("impuls40.raw","wb");
|
||||
for (i=0;i<LENGTH;i++) {
|
||||
temp = 0.0;
|
||||
for (j=1;j<=40;j++)
|
||||
temp += cos(i * j * 2 * PI / (double) LENGTH);
|
||||
data[i] = 32767 / 40.0 * temp;
|
||||
}
|
||||
fwrite(&data,2,LENGTH,fd);
|
||||
fclose(fd);
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -51,7 +51,7 @@ bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff -1.0 1 60 127"]
|
||||
puts $outID [format "NoteOff 0.0 1 60 127"]
|
||||
flush $outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
@@ -66,11 +66,11 @@ proc mellow {} {
|
||||
set cont4 0.0
|
||||
set cont11 10.0
|
||||
set cont7 3.0
|
||||
printWhatz "ControlChange -1.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange -1.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange -1.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange -1.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange -1.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
}
|
||||
|
||||
proc nicevibe {} {
|
||||
@@ -80,11 +80,11 @@ proc nicevibe {} {
|
||||
set cont4 21.0
|
||||
set cont11 50.0
|
||||
set cont7 60.0
|
||||
printWhatz "ControlChange -1.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange -1.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange -1.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange -1.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange -1.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
}
|
||||
|
||||
proc voicSolo {} {
|
||||
@@ -94,11 +94,11 @@ proc voicSolo {} {
|
||||
set cont4 90.0
|
||||
set cont11 10.0
|
||||
set cont7 120.0
|
||||
printWhatz "ControlChange -1.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange -1.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange -1.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange -1.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange -1.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
}
|
||||
|
||||
proc drumSolo {} {
|
||||
@@ -108,11 +108,11 @@ proc drumSolo {} {
|
||||
set cont4 0.0
|
||||
set cont11 100.0
|
||||
set cont7 120.0
|
||||
printWhatz "ControlChange -1.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange -1.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange -1.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange -1.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange -1.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
}
|
||||
|
||||
proc rockOut {} {
|
||||
@@ -122,28 +122,28 @@ proc rockOut {} {
|
||||
set cont4 52.0
|
||||
set cont11 120.0
|
||||
set cont7 123.0
|
||||
printWhatz "ControlChange -1.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange -1.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange -1.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange -1.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange -1.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 7 $cont7
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
}
|
||||
|
||||
proc raga {scale} {
|
||||
global outID
|
||||
puts $outID [format "ControlChange -1.0 1 64 %f" $scale]
|
||||
puts $outID [format "ControlChange 0.0 1 64 %f" $scale]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn -1.0 1 %f %f" $pitchVal $pressVal]
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff -1.0 1 %f %f" $pitchVal $pressVal]
|
||||
puts $outID [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
@@ -182,31 +182,31 @@ button .banner.butts.noteOn -text "Cease Meditations and Exit" \
|
||||
frame .controls -bg black
|
||||
|
||||
scale .controls.cont1 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 1} \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Drone Probability" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
|
||||
scale .controls.cont2 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 2} \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Sitar Probability" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
|
||||
scale .controls.cont4 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 4} \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Voice Drum Probability" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .controls.cont11 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 11} \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Tabla Probability" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
|
||||
scale .controls.cont7 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 7} \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Tempo" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
Reference in New Issue
Block a user