home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Complet / ZynAddFX / Setup_ZynAddSubFX-2.1.1.exe / OscilGenUI.fl < prev    next >
Encoding:
FLTK User Interface Designer  |  2004-08-15  |  31.1 KB  |  1,074 lines

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0105 
  3. header_name {.h} 
  4. code_name {.cc}
  5. decl {//Copyright (c) 2002-2004 Nasca Octavian Paul} {} 
  6.  
  7. decl {//License: GNU GPL version 2} {} 
  8.  
  9. decl {\#include "../Synth/OscilGen.h"} {public
  10.  
  11. decl {\#include "../Misc/Util.h"} {public
  12.  
  13. decl {\#include "../Misc/Master.h"} {public
  14.  
  15. decl {\#include "ResonanceUI.h"} {public
  16.  
  17. decl {\#include <FL/Fl_Box.H>} {public
  18.  
  19. decl {\#include <FL/Fl_Group.H>} {public
  20.  
  21. decl {\#include <FL/Fl_Slider.H>} {public
  22.  
  23. decl {\#include <math.h>} {} 
  24.  
  25. decl {\#include <stdio.h>} {} 
  26.  
  27. decl {\#include <stdlib.h>} {} 
  28.  
  29. decl {\#include <string.h>} {} 
  30.  
  31. decl {\#include "WidgetPDial.h"} {public
  32.  
  33. decl {\#include "EnvelopeUI.h"} {public
  34.  
  35. decl {\#include "LFOUI.h"} {public
  36.  
  37. decl {\#include "FilterUI.h"} {public
  38.  
  39. decl {\#include "PresetsUI.h"} {public
  40.  
  41. class OscilSpectrum {: {public Fl_Box}
  42. } {
  43.   Function {OscilSpectrum(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  44.     code {oscil=NULL;} {}
  45.   }
  46.   Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
  47.     code {oscil=oscil_;
  48. oscbase=oscbase_;
  49. master=master_;} {}
  50.   }
  51.   Function {draw()} {} {
  52.     code {int ox=x(),oy=y(),lx=w(),ly=h(),i;
  53. const int maxdb=60;//must be multiple of 10
  54. int GX=2;
  55. int n=lx/GX-1;
  56. if (n>OSCIL_SIZE/2) n=OSCIL_SIZE/2;
  57.  
  58. REALTYPE x;
  59. REALTYPE spc[n];
  60. for (i=0;i<n;i++) spc[i]=0.0;
  61.  
  62. pthread_mutex_lock(&master->mutex);
  63. if (oscbase==0) oscil->getspectrum(n,spc,0);
  64.     else oscil->getspectrum(n,spc,1);
  65. pthread_mutex_unlock(&master->mutex);
  66.  
  67. //normalize
  68. REALTYPE max=0;
  69. for (i=0;i<n;i++){
  70.    x=fabs(spc[i]);
  71.    if (max<x) max=x;
  72. }
  73. if (max<0.000001) max=1.0;
  74. max=max*1.05;
  75.  
  76. //draw
  77.  
  78. if (this->active_r()) fl_color(this->parent()->selection_color());
  79.     else fl_color(this->parent()->color());
  80. if ((ANTI_ALIAS==0)&&(oscbase==0)) fl_color(this->parent()->color());
  81. fl_line_style(FL_DOT);
  82.  
  83. for (i=1;i<maxdb/10;i++){
  84.   int ky=(int)((REALTYPE)i*ly*10.0/maxdb)/2;
  85.   ky*=2;
  86.   fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
  87. };
  88.  
  89. for (i=2;i<n;i++){
  90.     int tmp=i*GX-2;
  91.     if (i%10==1) fl_line_style(0);
  92.        else fl_line_style(FL_DOT);
  93.     fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
  94. }
  95.  
  96. if (this->active_r()) fl_color(this->parent()->labelcolor());
  97.     else fl_color(this->parent()->color());
  98. fl_line_style(0);
  99.  
  100. //draws the spectrum
  101. for (i=0;i<n;i++){
  102.    int tmp=i*GX+2;
  103.    x=spc[i]/max;
  104.    
  105.    if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
  106.        else x=0;
  107.  
  108.    int val=(int) ((ly-2)*x);
  109.    if (val>0) fl_line(ox+tmp,oy+ly-2-val,ox+tmp,oy+ly-2);
  110. };} {}
  111.   }
  112.   decl {OscilGen *oscil;} {}
  113.   decl {int oscbase;} {}
  114.   decl {Master *master;} {}
  115.  
  116. class PSlider {: {public Fl_Slider}
  117. } {
  118.   Function {PSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label)} {} {}
  119.   Function {handle(int event)} {return_type int
  120.   } {
  121.     code {int X=x(),Y=y(),W=w(),H=h();
  122.  
  123. if ((!Fl::event_buttons())|| (event==0)||(Fl::event_shift()==0)) return(Fl_Slider::handle(event));
  124.  
  125. if (!Fl::event_inside(X,Y,W,H)) {
  126.     if (event==FL_DRAG){
  127.         Fl_Slider::handle(FL_RELEASE);
  128.         Fl_Slider::handle(FL_LEAVE);
  129.         deactivate();
  130.         activate();
  131.         return(1);    
  132.     }else{
  133.         return(Fl_Slider::handle(event));
  134.     };
  135. } else {
  136.     //Fl_Slider::handle(FL_FOCUS);
  137.     Fl_Slider::handle(FL_PUSH);
  138. };
  139.  
  140. return(1);} {}
  141.   }
  142.  
  143. class Oscilloscope {: {public Fl_Box}
  144. } {
  145.   Function {Oscilloscope(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
  146.     code {oscil=NULL;
  147. phase=64;
  148. oscbase=0;} {}
  149.   }
  150.   Function {init(OscilGen *oscil_,Master *master_)} {} {
  151.     code {oscil=oscil_;
  152. master=master_;} {}
  153.   }
  154.   Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
  155.     code {oscil=oscil_;
  156. oscbase=oscbase_;
  157. master=master_;} {}
  158.   }
  159.   Function {init(OscilGen *oscil_,int oscbase_,int phase_,Master *master_)} {} {
  160.     code {oscil=oscil_;
  161. oscbase=oscbase_;
  162. phase=phase_;
  163. master=master_;} {}
  164.   }
  165.   Function {draw()} {} {
  166.     code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
  167. REALTYPE smps[OSCIL_SIZE];
  168. pthread_mutex_lock(&master->mutex);
  169. if (oscbase==0) oscil->get(smps,-1.0);
  170.     else oscil->getcurrentbasefunction(smps);
  171. pthread_mutex_unlock(&master->mutex);
  172.  
  173. if (damage()!=1){
  174.  fl_color(0,0,0);
  175.  fl_rectf(ox,oy,lx,ly);
  176. };
  177.  
  178. //normalize
  179. REALTYPE max=0;
  180. for (i=0;i<OSCIL_SIZE;i++)
  181.    if (max<fabs(smps[i])) max=fabs(smps[i]);
  182. //fprintf(stderr,"%.4f\\n",max);
  183. if (max<0.00001) max=1.0;
  184. max=-max*1.05;
  185.  
  186. //draw
  187. fl_line_style(FL_DASH);
  188. if (this->active_r()) fl_color(this->parent()->labelcolor());
  189.     else fl_color(this->parent()->color());
  190. int GX=16;if (lx<GX*3) GX=-1;
  191. for (i=1;i<GX;i++){
  192.    int tmp=(int)(lx/(REALTYPE)GX*i);
  193.    fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
  194. };
  195. int GY=8;if (ly<GY*3) GY=-1;
  196. for (i=1;i<GY;i++){
  197.    int tmp=(int)(ly/(REALTYPE)GY*i);
  198.    fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
  199. };
  200.  
  201. //draw the function
  202. fl_line_style(0,1);
  203. fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
  204. if (this->active_r()) fl_color(this->parent()->selection_color());
  205.     else fl_color(this->parent()->labelcolor());
  206. int lw=1;
  207. //if ((lx<135)||(ly<135)) lw=1;
  208. fl_line_style(0,lw);
  209. int ph=(int)((phase-64.0)/128.0*OSCIL_SIZE+OSCIL_SIZE);
  210. for (i=1;i<lx;i++){
  211.    int k1=(int)((REALTYPE)OSCIL_SIZE*(i-1)/lx)+ph;
  212.    int k2=(int)((REALTYPE)OSCIL_SIZE*i/lx)+ph;
  213.    REALTYPE y1=smps[k1%OSCIL_SIZE]/max;
  214.    REALTYPE y2=smps[k2%OSCIL_SIZE]/max;
  215.    fl_line(i-1+ox,(int)(y1*ly/2.0)+oy+ly/2,i+ox,(int)(y2*ly/2.0)+oy+ly/2);
  216. };} {}
  217.   }
  218.   decl {OscilGen *oscil;} {}
  219.   decl {int oscbase;} {}
  220.   decl {int phase;} {public
  221.   }
  222.   decl {Master *master;} {}
  223.  
  224. class Oscilharmonic {: {public Fl_Group}
  225. } {
  226.   Function {make_window()} {private
  227.   } {
  228.     Fl_Window harmonic {
  229.       private xywh {421 154 90 225} type Double hide
  230.       class Fl_Group
  231.     } {
  232.       Fl_Slider mag {
  233.         callback {int x=64;
  234. if (Fl::event_button3()) o->value(x);
  235.    else x=127-(int)o->value();
  236. if (x==64) o->selection_color(0);
  237.     else o->selection_color(222);
  238.  
  239. pthread_mutex_lock(&master->mutex);
  240.  oscil->Phmag[n]=x;
  241.  if (x==64) {
  242.     oscil->Phphase[n]=64;
  243.     phase->value(64);
  244.  };
  245.  oscil->prepare();
  246. pthread_mutex_unlock(&master->mutex);
  247.  
  248. display->redraw();
  249. oldosc->redraw();
  250. if (cbwidget!=NULL) cbwidget->do_callback();}
  251.         xywh {0 15 15 115} type {Vert Knob} box FLAT_BOX selection_color 222 labelcolor 0 maximum 127 step 1 value 64
  252.         code0 {o->value(127-oscil->Phmag[n]);}
  253.         code1 {if (oscil->Phmag[n]==64) o->selection_color(0);}
  254.         class PSlider
  255.       }
  256.       Fl_Slider phase {
  257.         callback {int x=64;
  258. if (Fl::event_button3()) o->value(x);
  259.    else x=(int)o->value();
  260.  
  261. pthread_mutex_lock(&master->mutex);
  262.  oscil->Phphase[n]=x;
  263.  oscil->prepare();
  264. pthread_mutex_unlock(&master->mutex);
  265.  
  266. display->redraw();
  267. oldosc->redraw();
  268. if (cbwidget!=NULL) cbwidget->do_callback();}
  269.         xywh {0 135 15 75} type {Vert Knob} box FLAT_BOX selection_color 222 maximum 127 step 1 value 64
  270.         code0 {o->value(oscil->Phphase[n]);}
  271.         class PSlider
  272.       }
  273.       Fl_Box {} {
  274.         xywh {15 70 5 5} box FLAT_BOX color 45
  275.       }
  276.       Fl_Box {} {
  277.         xywh {15 170 5 5} box FLAT_BOX color 45
  278.       }
  279.       Fl_Box {} {
  280.         label 01
  281.         xywh {0 210 20 15} labelfont 1 labelsize 9 align 20
  282.         code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
  283.       }
  284.       Fl_Box {} {
  285.         label 01
  286.         xywh {0 0 20 15} labelfont 1 labelsize 9 align 20
  287.         code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
  288.       }
  289.     }
  290.   }
  291.   Function {Oscilharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
  292.     code {n=0;
  293. oscil=NULL;
  294. display=NULL;} {}
  295.   }
  296.   Function {init(OscilGen *oscil_,int n_,Fl_Group *display_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_, Master *master_)} {} {
  297.     code {oscil=oscil_;
  298. n=n_;
  299. display=display_;
  300. master=master_;
  301. oldosc=oldosc_;
  302. cbwidget=cbwidget_;
  303. make_window();
  304. end();
  305. harmonic->show();} {}
  306.   }
  307.   Function {refresh()} {} {
  308.     code {mag->value(127-oscil->Phmag[n]);
  309. phase->value(oscil->Phphase[n]);
  310.  
  311. if (oscil->Phmag[n]==64) mag->selection_color(0);
  312.     else mag->selection_color(222);} {}
  313.   }
  314.   Function {~Oscilharmonic()} {} {
  315.     code {harmonic->hide();
  316. //delete(harmonic);} {}
  317.   }
  318.   decl {OscilGen *oscil;} {}
  319.   decl {Fl_Group *display;} {}
  320.   decl {int n;} {}
  321.   decl {Fl_Widget *oldosc,*cbwidget;} {}
  322.   decl {Master *master;} {}
  323.  
  324. class OscilEditor {: {public PresetsUI_}
  325. } {
  326.   Function {make_window()} {} {
  327.     Fl_Window osceditUI {
  328.       label {ADsynth Oscillator Editor}
  329.       xywh {4 91 745 600} type Double hide
  330.       code0 {if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");}
  331.     } {
  332.       Fl_Group oscildisplaygroup {
  333.         xywh {15 5 360 300} box ENGRAVED_FRAME
  334.       } {
  335.         Fl_Group {} {open
  336.           xywh {20 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
  337.           code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
  338.           code1 {osc->init(oscil,master);}
  339.         } {}
  340.         Fl_Box {} {
  341.           label Oscillator
  342.           xywh {130 10 110 20} box FLAT_BOX labelfont 1
  343.         }
  344.         Fl_Value_Slider rndslider {
  345.           label rnd
  346.           callback {oscil->Prand=(int)o->value()+64;
  347. oscildisplaygroup->redraw();
  348. oldosc->redraw();}
  349.           tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {150 285 100 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
  350.           code0 {if (oscil->ADvsPAD) o->hide();}
  351.         }
  352.         Fl_Group {} {open
  353.           xywh {20 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
  354.           code0 {OscilSpectrum *spc=new OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
  355.           code1 {spc->init(oscil,0,master);}
  356.         } {}
  357.         Fl_Group {} {
  358.           xywh {256 277 115 25} box ENGRAVED_BOX
  359.           code0 {if (oscil->ADvsPAD) o->hide();}
  360.         } {
  361.           Fl_Choice hrndtype {
  362.             label {H.rnd}
  363.             callback {oscil->Pamprandtype=(int) o->value();}
  364.             tooltip {Harmonic Amplitude Randomness} xywh {291 282 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  365.           } {
  366.             menuitem {} {
  367.               label None
  368.               xywh {60 60 100 20} labelfont 1 labelsize 10
  369.             }
  370.             menuitem {} {
  371.               label Pow
  372.               xywh {70 70 100 20} labelfont 1 labelsize 10
  373.             }
  374.             menuitem {} {
  375.               label Sin
  376.               xywh {80 80 100 20} labelfont 1 labelsize 10
  377.             }
  378.           }
  379.           Fl_Dial hrnddial {
  380.             callback {oscil->Pamprandpower=(int) o->value();}
  381.             tooltip {Oscillator's spectrum adjust parameter} xywh {348 280 18 18} maximum 127 step 1
  382.             class WidgetPDial
  383.           }
  384.         }
  385.       }
  386.       Fl_Box {} {
  387.         label {Base Func.}
  388.         xywh {505 15 110 20} box FLAT_BOX labelfont 1
  389.       }
  390.       Fl_Group basefuncdisplaygroup {
  391.         xywh {375 5 360 300} box ENGRAVED_FRAME
  392.       } {
  393.         Fl_Group {} {
  394.           xywh {380 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
  395.           code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
  396.           code1 {osc->init(oscil,1,master);}
  397.         } {}
  398.         Fl_Dial bfslider {
  399.           callback {oscil->Pbasefuncpar=(int)o->value()+64;
  400. basefuncdisplaygroup->redraw();
  401. bfparval->value(oscil->Pbasefuncpar-64);
  402.  
  403. redrawoscil();}
  404.           tooltip {Base Function Parameter} xywh {530 280 20 20} minimum -64 maximum 63 step 1
  405.           class WidgetPDial
  406.         }
  407.         Fl_Choice bftype {
  408.           label {Base.F..}
  409.           callback {oscil->Pcurrentbasefunc=(int) o->value();
  410.  
  411. basefuncdisplaygroup->redraw();
  412. redrawoscil();
  413.  
  414. if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
  415.       else basefuncmodulation->activate();}
  416.           xywh {380 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 12
  417.         } {
  418.           menuitem {} {
  419.             label Sine
  420.             xywh {10 10 100 20} labelfont 1 labelsize 12
  421.           }
  422.           menuitem {} {
  423.             label Triangle
  424.             xywh {20 20 100 20} labelfont 1 labelsize 12
  425.           }
  426.           menuitem {} {
  427.             label Pulse
  428.             xywh {30 30 100 20} labelfont 1 labelsize 12
  429.           }
  430.           menuitem {} {
  431.             label Saw
  432.             xywh {40 40 100 20} labelfont 1 labelsize 12
  433.           }
  434.           menuitem {} {
  435.             label Power
  436.             xywh {50 50 100 20} labelfont 1 labelsize 12
  437.           }
  438.           menuitem {} {
  439.             label Gauss
  440.             xywh {50 50 100 20} labelfont 1 labelsize 12
  441.           }
  442.           menuitem {} {
  443.             label Diode
  444.             xywh {60 60 100 20} labelfont 1 labelsize 12
  445.           }
  446.           menuitem {} {
  447.             label AbsSine
  448.             xywh {70 70 100 20} labelfont 1 labelsize 12
  449.           }
  450.           menuitem {} {
  451.             label PulseSine
  452.             xywh {80 80 100 20} labelfont 1 labelsize 12
  453.           }
  454.           menuitem {} {
  455.             label StrchSine
  456.             xywh {90 90 100 20} labelfont 1 labelsize 12
  457.           }
  458.           menuitem {} {
  459.             label Chirp
  460.             xywh {100 100 100 20} labelfont 1 labelsize 12
  461.           }
  462.           menuitem {} {
  463.             label AbsStrSine
  464.             xywh {102 102 100 20} labelfont 1 labelsize 12
  465.           }
  466.           menuitem {} {
  467.             label Chebyshev
  468.             xywh {112 112 100 20} labelfont 1 labelsize 12
  469.           }
  470.           menuitem {} {
  471.             label Sqr
  472.             xywh {122 122 100 20} labelfont 1 labelsize 12
  473.           }
  474.         }
  475.         Fl_Box {} {
  476.           label {Base Func.}
  477.           xywh {490 10 110 20} box FLAT_BOX labelfont 1
  478.         }
  479.         Fl_Group {} {open
  480.           xywh {380 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
  481.           code0 {OscilSpectrum *spc=new OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
  482.           code1 {spc->init(oscil,1,master);}
  483.         } {}
  484.         Fl_Value_Output bfparval {
  485.           label {Par.}
  486.           xywh {500 285 25 15} labelsize 13 minimum -63 maximum 63 step 1
  487.         }
  488.         Fl_Group basefuncmodulation {
  489.           xywh {560 276 169 25} box ENGRAVED_BOX
  490.           code0 {if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
  491.         } {
  492.           Fl_Choice bfmodtype {
  493.             label {B.F.Mod.}
  494.             callback {oscil->Pbasefuncmodulation=(int) o->value();
  495. basefuncdisplaygroup->redraw();
  496. redrawoscil();}
  497.             tooltip {Base function modulation} xywh {609 281 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  498.           } {
  499.             menuitem {} {
  500.               label None
  501.               xywh {50 50 100 20} labelfont 1 labelsize 10
  502.             }
  503.             menuitem {} {
  504.               label Rev
  505.               xywh {60 60 100 20} labelfont 1 labelsize 10
  506.             }
  507.             menuitem {} {
  508.               label Sine
  509.               xywh {70 70 100 20} labelfont 1 labelsize 10
  510.             }
  511.             menuitem {} {
  512.               label Pow
  513.               xywh {80 80 100 20} labelfont 1 labelsize 10
  514.             }
  515.           }
  516.           Fl_Dial bfmodpar1 {
  517.             callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
  518. basefuncdisplaygroup->redraw();
  519. redrawoscil();}
  520.             tooltip {Oscillator's modulation parameter 1} xywh {669 281 15 15} maximum 127 step 1
  521.             class WidgetPDial
  522.           }
  523.           Fl_Dial bfmodpar2 {
  524.             callback {oscil->Pbasefuncmodulationpar2=(int)o->value();
  525. basefuncdisplaygroup->redraw();
  526. redrawoscil();}
  527.             tooltip {Oscillator's modulation parameter 2} xywh {689 281 15 15} maximum 127 step 1
  528.             class WidgetPDial
  529.           }
  530.           Fl_Dial bfmodpar3 {
  531.             callback {oscil->Pbasefuncmodulationpar3=(int)o->value();
  532. basefuncdisplaygroup->redraw();
  533. redrawoscil();}
  534.             tooltip {Oscillator's modulation parameter 3} xywh {709 281 15 15} maximum 127 step 1
  535.             class WidgetPDial
  536.           }
  537.         }
  538.       }
  539.       Fl_Choice magtype {
  540.         label {Mag.Type}
  541.         callback {oscil->Phmagtype=(int) o->value();
  542. basefuncdisplaygroup->redraw();
  543.  
  544. redrawoscil();}
  545.         xywh {80 280 65 20} down_box BORDER_BOX labelsize 12 textsize 12
  546.       } {
  547.         menuitem {} {
  548.           label Linear
  549.           xywh {0 0 100 20} labelfont 1 labelsize 12
  550.         }
  551.         menuitem {} {
  552.           label {-40dB}
  553.           xywh {10 10 100 20} labelfont 1 labelsize 12
  554.         }
  555.         menuitem {} {
  556.           label {-60dB}
  557.           xywh {20 20 100 20} labelfont 1 labelsize 12
  558.         }
  559.         menuitem {} {
  560.           label {-80dB}
  561.           xywh {30 30 100 20} labelfont 1 labelsize 12
  562.         }
  563.         menuitem {} {
  564.           label {-100dB}
  565.           xywh {40 40 100 20} labelfont 1 labelsize 12
  566.         }
  567.       }
  568.       Fl_Button {} {
  569.         label {Use as base}
  570.         callback {oscil->useasbase();
  571. if (autoclearbutton->value()){
  572.    for (int i=0;i<MAX_AD_HARMONICS;i++){
  573.       h[i]->mag->value(64);
  574.       oscil->Phmag[i]=64;
  575.       h[i]->phase->value(64);
  576.       oscil->Phphase[i]=64;
  577.    };
  578.    oscil->Phmag[0]=127;
  579.  
  580.    oscil->Pharmonicshift=0;
  581.    harmonicshiftcounter->value(0);
  582.  
  583.    h[0]->mag->value(0);
  584.    wshbutton->value(0);
  585.    wshbutton->do_callback();
  586.    fltbutton->value(0);
  587.    fltbutton->do_callback();
  588.    sabutton->value(0);
  589.    sabutton->do_callback();
  590. };
  591.  
  592. pthread_mutex_lock(&master->mutex);
  593.  for (int i=0;i<MAX_AD_HARMONICS;i++){
  594.    if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
  595.       else h[i]->mag->selection_color(222);
  596.  };
  597.  oscil->prepare();
  598. pthread_mutex_unlock(&master->mutex);
  599.  
  600. basefuncdisplaygroup->redraw();
  601. redrawoscil();}
  602.         tooltip {Use this Oscillator as base function} xywh {15 313 85 20} box THIN_UP_BOX labelfont 1 labelsize 12
  603.       }
  604.       Fl_Button {} {
  605.         label Close
  606.         callback {osceditUI->hide();}
  607.         xywh {678 565 62 25} box THIN_UP_BOX
  608.       }
  609.       Fl_Button {} {
  610.         label Clear
  611.         callback {if (!fl_ask("Clear the harmonics settings?")) return;
  612.  
  613. for (int i=0;i<MAX_AD_HARMONICS;i++){
  614.     h[i]->mag->value(64);
  615.     oscil->Phmag[i]=64;
  616.     h[i]->phase->value(64);
  617.     oscil->Phphase[i]=64;
  618. };
  619. oscil->Phmag[0]=127;
  620. h[0]->mag->value(0);
  621.  
  622. for (int i=0;i<MAX_AD_HARMONICS;i++){
  623.   if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
  624.      else h[i]->mag->selection_color(222);
  625. };
  626.  
  627. //harmonics->redraw();
  628.  
  629. pthread_mutex_lock(&master->mutex);
  630.  oscil->prepare();
  631. pthread_mutex_unlock(&master->mutex);
  632.  
  633. redrawoscil();}
  634.         xywh {680 500 55 20} box THIN_UP_BOX labelfont 1 labelsize 12
  635.       }
  636.       Fl_Group {} {
  637.         xywh {145 308 150 30} box ENGRAVED_BOX
  638.       } {
  639.         Fl_Choice wshbutton {
  640.           label {Wsh.}
  641.           callback {oscil->Pwaveshapingfunction=(int) o->value();
  642. basefuncdisplaygroup->redraw();
  643. redrawoscil();} open
  644.           tooltip {Waveshaping function} xywh {175 313 55 20} down_box BORDER_BOX labelsize 10 textsize 10
  645.         } {
  646.           menuitem {} {
  647.             label None
  648.             xywh {25 25 100 20} labelfont 1 labelsize 10
  649.           }
  650.           menuitem {} {
  651.             label Atan
  652.             xywh {35 35 100 20} labelfont 1 labelsize 10
  653.           }
  654.           menuitem {} {
  655.             label Asym1
  656.             xywh {45 45 100 20} labelfont 1 labelsize 10
  657.           }
  658.           menuitem {} {
  659.             label Pow
  660.             xywh {55 55 100 20} labelfont 1 labelsize 10
  661.           }
  662.           menuitem {} {
  663.             label Sine
  664.             xywh {65 65 100 20} labelfont 1 labelsize 10
  665.           }
  666.           menuitem {} {
  667.             label Qnts
  668.             xywh {75 75 100 20} labelfont 1 labelsize 10
  669.           }
  670.           menuitem {} {
  671.             label Zigzg
  672.             xywh {85 85 100 20} labelfont 1 labelsize 10
  673.           }
  674.           menuitem {} {
  675.             label Lmt
  676.             xywh {95 95 100 20} labelfont 1 labelsize 10
  677.           }
  678.           menuitem {} {
  679.             label LmtU
  680.             xywh {105 105 100 20} labelfont 1 labelsize 10
  681.           }
  682.           menuitem {} {
  683.             label LmtL
  684.             xywh {115 115 100 20} labelfont 1 labelsize 10
  685.           }
  686.           menuitem {} {
  687.             label ILmt
  688.             xywh {127 127 100 20} labelfont 1 labelsize 10
  689.           }
  690.           menuitem {} {
  691.             label Clip
  692.             xywh {137 137 100 20} labelfont 1 labelsize 10
  693.           }
  694.           menuitem {} {
  695.             label Asym2
  696.             xywh {85 85 100 20} labelfont 1 labelsize 10
  697.           }
  698.           menuitem {} {
  699.             label Pow2
  700.             xywh {95 95 100 20} labelfont 1 labelsize 10
  701.           }
  702.           menuitem {} {
  703.             label Sgm
  704.             xywh {90 90 100 20} labelfont 1 labelsize 10
  705.           }
  706.         }
  707.         Fl_Dial wshpar {
  708.           callback {oscil->Pwaveshaping=(int)o->value()+64;
  709. wsparval->value(oscil->Pwaveshaping-64);
  710. redrawoscil();}
  711.           tooltip {Waveshaping Parameter} xywh {270 313 20 20} minimum -64 maximum 63 step 1
  712.           class WidgetPDial
  713.         }
  714.         Fl_Value_Output wsparval {
  715.           xywh {238 316 25 15} labelsize 13 minimum -63 maximum 63 step 1
  716.         }
  717.       }
  718.       Fl_Light_Button autoclearbutton {
  719.         label {Clr.}
  720.         tooltip {Auto clear when using the oscillator as base function} xywh {105 313 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
  721.       }
  722.       Fl_Group {} {
  723.         xywh {295 308 155 30} box ENGRAVED_BOX
  724.       } {
  725.         Fl_Choice fltbutton {
  726.           label Filter
  727.           callback {oscil->Pfiltertype=(int) o->value();
  728.  
  729. redrawoscil();}
  730.           tooltip {Oscillator's filter type} xywh {325 313 50 20} down_box BORDER_BOX labelsize 10 textsize 10
  731.         } {
  732.           menuitem {} {
  733.             label None
  734.             xywh {35 35 100 20} labelfont 1 labelsize 10
  735.           }
  736.           menuitem {} {
  737.             label LP1
  738.             xywh {45 45 100 20} labelfont 1 labelsize 10
  739.           }
  740.           menuitem {} {
  741.             label HP1a
  742.             xywh {55 55 100 20} labelfont 1 labelsize 10
  743.           }
  744.           menuitem {} {
  745.             label HP1b
  746.             xywh {65 65 100 20} labelfont 1 labelsize 10
  747.           }
  748.           menuitem {} {
  749.             label BP1
  750.             xywh {75 75 100 20} labelfont 1 labelsize 10
  751.           }
  752.           menuitem {} {
  753.             label BS1
  754.             xywh {85 85 100 20} labelfont 1 labelsize 10
  755.           }
  756.           menuitem {} {
  757.             label LP2
  758.             xywh {55 55 100 20} labelfont 1 labelsize 10
  759.           }
  760.           menuitem {} {
  761.             label HP2
  762.             xywh {65 65 100 20} labelfont 1 labelsize 10
  763.           }
  764.           menuitem {} {
  765.             label BP2
  766.             xywh {65 65 100 20} labelfont 1 labelsize 10
  767.           }
  768.           menuitem {} {
  769.             label BS2
  770.             xywh {75 75 100 20} labelfont 1 labelsize 10
  771.           }
  772.           menuitem {} {
  773.             label Cos
  774.             xywh {75 75 100 20} labelfont 1 labelsize 10
  775.           }
  776.           menuitem {} {
  777.             label Sin
  778.             xywh {85 85 100 20} labelfont 1 labelsize 10
  779.           }
  780.           menuitem {} {
  781.             label LSh
  782.             xywh {95 95 100 20} labelfont 1 labelsize 10
  783.           }
  784.           menuitem {} {
  785.             label S
  786.             xywh {105 105 100 20} labelfont 1 labelsize 10
  787.           }
  788.         }
  789.         Fl_Dial filtervalue1 {
  790.           callback {oscil->Pfilterpar1=(int)o->value();
  791.  
  792. redrawoscil();}
  793.           tooltip {Oscillator's filter parameter1} xywh {377 313 20 20} maximum 127 step 1
  794.           class WidgetPDial
  795.         }
  796.         Fl_Check_Button filterpref {
  797.           label p
  798.           callback {oscil->Pfilterbeforews=(int)o->value();
  799.  
  800. redrawoscil();}
  801.           tooltip {Apply the filter before the waveshaping} xywh {425 313 20 20} down_box DOWN_BOX labelsize 10 align 24
  802.         }
  803.         Fl_Dial filtervalue2 {
  804.           callback {oscil->Pfilterpar2=(int)o->value();
  805.  
  806. redrawoscil();}
  807.           tooltip {Oscillator's filter parameter2} xywh {402 313 20 20} maximum 127 step 1
  808.           class WidgetPDial
  809.         }
  810.       }
  811.       Fl_Scroll _this_has_to_be_the_last {
  812.         xywh {15 340 660 250} type HORIZONTAL box ENGRAVED_BOX
  813.       } {
  814.         Fl_Pack harmonics {open
  815.           xywh {20 345 650 225} type HORIZONTAL
  816.           code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(oscil,i,oscildisplaygroup,oldosc,cbwidget,master);}}
  817.         } {}
  818.       }
  819.       Fl_Group {} {
  820.         xywh {600 308 135 30} box ENGRAVED_BOX
  821.       } {
  822.         Fl_Choice sabutton {
  823.           label {Sp.adj.}
  824.           callback {oscil->Psatype=(int) o->value();
  825. redrawoscil();}
  826.           tooltip {Oscillator's spectrum adjust} xywh {640 313 60 20} down_box BORDER_BOX labelsize 10 textsize 10
  827.         } {
  828.           menuitem {} {
  829.             label None
  830.             xywh {55 55 100 20} labelfont 1 labelsize 10
  831.           }
  832.           menuitem {} {
  833.             label Pow
  834.             xywh {65 65 100 20} labelfont 1 labelsize 10
  835.           }
  836.           menuitem {} {
  837.             label ThrsD
  838.             xywh {75 75 100 20} labelfont 1 labelsize 10
  839.           }
  840.           menuitem {} {
  841.             label ThrsU
  842.             xywh {85 85 100 20} labelfont 1 labelsize 10
  843.           }
  844.         }
  845.         Fl_Dial sadjpar {
  846.           callback {oscil->Psapar=(int)o->value();
  847. redrawoscil();}
  848.           tooltip {Oscillator's spectrum adjust parameter} xywh {705 313 20 20} maximum 127 step 1
  849.           class WidgetPDial
  850.         }
  851.       }
  852.       Fl_Group {} {
  853.         xywh {675 340 65 65} box ENGRAVED_BOX
  854.       } {
  855.         Fl_Counter harmonicshiftcounter {
  856.           label {Harmonic Shift}
  857.           callback {oscil->Pharmonicshift=(int)o->value();
  858. redrawoscil();}
  859.           xywh {680 365 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
  860.         }
  861.         Fl_Check_Button harmonicshiftpre {
  862.           label preH
  863.           callback {oscil->Pharmonicshiftfirst=(int)o->value();
  864. redrawoscil();}
  865.           tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {700 385 34 15} down_box DOWN_BOX labelsize 10 align 24
  866.         }
  867.         Fl_Button {} {
  868.           label R
  869.           callback {oscil->Pharmonicshift=0;
  870. harmonicshiftcounter->value(0);
  871. redrawoscil();}
  872.           xywh {680 385 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
  873.         }
  874.       }
  875.       Fl_Group {} {
  876.         xywh {675 405 65 90} box ENGRAVED_FRAME
  877.       } {
  878.         Fl_Box {} {
  879.           label {Adaptive Harmonics}
  880.           xywh {678 410 60 25} labelsize 10 align 144
  881.         }
  882.         Fl_Choice adhrtype {
  883.           callback {oscil->Padaptiveharmonics=(int) o->value();
  884. redrawoscil();} open
  885.           tooltip {The type of the addaptive harmonics} xywh {680 435 55 15} down_box BORDER_BOX labelsize 10 when 6 textsize 10
  886.         } {
  887.           menuitem {} {
  888.             label OFF
  889.             xywh {80 80 100 20} labelfont 1 labelsize 10
  890.           }
  891.           menuitem {} {
  892.             label On
  893.             xywh {90 90 100 20} labelfont 1 labelsize 10
  894.           }
  895.         }
  896.         Fl_Dial adhrpow {
  897.           label pow
  898.           callback {oscil->Padaptiveharmonicspower=(int)o->value();
  899. redrawoscil();}
  900.           tooltip {Adaptive harmonics power} xywh {710 455 25 25} labelsize 10 maximum 100 step 1
  901.           class WidgetPDial
  902.         }
  903.         Fl_Dial adhrbf {
  904.           label baseF
  905.           callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();
  906. redrawoscil();}
  907.           tooltip {Adaptive harmonics base frequency} xywh {680 455 25 25} labelsize 10 maximum 255 step 1
  908.           class WidgetPDial
  909.         }
  910.       }
  911.       Fl_Group {} {
  912.         xywh {450 308 150 30} box ENGRAVED_BOX
  913.       } {
  914.         Fl_Choice modtype {
  915.           label {Mod.}
  916.           callback {oscil->Pmodulation=(int) o->value();
  917.  
  918. redrawoscil();}
  919.           tooltip modulation xywh {480 315 50 15} down_box BORDER_BOX labelsize 10 textsize 10
  920.         } {
  921.           menuitem {} {
  922.             label None
  923.             xywh {60 60 100 20} labelfont 1 labelsize 10
  924.           }
  925.           menuitem {} {
  926.             label Rev
  927.             xywh {70 70 100 20} labelfont 1 labelsize 10
  928.           }
  929.           menuitem {} {
  930.             label Sine
  931.             xywh {80 80 100 20} labelfont 1 labelsize 10
  932.           }
  933.           menuitem {} {
  934.             label Pow
  935.             xywh {90 90 100 20} labelfont 1 labelsize 10
  936.           }
  937.         }
  938.         Fl_Dial modpar1 {
  939.           callback {oscil->Pmodulationpar1=(int)o->value();
  940.  
  941. redrawoscil();}
  942.           tooltip {Oscillator's modulation parameter 1} xywh {540 315 15 15} maximum 127 step 1
  943.           class WidgetPDial
  944.         }
  945.         Fl_Dial modpar2 {
  946.           callback {oscil->Pmodulationpar2=(int)o->value();
  947.  
  948. redrawoscil();}
  949.           tooltip {Oscillator's modulation parameter 2} xywh {560 315 15 15} maximum 127 step 1
  950.           class WidgetPDial
  951.         }
  952.         Fl_Dial modpar3 {
  953.           callback {oscil->Pmodulationpar3=(int)o->value();
  954. redrawoscil();}
  955.           tooltip {Oscillator's modulation parameter 3} xywh {580 315 15 15} maximum 127 step 1
  956.           class WidgetPDial
  957.         }
  958.       }
  959.       Fl_Button {} {
  960.         label Sine
  961.         callback {if (!fl_ask("Convert to SINE?")) return;
  962.  
  963. pthread_mutex_lock(&master->mutex);
  964.  oscil->convert2sine(0);
  965. pthread_mutex_unlock(&master->mutex);
  966.  
  967. redrawoscil();
  968. refresh();}
  969.         xywh {680 520 55 20} box THIN_UP_BOX labelfont 1 labelsize 12
  970.       }
  971.       Fl_Button {} {
  972.         label C
  973.         callback {presetsui->copy(oscil);} selected
  974.         xywh {680 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
  975.       }
  976.       Fl_Button {} {
  977.         label P
  978.         callback {presetsui->paste(oscil,this);} selected
  979.         xywh {710 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7
  980.       }
  981.     }
  982.   }
  983.   Function {OscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Master *master_)} {} {
  984.     code {oscil=oscil_;
  985. oldosc=oldosc_;
  986. cbwidget=cbwidget_;
  987. master=master_;
  988.  
  989. make_window();
  990.  
  991. refresh();
  992. osceditUI->show();} {}
  993.   }
  994.   Function {~OscilEditor()} {} {
  995.     code {osceditUI->hide();
  996. //for (int i=0;i<MAX_AD_HARMONICS;i++) delete (h[i]);
  997. delete (osceditUI);} {}
  998.   }
  999.   Function {refresh()} {} {
  1000.     code {magtype->value(oscil->Phmagtype);
  1001. rndslider->value(oscil->Prand-64);
  1002.  
  1003. hrndtype->value(oscil->Pamprandtype);
  1004. hrnddial->value(oscil->Pamprandpower);
  1005.  
  1006. bftype->value(oscil->Pcurrentbasefunc);
  1007. bfparval->value(oscil->Pbasefuncpar-64);
  1008. bfslider->value(oscil->Pbasefuncpar-64);
  1009.  
  1010. bfmodtype->value(oscil->Pbasefuncmodulation);
  1011. bfmodpar1->value(oscil->Pbasefuncmodulationpar1);
  1012. bfmodpar2->value(oscil->Pbasefuncmodulationpar2);
  1013. bfmodpar3->value(oscil->Pbasefuncmodulationpar3);
  1014.  
  1015. wshbutton->value(oscil->Pwaveshapingfunction);
  1016. wsparval->value(oscil->Pwaveshaping-64);
  1017. wshpar->value(oscil->Pwaveshaping-64);
  1018.  
  1019. fltbutton->value(oscil->Pfiltertype);
  1020. filtervalue1->value(oscil->Pfilterpar1);
  1021. filtervalue2->value(oscil->Pfilterpar2);
  1022. filterpref->value(oscil->Pfilterbeforews);
  1023.  
  1024. modtype->value(oscil->Pmodulation);
  1025. modpar1->value(oscil->Pmodulationpar1);
  1026. modpar2->value(oscil->Pmodulationpar2);
  1027. modpar3->value(oscil->Pmodulationpar3);
  1028.  
  1029. sabutton->value(oscil->Psatype);
  1030. sadjpar->value(oscil->Psapar);
  1031.  
  1032. harmonicshiftcounter->value(oscil->Pharmonicshift);
  1033. harmonicshiftpre->value(oscil->Pharmonicshiftfirst);
  1034.  
  1035. adhrtype->value(oscil->Padaptiveharmonics);
  1036. adhrbf->value(oscil->Padaptiveharmonicsbasefreq);
  1037. adhrpow->value(oscil->Padaptiveharmonicspower);
  1038.  
  1039. for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();
  1040.  
  1041. pthread_mutex_lock(&master->mutex);
  1042.  oscil->prepare();
  1043. pthread_mutex_unlock(&master->mutex);
  1044.  
  1045. basefuncdisplaygroup->redraw();
  1046. redrawoscil();} {}
  1047.   }
  1048.   Function {redrawoscil()} {} {
  1049.     code {oscildisplaygroup->redraw();
  1050. oldosc->redraw();
  1051. if (cbwidget!=NULL) cbwidget->do_callback();} {}
  1052.   }
  1053.   decl {OscilGen *oscil;} {}
  1054.   decl {Fl_Widget *oldosc,*cbwidget;} {}
  1055.   decl {Oscilharmonic *h[MAX_AD_HARMONICS];} {}
  1056.   decl {Master *master;} {}
  1057.