zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 38b76c8b24375ad4696c47b524d201d4726478ff
parent 543fa1b1a2a47fc9e2a2364386b749457607950d
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sat, 10 Aug 2013 14:51:42 -0400

Fix The EQ Graph

Diffstat:
Msrc/DSP/AnalogFilter.h | 10++++++----
Msrc/Effects/EQ.cpp | 39+++++++++++++++++++++++++++++++++++++++
Msrc/Effects/EQ.h | 2++
Msrc/Effects/EffectMgr.cpp | 15++++++++++++++-
Msrc/Effects/EffectMgr.h | 2+-
Msrc/UI/EffUI.fl | 318++++++++++++++++++++++++++++---------------------------------------------------
Msrc/UI/Fl_EQGraph.H | 11++++++++---
Msrc/UI/Fl_EQGraph.cpp | 35+++++++++++++++++++++++++----------
Msrc/UI/Fl_Osc_Counter.H | 2+-
Msrc/UI/Fl_Osc_Widget.H | 1+
Msrc/UI/Fl_Osc_Widget.cpp | 7+++++++
Msrc/UI/MasterUI.fl | 28++++++++++++++++------------
Msrc/UI/PartUI.fl | 7++++---
13 files changed, 235 insertions(+), 242 deletions(-)

diff --git a/src/DSP/AnalogFilter.h b/src/DSP/AnalogFilter.h @@ -48,6 +48,12 @@ class AnalogFilter:public Filter void cleanup(); float H(float freq); //Obtains the response for a given frequency + + + struct Coeff { + float c[3], //Feed Forward + d[3]; //Feed Back + } coeff, oldCoeff; private: struct fstage { @@ -55,10 +61,6 @@ class AnalogFilter:public Filter float y1, y2; //Output History } history[MAX_FILTER_STAGES + 1], oldHistory[MAX_FILTER_STAGES + 1]; - struct Coeff { - float c[3], //Feed Forward - d[3]; //Feed Back - } coeff, oldCoeff; //old coeffs are used for interpolation when paremeters change quickly //Apply IIR filter to Samples, with coefficients, and past history diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp @@ -196,3 +196,42 @@ float EQ::getfreqresponse(float freq) } return rap2dB(resp * outvolume); } + +//full taps & three filter taps +static void convolve(float *a, const float *filter) +{ + float tmp[MAX_EQ_BANDS*2+1]; + + for(int i=0; i<MAX_EQ_BANDS*2+1; ++i) + tmp[i] = a[i]; + + //Base Case + a[0] = tmp[0]*filter[0]; + a[1] = tmp[0]*filter[1] + tmp[1]*filter[0]; + + for(int i=2; i<MAX_EQ_BANDS+1; ++i) { + a[i] = filter[0]*tmp[i] + + filter[1]*tmp[i-1] + + filter[2]*tmp[i-2]; + } +} + +//Not exactly the most efficient manner to derive the total taps, but it should +//be fast enough in practice +void EQ::getFilter(float *a, float *b) const +{ + a[0] = 1; + b[0] = 1; + for(int i = 0; i < MAX_EQ_BANDS; ++i) { + auto &F = filter[i]; + if(F.Ptype == 0) + continue; + float Fb[3] = {F.l->coeff.c[0], F.l->coeff.c[1], F.l->coeff.c[2]}; + float Fa[3] = {1.0f, -F.l->coeff.d[1], -F.l->coeff.d[2]}; + + for(int j=0; j<F.Pstages+1; ++j) { + convolve(b, Fb); + convolve(a, Fa); + } + } +} diff --git a/src/Effects/EQ.h b/src/Effects/EQ.h @@ -38,6 +38,8 @@ class EQ:public Effect void cleanup(void); float getfreqresponse(float freq); + void getFilter(float *a/*[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]*/, + float *b/*[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]*/) const; private: //Parameters unsigned char Pvolume; diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp @@ -58,9 +58,22 @@ rtosc::Ports EffectMgr::ports = { else eff->changepreset_nolock(rtosc_argument(msg, 0).i); }}, - + {"eq-coeffs:", rProp(internal), NULL, [](const char *, rtosc::RtData &d) + { + EffectMgr *eff = (EffectMgr*)d.obj; + if(eff->nefx != 7) + return; + EQ *eq = (EQ*)eff->efx; + float a[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]; + float b[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]; + memset(a, 0, sizeof(a)); + memset(b, 0, sizeof(b)); + eq->getFilter(a,b); + d.reply(d.loc, "bb", sizeof(a), a, sizeof(b), b); + }}, }; + EffectMgr::EffectMgr(const bool insertion_) :insertion(insertion_), efxoutl(new float[synth->buffersize]), diff --git a/src/Effects/EffectMgr.h b/src/Effects/EffectMgr.h @@ -77,9 +77,9 @@ class EffectMgr:public Presets FilterParams *filterpars; static rtosc::Ports ports; - private: int nefx; Effect *efx; + private: bool dryonly; }; diff --git a/src/UI/EffUI.fl b/src/UI/EffUI.fl @@ -50,8 +50,7 @@ decl {\#include "common.H"} {public local class EffUI {open : {public Fl_Osc_Group,public PresetsUI_} } { Function {EffUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} { - code {eff=NULL; -filterwindow=NULL;} {} + code {filterwindow=NULL;} {} } Function {~EffUI()} {} { code {effnullwindow->hide();//delete (effnullwindow); @@ -69,20 +68,18 @@ if (filterwindow!=NULL){ delete(filterwindow); };} {} } - Function {make_null_window()} {open - } { + Function {make_null_window()} {} { Fl_Window effnullwindow { label {No Effect} - xywh {618 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {621 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } {} } - Function {make_reverb_window()} {open - } { + Function {make_reverb_window()} {} { Fl_Window effreverbwindow { label Reverb open - xywh {383 682 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {386 705 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -234,11 +231,10 @@ if (filterwindow!=NULL){ } } } - Function {make_echo_window()} {open - } { + Function {make_echo_window()} {} { Fl_Window effechowindow { label Echo - xywh {897 657 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {897 680 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -329,11 +325,10 @@ if (filterwindow!=NULL){ } } } - Function {make_chorus_window()} {open - } { + Function {make_chorus_window()} {} { Fl_Window effchoruswindow { label Chorus open - xywh {473 788 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {476 811 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -467,11 +462,10 @@ if (filterwindow!=NULL){ } } } - Function {make_phaser_window()} {open - } { + Function {make_phaser_window()} {} { Fl_Window effphaserwindow { label Phaser open - xywh {107 278 380 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {110 301 380 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -632,11 +626,10 @@ if (filterwindow!=NULL){ } } } - Function {make_alienwah_window()} {open - } { + Function {make_alienwah_window()} {} { Fl_Window effalienwahwindow { label AlienWah - xywh {259 399 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {262 422 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -741,11 +734,10 @@ if (filterwindow!=NULL){ } } } - Function {make_distorsion_window()} {open - } { + Function {make_distorsion_window()} {} { Fl_Window effdistorsionwindow { label Distortion open - xywh {550 263 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {553 286 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -905,11 +897,10 @@ if (filterwindow!=NULL){ } } } - Function {make_eq_window()} {open - } { + Function {make_eq_window()} {} { Fl_Window effeqwindow { label EQ open - xywh {688 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {691 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -925,73 +916,58 @@ if (filterwindow!=NULL){ callback {eqband=(int) o->value(); int npb=eqband*5+10; -int type=eff->geteffectpar(npb); -typechoice->value(type); - -if (type>6) gaindial->activate(); - else gaindial->deactivate(); - -if (type==0) bandgroup->deactivate(); -else bandgroup->activate(); - -int freq=eff->geteffectpar(npb+1); -freqdial->value(freq); - -int gain=eff->geteffectpar(npb+2); -gaindial->value(gain); - -int q=eff->geteffectpar(npb+3); -qdial->value(q); - -int dbl=eff->geteffectpar(npb+4); -stagescounter->value(dbl);} +typechoice->oscMove("parameter"+to_s(npb)); +freqdial->oscMove("parameter"+to_s(npb+1)); +gaindial->oscMove("parameter"+to_s(npb+2)); +qdial->oscMove("parameter"+to_s(npb+3)); +stagescounter->oscMove("parameter"+to_s(npb+4));} tooltip {Band no.} xywh {240 20 45 15} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 1 step 1 textfont 1 textsize 11 code0 {o->bounds(0,MAX_EQ_BANDS-1);} } Fl_Group bandgroup { xywh {245 40 130 50} box ENGRAVED_FRAME - code0 {if (eff->geteffectpar(10)==0) o->deactivate();} } { Fl_Dial freqdial { label Freq - callback {int np=eqband*5+11; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->update();} xywh {250 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 + code0 {o->init("parameter11");} class Fl_Osc_Dial } Fl_Dial gaindial { label Gain - callback {int np=eqband*5+12; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->update();} xywh {280 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 step 1 + code0 {o->init("parameter12");} class Fl_Osc_Dial } Fl_Dial qdial { label Q - callback {int np=eqband*5+13; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->update();} tooltip {Resonance/Bandwidth} xywh {310 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 + code0 {o->init("parameter13");} class Fl_Osc_Dial } Fl_Counter stagescounter { label {St.} - callback {int np=eqband*5+14; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->update();} tooltip {Additional filter stages} xywh {340 60 30 15} type Simple labelfont 1 labelsize 10 minimum 1 maximum 127 step 1 textfont 1 textsize 11 - code0 {o->bounds(0,MAX_FILTER_STAGES-1);} + code0 {o->init("parameter14");} + class Fl_Osc_Counter } } Fl_Choice typechoice { label {T.} - callback {int np=eqband*5+10; -eff->seteffectpar(np,(int) o->value()); -bandcounter->do_callback(); -eqgraph->redraw();} + callback {int type = o->value(); +if (type>6) gaindial->activate(); + else gaindial->deactivate(); + +if (type==0) bandgroup->deactivate(); +else bandgroup->activate(); +eqgraph->update();} tooltip Type xywh {290 20 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 when 6 textsize 10 + code0 {o->init("parameter15");} + class Fl_Osc_Choice } { MenuItem {} { label OFF @@ -1040,11 +1016,10 @@ eqgraph->redraw();} } } } - Function {make_dynamicfilter_window()} {open - } { + Function {make_dynamicfilter_window()} {} { Fl_Window effdynamicfilterwindow { label DynFilter open - xywh {825 336 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {828 359 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } { @@ -1155,11 +1130,10 @@ eqgraph->redraw();} } } } - Function {make_filter_window()} {open - } { + Function {make_filter_window()} {} { Fl_Window filterwindow { label {Filter Parameters for DynFilter Eff.} - xywh {807 520 290 110} type Double + xywh {810 543 290 110} type Double code0 {set_module_parameters(o);} visible } { Fl_Group {} { @@ -1176,8 +1150,10 @@ eqgraph->redraw();} } } } - Function {init(EffectMgr *eff_)} {} { - code {eff=eff_; + Function {init(bool ins_)} {open + } { + code {efftype = 0; + insertion = ins_; make_null_window(); make_reverb_window(); @@ -1202,27 +1178,13 @@ effdistorsionwindow->position(px,py); effeqwindow->position(px,py); effdynamicfilterwindow->position(px,py); -refresh(eff);} {} +refresh();} {} } - Function {refresh(EffectMgr *eff_)} {open + Function {refresh()} {open } { - code {eff=eff_; -this->hide(); -osc->requestValue(loc()+"parameter0"); -osc->requestValue(loc()+"parameter1"); -osc->requestValue(loc()+"parameter2"); -osc->requestValue(loc()+"parameter3"); -osc->requestValue(loc()+"parameter4"); -osc->requestValue(loc()+"parameter5"); -osc->requestValue(loc()+"parameter6"); -osc->requestValue(loc()+"parameter7"); -osc->requestValue(loc()+"parameter8"); -osc->requestValue(loc()+"parameter9"); -osc->requestValue(loc()+"parameter10"); -osc->requestValue(loc()+"parameter11"); -osc->requestValue(loc()+"parameter12"); -osc->requestValue(loc()+"parameter13"); -osc->requestValue(loc()+"parameter14"); + code {this->hide(); +for(int i=0; i<32; ++i) + osc->requestValue(loc()+"parameter"+to_s(i)); effnullwindow->hide(); effreverbwindow->hide(); @@ -1252,7 +1214,7 @@ if (filterwindow){ dfp0->label("D/W"); } -switch(eff->geteffect()){ +switch(efftype){ case 1: effreverbwindow->show(); break; @@ -1272,16 +1234,9 @@ switch(eff->geteffect()){ effdistorsionwindow->show(); break; case 7:eqband=0; - eqp0->value(eff->geteffectpar(0)); bandcounter->value(eqband); bandcounter->do_callback(); - typechoice->value(eff->geteffectpar(10)); eqgraph->redraw(); - freqdial->value(eff->geteffectpar(11)); - gaindial->value(eff->geteffectpar(12)); - if (eff->geteffectpar(10)<6) gaindial->deactivate(); - qdial->value(eff->geteffectpar(13)); - stagescounter->value(eff->geteffectpar(14)); effeqwindow->show(); break; case 8:make_filter_window(); @@ -1292,22 +1247,21 @@ switch(eff->geteffect()){ break; }; -this->show();} {} +this->show();} {selected + } } - Function {refresh()} {open - } { - code {refresh(eff);} {} + decl {int eqband;} {private local } - decl {EffectMgr *eff;} {} - decl {int eqband;} {} decl {bool insertion;} {public local } + decl {int efftype;} {public local + } } class SimpleEffUI {open : {public Fl_Osc_Group,public PresetsUI_} } { Function {SimpleEffUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} { - code {eff=NULL;} {} + code {} {} } Function {~SimpleEffUI()} {} { code {effnullwindow->hide();//delete (effnullwindow); @@ -1320,20 +1274,18 @@ effdistorsionwindow->hide();//delete (effdistorsionwindow); effeqwindow->hide();//delete (effeqwindow); effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } - Function {make_null_window()} {open - } { + Function {make_null_window()} {} { Fl_Window effnullwindow { label {No Effect} open - xywh {1047 801 230 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 + xywh {1047 824 230 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 code0 {set_module_parameters(o);} class Fl_Group visible } {} } - Function {make_reverb_window()} {open - } { + Function {make_reverb_window()} {} { Fl_Window effreverbwindow { label Reverb open - xywh {1047 509 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {1047 532 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1422,11 +1374,10 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_echo_window()} {open - } { + Function {make_echo_window()} {} { Fl_Window effechowindow { label Echo open - xywh {434 869 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {437 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1493,11 +1444,10 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_chorus_window()} {open - } { + Function {make_chorus_window()} {} { Fl_Window effchoruswindow { label Chorus open - xywh {725 634 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {728 657 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1586,11 +1536,10 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_phaser_window()} {open - } { + Function {make_phaser_window()} {} { Fl_Window effphaserwindow { label Phaser open - xywh {1047 877 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {1047 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1664,11 +1613,10 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_alienwah_window()} {open - } { + Function {make_alienwah_window()} {} { Fl_Window effalienwahwindow { label AlienWah open - xywh {409 526 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {412 549 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1722,11 +1670,10 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_distorsion_window()} {open - } { + Function {make_distorsion_window()} {} { Fl_Window effdistorsionwindow { label Distortion open - xywh {85 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {88 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -1850,8 +1797,7 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} } } } - Function {make_eq_window()} {open - } { + Function {make_eq_window()} {} { Fl_Window effeqwindow { label EQ open xywh {1047 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 @@ -1862,74 +1808,59 @@ effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {} label Band callback {eqband=(int) o->value(); int npb=eqband*5+10; - -int type=eff->geteffectpar(npb); -typechoice->value(type); - -if (type>6) gaindial->activate(); - else gaindial->deactivate(); - -if (type==0) bandgroup->deactivate(); -else bandgroup->activate(); - -int freq=eff->geteffectpar(npb+1); -freqdial->value(freq); - -int gain=eff->geteffectpar(npb+2); -gaindial->value(gain); - -int q=eff->geteffectpar(npb+3); -qdial->value(q); - -int dbl=eff->geteffectpar(npb+4); -stagescounter->value(dbl);} +typechoice->oscMove("parameter"+to_s(npb)); +freqdial->oscMove("parameter"+to_s(npb+1)); +gaindial->oscMove("parameter"+to_s(npb+2)); +qdial->oscMove("parameter"+to_s(npb+3)); +stagescounter->oscMove("parameter"+to_s(npb+4));} tooltip {Band no.} xywh {85 15 45 15} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 1 step 1 textfont 1 textsize 11 code0 {o->bounds(0,MAX_EQ_BANDS-1);} } Fl_Group bandgroup { xywh {5 5 75 85} box UP_FRAME - code0 {if (eff->geteffectpar(10)==0) o->deactivate();} } { Fl_Dial freqdial { label Freq - callback {int np=eqband*5+11; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->redraw();} xywh {10 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 + code0 {o->init("parameter11");} class Fl_Osc_Dial } Fl_Dial gaindial { label Gain - callback {int np=eqband*5+12; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->redraw();} xywh {45 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 step 1 + code0 {o->init("parameter12");} class Fl_Osc_Dial } Fl_Dial qdial { label Q - callback {int np=eqband*5+13; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->redraw();} tooltip {Bandwidth/Resonance} xywh {10 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 + code0 {o->init("parameter13");} class Fl_Osc_Dial } Fl_Counter stagescounter { label Stages - callback {int np=eqband*5+14; -eff->seteffectpar(np,(int) o->value()); -eqgraph->redraw();} + callback {eqgraph->redraw();} tooltip {Additional filter stages} xywh {40 55 30 15} type Simple labelfont 1 labelsize 10 minimum 1 maximum 127 step 1 textfont 1 textsize 11 code0 {o->bounds(0,MAX_FILTER_STAGES-1);} + code1 {o->init("parameter14");} + class Fl_Osc_Counter } } Fl_Choice typechoice { label Type - callback {int np=eqband*5+10; -eff->seteffectpar(np,(int) o->value()); -bandcounter->do_callback(); + callback {int type = o->value(); +if (type>6) gaindial->activate(); + else gaindial->deactivate(); + +if (type==0) bandgroup->deactivate(); +else bandgroup->activate(); eqgraph->redraw();} tooltip Type xywh {135 15 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 when 6 textsize 10 + code0 {o->init("parameter10");} + class Fl_Osc_Choice } { MenuItem {} { label OFF @@ -1972,17 +1903,16 @@ eqgraph->redraw();} xywh {90 90 100 20} labelfont 1 labelsize 10 } } - Fl_Box eqgraph {selected + Fl_Box eqgraph { xywh {85 35 140 55} box BORDER_BOX color 50 class Fl_EQGraph } } } - Function {make_dynamicfilter_window()} {open - } { + Function {make_dynamicfilter_window()} {} { Fl_Window effdynamicfilterwindow { label DynFilter open - xywh {971 573 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 + xywh {974 596 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 code3 {set_module_parameters(o);} class Fl_Group visible } { @@ -2049,10 +1979,10 @@ eqgraph->redraw();} } } } - Function {init(EffectMgr *eff_)} {open + Function {init(bool ins_)} {open } { - code {eff=eff_; - + code {efftype = 0; + insertion = ins_; make_null_window(); make_reverb_window(); make_echo_window(); @@ -2074,30 +2004,14 @@ effphaserwindow->position(px,py); effalienwahwindow->position(px,py); effdistorsionwindow->position(px,py); effeqwindow->position(px,py); -effdynamicfilterwindow->position(px,py); - -refresh(eff);} {} +effdynamicfilterwindow->position(px,py);} {} } - Function {refresh(EffectMgr *eff_)} {open + Function {refresh()} {open } { - code {eff=eff_; -this->hide(); + code {this->hide(); -osc->requestValue(loc()+"parameter0"); -osc->requestValue(loc()+"parameter1"); -osc->requestValue(loc()+"parameter2"); -osc->requestValue(loc()+"parameter3"); -osc->requestValue(loc()+"parameter4"); -osc->requestValue(loc()+"parameter5"); -osc->requestValue(loc()+"parameter6"); -osc->requestValue(loc()+"parameter7"); -osc->requestValue(loc()+"parameter8"); -osc->requestValue(loc()+"parameter9"); -osc->requestValue(loc()+"parameter10"); -osc->requestValue(loc()+"parameter11"); -osc->requestValue(loc()+"parameter12"); -osc->requestValue(loc()+"parameter13"); -osc->requestValue(loc()+"parameter14"); +for(int i=0; i<32; ++i) + osc->requestValue(loc()+"parameter"+to_s(i)); effnullwindow->hide(); effreverbwindow->hide(); @@ -2121,7 +2035,7 @@ eqband=0; dfp0->label("D/W"); } -switch(eff->geteffect()){ +switch(efftype){ case 1: effreverbwindow->show(); break; @@ -2143,13 +2057,6 @@ switch(eff->geteffect()){ case 7: bandcounter->value(eqband); bandcounter->do_callback(); - typechoice->value(eff->geteffectpar(10)); - eqgraph->redraw(); - freqdial->value(eff->geteffectpar(11)); - gaindial->value(eff->geteffectpar(12)); - if (eff->geteffectpar(10)<6) gaindial->deactivate(); - qdial->value(eff->geteffectpar(13)); - stagescounter->value(eff->geteffectpar(14)); effeqwindow->show(); break; case 8: @@ -2161,13 +2068,10 @@ switch(eff->geteffect()){ this->show();} {} } - Function {refresh()} {} { - code {refresh(eff);} {} - } - decl {EffectMgr *eff;} {private local - } decl {int eqband;} {private local } decl {bool insertion;} {public local } + decl {int efftype;} {public local + } } diff --git a/src/UI/Fl_EQGraph.H b/src/UI/Fl_EQGraph.H @@ -1,15 +1,20 @@ #pragma once #include "Fl_Osc_Widget.H" #include <FL/Fl_Box.H> +#include "../globals.h" class EffectMgr; class Fl_Osc_Interface; -class Fl_EQGraph : public Fl_Osc_Widget, public Fl_Box { +class Fl_EQGraph:public Fl_Box, public Fl_Osc_Widget +{ public: Fl_EQGraph(int x,int y, int w, int h, const char *label=0); virtual ~Fl_EQGraph(void); void draw(void); + void OSC_raw(const char *msg); + void update(void); + private: void draw_freq_line(float freq,int type); @@ -18,6 +23,6 @@ class Fl_EQGraph : public Fl_Osc_Widget, public Fl_Box { float getfreqx(float x) const; float getfreqpos(float freq) const; - float *num; - float *dem; + float num[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]; + float dem[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]; }; diff --git a/src/UI/Fl_EQGraph.cpp b/src/UI/Fl_EQGraph.cpp @@ -5,18 +5,35 @@ #include "../Effects/EffectMgr.h" #include "../globals.h" +#include <rtosc/rtosc.h> + #define MAX_DB 30 Fl_EQGraph::Fl_EQGraph(int x,int y, int w, int h, const char *label) - :Fl_Box(x,y,w,h,label) + :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this) { - num = new float [3*MAX_EQ_BANDS*MAX_FILTER_STAGES]; - dem = new float [3*MAX_EQ_BANDS*MAX_FILTER_STAGES]; + memset(num, 0, sizeof(num)); + memset(dem, 0, sizeof(dem)); + num[0] = 1; + dem[0] = 1; + oscRegister("eq-coeffs"); } Fl_EQGraph::~Fl_EQGraph(void) {} +void Fl_EQGraph::OSC_raw(const char *msg) +{ + memcpy(dem, rtosc_argument(msg, 0).b.data, sizeof(dem)); + memcpy(num, rtosc_argument(msg, 1).b.data, sizeof(dem)); + redraw(); +} + +void Fl_EQGraph::update(void) +{ + oscWrite("eq-coeffs"); +} + void Fl_EQGraph::draw_freq_line(float freq, int type) { fl_color(FL_GRAY); @@ -48,7 +65,7 @@ void Fl_EQGraph::draw(void) //draw the lines - fl_color(fl_lighter( FL_GRAY)); + fl_color(fl_lighter(FL_GRAY)); fl_line_style(FL_SOLID); fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2); @@ -120,14 +137,12 @@ double Fl_EQGraph::getresponse(int maxy,float freq) const std::complex<float> dem_res = 0; - for(int i = 0; i < 3*MAX_EQ_BANDS*MAX_FILTER_STAGES; ++i) { - num_res += std::polar(num[i], i*angle); - dem_res += std::polar(dem[i], i*angle); + for(int i = 0; i < MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1; ++i) { + num_res += std::polar<float>(num[i], i*angle); + dem_res += std::polar<float>(dem[i], i*angle); } - float dbresp=abs(num_res/dem_res);//eff->getEQfreqresponse(freq); - - + float dbresp=20*log(abs(num_res/dem_res))/log(10); //rescale return (int) ((dbresp/MAX_DB+1.0)*maxy/2.0); diff --git a/src/UI/Fl_Osc_Counter.H b/src/UI/Fl_Osc_Counter.H @@ -3,7 +3,7 @@ #include "Fl_Osc_Widget.H" #include <string> -class Fl_Osc_Counter: public Fl_Counter, Fl_Osc_Widget +class Fl_Osc_Counter: public Fl_Counter, public Fl_Osc_Widget { public: Fl_Osc_Counter(int x, int y, int w, int h, const char *label=0); diff --git a/src/UI/Fl_Osc_Widget.H b/src/UI/Fl_Osc_Widget.H @@ -38,6 +38,7 @@ class Fl_Osc_Widget //Smoothly change the base path void rebase(std::string new_base); + void oscMove(std::string new_ext); //Base path std::string loc; diff --git a/src/UI/Fl_Osc_Widget.cpp b/src/UI/Fl_Osc_Widget.cpp @@ -91,3 +91,10 @@ void Fl_Osc_Widget::rebase(std::string new_base) loc = new_base; osc->requestValue(loc+ext); } + +void Fl_Osc_Widget::oscMove(std::string new_ext) +{ + osc->renameLink(loc+ext, loc+new_ext, this); + ext = new_ext; + osc->requestValue(loc+ext); +} diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl @@ -541,7 +541,7 @@ if (result!=0) fl_alert("Error: Could not save the file.");} label {Sys.Effect No.} callback {nsyseff=(int) o->value()-1; sysefftype->value(master->sysefx[nsyseff]->geteffect()); -syseffectui->refresh(master->sysefx[nsyseff]);} +syseffectui->refresh();} xywh {10 186 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1 code0 {o->bounds(1,NUM_SYS_EFX);} code1 {o->value(nsyseff+1);} @@ -551,7 +551,8 @@ syseffectui->refresh(master->sysefx[nsyseff]);} callback {pthread_mutex_lock(&master->mutex); master->sysefx[nsyseff]->changeeffect((int) o->value()); pthread_mutex_unlock(&master->mutex); -syseffectui->refresh(master->sysefx[nsyseff]);} +syseffectui->efftype = o->value(); +syseffectui->refresh();} xywh {290 181 100 22} down_box BORDER_BOX labelsize 10 code0 {o->value(master->sysefx[nsyseff]->geteffect());} } { @@ -602,7 +603,7 @@ syseffectui->refresh(master->sysefx[nsyseff]);} } Fl_Group syseffectui { xywh {10 208 380 95} - code0 {o->init(master->sysefx[nsyseff]);} + code0 {o->init(false);} class EffUI } {} } @@ -633,7 +634,7 @@ pthread_mutex_unlock(&master->mutex);*/} callback {ninseff=(int) o->value()-1; insefftype->value(master->insefx[ninseff]->geteffect()); inseffpart->value(master->Pinsparts[ninseff]+2); -inseffectui->refresh(master->insefx[ninseff]); +inseffectui->refresh(); if (master->Pinsparts[ninseff]!=-1) { insefftype->activate(); @@ -653,7 +654,8 @@ if (master->Pinsparts[ninseff]!=-1) { callback {pthread_mutex_lock(&master->mutex); master->insefx[ninseff]->changeeffect((int) o->value()); pthread_mutex_unlock(&master->mutex); -inseffectui->refresh(master->insefx[ninseff]); +inseffectui->efftype = o->value(); +inseffectui->refresh(); inseffectui->show();} xywh {290 178 100 22} down_box BORDER_BOX labelsize 10 code0 {o->value(master->insefx[ninseff]->geteffect());} @@ -706,7 +708,7 @@ inseffectui->show();} } Fl_Group inseffectui { xywh {10 210 380 90} box UP_FRAME - code0 {o->init(master->insefx[ninseff]);} + code0 {o->init(true);} code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();} class EffUI } {} @@ -1199,7 +1201,7 @@ o->redraw();} label {Sys.Effect No.} callback {nsyseff=(int) o->value()-1; simplesysefftype->value(master->sysefx[nsyseff]->geteffect()); -simplesyseffectui->refresh(master->sysefx[nsyseff]); +simplesyseffectui->refresh(); simplerefresh();} xywh {350 75 80 20} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1 code0 {o->bounds(1,NUM_SYS_EFX);} @@ -1210,7 +1212,8 @@ simplerefresh();} callback {pthread_mutex_lock(&master->mutex); master->sysefx[nsyseff]->changeeffect((int) o->value()); pthread_mutex_unlock(&master->mutex); -simplesyseffectui->refresh(master->sysefx[nsyseff]);} +simplesyseffectui->efftype = o->value(); +simplesyseffectui->refresh();} xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5 code0 {o->value(master->sysefx[nsyseff]->geteffect());} } { @@ -1261,7 +1264,7 @@ simplesyseffectui->refresh(master->sysefx[nsyseff]);} } Fl_Group simplesyseffectui { xywh {350 95 234 95} - code0 {o->init(master->sysefx[nsyseff]);} + code0 {o->init(false);} class SimpleEffUI } {} } @@ -1287,7 +1290,7 @@ pthread_mutex_unlock(&master->mutex);} callback {ninseff=(int) o->value()-1; simpleinsefftype->value(master->insefx[ninseff]->geteffect()); simpleinseffpart->value(master->Pinsparts[ninseff]+2); -simpleinseffectui->refresh(master->insefx[ninseff]); +simpleinseffectui->refresh(); if (master->Pinsparts[ninseff]!=-1) { simpleinsefftype->activate(); @@ -1307,7 +1310,8 @@ if (master->Pinsparts[ninseff]!=-1) { callback {pthread_mutex_lock(&master->mutex); master->insefx[ninseff]->changeeffect((int) o->value()); pthread_mutex_unlock(&master->mutex); -simpleinseffectui->refresh(master->insefx[ninseff]); +simpleinseffectui->efftype = o->value(); +simpleinseffectui->refresh(); simpleinseffectui->show();} xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5 code0 {o->value(master->insefx[ninseff]->geteffect());} @@ -1360,7 +1364,7 @@ simpleinseffectui->show();} } Fl_Group simpleinseffectui { xywh {350 95 234 95} - code0 {o->init(master->insefx[ninseff]);} + code0 {o->init(true);} code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();} class SimpleEffUI } {} diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl @@ -651,7 +651,7 @@ else {propta->deactivate();proptb->deactivate();}} callback {ninseff=(int) o->value()-1; insefftype->value(part->partefx[ninseff]->geteffect()); //insefftype->do_callback(); -inseffectui->refresh(part->partefx[ninseff]); +inseffectui->refresh(); int x=part->Pefxroute[ninseff]; if (x==127) x=1; bypasseff->value(part->Pefxbypass[ninseff]); @@ -667,7 +667,8 @@ sendtochoice->value(x);} pthread_mutex_lock(part->mutex); part->partefx[ninseff]->changeeffect((int) o->value()); pthread_mutex_unlock(part->mutex); -inseffectui->refresh(part->partefx[ninseff]);} +inseffectui->efftype = o->value(); +inseffectui->refresh();} xywh {155 110 70 15} down_box BORDER_BOX labelsize 10 align 6 code0 {o->value(part->partefx[ninseff]->geteffect());} } { @@ -718,7 +719,7 @@ inseffectui->refresh(part->partefx[ninseff]);} } Fl_Group inseffectui { xywh {5 5 380 95} - code0 {o->init(part->partefx[ninseff]);} + code0 {o->init(true);} class EffUI } {} }