fixes and comment clarification;
* made stereo output actually work, just with unity gain output. * clarified the calcPan function that has not yet been truely implentedmaster
parent
5d299dee9e
commit
a5228f1c13
|
@ -21,7 +21,7 @@ namespace FM {
|
||||||
template <int T>
|
template <int T>
|
||||||
class Engine {
|
class Engine {
|
||||||
Matrix<double,T> gains;
|
Matrix<double,T> gains;
|
||||||
std::array<float, T> pans; // panning on master channels.
|
std::array<float, T> pans; // panning on master channels.?
|
||||||
Matrix<bool,T> mutes;
|
Matrix<bool,T> mutes;
|
||||||
std::array<Operator*,T> operators;
|
std::array<Operator*,T> operators;
|
||||||
std::pair<double,double> out;
|
std::pair<double,double> out;
|
||||||
|
@ -44,6 +44,9 @@ namespace FM {
|
||||||
o->setFeedbackLevel(fbg);
|
o->setFeedbackLevel(fbg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this isn't going to work, unfortunately.
|
||||||
|
// TODO: figure out some way handle panning
|
||||||
|
// that doesn't suck
|
||||||
std::pair<double,double> calcPan(float p) {
|
std::pair<double,double> calcPan(float p) {
|
||||||
double l,r;
|
double l,r;
|
||||||
if (p > 0) {
|
if (p > 0) {
|
||||||
|
@ -56,7 +59,7 @@ namespace FM {
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(){
|
void process(){
|
||||||
out = 0.0;
|
double out = 0.0;
|
||||||
for (int o = 0; o < T; o++) {
|
for (int o = 0; o < T; o++) {
|
||||||
// do matrix
|
// do matrix
|
||||||
doFeedback(o);
|
doFeedback(o);
|
||||||
|
@ -78,7 +81,7 @@ namespace FM {
|
||||||
|
|
||||||
out += postg;
|
out += postg;
|
||||||
}
|
}
|
||||||
this->out = out;
|
this->out = {out,out};
|
||||||
}
|
}
|
||||||
|
|
||||||
double sampleMono() {
|
double sampleMono() {
|
||||||
|
|
|
@ -39,20 +39,6 @@ int main(int argc, char** argv){
|
||||||
f->setGainMatrix(1,2,1.0); // op2 -> out = 1
|
f->setGainMatrix(1,2,1.0); // op2 -> out = 1
|
||||||
f->freq = 440;
|
f->freq = 440;
|
||||||
f->gate = true;
|
f->gate = true;
|
||||||
FM::Engine<2> *g = new FM::Engine<2>();
|
|
||||||
g->getOperator(0)->setAll(2.0,0.0,0.0);
|
|
||||||
g->getOperator(0)->getEnvelope()->setAttackTime(1.0);
|
|
||||||
g->getOperator(0)->getEnvelope()->setDecayTime(0.5);
|
|
||||||
g->getOperator(0)->getEnvelope()->setMaxLevel(1.0);
|
|
||||||
g->getOperator(0)->getEnvelope()->setModMode(true); // play until reset.
|
|
||||||
g->getOperator(1)->getEnvelope()->setReleaseTime(2.5);
|
|
||||||
g->getOperator(1)->setAll(1.0,0.0,0.0);
|
|
||||||
g->setGainMatrix(0,0,0.0); // op1 fbl = 0
|
|
||||||
g->setGainMatrix(0,1,1.0); // op1 -> op2 = 1
|
|
||||||
g->setGainMatrix(1,0,0.0); // op2 -> op1 = 0
|
|
||||||
g->setGainMatrix(1,2,1.0); // op2 -> out = 1
|
|
||||||
g->freq = 256;
|
|
||||||
g->gate = true;
|
|
||||||
FILE* w = fopen("testwav.wav", "w");
|
FILE* w = fopen("testwav.wav", "w");
|
||||||
fprintf(w,"RIFF");
|
fprintf(w,"RIFF");
|
||||||
double seconds = 20;
|
double seconds = 20;
|
||||||
|
@ -82,10 +68,9 @@ int main(int argc, char** argv){
|
||||||
writeBytes(w,(char*) &datasize, 4);
|
writeBytes(w,(char*) &datasize, 4);
|
||||||
|
|
||||||
for (int s = 0; s < samples; s++) {
|
for (int s = 0; s < samples; s++) {
|
||||||
double ld = (*f)();
|
std::pair<double,double> st = (*f)();
|
||||||
double rd = (*g)();
|
int16_t l = toint16(st.first/4.0);
|
||||||
int16_t l = toint16(ld/4.0);
|
int16_t r = toint16(st.second/4.0);
|
||||||
int16_t r = toint16(rd/4.0);
|
|
||||||
writeBytes(w,(char*) &l,2);
|
writeBytes(w,(char*) &l,2);
|
||||||
writeBytes(w,(char*) &r,2);
|
writeBytes(w,(char*) &r,2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue