~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/zynaddsubfx/src/UI/FilterUI.cc

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
FormantFilterGraph::FormantFilterGraph(int x,int y, int w, int h, const char *label):Fl_Box(x,y,w,h,label) {
8
8
  pars=NULL;
9
 
nvowel=NULL;
10
 
nformant=NULL;
11
 
graphpoints=NULL;
 
9
  nvowel=NULL;
 
10
  nformant=NULL;
 
11
  graphpoints=NULL;
12
12
}
13
13
 
14
14
void FormantFilterGraph::init(FilterParams *pars_,int *nvowel_,int *nformant_) {
15
15
  pars=pars_;
16
 
nvowel=nvowel_;
17
 
nformant=nformant_;
18
 
oldx=-1;
19
 
graphpoints=new REALTYPE [w()];
 
16
  nvowel=nvowel_;
 
17
  nformant=nformant_;
 
18
  oldx=-1;
 
19
  graphpoints=new REALTYPE [w()];
20
20
}
21
21
 
22
22
void FormantFilterGraph::draw_freq_line(REALTYPE freq,int type) {
23
23
  REALTYPE freqx=pars->getfreqpos(freq);
24
 
switch(type){
25
 
  case 0:fl_line_style(FL_SOLID);break;
26
 
  case 1:fl_line_style(FL_DOT);break;
27
 
  case 2:fl_line_style(FL_DASH);break;
28
 
}; 
29
 
 
30
 
 
31
 
if ((freqx>0.0)&&(freqx<1.0))
32
 
   fl_line(x()+(int) (freqx*w()),y(),
33
 
   x()+(int) (freqx*w()),y()+h());
 
24
  switch(type){
 
25
    case 0:fl_line_style(FL_SOLID);break;
 
26
    case 1:fl_line_style(FL_DOT);break;
 
27
    case 2:fl_line_style(FL_DASH);break;
 
28
  }; 
 
29
  
 
30
  
 
31
  if ((freqx>0.0)&&(freqx<1.0))
 
32
     fl_line(x()+(int) (freqx*w()),y(),
 
33
     x()+(int) (freqx*w()),y()+h());
34
34
}
35
35
 
36
36
void FormantFilterGraph::draw() {
37
37
  int maxdB=30;
38
 
int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
39
 
REALTYPE freqx;
40
 
 
41
 
fl_color(FL_BLACK);
42
 
fl_rectf(ox,oy,lx,ly);
43
 
 
44
 
 
45
 
//draw the lines
46
 
fl_color(FL_GRAY);
47
 
 
48
 
fl_line_style(FL_SOLID);
49
 
//fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
50
 
 
51
 
freqx=pars->getfreqpos(1000.0);
52
 
if ((freqx>0.0)&&(freqx<1.0))
53
 
   fl_line(ox+(int) (freqx*lx),oy,
54
 
    ox+(int) (freqx*lx),oy+ly);
55
 
 
56
 
for (i=1;i<10;i++){
57
 
   if(i==1){
58
 
     draw_freq_line(i*100.0,0);
59
 
     draw_freq_line(i*1000.0,0);
60
 
   }else 
61
 
    if (i==5){
62
 
      draw_freq_line(i*100.0,2);
63
 
      draw_freq_line(i*1000.0,2);
64
 
    }else{
65
 
      draw_freq_line(i*100.0,1);
66
 
      draw_freq_line(i*1000.0,1);
67
 
    };
68
 
};
69
 
 
70
 
draw_freq_line(10000.0,0);
71
 
draw_freq_line(20000.0,1);
72
 
 
73
 
fl_line_style(FL_DOT);
74
 
int GY=10;if (ly<GY*3) GY=-1;
75
 
for (i=1;i<GY;i++){
76
 
   int tmp=(int)(ly/(REALTYPE)GY*i);
77
 
   fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
78
 
};
79
 
 
80
 
fl_color(FL_YELLOW);
81
 
fl_font(FL_HELVETICA,10);
82
 
if (*nformant<pars->Pnumformants){
83
 
   draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);
84
 
 
85
 
//show some information (like current formant frequency,amplitude)
86
 
   char tmpstr[20];
87
 
 
88
 
   snprintf(tmpstr,20,"%.2f kHz",pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq)*0.001);
89
 
   fl_draw(tmpstr,ox+1,oy+1,40,12,FL_ALIGN_LEFT,NULL,0);
90
 
 
91
 
   snprintf(tmpstr,20,"%d dB",(int)( rap2dB(1e-9 + pars->getformantamp(pars->Pvowels[*nvowel].formants[*nformant].amp)) + pars->getgain() ));
