diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-01-09 17:46:26 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-01-09 17:50:20 +0100 |
commit | 80fdc1e39d864f05f271c8035715ab4c155a2002 (patch) | |
tree | 48115fa8081b9ae9101a8c75163db651a1b02e2d | |
parent | 216f7933c5b4b65f7f45d3c459ead10f160d124b (diff) |
Improved note-compiler: optimizing output now works properly
Previously, output was always considered as non-const, even if is was
zero and without any controller-influence, because output had always
pfactor-influence. Now, a pfactor-influenced output which is constant
zero is considered as still constant, because pfactor*0 is always 0.
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | note_compiler/parser.cpp | 28 | ||||
-rw-r--r-- | note_compiler/programs.h | 1 |
3 files changed, 28 insertions, 7 deletions
@@ -1,10 +1,10 @@ TODO für den synth o .so unloaden! - o note-compiler: wenn vel_influence für foo, aber foo ist konstant + x note-compiler: wenn vel_influence für foo, aber foo ist konstant null, bleibt foo trotzdem konstant. - o note-compiler: vel_influence ist IMMER gegeben für output, außer + x note-compiler: vel_influence ist IMMER gegeben für output, außer wenn anders angegeben - o note-compiler: *1 bzw /2 optimierungen klappen nicht? + x note-compiler: *1 bzw /2 optimierungen klappen nicht? x note-compiler: pfactor nicht wegoptimieren, immer verwenden o beide parser: envelopes von oscs mit out=0 standardmäßig deaktivieren o envelope, filter, ggf. auch alles aus program.o im hauptprogramm diff --git a/note_compiler/parser.cpp b/note_compiler/parser.cpp index b15b981..c89ddd9 100644 --- a/note_compiler/parser.cpp +++ b/note_compiler/parser.cpp @@ -23,7 +23,8 @@ void init_oscs(int n_osc, oscillator_t *osc) } osc[i].output=0; - osc[i].output_const=false; //TODO FINDMICH war true + osc[i].output_const=true; + osc[i].output_no_pfactor=false; osc[i].waveform=0; osc[i].waveform_const=true; osc[i].factor=ONE; @@ -369,7 +370,13 @@ program_t parse(string fn) osc[ind].fm_strength_const[ind2]=false; break; case OUTPUT: - osc[ind].output_const=false; break; + if (state==4) // vel.-influence + { + if (isfloat(strval)) //is it a plain number, not a formula? + osc[ind].output_no_pfactor=true; + } + else + osc[ind].output_const=false; break; case WAVEFORM: osc[ind].waveform_const=false; break; case FACTOR: @@ -438,7 +445,7 @@ program_t parse(string fn) } - //some optimizations + //some optimizations and checks for (int i=0;i<n_osc;i++) if ((env[i].attack==0) && (env[i].sustain==1.0) @@ -464,7 +471,20 @@ program_t parse(string fn) sync_factor_const=true; } - //end optimizations + if ((sync_factor==0) && (sync_factor_const==true)) + for (int i=0;i<n_osc;i++) + { + osc[i].sync=false; + osc[i].sync_const=true; + } + + + + for (int i=0;i<n_osc;i++) + if ( (osc[i].output_no_pfactor==false) && !((osc[i].output==0) && (osc[i].output_const=true)) ) + osc[i].output_const=false; + + //end optimizations and checks result.n_osc=n_osc; result.osc=osc; diff --git a/note_compiler/programs.h b/note_compiler/programs.h index d7acd61..9025ba1 100644 --- a/note_compiler/programs.h +++ b/note_compiler/programs.h @@ -47,6 +47,7 @@ struct oscillator_t bool *fm_strength_const; fixed_t output; bool output_const; + bool output_no_pfactor; int waveform; bool waveform_const; fixed_t factor; |