From f76e20a3486b31945fd35f6b1a0bd517d6dc176e Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 7 Jan 2011 18:40:47 +0100 Subject: Improved note-compiler and added TODO-entries --- note_compiler/plugin_factory/infile.cpp | 109 ++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 33 deletions(-) (limited to 'note_compiler/plugin_factory/infile.cpp') diff --git a/note_compiler/plugin_factory/infile.cpp b/note_compiler/plugin_factory/infile.cpp index f8e34a0..147aec0 100644 --- a/note_compiler/plugin_factory/infile.cpp +++ b/note_compiler/plugin_factory/infile.cpp @@ -48,13 +48,17 @@ class Note : public NoteSkel // member variables begin here Envelope *env0; - Envelope *env1; + //envelope1 is unused + //envelope2 is unused + //envelope3 is unused fixed_t *oscval; fixed_t *old_oscval; oscillator_t osc0; oscillator_t osc1; + oscillator_t osc2; + oscillator_t osc3; //sync is disabled @@ -65,6 +69,8 @@ class Note : public NoteSkel { oscillator_t osc0; oscillator_t osc1; + oscillator_t osc2; + oscillator_t osc3; //filter is disabled } orig; // member variables end here @@ -83,27 +89,35 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr { curr_prg=&prg; - oscval=new fixed_t[2]; - old_oscval=new fixed_t[2]; - for (int i=0;i<2;i++) + oscval=new fixed_t[4]; + old_oscval=new fixed_t[4]; + for (int i=0;i<4;i++) oscval[i]=old_oscval[i]=0; - pfactor.out=new fixed_t [2]; - pfactor.fm=new fixed_t* [2]; - for (int i=0;i<2;i++) - pfactor.fm[i]=new fixed_t [2]; + pfactor.out=new fixed_t [4]; + pfactor.fm=new fixed_t* [4]; + for (int i=0;i<4;i++) + pfactor.fm[i]=new fixed_t [4]; env0=new Envelope (prg.env_settings[0]); - env1=new Envelope (prg.env_settings[1]); + //envelope1 is disabled + //envelope2 is disabled + //envelope3 is disabled osc0=prg.osc_settings[0]; orig.osc0=prg.osc_settings[0]; osc1=prg.osc_settings[1]; orig.osc1=prg.osc_settings[1]; + osc2=prg.osc_settings[2]; + orig.osc2=prg.osc_settings[2]; + osc3=prg.osc_settings[3]; + orig.osc3=prg.osc_settings[3]; //initalize oscillator.phase to multiples of their wave resolution osc0.phase=ONE * PHASE_INIT; osc1.phase=ONE * PHASE_INIT; + osc2.phase=ONE * PHASE_INIT; + osc3.phase=ONE * PHASE_INIT; do_ksl(); @@ -127,9 +141,17 @@ Note::~Note() delete pfactor.fm[0]; delete [] osc1.fm_strength; - delete env1; + //envelope1 is disabled delete pfactor.fm[1]; + delete [] osc2.fm_strength; + //envelope2 is disabled + delete pfactor.fm[2]; + + delete [] osc3.fm_strength; + //envelope3 is disabled + delete pfactor.fm[3]; + delete [] oscval; delete [] old_oscval; @@ -144,28 +166,36 @@ void Note::destroy() void Note::recalc_factors() { - for (int i=0;i<2;i++) + for (int i=0;i<4;i++) { pfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel); - for (int j=0;j<2;j++) + for (int j=0;j<4;j++) pfactor.fm[i][j]=calc_pfactor(curr_prg->pfactor.fm[i][j], vel); } } void Note::apply_pfactor() { osc0.output=orig.osc0.output*pfactor.out[0] >>SCALE; - for (int i=0;i<2;i++) + for (int i=0;i<4;i++) osc0.fm_strength[i]=orig.osc0.fm_strength[i]*pfactor.fm[0][i] >>SCALE; osc1.output=orig.osc1.output*pfactor.out[1] >>SCALE; - for (int i=0;i<2;i++) + for (int i=0;i<4;i++) osc1.fm_strength[i]=orig.osc1.fm_strength[i]*pfactor.fm[1][i] >>SCALE; + osc2.output=orig.osc2.output*pfactor.out[2] >>SCALE; + for (int i=0;i<4;i++) + osc2.fm_strength[i]=orig.osc2.fm_strength[i]*pfactor.fm[2][i] >>SCALE; + osc3.output=orig.osc3.output*pfactor.out[3] >>SCALE; + for (int i=0;i<4;i++) + osc3.fm_strength[i]=orig.osc3.fm_strength[i]*pfactor.fm[3][i] >>SCALE; } bool Note::still_active() { if ( ((osc0.output>0) && (env0->still_active())) - || ((osc1.output>0) && (env1->still_active())) ) + /* envelope1 is disabled */ + /* envelope2 is disabled */ + /* envelope3 is disabled */ ) return true; else return false; @@ -173,7 +203,9 @@ bool Note::still_active() void Note::release() { env0->release_key(); - env1->release_key(); + //envelope1 is disabled + //envelope2 is disabled + //envelope3 is disabled } void Note::release_quickly(jack_nframes_t maxt) { @@ -181,28 +213,30 @@ void Note::release_quickly(jack_nframes_t maxt) env0->set_release(maxt); env0->release_key(); - if (env1->get_release() > maxt) - env1->set_release(maxt); - env1->release_key(); + //envelope1 is disabled + + //envelope2 is disabled + + //envelope3 is disabled } void Note::reattack() { env0->reattack(); - env1->reattack(); + //envelope1 is disabled + //envelope2 is disabled + //envelope3 is disabled } void Note::do_ksr() { env0->set_ratefactor(1.0 / pow(freq>>SCALE, osc0.ksr)); - env1->set_ratefactor(1.0 / pow(freq>>SCALE, osc1.ksr)); + //envelope1 is disabled + //envelope2 is disabled + //envelope3 is disabled } void Note::do_ksl() { - double tempfreq=double ( freq >> SCALE ); - - env0->set_max( ( (osc0.ksl==0) ? ONE : ( fixed_t(double(ONE) / pow(tempfreq, osc0.ksl)) ) ) ); - env1->set_max( ( (osc1.ksl==0) ? ONE : ( fixed_t(double(ONE) / pow(tempfreq, osc1.ksl)) ) ) ); } fixed_t Note::get_sample() @@ -232,16 +266,23 @@ fixed_t Note::get_sample() //sync is disabled - osc0.phase+= ( (osc0.vibrato_depth==0) ? ((actual_freq*osc0.factor/samp_rate)>>SCALE) : (( (curr_lfo[osc0.vibrato_lfo][osc0.vibrato_depth]*actual_freq >>SCALE)*osc0.factor/samp_rate)>>SCALE) ); - oscval[0] = wave[1][ ( ( osc0.phase + ( + (old_oscval[0] * 104857) + (old_oscval[1] * osc0.fm_strength[1]) >>SCALE ) ) * WAVE_RES >>SCALE ) % WAVE_RES ] * env0->get_level() >>SCALE; - if (osc0.tremolo_depth) - oscval[0] = oscval[0] * curr_lfo[0][osc0.tremolo_depth] >>SCALE; + osc0.phase+= (actual_freq*osc0.factor/samp_rate)>>SCALE; + oscval[0] = wave[0][ ( ( osc0.phase + ( + (old_oscval[1]) ) ) * WAVE_RES >>SCALE ) % WAVE_RES ] * env0->get_level() >>SCALE; + //oscillator0 has no tremolo - osc1.phase+= ( (curr_lfo[osc1.vibrato_lfo][osc1.vibrato_depth]*actual_freq >>SCALE)*osc1.factor/samp_rate)>>SCALE; - oscval[1] = wave[0][ ( osc1.phase * WAVE_RES >>SCALE ) % WAVE_RES ] * env1->get_level() >>SCALE; + osc1.phase+= (actual_freq*osc1.factor/samp_rate)>>SCALE; + oscval[1] = wave[0][ ( ( osc1.phase + ( + (old_oscval[2] /2) ) ) * WAVE_RES >>SCALE ) % WAVE_RES ]; //oscillator1 has no tremolo - fixed_t out = ( + osc0.output*oscval[0] >>SCALE ); + osc2.phase+= (actual_freq*osc2.factor/samp_rate)>>SCALE; + oscval[2] = wave[0][ ( ( osc2.phase + ( + (old_oscval[3] * 209715) >>SCALE ) ) * WAVE_RES >>SCALE ) % WAVE_RES ]; + //oscillator2 has no tremolo + + osc3.phase+= (actual_freq*osc3.factor/samp_rate)>>SCALE; + oscval[3] = wave[0][ ( osc3.phase * WAVE_RES >>SCALE ) % WAVE_RES ]; + //oscillator3 has no tremolo + + fixed_t out = ( + osc0.output*oscval[0] + osc1.output*oscval[1] + osc2.output*oscval[2] + osc3.output*oscval[3] >>SCALE ); @@ -256,7 +297,9 @@ void Note::set_param(const parameter_t &p, fixed_t v) switch (p.osc) { case 0: sel_osc=&osc0; sel_env=env0; break; - case 1: sel_osc=&osc1; sel_env=env1; break; + case 1: sel_osc=&osc1; /* envelope1 is disabled */ break; + case 2: sel_osc=&osc2; /* envelope2 is disabled */ break; + case 3: sel_osc=&osc3; /* envelope3 is disabled */ break; default: output_note("NOTE: trying to change the nonexistent oscillator"+IntToStr(p.osc)); } -- cgit v1.2.3