92
 
   fl_draw(tmpstr,ox+1,oy+15,40,12,FL_ALIGN_LEFT,NULL,0);
93
 
 
94
 
};
95
 
 
96
 
//draw the data
97
 
 
98
 
fl_color(FL_RED);
99
 
fl_line_style(FL_SOLID);
100
 
 
101
 
pars->formantfilterH(*nvowel,lx,graphpoints);
102
 
 
103
 
oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
104
 
for (i=1;i<lx;i++){
105
 
   int iy=(int) ((graphpoints[i]/maxdB+1.0)*ly/2.0);
106
 
   if ((iy>=0)&&(oiy>=0)&&(iy<ly)&&(oiy<lx))
107
 
      fl_line(ox+i-1,oy+ly-oiy,ox+i,oy+ly-iy);
108
 
   oiy=iy;
109
 
};
 
38
  int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
 
39
  REALTYPE freqx;
 
40
  
 
41
  fl_color(FL_BLACK);
 
42
  fl_rectf(ox,oy,lx,ly);
 
43
  
 
44
  
 
45
  //draw the lines
 
46
  fl_color(FL_GRAY);
 
47
  
 
48
  fl_line_style(FL_SOLID);
 
49
  //fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
 
50
  
 
51
  freqx=pars->getfreqpos(1000.0);
 
52
  if ((freqx>0.0)&&(freqx<1.0))
 
53
     fl_line(ox+(int) (freqx*lx),oy,
 
54
      ox+(int) (freqx*lx),oy+ly);
 
55
  
 
56
  for (i=1;i<10;i++){
 
57
     if(i==1){
 
58
       draw_freq_line(i*100.0,0);
 
59
       draw_freq_line(i*1000.0,0);
 
60
     }else 
 
61
      if (i==5){
 
62
        draw_freq_line(i*100.0,2);
 
63
        draw_freq_line(i*1000.0,2);
 
64
      }else{
 
65
        draw_freq_line(i*100.0,1);
 
66
        draw_freq_line(i*1000.0,1);
 
67
      };
 
68
  };
 
69
  
 
70
  draw_freq_line(10000.0,0);
 
71
  draw_freq_line(20000.0,1);
 
72
  
 
73
  fl_line_style(FL_DOT);
 
74
  int GY=10;if (ly<GY*3) GY=-1;
 
75
  for (i=1;i<GY;i++){
 
76
     int tmp=(int)(ly/(REALTYPE)GY*i);
 
77
     fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
 
78
  };
 
79
  
 
80
  fl_color(FL_YELLOW);
 
81
  fl_font(FL_HELVETICA,10);
 
82
  if (*nformant<pars->Pnumformants){
 
83
     draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);
 
84
  
 
85
  //show some information (like current formant frequency,amplitude)
 
86
     char tmpstr[20];
 
87
  
 
88
     snprintf(tmpstr,20,"%.2f kHz",pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq)*0.001);
 
89
     fl_draw(tmpstr,ox+1,oy+1,40,12,FL_ALIGN_LEFT,NULL,0);
 
90
  
 
91
     snprintf(tmpstr,20,"%d dB",(int)( rap2dB(1e-9 + pars->getformantamp(pars->Pvowels[*nvowel].formants[*nformant].amp)) + pars->getgain() ));
 
92
     fl_draw(tmpstr,ox+1,oy+15,40,12,FL_ALIGN_LEFT,NULL,0);
 
93
  
 
94
  };
 
95
  
 
96
  //draw the data
 
97
  
 
98
  fl_color(FL_RED);
 
99
  fl_line_style(FL_SOLID);
 
100
  
 
101
  pars->formantfilterH(*nvowel,lx,graphpoints);
 
102
  
 
103
  oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
 
104
  for (i=1;i<lx;i++){
 
105
     int iy=(int) ((graphpoints[i]/maxdB+1.0)*ly/2.0);
 
106
     if ((iy>=0)&&(oiy>=0)&&(iy<ly)&&(oiy<lx))
 
107
        fl_line(ox+i-1,oy+ly-oiy,ox+i,oy+ly-iy);
 
108
     oiy=iy;
 
109
  };
110
110
}
111
111
 
