summaryrefslogtreecommitdiff
path: root/note_compiler/main.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2011-01-08 18:27:40 +0100
committerFlorian Jung <flo@thinkpad.(none)>2011-01-08 18:27:40 +0100
commitd84da6cdfb9027a67b8ab50fe2c23374acc3b245 (patch)
tree36fe2b669da46e0e320a03e4f18c3a25c743107d /note_compiler/main.cpp
parent82e74a33661d235029f413eff2b21c4e29e057bc (diff)
Added some of the bugfixes to the note_compiler and removed use_pfactor
Diffstat (limited to 'note_compiler/main.cpp')
-rw-r--r--note_compiler/main.cpp133
1 files changed, 47 insertions, 86 deletions
diff --git a/note_compiler/main.cpp b/note_compiler/main.cpp
index 38302ef..47ed685 100644
--- a/note_compiler/main.cpp
+++ b/note_compiler/main.cpp
@@ -92,20 +92,15 @@ void write_filter_decs()
void write_pfactor_decs()
{
- if (prog.use_pfactor)
- {
- out << "\t\tpfactor_value_t pfactor;\n"
- "\t\tstruct\n"
- "\t\t{\n";
- write_osc_decs2();
- if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
- out << "\t\t\tfilter_params_t filter_params;\n";
- else
- comment << "\t\t\t//filter is disabled\n";
- out << "\t\t} orig;\n";
- }
+ out << "\t\tpfactor_value_t pfactor;\n"
+ "\t\tstruct\n"
+ "\t\t{\n";
+ write_osc_decs2();
+ if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
+ out << "\t\t\tfilter_params_t filter_params;\n";
else
- comment << "\t\t//pfactors/velocity influence are disabled\n";
+ comment << "\t\t\t//filter is disabled\n";
+ out << "\t\t} orig;\n";
}
@@ -139,9 +134,8 @@ void write_ctor()
for (i=0;i<prog.n_osc;i++)
{
- out << "\tosc"<<i<<"=prg.osc_settings["<<i<<"];\n";
- if (prog.use_pfactor)
- out << "\torig.osc"<<i<<"=prg.osc_settings["<<i<<"];\n";
+ out << "\tosc"<<i<<"=prg.osc_settings["<<i<<"];\n"
+ "\torig.osc"<<i<<"=prg.osc_settings["<<i<<"];\n";
}
out << "\t\n";
@@ -164,9 +158,8 @@ void write_ctor()
if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
{
//a filter_params and orig.filter_params member exist
- out << "\tfilter_params=prg.filter_settings;\n";
- if (prog.use_pfactor)
- out << "\torig.filter_params=prg.filter_settings;\n";
+ out << "\tfilter_params=prg.filter_settings;\n"
+ "\torig.filter_params=prg.filter_settings;\n";
if (prog.filter.enabled_const==false)
{
@@ -211,23 +204,18 @@ void write_dtor()
else
comment << "\t//envelope"<<i<<" is disabled\n";
- if (prog.use_pfactor)
- out << "\tdelete pfactor.fm["<<i<<"];\n";
+ out << "\tdelete pfactor.fm["<<i<<"];\n";
out << "\t\n";
}
out << "\t\n"
"\tdelete [] oscval;\n"
- "\tdelete [] old_oscval;\n";
-
- if (prog.use_pfactor)
- {
- out << "\t\n"
- "\tdelete [] pfactor.out;\n"
- "\tdelete [] pfactor.fm;\n";
- }
- out << "}\n";
+ "\tdelete [] old_oscval;\n"
+ "\t\n"
+ "\tdelete [] pfactor.out;\n"
+ "\tdelete [] pfactor.fm;\n"
+ "}\n";
}
@@ -236,25 +224,22 @@ void write_recalc_factors()
out << "void Note::recalc_factors()\n"
"{\n";
- if (prog.use_pfactor)
+ if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
{
- if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
- {
- out << "\tpfactor.filter_env=calc_pfactor(curr_prg->pfactor.filter_env, vel);\n"
- "\tpfactor.filter_res=calc_pfactor(curr_prg->pfactor.filter_res, vel);\n"
- "\tpfactor.filter_offset=calc_pfactor(curr_prg->pfactor.filter_offset, vel);\n"
- "\t\n";
- }
-
- out << "\tfor (int i=0;i<"<<prog.n_osc<<";i++)\n"
- "\t{\n"
- "\t\tpfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel);\n"
- "\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}\n";
+ out << "\tpfactor.filter_env=calc_pfactor(curr_prg->pfactor.filter_env, vel);\n"
+ "\tpfactor.filter_res=calc_pfactor(curr_prg->pfactor.filter_res, vel);\n"
+ "\tpfactor.filter_offset=calc_pfactor(curr_prg->pfactor.filter_offset, vel);\n"
+ "\t\n";
}
+ out << "\tfor (int i=0;i<"<<prog.n_osc<<";i++)\n"
+ "\t{\n"
+ "\t\tpfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel);\n"
+ "\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}\n";
+
out << "}\n";
}
@@ -263,20 +248,17 @@ void write_apply_pfactor()
out << "void Note::apply_pfactor()\n"
"{\n";
- if (prog.use_pfactor)
+ if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
+ out << "\tfilter_params.env_amount=orig.filter_params.env_amount*pfactor.filter_env /ONE;\n"
+ "\tfilter_params.freqfactor_offset=orig.filter_params.freqfactor_offset*pfactor.filter_offset /ONE;\n"
+ "\tfilter_params.resonance=orig.filter_params.resonance*pfactor.filter_res /ONE;\n"
+ "\t\n";
+
+ for (int i=0;i<prog.n_osc;i++)
{
- if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
- out << "\tfilter_params.env_amount=orig.filter_params.env_amount*pfactor.filter_env /ONE;\n"
- "\tfilter_params.freqfactor_offset=orig.filter_params.freqfactor_offset*pfactor.filter_offset /ONE;\n"
- "\tfilter_params.resonance=orig.filter_params.resonance*pfactor.filter_res /ONE;\n"
- "\t\n";
-
- for (int i=0;i<prog.n_osc;i++)
- {
- 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";
- }
+ 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";
}
out << "}\n";
@@ -661,15 +643,16 @@ void write_set_param()
{
out << "void Note::set_param(const parameter_t &p, fixed_t v)\n"
"{\n"
- "\toscillator_t *sel_osc=NULL;\n"
- "\tEnvelope *sel_env=NULL;\n"
+ "\toscillator_t* sel_osc=NULL;\n"
+ "\toscillator_t* sel_orig_osc=NULL;\n"
+ "\tEnvelope* sel_env=NULL;\n"
"\t\n"
"\tswitch (p.osc)\n"
"\t{\n";
for (int i=0;i<prog.n_osc;i++)
{
- out << "\t\tcase "<<i<<": sel_osc=&osc"<<i<<"; ";
+ out << "\t\tcase "<<i<<": sel_osc=&osc"<<i<<"; sel_orig_osc=&orig.osc"<<i<<"; ";
if (prog.env[i].enabled)
out << "sel_env=env"<<i<<"; ";
@@ -686,36 +669,14 @@ void write_set_param()
include_file("set_param.1");
- if (prog.use_pfactor)
- out << "\t\tcase MODULATION: sel_osc->fm_strength[p.index]=v*pfactor.fm[p.osc][p.index] >>SCALE; break;\n"
- "\t\tcase OUTPUT: sel_osc->output=v*pfactor.out[p.osc] >>SCALE; break;\n";
- else
- out << "\t\tcase MODULATION: sel_osc->fm_strength[p.index]=v; break;\n"
- "\t\tcase OUTPUT: sel_osc->output=v; break;\n";
-
if ((prog.filter.enabled==true) || (prog.filter.enabled_const==false))
{
- out << "\t\t\n"
- "\t\tcase FILTER_ENABLED: output_note(\"NOTE: cannot enable filter in playing notes\"); break;\n"
- "\t\t\n";
-
+ include_file("set_param.filter");
if (prog.filter.env_settings.enabled)
- include_file("set_param.2");
+ include_file("set_param.filterenv");
else
include_file("set_param.nofilterenv");
-
- if (prog.use_pfactor)
- out << "\t\tcase FILTER_ENV_AMOUNT: filter_params.env_amount=float(v*pfactor.filter_env)/ONE/ONE; break;\n"
- "\t\tcase FILTER_OFFSET: filter_params.freqfactor_offset=float(v*pfactor.filter_offset)/ONE/ONE; break;\n"
- "\t\tcase FILTER_RESONANCE: filter_params.resonance=float(v*pfactor.filter_res)/ONE/ONE; break;\n";
- else
- out << "\t\tcase FILTER_ENV_AMOUNT: filter_params.env_amount=float(v)/ONE; break;\n"
- "\t\tcase FILTER_OFFSET: filter_params.freqfactor_offset=float(v)/ONE; break;\n"
- "\t\tcase FILTER_RESONANCE: filter_params.resonance=float(v)/ONE; break;\n";
-
- out << "\t\tcase FILTER_TREMOLO: filter_params.trem_strength=v; break;\n"
- "\t\tcase FILTER_TREM_LFO: filter_params.trem_lfo=v; break;\n";
}
else
include_file("set_param.nofilter");