7
7
FormantFilterGraph::FormantFilterGraph(int x,int y, int w, int h, const char *label):Fl_Box(x,y,w,h,label) {
14
14
void FormantFilterGraph::init(FilterParams *pars_,int *nvowel_,int *nformant_) {
19
graphpoints=new REALTYPE [w()];
19
graphpoints=new REALTYPE [w()];
22
22
void FormantFilterGraph::draw_freq_line(REALTYPE freq,int type) {
23
23
REALTYPE freqx=pars->getfreqpos(freq);
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;
31
if ((freqx>0.0)&&(freqx<1.0))
32
fl_line(x()+(int) (freqx*w()),y(),
33
x()+(int) (freqx*w()),y()+h());
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;
31
if ((freqx>0.0)&&(freqx<1.0))
32
fl_line(x()+(int) (freqx*w()),y(),
33
x()+(int) (freqx*w()),y()+h());
36
36
void FormantFilterGraph::draw() {
38
int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
42
fl_rectf(ox,oy,lx,ly);
48
fl_line_style(FL_SOLID);
49
//fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
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);
58
draw_freq_line(i*100.0,0);
59
draw_freq_line(i*1000.0,0);
62
draw_freq_line(i*100.0,2);
63
draw_freq_line(i*1000.0,2);
65
draw_freq_line(i*100.0,1);
66
draw_freq_line(i*1000.0,1);
70
draw_freq_line(10000.0,0);
71
draw_freq_line(20000.0,1);
73
fl_line_style(FL_DOT);
74
int GY=10;if (ly<GY*3) GY=-1;
76
int tmp=(int)(ly/(REALTYPE)GY*i);
77
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
81
fl_font(FL_HELVETICA,10);
82
if (*nformant<pars->Pnumformants){
83
draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);
85
//show some information (like current formant frequency,amplitude)
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);
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);
99
fl_line_style(FL_SOLID);
101
pars->formantfilterH(*nvowel,lx,graphpoints);
103
oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
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);
38
int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
42
fl_rectf(ox,oy,lx,ly);
48
fl_line_style(FL_SOLID);
49
//fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
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);
58
draw_freq_line(i*100.0,0);
59
draw_freq_line(i*1000.0,0);
62
draw_freq_line(i*100.0,2);
63
draw_freq_line(i*1000.0,2);
65
draw_freq_line(i*100.0,1);
66
draw_freq_line(i*1000.0,1);
70
draw_freq_line(10000.0,0);
71
draw_freq_line(20000.0,1);
73
fl_line_style(FL_DOT);
74
int GY=10;if (ly<GY*3) GY=-1;
76
int tmp=(int)(ly/(REALTYPE)GY*i);
77
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
81
fl_font(FL_HELVETICA,10);
82
if (*nformant<pars->Pnumformants){
83
draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);
85
//show some information (like current formant frequency,amplitude)
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);
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);
99
fl_line_style(FL_SOLID);
101
pars->formantfilterH(*nvowel,lx,graphpoints);
103
oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
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);
112
112
FormantFilterGraph::~FormantFilterGraph() {
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();
883
if (nseqpos<pars->Psequencesize) vowel_counter->activate();
884
else vowel_counter->deactivate();
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();
883
if (nseqpos<pars->Psequencesize) vowel_counter->activate();
884
else vowel_counter->deactivate();
887
vowel_counter->value(pars->Psequence[nseqpos].nvowel);
890
890
void FilterUI::refresh() {
891
891
update_formant_window();
892
formantfiltergraph->redraw();
894
if (pars->Pcategory==0) svfiltertypechoice->value(pars->Ptype);
895
if (pars->Pcategory==2) analogfiltertypechoice->value(pars->Ptype);
897
filtertype->value(pars->Pcategory);
899
cfreqdial->value(pars->Pfreq);
900
qdial->value(pars->Pq);
902
freqtrdial->value(pars->Pfreqtrack);
903
gaindial->value(pars->Pgain);
905
stcounter->value(pars->Pstages);
907
int categ=pars->Pcategory;
908
if ((categ==0)||(categ==2)) {
910
analogfiltertypechoice->show();
911
svfiltertypechoice->hide();
913
svfiltertypechoice->show();
914
analogfiltertypechoice->hide();
917
formantparswindow->hide();
918
cfreqdial->label("C.freq");
920
analogfiltertypechoice->hide();
921
svfiltertypechoice->hide();
923
cfreqdial->label("BS.pos");
926
filterparamswindow->redraw();
892
formantfiltergraph->redraw();
894
if (pars->Pcategory==0) svfiltertypechoice->value(pars->Ptype);
895
if (pars->Pcategory==2) analogfiltertypechoice->value(pars->Ptype);
897
filtertype->value(pars->Pcategory);
899
cfreqdial->value(pars->Pfreq);
900
qdial->value(pars->Pq);
902
freqtrdial->value(pars->Pfreqtrack);
903
gaindial->value(pars->Pgain);
905
stcounter->value(pars->Pstages);
907
int categ=pars->Pcategory;
908
if ((categ==0)||(categ==2)) {
910
analogfiltertypechoice->show();
911
svfiltertypechoice->hide();
913
svfiltertypechoice->show();
914
analogfiltertypechoice->hide();
917
formantparswindow->hide();
918
cfreqdial->label("C.freq");
920
analogfiltertypechoice->hide();
921
svfiltertypechoice->hide();
923
cfreqdial->label("BS.pos");
926
filterparamswindow->redraw();
929
929
void FilterUI::init(FilterParams *filterpars_,unsigned char *velsnsamp_,unsigned char *velsns_) {
930
930
pars=filterpars_;
931
velsnsamp=velsnsamp_;
936
make_formant_window();
939
filterui->resize(this->x(),this->y(),this->w(),this->h());
942
if (velsnsamp==NULL){
943
vsnsadial->deactivate();
944
vsnsadial->value(127);
945
} else vsnsadial->value(*velsnsamp);
948
vsnsdial->deactivate();
949
vsnsdial->value(127);
950
} else vsnsdial->value(*velsns);
952
switchcategory(pars->Pcategory);
955
formantparswindow->label(this->label());
957
update_formant_window();
931
velsnsamp=velsnsamp_;
936
make_formant_window();
939
filterui->resize(this->x(),this->y(),this->w(),this->h());
942
if (velsnsamp==NULL){
943
vsnsadial->deactivate();
944
vsnsadial->value(127);
945
} else vsnsadial->value(*velsnsamp);
948
vsnsdial->deactivate();
949
vsnsdial->value(127);
950
} else vsnsdial->value(*velsns);
952
switchcategory(pars->Pcategory);
955
formantparswindow->label(this->label());
957
update_formant_window();
960
960
void FilterUI::switchcategory(int newcat) {
961
961
if (pars->Pcategory!=newcat){
964
analogfiltertypechoice->value(0);
965
analogfiltertypechoice->do_callback();
966
svfiltertypechoice->value(0);
967
svfiltertypechoice->do_callback();
969
pars->Pcategory=newcat;
964
analogfiltertypechoice->value(0);
965
analogfiltertypechoice->do_callback();
966
svfiltertypechoice->value(0);
967
svfiltertypechoice->do_callback();
969
pars->Pcategory=newcat;
974
974
void FilterUI::use_for_dynamic_filter() {
975
975
freqtrdial->deactivate();
978
cfknob->when(FL_WHEN_RELEASE);
979
octknob->when(FL_WHEN_RELEASE);
983
formant_freq_dial->when(0);
984
formant_q_dial->when(0);
985
formant_amp_dial->when(0);
978
cfknob->when(FL_WHEN_RELEASE);
979
octknob->when(FL_WHEN_RELEASE);
983
formant_freq_dial->when(0);
984
formant_q_dial->when(0);
985
formant_amp_dial->when(0);