112
112
FormantFilterGraph::~FormantFilterGraph() {
409
409
 
410
410
FilterUI::FilterUI(int x,int y, int w, int h, const char *label):Fl_Group(x,y,w,h,label) {
411
411
  pars=NULL;
412
 
velsnsamp=NULL;
413
 
velsns=NULL;
414
 
nvowel=0;nformant=0;nseqpos=0;
 
412
  velsnsamp=NULL;
 
413
  velsns=NULL;
 
414
  nvowel=0;nformant=0;nseqpos=0;
415
415
}
416
416
 
417
417
FilterUI::~FilterUI() {
418
418
  filterui->hide();
419
 
formantparswindow->hide();
420
 
hide();
421
 
//delete (filterui);
422
 
delete (formantparswindow);
 
419
  formantparswindow->hide();
 
420
  hide();
 
421
  //delete (filterui);
 
422
  delete (formantparswindow);
423
423
}
424
424
 
425
425
Fl_Group* FilterUI::make_window() {
875
875
 
876
876
void FilterUI::update_formant_window() {
877
877
  formant_freq_dial->value(pars->Pvowels[nvowel].formants[nformant].freq);
878
 
formant_q_dial->value(pars->Pvowels[nvowel].formants[nformant].q);
879
 
formant_amp_dial->value(pars->Pvowels[nvowel].formants[nformant].amp);
880
 
if (nformant<pars->Pnumformants) formantparsgroup->activate();
881
 
        else formantparsgroup->deactivate();
882
 
 
883
 
if (nseqpos<pars->Psequencesize) vowel_counter->activate();
884
 
        else vowel_counter->deactivate();
885
 
 
886
 
 
887
 
vowel_counter->value(pars->Psequence[nseqpos].nvowel);
 
878
  formant_q_dial->value(pars->Pvowels[nvowel].formants[nformant].q);
 
879
  formant_amp_dial->value(pars->Pvowels[nvowel].formants[nformant].amp);
 
880
  if (nformant<pars->Pnumformants) formantparsgroup->activate();
 
881
        else formantparsgroup->deactivate();
 
882
  
 
883
  if (nseqpos<pars->Psequencesize) vowel_counter->activate();
 
884
        else vowel_counter->deactivate();
 
885
  
 
886
  
 
887
  vowel_counter->value(pars->Psequence[nseqpos].nvowel);
888
888
}
889
889
 
890
890
void FilterUI::refresh() {
891
891
  update_formant_window();
892
 
formantfiltergraph->redraw();
893
 
 
894
 
if (pars->Pcategory==0) svfiltertypechoice->value(pars->Ptype);
895
 
if (pars->Pcategory==2) analogfiltertypechoice->value(pars->Ptype);
896
 
 
897
 
filtertype->value(pars->Pcategory);
898
 
 
899
 
cfreqdial->value(pars->Pfreq);
900
 
qdial->value(pars->Pq);
901
 
 
902
 
freqtrdial->value(pars->Pfreqtrack);
903
 
gaindial->value(pars->Pgain);
904
 
 
905
 
stcounter->value(pars->Pstages);
906
 
 
907
 
int categ=pars->Pcategory;
908
 
if ((categ==0)||(categ==2)) {
909
 
        if (categ==0) {
910
 
           analogfiltertypechoice->show();
911
 
           svfiltertypechoice->hide();
912
 
        } else {
913
 
           svfiltertypechoice->show();
914
 
           analogfiltertypechoice->hide();
915
 
        };
916
 
        editbutton->hide();
917
 
        formantparswindow->hide();
918
 
        cfreqdial->label("C.freq");
919
 
} else {
920
 
        analogfiltertypechoice->hide();
921
 
        svfiltertypechoice->hide();
922
 
        editbutton->show();
923
 
        cfreqdial->label("BS.pos");
924
 
};
925
 
 
926
 
filterparamswindow->redraw();
 
892
  formantfiltergraph->redraw();
 
893
  
 
894
  if (pars->Pcategory==0) svfiltertypechoice->value(pars->Ptype);
 
895
  if (pars->Pcategory==2) analogfiltertypechoice->value(pars->Ptype);
 
896
  
 
897
  filtertype->value(pars->Pcategory);
 
898
  
 
899
  cfreqdial->value(pars->Pfreq);
 
900
  qdial->value(pars->Pq);
 
901
  
 
902
  freqtrdial->value(pars->Pfreqtrack);
 
903
  gaindial->value(pars->Pgain);
 
904
  
 
905
  stcounter->value(pars->Pstages);
 
906
  
 
907
  int categ=pars->Pcategory;
 
908
  if ((categ==0)||(categ==2)) {
 
909
        if (categ==0) {
 
910
             analogfiltertypechoice->show();
 
911
             svfiltertypechoice->hide();
 
912
          } else {
 
913
             svfiltertypechoice->show();
 
914
             analogfiltertypechoice->hide();
 
915
          };
 
916
        editbutton->hide();
 
917
          formantparswindow->hide();
 
918
          cfreqdial->label("C.freq");
 
919
  } else {
 
920
        analogfiltertypechoice->hide();
 
921
        svfiltertypechoice->hide();
 
922
        editbutton->show();
 
923
          cfreqdial->label("BS.pos");
 
924
  };
 
925
  
 
926
  filterparamswindow->redraw();
927
927
}
928
928
 
929
929
void FilterUI::init(FilterParams *filterpars_,unsigned char *velsnsamp_,unsigned char *velsns_) {
930
930
  pars=filterpars_;
931
 
velsnsamp=velsnsamp_;
932
 
velsns=velsns_;
933
 
 
934
 
make_window();
935
 
end();
936
 
make_formant_window();
937
 
 
938
 
 
939
 
filterui->resize(this->x(),this->y(),this->w(),this->h());
940
 
 
941
 
 
942
 
if (velsnsamp==NULL){
943
 
        vsnsadial->deactivate();
944
 
        vsnsadial->value(127);
945
 
   } else vsnsadial->value(*velsnsamp);
946
 
 
947
 
if (velsns==NULL){
948
 
        vsnsdial->deactivate();
949
 
        vsnsdial->value(127);
950
 
   } else vsnsdial->value(*velsns);
951
 
 
952
 
switchcategory(pars->Pcategory);
953
 
 
954
 
 
955
 
formantparswindow->label(this->label());
956
 
 
957
 
update_formant_window();
 
931
  velsnsamp=velsnsamp_;
 
932
  velsns=velsns_;
 
933
  
 
934
  make_window();
 
935
  end();
 
936
  make_formant_window();
 
937
  
 
938
  
 
939
  filterui->resize(this->x(),this->y(),this->w(),this->h());
 
940
  
 
941
  
 
942
  if (velsnsamp==NULL){
 
943
        vsnsadial->deactivate();
 
944
        vsnsadial->value(127);
 
945
     } else vsnsadial->value(*velsnsamp);
 
946
  
 
947
  if (velsns==NULL){
 
948
        vsnsdial->deactivate();
 
949
        vsnsdial->value(127);
 
950
     } else vsnsdial->value(*velsns);
 
951
  
 
952
  switchcategory(pars->Pcategory);
 
953
  
 
954
  
 
955
  formantparswindow->label(this->label());
 
956
  
 
957
  update_formant_window();
958
958
}
959
959
 
960
960
void FilterUI::switchcategory(int newcat) {
961
961
  if (pars->Pcategory!=newcat){
962
 
    pars->Pgain=64;
963
 
    gaindial->value(64);
964
 
    analogfiltertypechoice->value(0);
965
 
    analogfiltertypechoice->do_callback();
966
 
    svfiltertypechoice->value(0);
967
 
    svfiltertypechoice->do_callback();
968
 
};
969
 
pars->Pcategory=newcat;
970
 
 
971
 
refresh();
 
962
      pars->Pgain=64;
 
963
      gaindial->value(64);
 
964
      analogfiltertypechoice->value(0);
 
965
      analogfiltertypechoice->do_callback();
 
966
      svfiltertypechoice->value(0);
 
967
      svfiltertypechoice->do_callback();
 
968
  };
 
969
  pars->Pcategory=newcat;
 
970
  
 
971
  refresh();
972
972
}
973
973
 
974
974
void FilterUI::use_for_dynamic_filter() {
975
975
  freqtrdial->deactivate();
976
 
gaindial->when(0);
977
 
 
978
 
cfknob->when(FL_WHEN_RELEASE);
979
 
octknob->when(FL_WHEN_RELEASE);
980
 
 
981
 
frsldial->when(0);
982
 
wvknob->when(0);
983
 
formant_freq_dial->when(0);
984
 
formant_q_dial->when(0);
985
 
formant_amp_dial->when(0);
986
 
strchdial->when(0);
 
976
  gaindial->when(0);
 
977
  
 
978
  cfknob->when(FL_WHEN_RELEASE);
 
979
  octknob->when(FL_WHEN_RELEASE);
 
980
  
 
981
  frsldial->when(0);
 
982
  wvknob->when(0);
 
983
  formant_freq_dial->when(0);
 
984
  formant_q_dial->when(0);
 
985
  formant_amp_dial->when(0);
 
986
  strchdial->when(0);
987
987
}