# data file for the Fltk User Interface Designer (fluid) version 1.0110 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} decl {//License: GNU GPL version 2 or later} {} decl {\#include } {public } decl {\#include } {public } decl {\#include } {public } decl {\#include } {} decl {\#include } {} decl {\#include } {} decl {\#include } {} decl {\#include "../Synth/Resonance.h"} {public } decl {\#include "WidgetPDial.h"} {public } decl {\#include "PresetsUI.h"} {public } class ResonanceGraph {open : {public Fl_Box} } { Function {ResonanceGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} { code {respar=NULL; cbwidget=NULL; applybutton=NULL;} {} } Function {init(Resonance *respar_,Fl_Value_Output *khzvalue_,Fl_Value_Output *dbvalue_)} {} { code {respar=respar_; khzvalue=khzvalue_; dbvalue=dbvalue_; oldx=-1; khzval=-1;} {} } Function {draw_freq_line(float freq,int type)} {open } { code {float freqx=respar->getfreqpos(freq); switch(type){ case 0:fl_line_style(FL_SOLID);break; case 1:fl_line_style(FL_DOT);break; case 2:fl_line_style(FL_DASH);break; }; if ((freqx>0.0)&&(freqx<1.0)) fl_line(x()+(int) (freqx*w()),y(), x()+(int) (freqx*w()),y()+h());} {} } Function {draw()} {open } { code {int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy; float freqx; fl_color(FL_DARK1); fl_rectf(ox,oy,lx,ly); //draw the lines fl_color(FL_GRAY); fl_line_style(FL_SOLID); fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2); freqx=respar->getfreqpos(1000.0); if ((freqx>0.0)&&(freqx<1.0)) fl_line(ox+(int) (freqx*lx),oy, ox+(int) (freqx*lx),oy+ly); for (i=1;i<10;i++){ if(i==1){ draw_freq_line(i*100.0,0); draw_freq_line(i*1000.0,0); }else if (i==5){ draw_freq_line(i*100.0,2); draw_freq_line(i*1000.0,2); }else{ draw_freq_line(i*100.0,1); draw_freq_line(i*1000.0,1); }; }; draw_freq_line(10000.0,0); draw_freq_line(20000.0,1); fl_line_style(FL_DOT); int GY=10;if (lyPrespoints[0]/128.0*ly); for (i=1;iPrespoints[i]/128.0*ly); fl_vertex(ox+ix,oy+ly-oiy); oiy=iy; }; fl_end_line(); fl_line_style(FL_SOLID,0);} {selected } } Function {handle(int event)} {return_type int } { code {int x_=Fl::event_x()-x(); int y_=Fl::event_y()-y(); if ( (x_>=0)&&(x_=0)&&(y_value(respar->getfreqx(x_*1.0/w())/1000.0); dbvalue->value((1.0-y_*2.0/h())*respar->PmaxdB); }; if ((event==FL_PUSH)||(event==FL_DRAG)){ int leftbutton=1; if (Fl::event_button()==FL_RIGHT_MOUSE) leftbutton=0; if (x_<0) x_=0;if (y_<0) y_=0; if (x_>=w()) x_=w();if (y_>=h()-1) y_=h()-1; if ((oldx<0)||(oldx==x_)){ int sn=(int)(x_*1.0/w()*N_RES_POINTS); int sp=127-(int)(y_*1.0/h()*127); if (leftbutton!=0) respar->setpoint(sn,sp); else respar->setpoint(sn,64); } else { int x1=oldx; int x2=x_; int y1=oldy; int y2=y_; if (oldx>x_){ x1=x_;y1=y_; x2=oldx;y2=oldy; }; for (int i=0;isetpoint(sn,sp); else respar->setpoint(sn,64); }; }; oldx=x_;oldy=y_; redraw(); }; if (event==FL_RELEASE) { oldx=-1; if (cbwidget!=NULL) { cbwidget->do_callback(); if (applybutton!=NULL) { applybutton->color(FL_RED); applybutton->redraw(); }; }; }; return(1);} {} } Function {setcbwidget(Fl_Widget *cbwidget,Fl_Widget *applybutton)} {} { code {this->cbwidget=cbwidget; this->applybutton=applybutton;} {} } decl {Fl_Value_Output *khzvalue;} {} decl {Fl_Value_Output *dbvalue;} {} decl {Resonance *respar;} {} decl {int oldx,oldy;} {} decl {float khzval;} {public } decl {Fl_Widget *cbwidget,*applybutton;} {} } class ResonanceUI {open : PresetsUI_ } { Function {make_window()} {open } { Fl_Window resonancewindow { label Resonance open xywh {120 70 780 305} type Double hide } { Fl_Value_Output khzvalue { label kHz xywh {415 264 45 18} labelsize 12 align 8 minimum 0.001 maximum 48 step 0.01 textfont 1 textsize 12 code0 {//this widget must be before the calling widgets} } Fl_Value_Output dbvalue { label dB xywh {415 282 45 18} labelsize 12 align 8 minimum -150 maximum 150 step 0.1 textfont 1 textsize 12 code0 {//this widget must be before the calling widgets} } Fl_Group {} { xywh {6 5 768 256} box BORDER_BOX code0 {rg=new ResonanceGraph(o->x(),o->y(),o->w(),o->h(),"");} code1 {rg->init(respar,khzvalue,dbvalue);} code2 {rg->show();} } {} Fl_Button {} { label Close callback {resonancewindow->hide();} xywh {690 283 84 17} box THIN_UP_BOX } Fl_Button {} { label Zero callback {for (int i=0;isetpoint(i,64); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Clear the resonance function} xywh {491 264 66 15} box THIN_UP_BOX labelfont 1 labelsize 12 } Fl_Button {} { label Smooth callback {respar->smooth(); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Smooth the resonance function} xywh {491 282 66 18} box THIN_UP_BOX labelfont 1 labelsize 12 } Fl_Check_Button enabled { label Enable callback {respar->Penabled=(int) o->value(); redrawPADnoteApply();} xywh {6 270 78 27} box THIN_UP_BOX down_box DOWN_BOX code0 {o->value(respar->Penabled);} } Fl_Roller maxdb { callback {maxdbvo->value(o->value()); respar->PmaxdB=(int) o->value(); redrawPADnoteApply();} xywh {90 282 84 15} type Horizontal minimum 1 maximum 90 step 1 value 30 } Fl_Value_Output maxdbvo { label {Max.} callback {o->value(respar->PmaxdB);} tooltip {The Maximum amplitude (dB)} xywh {126 264 24 18} labelsize 12 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12 code0 {o->value(respar->PmaxdB);} } Fl_Box {} { label dB xywh {150 264 24 18} } Fl_Value_Output centerfreqvo { label {C.f.} callback {o->value(respar->getcenterfreq()/1000.0);} tooltip {Center Frequency (kHz)} xywh {210 264 33 18} labelsize 12 when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 12 code0 {o->value(respar->getcenterfreq()/1000.0);} } Fl_Value_Output octavesfreqvo { label {Oct.} callback {o->value(respar->getoctavesfreq());} tooltip {No. of octaves} xywh {210 282 33 18} labelsize 12 when 3 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12 code0 {o->value(respar->getoctavesfreq());} } Fl_Button {} { label RND2 callback {respar->randomize(1); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Randomize the resonance function} xywh {566 276 42 12} box THIN_UP_BOX labelfont 1 labelsize 10 } Fl_Button {} { label RND1 callback {respar->randomize(0); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Randomize the resonance function} xywh {566 264 42 12} box THIN_UP_BOX labelfont 1 labelsize 10 } Fl_Button {} { label RND3 callback {respar->randomize(2); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Randomize the resonance function} xywh {566 288 42 12} box THIN_UP_BOX labelfont 1 labelsize 10 } Fl_Check_Button p1st { label {P.1st} callback {respar->Pprotectthefundamental=(int) o->value(); redrawPADnoteApply();} tooltip {Protect the fundamental frequency (do not damp the first harmonic)} xywh {365 285 45 15} down_box DOWN_BOX labelsize 10 code0 {o->value(respar->Pprotectthefundamental);} } Fl_Button {} { label InterpP callback {int type; if (Fl::event_button()==FL_LEFT_MOUSE) type=0; else type=1; respar->interpolatepeaks(type); resonancewindow->redraw(); redrawPADnoteApply();} tooltip {Interpolate the peaks} xywh {365 265 46 15} box THIN_UP_BOX labelfont 1 labelsize 10 } Fl_Dial centerfreq { label {C.f.} callback {respar->Pcenterfreq=(int)o->value(); centerfreqvo->do_callback(); rg->redraw(); redrawPADnoteApply();} xywh {245 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1 code0 {o->value(respar->Pcenterfreq);} class WidgetPDial } Fl_Dial octavesfreq { label {Oct.} callback {respar->Poctavesfreq=(int)o->value(); octavesfreqvo->do_callback(); rg->redraw(); redrawPADnoteApply();} xywh {280 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1 code0 {o->value(respar->Poctavesfreq);} class WidgetPDial } Fl_Button {} { label C callback {presetsui->copy(respar);} xywh {625 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label P callback {presetsui->paste(respar,this);} xywh {655 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button applybutton { label Apply callback {applybutton->color(FL_GRAY); applybutton->redraw(); if (cbapplywidget!=NULL) { cbapplywidget->do_callback(); cbapplywidget->color(FL_GRAY); cbapplywidget->redraw(); };} xywh {690 265 85 15} box THIN_UP_BOX labelfont 1 labelsize 11 } } } Function {ResonanceUI(Resonance *respar_)} {} { code {respar=respar_; cbwidget=NULL; cbapplywidget=NULL; make_window(); applybutton->hide();} {} } Function {~ResonanceUI()} {} { code {resonancewindow->hide();} {} } Function {redrawPADnoteApply()} {} { code {if (cbwidget!=NULL) { cbwidget->do_callback(); applybutton->color(FL_RED); applybutton->redraw(); };} {} } Function {setcbwidget(Fl_Widget *cbwidget,Fl_Widget *cbapplywidget)} {} { code {this->cbwidget=cbwidget; this->cbapplywidget=cbapplywidget; rg->setcbwidget(cbwidget,applybutton); applybutton->show();} {} } Function {refresh()} {} { code {redrawPADnoteApply(); enabled->value(respar->Penabled); maxdb->value(respar->PmaxdB); maxdbvo->value(respar->PmaxdB); centerfreqvo->value(respar->getcenterfreq()/1000.0); octavesfreqvo->value(respar->getoctavesfreq()); centerfreq->value(respar->Pcenterfreq); octavesfreq->value(respar->Poctavesfreq); p1st->value(respar->Pprotectthefundamental); rg->redraw();} {} } decl {Resonance *respar;} {public } decl {ResonanceGraph *rg;} {} decl {Fl_Widget *cbwidget,*cbapplywidget;} {} }