mirror of
https://github.com/thestk/stk
synced 2026-04-27 09:38:37 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
@@ -1,123 +0,0 @@
|
||||
/******************************************/
|
||||
/* Chorus Effect Applied to Soundfile */
|
||||
/* by Perry Cook, 1996 */
|
||||
/******************************************/
|
||||
|
||||
#include "Chorus.h"
|
||||
|
||||
Chorus :: Chorus(MY_FLOAT baseDelay)
|
||||
{
|
||||
delayLine[0] = new DLineL((long) (baseDelay * 1.414) + 2);
|
||||
delayLine[1] = new DLineL((long) (baseDelay) + 2);
|
||||
delayLine[0]->setDelay(baseDelay);
|
||||
delayLine[1]->setDelay(baseDelay);
|
||||
baseLength = baseDelay;
|
||||
|
||||
// Concatenate the STK RAWWAVE_PATH to the rawwave file
|
||||
char temp[128];
|
||||
strcpy(temp, RAWWAVE_PATH);
|
||||
mods[0] = new RawWvIn(strcat(temp,"rawwaves/sinewave.raw"),"looping");
|
||||
strcpy(temp, RAWWAVE_PATH);
|
||||
mods[1] = new RawWvIn(strcat(temp,"rawwaves/sinewave.raw"),"looping");
|
||||
mods[0]->setFreq(0.2);
|
||||
mods[1]->setFreq(0.222222);
|
||||
modDepth = 0.05;
|
||||
effectMix = (MY_FLOAT) 0.5;
|
||||
this->clear();
|
||||
}
|
||||
|
||||
Chorus :: ~Chorus()
|
||||
{
|
||||
delete delayLine[0];
|
||||
delete delayLine[1];
|
||||
delete mods[0];
|
||||
delete mods[1];
|
||||
}
|
||||
|
||||
void Chorus :: clear()
|
||||
{
|
||||
delayLine[0]->clear();
|
||||
delayLine[1]->clear();
|
||||
lastOutL = (MY_FLOAT) 0.0;
|
||||
lastOutR = (MY_FLOAT) 0.0;
|
||||
}
|
||||
|
||||
void Chorus :: setEffectMix(MY_FLOAT mix)
|
||||
{
|
||||
effectMix = mix;
|
||||
}
|
||||
|
||||
void Chorus :: setModDepth(MY_FLOAT depth)
|
||||
{
|
||||
modDepth = depth;
|
||||
}
|
||||
|
||||
void Chorus :: setModFreq(MY_FLOAT freq)
|
||||
{
|
||||
mods[0]->setFreq(freq);
|
||||
mods[1]->setFreq(freq*1.1111);
|
||||
}
|
||||
|
||||
MY_FLOAT Chorus :: lastOutput()
|
||||
{
|
||||
return (lastOutL + lastOutR) * (MY_FLOAT) 0.5;
|
||||
}
|
||||
|
||||
MY_FLOAT Chorus :: lastOutputL()
|
||||
{
|
||||
return lastOutL;
|
||||
}
|
||||
|
||||
MY_FLOAT Chorus :: lastOutputR()
|
||||
{
|
||||
return lastOutR;
|
||||
}
|
||||
|
||||
MY_FLOAT Chorus :: tick(MY_FLOAT input)
|
||||
{
|
||||
delayLine[0]->setDelay(baseLength * 0.707 * (1.0 + mods[0]->tick()));
|
||||
delayLine[1]->setDelay(baseLength * 0.5 * (1.0 - mods[1]->tick()));
|
||||
lastOutL = input * (1.0 - effectMix);
|
||||
lastOutL += effectMix * delayLine[0]->tick(input);
|
||||
lastOutR = input * (1.0 - effectMix);
|
||||
lastOutR += effectMix * delayLine[1]->tick(input);
|
||||
return (lastOutL + lastOutR) * (MY_FLOAT) 0.5;
|
||||
}
|
||||
|
||||
/************** Test Main Program *********************/
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *soundIn,*soundOut;
|
||||
short data;
|
||||
float efMix,maxDel;
|
||||
Chorus *effect;
|
||||
|
||||
if (argc==5) {
|
||||
soundIn = fopen(argv[3],"rb");
|
||||
soundOut = fopen(argv[4],"wb");
|
||||
if (soundIn && soundOut) {
|
||||
efMix = atof(argv[1]);
|
||||
maxDel = atof(argv[2]);
|
||||
effect = new Chorus(maxDel);
|
||||
effect->setEffectMix(efMix);
|
||||
while (fread(&data,2,1,soundIn)) {
|
||||
data = effect->tick(data);
|
||||
fwrite(&data,2,1,soundOut);
|
||||
}
|
||||
delete effect;
|
||||
fclose(soundIn);
|
||||
fclose(soundOut);
|
||||
}
|
||||
else {
|
||||
printf("Can't open one of the files\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("useage: Chorus mix maxDelay soundIn.snd soundOut.snd\n");
|
||||
printf("0.0 <= mix <= 1.0\n");
|
||||
printf("maxDelay is in samples\n");
|
||||
printf("soundfiles are 16 bit linear mono or stereo\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,37 +0,0 @@
|
||||
/******************************************/
|
||||
/* Chorus Effect */
|
||||
/* by Perry Cook, 1996 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Chorus_h)
|
||||
#define __Chorus_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "DLineL.h"
|
||||
#include "RawWvIn.h"
|
||||
|
||||
class Chorus : public Object
|
||||
{
|
||||
protected:
|
||||
DLineL *delayLine[2];
|
||||
RawWvIn *mods[2];
|
||||
MY_FLOAT baseLength;
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT lastOutL;
|
||||
MY_FLOAT lastOutR;
|
||||
MY_FLOAT effectMix;
|
||||
public:
|
||||
Chorus(MY_FLOAT baseDelay);
|
||||
~Chorus();
|
||||
void clear();
|
||||
void setModDepth(MY_FLOAT depth);
|
||||
void setModFreq(MY_FLOAT freq);
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
MY_FLOAT lastOutput();
|
||||
MY_FLOAT lastOutputL();
|
||||
MY_FLOAT lastOutputR();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/******************************************/
|
||||
/* Echo Effect */
|
||||
/* by Perry Cook, 1996 */
|
||||
/******************************************/
|
||||
|
||||
#include "Echo.h"
|
||||
|
||||
Echo :: Echo(MY_FLOAT longestDelay)
|
||||
{
|
||||
length = (long) longestDelay + 2;
|
||||
delayLine = new DLineN(length);
|
||||
effectMix = 0.5;
|
||||
this->clear();
|
||||
this->setDelay(longestDelay);
|
||||
}
|
||||
|
||||
Echo :: ~Echo()
|
||||
{
|
||||
delete delayLine;
|
||||
}
|
||||
|
||||
void Echo :: clear()
|
||||
{
|
||||
delayLine->clear();
|
||||
lastOut = 0.0;
|
||||
}
|
||||
|
||||
void Echo :: setDelay(MY_FLOAT delay)
|
||||
{
|
||||
delayLine->setDelay(delay);
|
||||
}
|
||||
|
||||
void Echo :: setEffectMix(MY_FLOAT mix)
|
||||
{
|
||||
effectMix = mix;
|
||||
}
|
||||
|
||||
MY_FLOAT Echo :: tick(MY_FLOAT input)
|
||||
{
|
||||
lastOut = effectMix * delayLine->tick(input);
|
||||
lastOut += input * (1.0 - effectMix);
|
||||
return lastOut;
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/******************************************/
|
||||
/* Echo Effect Applied to Soundfile */
|
||||
/* by Perry Cook, 1996 */
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__Echo_h)
|
||||
#define __Echo_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "DLineN.h"
|
||||
|
||||
class Echo : public Object
|
||||
{
|
||||
protected:
|
||||
DLineN *delayLine;
|
||||
long length;
|
||||
MY_FLOAT lastOut;
|
||||
MY_FLOAT effectMix;
|
||||
public:
|
||||
Echo(MY_FLOAT longestDelay);
|
||||
~Echo();
|
||||
void clear();
|
||||
void setDelay(MY_FLOAT delay);
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
MY_FLOAT lastOutput();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,11 @@ OS = $(shell uname)
|
||||
# the core STK classes.
|
||||
STK_PATH = ../../src/
|
||||
|
||||
O_FILES = Object.o Reverb.o PRCRev.o JCRev.o \
|
||||
NRev.o RtAudio.o DLineN.o Filter.o \
|
||||
RtDuplex.o SKINI11.o Envelope.o Echo.o \
|
||||
PitShift.o DLineL.o Chorus.o RawWvIn.o \
|
||||
WvIn.o ByteSwap.o StkError.o Controller.o \
|
||||
O_FILES = Stk.o Reverb.o PRCRev.o JCRev.o \
|
||||
NRev.o RtAudio.o Delay.o Filter.o \
|
||||
RtDuplex.o SKINI.o Envelope.o Echo.o \
|
||||
PitShift.o DelayL.o Chorus.o WvIn.o \
|
||||
WaveLoop.o Messager.o Thread.o Socket.o \
|
||||
RtMidi.o
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ RM = /bin/rm
|
||||
|
||||
ifeq ($(OS),IRIX) # These are for SGI
|
||||
INSTR = effects
|
||||
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 = effects
|
||||
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
|
||||
@@ -49,12 +49,3 @@ effects: effects.cpp $(O_FILES)
|
||||
$(CC) $(INCLUDE) -o effects effects.cpp $(O_FILES) $(LIBRARY)
|
||||
|
||||
# $(O_FILES) :
|
||||
|
||||
Echo.o: Echo.cpp
|
||||
$(CC) $(INCLUDE) -c Echo.cpp
|
||||
|
||||
PitShift.o: PitShift.cpp
|
||||
$(CC) $(INCLUDE) -c PitShift.cpp
|
||||
|
||||
Chorus.o: Chorus.cpp
|
||||
$(CC) $(INCLUDE) -c Chorus.cpp
|
||||
@@ -4,19 +4,19 @@
|
||||
# the core STK classes.
|
||||
STK_PATH = ../../src/
|
||||
|
||||
O_FILES = $(STK_PATH)Object.o $(STK_PATH)Envelope.o $(STK_PATH)Filter.o \
|
||||
$(STK_PATH)DLineL.o $(STK_PATH)DLineN.o $(STK_PATH)ByteSwap.o \
|
||||
$(STK_PATH)SKINI11.o $(STK_PATH)WvIn.o $(STK_PATH)RawWvIn.o \
|
||||
$(STK_PATH)Reverb.o $(STK_PATH)PRCRev.o $(STK_PATH)JCRev.o \
|
||||
$(STK_PATH)NRev.o $(STK_PATH)RtAudio.o $(STK_PATH)RtMidi.o \
|
||||
$(STK_PATH)RtDuplex.o $(STK_PATH)StkError.o $(STK_PATH)Controller.o
|
||||
O_FILES = $(STK_PATH)Stk.o $(STK_PATH)Envelope.o $(STK_PATH)Filter.o \
|
||||
$(STK_PATH)DelayL.o $(STK_PATH)Delay.o $(STK_PATH)SKINI.o \
|
||||
$(STK_PATH)WvIn.o $(STK_PATH)Reverb.o $(STK_PATH)PRCRev.o \
|
||||
$(STK_PATH)JCRev.o $(STK_PATH)NRev.o $(STK_PATH)RtAudio.o \
|
||||
$(STK_PATH)RtMidi.o $(STK_PATH)RtDuplex.o $(STK_PATH)Messager.o \
|
||||
$(STK_PATH)WaveLoop.o $(STK_PATH)Thread.o $(STK_PATH)Socket.o
|
||||
|
||||
O_LOCAL_FILES = Echo.o PitShift.o Chorus.o
|
||||
|
||||
RM = /bin/rm
|
||||
|
||||
INSTR = effects
|
||||
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/
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*********************************************/
|
||||
/* PitchShift Effect */
|
||||
/* by Perry Cook, 1996 */
|
||||
/*********************************************/
|
||||
|
||||
#include "PitShift.h"
|
||||
|
||||
PitShift :: PitShift()
|
||||
{
|
||||
delayLine[0] = new DLineL((long) 1024);
|
||||
delayLine[1] = new DLineL((long) 1024);
|
||||
delay[0] = 12;
|
||||
delay[1] = 512;
|
||||
delayLine[0]->setDelay(delay[0]);
|
||||
delayLine[1]->setDelay(delay[1]);
|
||||
effectMix = (MY_FLOAT) 0.5;
|
||||
rate = 1.0;
|
||||
}
|
||||
|
||||
PitShift :: ~PitShift()
|
||||
{
|
||||
delete delayLine[0];
|
||||
delete delayLine[1];
|
||||
}
|
||||
|
||||
void PitShift :: setEffectMix(MY_FLOAT mix)
|
||||
{
|
||||
effectMix = mix;
|
||||
}
|
||||
|
||||
void PitShift :: setShift(MY_FLOAT shift)
|
||||
{
|
||||
if (shift < 1.0) {
|
||||
rate = 1.0 - shift;
|
||||
}
|
||||
else if (shift > 1.0) {
|
||||
rate = 1.0 - shift;
|
||||
}
|
||||
else {
|
||||
rate = 0.0;
|
||||
delay[0] = 512;
|
||||
}
|
||||
}
|
||||
|
||||
MY_FLOAT PitShift :: lastOutput()
|
||||
{
|
||||
return lastOut;
|
||||
}
|
||||
|
||||
MY_FLOAT PitShift :: tick(MY_FLOAT input)
|
||||
{
|
||||
delay[0] = delay[0] + rate;
|
||||
while (delay[0] > 1012) delay[0] -= 1000;
|
||||
while (delay[0] < 12) delay[0] += 1000;
|
||||
delay[1] = delay[0] + 500;
|
||||
while (delay[1] > 1012) delay[1] -= 1000;
|
||||
while (delay[1] < 12) delay[1] += 1000;
|
||||
delayLine[0]->setDelay(delay[0]);
|
||||
delayLine[1]->setDelay(delay[1]);
|
||||
env[1] = fabs(delay[0] - 512) * 0.002;
|
||||
env[0] = 1.0 - env[1];
|
||||
lastOut = env[0] * delayLine[0]->tick(input);
|
||||
lastOut += env[1] * delayLine[1]->tick(input);
|
||||
lastOut *= effectMix;
|
||||
lastOut += (1.0 - effectMix) * input;
|
||||
return lastOut;
|
||||
}
|
||||
|
||||
/************** Test Main Program *********************/
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *soundIn,*soundOut;
|
||||
short data;
|
||||
float efMix,pitchshift;
|
||||
PitShift *effect;
|
||||
|
||||
if (argc==5) {
|
||||
soundIn = fopen(argv[3],"rb");
|
||||
soundOut = fopen(argv[4],"wb");
|
||||
if (soundIn && soundOut) {
|
||||
efMix = atof(argv[1]);
|
||||
pitchshift = atof(argv[2]);
|
||||
effect = new PitShift();
|
||||
effect->setShift(pitchshift);
|
||||
effect->setEffectMix(efMix);
|
||||
while (fread(&data,2,1,soundIn)) {
|
||||
data = effect->tick(data);
|
||||
fwrite(&data,2,1,soundOut);
|
||||
}
|
||||
delete effect;
|
||||
fclose(soundIn);
|
||||
fclose(soundOut);
|
||||
}
|
||||
else {
|
||||
printf("Can't open one of the files\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("useage: pitshift mix shiftRate soundIn.snd soundOut.snd\n");
|
||||
printf("0.0 <= mix <= 1.0\n");
|
||||
printf("maxDelay is in samples\n");
|
||||
printf("soundfiles are 16 bit linear mono or stereo\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,32 +0,0 @@
|
||||
/*********************************************/
|
||||
/* PitchShift Effect */
|
||||
/* by Perry Cook, 1996 */
|
||||
/*********************************************/
|
||||
|
||||
#if !defined(__PitShift_h)
|
||||
#define __PitShift_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "DLineL.h"
|
||||
|
||||
class PitShift : public Object
|
||||
{
|
||||
protected:
|
||||
DLineL *delayLine[2];
|
||||
MY_FLOAT lastOut;
|
||||
MY_FLOAT delay[2];
|
||||
MY_FLOAT env[2];
|
||||
MY_FLOAT effectMix;
|
||||
MY_FLOAT rate;
|
||||
public:
|
||||
PitShift();
|
||||
~PitShift();
|
||||
void clear();
|
||||
void setShift(MY_FLOAT shift);
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
virtual MY_FLOAT lastOutput();
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
|
||||
Version 3.2
|
||||
|
||||
By Perry R. Cook, 1995-2000
|
||||
and Gary P. Scavone, 1997-2000.
|
||||
The Synthesis ToolKit in C++ (STK)
|
||||
|
||||
By Perry R. Cook and Gary P. Scavone, 1995-2002.
|
||||
|
||||
EFFECTS PROJECT:
|
||||
|
||||
This directory contains a program that demonstrates realtime duplex mode (simultaneous audio input and output) operation, as well as several simple delay-line based effects algorithms. Proper duplex mode operation is very hardware dependent. If you have trouble with this application, make sure your soundcard supports the desired sample rate and sample size (16-bit).
|
||||
This directory contains a program that demonstrates realtime duplex mode (simultaneous audio input and output) operation, as well as several simple delay-line based effects algorithms. Duplex mode operation is very hardware dependent. If you have trouble with this application, make sure your soundcard supports the desired sample rate and sample size (16-bit).
|
||||
|
||||
NOTES:
|
||||
|
||||
1. This project will not run under WindowsNT or NeXTStep, due to lack of realtime audio input support. However, it should run under Windows2000.
|
||||
1. This project will not run under WindowsNT or NeXTStep, due to lack of realtime audio input support. However, it should run under other flavors of Windows.
|
||||
|
||||
2. Audio input from either a microphone or line-input device MUST be available to the audio input port when the program is started.
|
||||
2. Audio input from either a microphone or line-input device MUST be available to the audio input port when the program is started.
|
||||
|
||||
3. Latency can be controlled using the RtDuplex bufferSize and nBuffers constructor arguments. The default settings in effects.cpp are relatively high because some Windows soundcard drivers crash if the settings are too low.
|
||||
@@ -1,8 +1,8 @@
|
||||
/************** Effects Program *********************/
|
||||
|
||||
#include "RtDuplex.h"
|
||||
#include "SKINI11.h"
|
||||
#include "SKINI11.msg"
|
||||
#include "SKINI.h"
|
||||
#include "SKINI.msg"
|
||||
#include "Envelope.h"
|
||||
#include "PRCRev.h"
|
||||
#include "JCRev.h"
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Chorus.h"
|
||||
|
||||
// The input control handler.
|
||||
#include "Controller.h"
|
||||
#include "Messager.h"
|
||||
|
||||
void usage(void) {
|
||||
/* Error function in case of incorrect command-line argument specifications */
|
||||
@@ -25,17 +25,9 @@ void usage(void) {
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
MY_FLOAT inSample = 0.0;
|
||||
MY_FLOAT lastSample = 0.0;
|
||||
MY_FLOAT byte2, byte3;
|
||||
long i, nTicks;
|
||||
int type, effect = 0;
|
||||
int controlMask = 0;
|
||||
bool done;
|
||||
Controller *controller;
|
||||
|
||||
if (argc != 2) usage();
|
||||
|
||||
int controlMask = 0;
|
||||
if (!strcmp(argv[1],"-is") )
|
||||
controlMask |= STK_SOCKET;
|
||||
else if (!strcmp(argv[1],"-ip") )
|
||||
@@ -43,36 +35,51 @@ int main(int argc,char *argv[])
|
||||
else
|
||||
usage();
|
||||
|
||||
// If you want to change the default sample rate (set in Stk.h), do
|
||||
// it before instantiating any objects!!
|
||||
Stk::setSampleRate(22050.0);
|
||||
|
||||
bool done;
|
||||
int effect = 0;
|
||||
MY_FLOAT lastSample, inSample;
|
||||
Envelope *envelope = new Envelope;
|
||||
PRCRev *prcrev = new PRCRev(2.0);
|
||||
JCRev *jcrev = new JCRev(2.0);
|
||||
NRev *nrev = new NRev(2.0);
|
||||
Echo *echo = new Echo(SRATE); // one second delay
|
||||
Echo *echo = new Echo( (long) Stk::sampleRate() ); // one second delay
|
||||
PitShift *shifter = new PitShift();
|
||||
Chorus *chorus = new Chorus(5000.0);
|
||||
SKINI11 *score = new SKINI11();
|
||||
RtDuplex *inout;
|
||||
SKINI *score = new SKINI();
|
||||
Messager *messager = 0;
|
||||
RtDuplex *inout = 0;
|
||||
|
||||
try {
|
||||
inout = new RtDuplex(1, SRATE);
|
||||
// Change the nBuffers parameter to a smaller number to get better input/output latency.
|
||||
inout = new RtDuplex(1, Stk::sampleRate(), 0, RT_BUFFER_SIZE, 10);
|
||||
|
||||
// Instantiate the input message controller.
|
||||
controller = new Controller( controlMask );
|
||||
messager = new Messager( controlMask );
|
||||
}
|
||||
catch (StkError& m) {
|
||||
m.printMessage();
|
||||
exit(0);
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// The runtime loop begins here:
|
||||
long i, nTicks;
|
||||
int type;
|
||||
lastSample = 0.0;
|
||||
inSample = 0.0;
|
||||
MY_FLOAT byte2, byte3;
|
||||
done = FALSE;
|
||||
while (!done) {
|
||||
|
||||
nTicks = controller->getNextMessage();
|
||||
|
||||
if (nTicks == -1)
|
||||
// Look for new messages and return a delta time (in samples).
|
||||
type = messager->nextMessage();
|
||||
if (type < 0)
|
||||
done = TRUE;
|
||||
|
||||
nTicks = messager->getDelta();
|
||||
|
||||
for (i=0; i<nTicks; i++) {
|
||||
if (effect == 0)
|
||||
inSample = inout->tick(envelope->tick() * echo->tick(lastSample));
|
||||
@@ -89,12 +96,11 @@ int main(int argc,char *argv[])
|
||||
lastSample = inSample;
|
||||
}
|
||||
|
||||
type = controller->getType();
|
||||
if (type > 0) {
|
||||
// parse the input control message
|
||||
|
||||
byte2 = controller->getByte2();
|
||||
byte3 = controller->getByte3();
|
||||
byte2 = messager->getByteTwo();
|
||||
byte3 = messager->getByteThree();
|
||||
|
||||
switch(type) {
|
||||
|
||||
@@ -117,20 +123,20 @@ int main(int argc,char *argv[])
|
||||
case __SK_ControlChange_:
|
||||
if (byte2 == 20) effect = (int) byte3; // effect change
|
||||
else if (byte2 == 44) { // effects mix
|
||||
echo->setEffectMix(byte3*NORM_7);
|
||||
shifter->setEffectMix(byte3*NORM_7);
|
||||
chorus->setEffectMix(byte3*NORM_7);
|
||||
prcrev->setEffectMix(byte3*NORM_7);
|
||||
jcrev->setEffectMix(byte3*NORM_7);
|
||||
nrev->setEffectMix(byte3*NORM_7);
|
||||
echo->setEffectMix(byte3*ONE_OVER_128);
|
||||
shifter->setEffectMix(byte3*ONE_OVER_128);
|
||||
chorus->setEffectMix(byte3*ONE_OVER_128);
|
||||
prcrev->setEffectMix(byte3*ONE_OVER_128);
|
||||
jcrev->setEffectMix(byte3*ONE_OVER_128);
|
||||
nrev->setEffectMix(byte3*ONE_OVER_128);
|
||||
}
|
||||
else if (byte2 == 22) { // effect1 parameter change
|
||||
echo->setDelay(byte3*NORM_7*SRATE*0.95 + 2);
|
||||
shifter->setShift(byte3*NORM_7*3 + 0.25);
|
||||
chorus->setModFreq(byte3*NORM_7);
|
||||
echo->setDelay(byte3*ONE_OVER_128*Stk::sampleRate()*0.95);
|
||||
shifter->setShift(byte3*ONE_OVER_128*3 + 0.25);
|
||||
chorus->setModFrequency(byte3*ONE_OVER_128);
|
||||
}
|
||||
else if (byte2 == 23) { // effect1 parameter change
|
||||
chorus->setModDepth(byte3*NORM_7*0.2);
|
||||
chorus->setModDepth(byte3*ONE_OVER_128*0.2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -139,7 +145,8 @@ int main(int argc,char *argv[])
|
||||
|
||||
envelope->setRate(0.001);
|
||||
envelope->setTarget(0.0);
|
||||
for (i=0;i<SRATE;i++) { /* let the sound settle a bit */
|
||||
nTicks = (long) Stk::sampleRate();
|
||||
for (i=0; i<nTicks; i++) { // let the sound settle a bit
|
||||
if (effect == 0)
|
||||
inSample = inout->tick(envelope->tick() * echo->tick(lastSample));
|
||||
else if (effect == 1)
|
||||
@@ -155,7 +162,6 @@ int main(int argc,char *argv[])
|
||||
lastSample = inSample;
|
||||
}
|
||||
|
||||
delete inout;
|
||||
delete echo;
|
||||
delete shifter;
|
||||
delete chorus;
|
||||
@@ -164,7 +170,10 @@ int main(int argc,char *argv[])
|
||||
delete nrev;
|
||||
delete score;
|
||||
delete envelope;
|
||||
delete controller;
|
||||
|
||||
cleanup:
|
||||
delete messager;
|
||||
delete inout;
|
||||
|
||||
printf("effects finished ... goodbye.\n");
|
||||
return 0;
|
||||
|
||||
@@ -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
|
||||
@@ -63,11 +63,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
|
||||
@@ -86,51 +86,35 @@ LINK32=link.exe
|
||||
# Name "effects - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\ByteSwap.cpp
|
||||
SOURCE=..\..\src\Chorus.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\ByteSwap.h
|
||||
SOURCE=..\..\include\Chorus.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Chorus.cpp
|
||||
SOURCE=..\..\src\Delay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Chorus.h
|
||||
SOURCE=..\..\include\Delay.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Controller.cpp
|
||||
SOURCE=..\..\src\DelayL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Controller.h
|
||||
SOURCE=..\..\include\DelayL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\DLineL.cpp
|
||||
SOURCE=..\..\src\Echo.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
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Echo.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Echo.h
|
||||
SOURCE=..\..\include\Echo.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -162,6 +146,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\NRev.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -170,19 +162,11 @@ SOURCE=..\..\include\NRev.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Object.cpp
|
||||
SOURCE=..\..\src\PitShift.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Object.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PitShift.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PitShift.h
|
||||
SOURCE=..\..\include\PitShift.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -194,14 +178,6 @@ SOURCE=..\..\include\PRCRev.h
|
||||
# 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
|
||||
@@ -234,19 +210,43 @@ SOURCE=..\..\include\RtMidi.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=..\..\src\Stk.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Stk.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=..\..\src\WaveLoop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\WaveLoop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
Reference in New Issue
Block a user