32 lines
687 B
C++
32 lines
687 B
C++
/*
|
|
* Filename: core.c
|
|
*
|
|
* Description:
|
|
*
|
|
*
|
|
* Version:
|
|
* Created: Fri Nov 1 01:38:00 2019
|
|
* Revision: None
|
|
* Author: Rachel Fae Fox (foxiepaws),fox@foxiepa.ws
|
|
*
|
|
*/
|
|
|
|
#include "core.h"
|
|
#include <math.h>
|
|
|
|
FM::Operator() {
|
|
this->t = 0;
|
|
this->sample_rate = 44100;
|
|
this->gate = false;
|
|
this->feedback_buffer = 0.0;
|
|
}
|
|
|
|
float FM::Operator::run(float phase) {
|
|
this->e.gate = this->gate;
|
|
float out = 0;
|
|
out = sin(2 * M_PI * this->t * (this->mul * this->freq) / this->sample_rate + ((this->feedback_level > 0.0) ? this->feedback_buffer : phase));
|
|
out *= (this->level * this->e.run());
|
|
this->feedback_buffer = out;
|
|
return out;
|
|
}
|