diff --git a/FM/Engine.h b/FM/Engine.h index 89a21b6..b6112af 100644 --- a/FM/Engine.h +++ b/FM/Engine.h @@ -21,7 +21,7 @@ namespace FM { template class Engine { Matrix gains; - std::array pans; // panning on master channels. + std::array pans; // panning on master channels.? Matrix mutes; std::array operators; std::pair out; @@ -44,6 +44,9 @@ namespace FM { o->setFeedbackLevel(fbg); } + // this isn't going to work, unfortunately. + // TODO: figure out some way handle panning + // that doesn't suck std::pair calcPan(float p) { double l,r; if (p > 0) { @@ -56,7 +59,7 @@ namespace FM { } void process(){ - out = 0.0; + double out = 0.0; for (int o = 0; o < T; o++) { // do matrix doFeedback(o); @@ -78,7 +81,7 @@ namespace FM { out += postg; } - this->out = out; + this->out = {out,out}; } double sampleMono() { diff --git a/FM/fmtest.cpp b/FM/fmtest.cpp index 5a50527..93a6fc8 100644 --- a/FM/fmtest.cpp +++ b/FM/fmtest.cpp @@ -39,20 +39,6 @@ int main(int argc, char** argv){ f->setGainMatrix(1,2,1.0); // op2 -> out = 1 f->freq = 440; 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"); fprintf(w,"RIFF"); double seconds = 20; @@ -82,10 +68,9 @@ int main(int argc, char** argv){ writeBytes(w,(char*) &datasize, 4); for (int s = 0; s < samples; s++) { - double ld = (*f)(); - double rd = (*g)(); - int16_t l = toint16(ld/4.0); - int16_t r = toint16(rd/4.0); + std::pair st = (*f)(); + int16_t l = toint16(st.first/4.0); + int16_t r = toint16(st.second/4.0); writeBytes(w,(char*) &l,2); writeBytes(w,(char*) &r,2); }