mirror of
https://github.com/thestk/stk
synced 2026-01-14 05:21:53 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
71
src/Modulate.cpp
Normal file
71
src/Modulate.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************/
|
||||
/*! \class Modulate
|
||||
\brief STK periodic/random modulator.
|
||||
|
||||
This class combines random and periodic
|
||||
modulations to give a nice, natural human
|
||||
modulation function.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Modulate.h"
|
||||
#include <string.h>
|
||||
|
||||
Modulate :: Modulate()
|
||||
{
|
||||
// Concatenate the STK RAWWAVE_PATH to the rawwave file
|
||||
char file[128];
|
||||
strcpy(file, RAWWAVE_PATH);
|
||||
vibrato = new WaveLoop( strcat(file,"rawwaves/sinewave.raw"), TRUE );
|
||||
vibrato->setFrequency( 6.0 );
|
||||
vibratoGain = 0.04;
|
||||
|
||||
noise = new SubNoise(330);
|
||||
randomGain = 0.05;
|
||||
|
||||
filter = new OnePole( 0.999 );
|
||||
filter->setGain( randomGain );
|
||||
}
|
||||
|
||||
Modulate :: ~Modulate()
|
||||
{
|
||||
delete vibrato;
|
||||
delete noise;
|
||||
delete filter;
|
||||
}
|
||||
|
||||
void Modulate :: reset()
|
||||
{
|
||||
lastOutput = (MY_FLOAT) 0.0;
|
||||
}
|
||||
|
||||
void Modulate :: setVibratoRate(MY_FLOAT aRate)
|
||||
{
|
||||
vibrato->setFrequency( aRate );
|
||||
}
|
||||
|
||||
void Modulate :: setVibratoGain(MY_FLOAT aGain)
|
||||
{
|
||||
vibratoGain = aGain;
|
||||
}
|
||||
|
||||
void Modulate :: setRandomGain(MY_FLOAT aGain)
|
||||
{
|
||||
randomGain = aGain;
|
||||
filter->setGain( randomGain );
|
||||
}
|
||||
|
||||
MY_FLOAT Modulate :: tick()
|
||||
{
|
||||
// Compute periodic and random modulations.
|
||||
lastOutput = vibratoGain * vibrato->tick();
|
||||
lastOutput += filter->tick( noise->tick() );
|
||||
return lastOutput;
|
||||
}
|
||||
|
||||
MY_FLOAT Modulate :: lastOut() const
|
||||
{
|
||||
return lastOutput;
|
||||
}
|
||||
Reference in New Issue
Block a user