diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-02-08 15:58:19 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-02-08 15:58:19 +0100 |
commit | a51271035a8591f8221e9ca6bccc5b98e29f23e1 (patch) | |
tree | a0f0259b19d65d0a9b4ce39e14037f78937a9cf4 /note_compiler/main.cpp | |
parent | 080ddd252d94b9304db3858bc3b7f79cf2f89f33 (diff) |
First try to make the compiler up-to-dateupdated_compiler
Diffstat (limited to 'note_compiler/main.cpp')
-rw-r--r-- | note_compiler/main.cpp | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/note_compiler/main.cpp b/note_compiler/main.cpp index 4d3fcae..ee69471 100644 --- a/note_compiler/main.cpp +++ b/note_compiler/main.cpp @@ -36,6 +36,15 @@ void include_file(string file) } } +void write_freqenv_decs() +{ + out << "\t\tdouble freqfactor_factor["<<prog.n_osc<<"];\n"; + for (int i=0;i<prog.n_osc;i++) + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "\t\tEnvelope* freq_env"<<i<<";\n"; + else + comment << "\t\t//freq-envelope #"<<i<<" is unused\n"; +} void write_env_decs() { for (int i=0;i<prog.n_osc;i++) @@ -122,14 +131,25 @@ void write_ctor() "\tpfactor.fm=new fixed_t* ["<<prog.n_osc<<"];\n" "\tfor (int i=0;i<"<<prog.n_osc<<";i++)\n" "\t\tpfactor.fm[i]=new fixed_t ["<<prog.n_osc<<"];\n" + "\t\n" + "\t\tpfactor.freq_env_amount=new fixed_t ["<<prog.n_osc<<"];\n" "\t\n"; for (i=0;i<prog.n_osc;i++) if (prog.env[i].enabled) - out << "\tenv"<<i<<"=new Envelope (prg.env_settings["<<i<<"]);\n"; + out << "\tenv"<<i<<"=new Envelope (prg.env_settings["<<i<<"], envelope_update_frames);\n"; else comment << "\t//envelope"<<i<<" is disabled\n"; + for (i=0;i<prog.n_osc;i++) + { + out << "\tfreqfactor_factor["<<i<<"]=1.0;\n"; + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "\tfreq_env"<<i<<"=new Envelope (prg.osc_settings["<<i<<"].freq_env, envelope_update_frames);\n"; + else + comment << "\t//freq-env #"<<i<<" is disabled\n"; + } + out << "\t\n"; for (i=0;i<prog.n_osc;i++) @@ -204,6 +224,11 @@ void write_dtor() else comment << "\t//envelope"<<i<<" is disabled\n"; + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "\tdelete freq_env"<<i<<",\n"; + else + comment << "\t//freq-env #"<<i<<" is disabled\n"; + out << "\tdelete pfactor.fm["<<i<<"];\n"; out << "\t\n"; @@ -215,6 +240,7 @@ void write_dtor() "\t\n" "\tdelete [] pfactor.out;\n" "\tdelete [] pfactor.fm;\n" + "\tdelete [] pfactor.freq_env_amount;\n" "}\n"; } @@ -238,6 +264,8 @@ void write_recalc_factors() "\t\t\n" "\t\tfor (int j=0;j<"<<prog.n_osc<<";j++)\n" "\t\t\tpfactor.fm[i][j]=calc_pfactor(curr_prg->pfactor.fm[i][j], vel);\n" + "\t\t\n" + "\t\tpfactor.freq_env_amount[i]=calc_pfactor(curr_prg->pfactor.freq_env_amount[i], vel);\n" "\t}\n"; out << "}\n"; @@ -258,7 +286,8 @@ void write_apply_pfactor() { out << "\tosc"<<i<<".output=orig.osc"<<i<<".output*pfactor.out["<<i<<"] >>SCALE;\n" "\tfor (int i=0;i<"<<prog.n_osc<<";i++)\n" - "\t\tosc"<<i<<".fm_strength[i]=orig.osc"<<i<<".fm_strength[i]*pfactor.fm["<<i<<"][i] >>SCALE;\n"; + "\t\tosc"<<i<<".fm_strength[i]=orig.osc"<<i<<".fm_strength[i]*pfactor.fm["<<i<<"][i] >>SCALE;\n" + "\tosc"<<i<<".freq_env_amount=orig.osc"<<i<<".freq_env_amount*pfactor.freq_env_amount["<<i<<"] /ONE;\n"; } out << "}\n"; @@ -303,6 +332,11 @@ void write_release() out << "\tenv"<<i<<"->release_key();\n"; else comment << "\t//envelope"<<i<<" is disabled\n"; + + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "\tfreq_env"<<i<<"->release_key();\n"; + else + comment << "\t//freq-env #"<<i<<" is disabled\n"; } @@ -346,6 +380,11 @@ void write_reattack() out << "\tenv"<<i<<"->reattack();\n"; else comment << "\t//envelope"<<i<<" is disabled\n"; + + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "\tfreq_env"<<i<<"->reattack();\n"; + else + comment << "\t//freq-env #"<<i<<" is disabled\n"; } @@ -646,6 +685,7 @@ void write_set_param() "\toscillator_t* sel_osc=NULL;\n" "\toscillator_t* sel_orig_osc=NULL;\n" "\tEnvelope* sel_env=NULL;\n" + "\tEnvelope* sel_factor_env=NULL;\n" "\t\n" "\tswitch (p.osc)\n" "\t{\n"; @@ -659,6 +699,11 @@ void write_set_param() else comment << "/* envelope"<<i<<" is disabled */ "; + if ((prog.osc[i].freq_env_amount!=0) || (prog.osc[i].freq_env_amount==false)) + out << "sel_factor_env=freq_env"<<i<<"; "; + else + comment << "/* freq-env #"<<i<<" is disabled */ "; + out << "break;\n"; } @@ -720,6 +765,8 @@ void generate_source() write_empty_line(); write_osc_decs(); write_empty_line(); + write_freqenv_decs(); + write_empty_line(); write_sync_decs(); write_empty_line(); write_filter_decs(); |