fixes and comment clarification;

* made stereo output actually work, just with unity gain output.
  * clarified the calcPan function that has not yet been truely implented
master
Rachel Fae Fox (foxiepaws) 2020-03-08 14:44:49 -04:00
parent 5d299dee9e
commit a5228f1c13
2 changed files with 9 additions and 21 deletions

View File

@ -21,7 +21,7 @@ namespace FM {
template <int T>
class Engine {
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;
std::array<Operator*,T> operators;
std::pair<double,double> 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<double,double> 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() {

View File

@ -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<double,double> 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);
}