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/note.cpp.todo | |
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/note.cpp.todo')
-rw-r--r-- | note_compiler/note.cpp.todo | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/note_compiler/note.cpp.todo b/note_compiler/note.cpp.todo new file mode 100644 index 0000000..a256525 --- /dev/null +++ b/note_compiler/note.cpp.todo @@ -0,0 +1,72 @@ +void Note::set_param(const parameter_t &p, fixed_t v) //ACHTUNG: +{ + //wenn das verändert wird, muss auch program_t::set_param verändert werden! + switch(p.par) + { + case ATTACK: envelope[p.osc]->set_attack(v*samp_rate >>SCALE); break; + case DECAY: envelope[p.osc]->set_decay(v*samp_rate >>SCALE); break; + case SUSTAIN: envelope[p.osc]->set_sustain(v); break; + case RELEASE: envelope[p.osc]->set_release(v*samp_rate >>SCALE); break; + case HOLD: envelope[p.osc]->set_hold(v!=0); break; + + case KSR: oscillator[p.osc].ksr=float(v)/ONE; break; + case KSL: oscillator[p.osc].ksl=float(v)/ONE; break; + + case FACTOR: oscillator[p.osc].factor=v; break; + case MODULATION: oscillator[p.osc].fm_strength[p.index]=v*pfactor.fm[p.osc][p.index] >>SCALE; break; + case OUTPUT: oscillator[p.osc].output=v*pfactor.out[p.osc] >>SCALE; break; + case TREMOLO: oscillator[p.osc].tremolo_depth=v; break; + case TREM_LFO: oscillator[p.osc].tremolo_lfo=v; break; + case VIBRATO: oscillator[p.osc].vibrato_depth=v; break; + case VIB_LFO: oscillator[p.osc].vibrato_lfo=v; break; + case WAVEFORM: oscillator[p.osc].waveform=v; break; + case SYNC: oscillator[p.osc].sync=(v!=0); break; + + case FILTER_ENABLED: output_note("NOTE: cannot enable filter in playing notes"); break; + case FILTER_ENV_AMOUNT: filter_params.env_amount=float(v*pfactor.filter_env)/ONE/ONE; break; + + case FILTER_ATTACK: + if (filter_params.enabled) + filter_envelope->set_attack(v*samp_rate/filter_update_frames >>SCALE); + else + output_note("NOTE: cannot set filter-attack when filter is disabled"); + break; + + case FILTER_DECAY: + if (filter_params.enabled) + filter_envelope->set_decay(v*samp_rate/filter_update_frames >>SCALE); + else + output_note("NOTE: cannot set filter-decay when filter is disabled"); + break; + + case FILTER_SUSTAIN: + if (filter_params.enabled) + filter_envelope->set_sustain(v); + else + output_note("NOTE: cannot set filter-sustain when filter is disabled"); + break; + + case FILTER_RELEASE: + if (filter_params.enabled) + filter_envelope->set_release(v*samp_rate/filter_update_frames >>SCALE); + else + output_note("NOTE: cannot set filter-release when filter is disabled"); + break; + + case FILTER_HOLD: + if (filter_params.enabled) + filter_envelope->set_hold(v!=0); + else + output_note("NOTE: cannot set filter-hold when filter is disabled"); + break; + + case FILTER_OFFSET: filter_params.freqfactor_offset=float(v*pfactor.filter_offset)/ONE/ONE; break; + case FILTER_RESONANCE: filter_params.resonance=float(v*pfactor.filter_res)/ONE/ONE; break; + case FILTER_TREMOLO: filter_params.trem_strength=v; break; + case FILTER_TREM_LFO: filter_params.trem_lfo=v; break; + + case SYNC_FACTOR: sync_factor=v; break; + default: throw string("trying to set an unknown parameter"); + + } +} |