synththing-plusplus/src/synths/fm2.cpp

39 lines
770 B
C++

/*
* Filename: fm2.cpp
*
* Description:
*
*
* Version:
* Created: Fri Nov 1 03:05:59 2019
* Revision: None
* Author: Rachel Fae Fox (foxiepaws),fox@foxiepa.ws
*
*/
#include "fm2.h"
FM2::FM2 ( ) {
this->carrier = FM::Operator;
this->modulator = FM::Operator;
this->gate = false;
this->algorithm = 1;
}
FM2::run() {
float v1, v2, z;
this->carrier->freq=this->modulator->freq=this->freq;
this->carrier->gate=this->modulator->gate=this->gate;
switch(this->algorithm) {
case 0:
v1 = this->carrier->run(0.0);
v2 = this->modulator->run(0.0);
z = (double) v1 + (double) v2 - ((double) v1 * (double) v2);
return z;
case 1:
return this->carrier->run(this->modulator->run(0.0));
}
}