diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-01-05 15:47:55 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-01-05 15:50:41 +0100 |
commit | 3d95a25600b5cab8a7e5245b7a581bd8c8939276 (patch) | |
tree | be3c2d1b14dd309e48c4f541e67020fed47f5a6c /note_compiler/parser.cpp | |
parent | 5e731c349b63a557b2e705ce3cd741f90c62c694 (diff) |
Note-compiler is _mostly_ complete; plus some tiny bugfixes
The note-compiler can read a program-definition and emits a cpp-file
which implements that definition. This implementation is optimized.
HOWEVER, the compiler still does not emit a set_param() function. this
will lead to a linker error because the function is not implemented
(but defined). After adding an empty implementation by hand the emitted
compiles well, and also seems to work when used in the synth.
TODO:
- implement set_param()
- compiler must emit a loader-function (which returns a new Note)
- use that loader function in the synth
Diffstat (limited to 'note_compiler/parser.cpp')
-rw-r--r-- | note_compiler/parser.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/note_compiler/parser.cpp b/note_compiler/parser.cpp index 98c65ac..3f142bd 100644 --- a/note_compiler/parser.cpp +++ b/note_compiler/parser.cpp @@ -37,6 +37,8 @@ void init_oscs(int n_osc, oscillator_t *osc) osc[i].vibrato_lfo=0; osc[i].vibrato_lfo_const=true; osc[i].have_custom_wave=false; + osc[i].sync=false; + osc[i].sync_const=true; } } @@ -44,11 +46,12 @@ void init_envs(int n_osc, env_settings_t *env) { for (int i=0;i<n_osc;i++) { + env[i].enabled=true; env[i].attack=0; env[i].attack_const=true; env[i].decay=0; env[i].decay_const=true; - env[i].sustain=ONE; + env[i].sustain=1.0; env[i].sustain_const=true; env[i].release=0; env[i].release_const=true; @@ -118,9 +121,11 @@ program_t parse(string fn) oscillator_t *osc=NULL; env_settings_t *env=NULL; filter_params_t filter; - fixed_t sync_factor; + fixed_t sync_factor=0; bool sync_factor_const=true; + bool use_pfactor=false; + char buf[2000]; string line; string var; @@ -351,6 +356,7 @@ program_t parse(string fn) default: // other params than the above may not be influenced! throw string("velocity cannot influence parameter '"+array+"'"); } + use_pfactor=true; } @@ -432,13 +438,42 @@ program_t parse(string fn) } } + + //some optimizations + + for (int i=0;i<n_osc;i++) + if ((env[i].attack==0) && (env[i].sustain==1.0) + && (env[i].release>100)) //TODO FINDMICH besseres kriterium? + env[i].enabled=false; + + if ( ((filter.env_settings.attack==0) && (filter.env_settings.sustain==1.0) + && (filter.env_settings.release>100)) //TODO FINDMICH siehe oben + || ((filter.env_amount==0) && (filter.env_amount_const==true)) ) + filter.env_settings.enabled=false; + + bool use_sync=false; + for (int i=0;i<n_osc;i++) + if ((osc[i].sync==true) || (osc[i].sync_const==false)) + { + use_sync=true; + break; + } + + if (!use_sync) + { + sync_factor=0; + sync_factor_const=true; + } + + //end optimizations + result.n_osc=n_osc; result.osc=osc; result.env=env; result.filter=filter; result.sync_factor=sync_factor; result.sync_factor_const=sync_factor_const; - + result.use_pfactor=use_pfactor; } else throw string ("could not open '"+fn+"'"); |