You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
411 B
28 lines
411 B
4 years ago
|
#include <math.h>
|
||
|
#include "phasor.h"
|
||
|
#include "../utility/dsp.h"
|
||
|
|
||
|
using namespace daisysp;
|
||
|
|
||
|
void Phasor::SetFreq(float freq)
|
||
|
{
|
||
|
freq_ = freq;
|
||
|
inc_ = (TWOPI_F * freq_) / sample_rate_;
|
||
|
}
|
||
|
|
||
|
float Phasor::Process()
|
||
|
{
|
||
|
float out;
|
||
|
out = phs_ / TWOPI_F;
|
||
|
phs_ += inc_;
|
||
|
if(phs_ > TWOPI_F)
|
||
|
{
|
||
|
phs_ -= TWOPI_F;
|
||
|
}
|
||
|
if(phs_ < 0.0f)
|
||
|
{
|
||
|
phs_ = 0.0f;
|
||
|
}
|
||
|
return out;
|
||
|
}
|