commit b6ab241303f1016c90c8da3c34f2c782b82df0a9
parent a55da9b25c8d4f22539ca19bed29493b847cc0ad
Author: paulnasca <paulnasca>
Date: Fri, 12 Mar 2004 22:04:15 +0000
*** empty log message ***
Diffstat:
4 files changed, 158 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -555,7 +555,8 @@
03 Mar 2004 - Terminat (teoretic) partea de XML
05 Mar 2004 - Actualizat Copyright-ul la 2004 in fisiere
08 Mar 2004 - Corectat o mica eroare la OscilGen (se aplica gain-ul rezonantei incorect)
-09 Mar 2004 - Adaugat posibilitatea de stretch la LFO in functie de frecventa notei
+09 Mar 2004 - Adaugata posibilitatea de stretch la LFO in functie de frecventa notei
+12 Mar 2004 - Adaugata modulatie la OscilGen (functia de baza)
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -49,6 +49,7 @@ OscilGen::~OscilGen(){
void OscilGen::defaults(){
oldbasefunc=0;oldbasepar=64;oldhmagtype=0;oldwaveshapingfunction=0;oldwaveshaping=64,oldnormalizemethod=0;
+ oldbasefuncmodulation=0;
for (int i=0;i<MAX_AD_HARMONICS;i++){
hmag[i]=0.0;
hphase[i]=0.0;
@@ -61,6 +62,11 @@ void OscilGen::defaults(){
Pcurrentbasefunc=0;
Pbasefuncpar=64;
+
+ Pbasefuncmodulation=0;
+ Pbasefuncmodulationpar1=64;
+ Pbasefuncmodulationpar2=0;
+
Pwaveshapingfunction=0;
Pwaveshaping=64;
Pnormalizemethod=2;
@@ -194,33 +200,60 @@ void OscilGen::getbasefunction(REALTYPE *smps){
int i;
REALTYPE par=(Pbasefuncpar+0.5)/128.0;
if (Pbasefuncpar==64) par=0.5;
- switch (Pcurrentbasefunc){
- case 1:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_triangle(1.0*i/OSCIL_SIZE,par);
- break;
- case 2:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_pulse(1.0*i/OSCIL_SIZE,par);
- break;
- case 3:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_saw(1.0*i/OSCIL_SIZE,par);
- break;
- case 4:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_power(1.0*i/OSCIL_SIZE,par);
- break;
- case 5:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_gauss(1.0*i/OSCIL_SIZE,par);
- break;
- case 6:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_diode(1.0*i/OSCIL_SIZE,par);
- break;
- case 7:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_abssine(1.0*i/OSCIL_SIZE,par);
- break;
- case 8:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_pulsesine(1.0*i/OSCIL_SIZE,par);
- break;
- case 9:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_stretchsine(1.0*i/OSCIL_SIZE,par);
+
+ REALTYPE basefuncmodulationpar1=Pbasefuncmodulationpar1/127.0,
+ basefuncmodulationpar2=Pbasefuncmodulationpar2/127.0;
+
+ switch(Pbasefuncmodulation){
+ case 1:basefuncmodulationpar1=(pow(2,basefuncmodulationpar1*5.0)-1.0)/10.0;
+ basefuncmodulationpar2=floor((pow(2,basefuncmodulationpar2*5.0)-1.0));
+ if (basefuncmodulationpar2<0.9999) basefuncmodulationpar2=-1.0;
+ break;
+ case 2:basefuncmodulationpar1=(pow(2,basefuncmodulationpar1*5.0)-1.0)/10.0;
+ basefuncmodulationpar2=1.0+floor((pow(2,basefuncmodulationpar2*5.0)-1.0));
+ break;
+ };
+
+ for (i=0;i<OSCIL_SIZE;i++) {
+ REALTYPE t=i*1.0/OSCIL_SIZE;
+
+ switch(Pbasefuncmodulation){
+ case 1:t=t*basefuncmodulationpar2+sin(t*2.0*PI)*basefuncmodulationpar1;//rev
+ break;
+ case 2:t=t+sin(t*2.0*PI*basefuncmodulationpar2)*basefuncmodulationpar1;//sine
+ break;
+ };
+
+ t=t-floor(t);
+
+ switch (Pcurrentbasefunc){
+ case 1:smps[i]=basefunc_triangle(t,par);
+ break;
+ case 2:smps[i]=basefunc_pulse(t,par);
+ break;
+ case 3:smps[i]=basefunc_saw(t,par);
+ break;
+ case 4:smps[i]=basefunc_power(t,par);
+ break;
+ case 5:smps[i]=basefunc_gauss(t,par);
+ break;
+ case 6:smps[i]=basefunc_diode(t,par);
+ break;
+ case 7:smps[i]=basefunc_abssine(t,par);
+ break;
+ case 8:smps[i]=basefunc_pulsesine(t,par);
+ break;
+ case 9:smps[i]=basefunc_stretchsine(t,par);
break;
- case 10:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_chirp(1.0*i/OSCIL_SIZE,par);
+ case 10:smps[i]=basefunc_chirp(t,par);
break;
- case 11:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_absstretchsine(1.0*i/OSCIL_SIZE,par);
+ case 11:smps[i]=basefunc_absstretchsine(t,par);
break;
- case 12:for (i=0;i<OSCIL_SIZE;i++) smps[i]=basefunc_chebyshev(1.0*i/OSCIL_SIZE,par);
+ case 12:smps[i]=basefunc_chebyshev(t,par);
break;
- default:for (i=0;i<OSCIL_SIZE;i++) smps[i]=-sin(2.0*PI*i/OSCIL_SIZE);
+ default:smps[i]=-sin(2.0*PI*i/OSCIL_SIZE);
};
+ };
};
/*
@@ -281,7 +314,8 @@ void OscilGen::changebasefunction(){
if (basefuncFFTfreqs!=NULL) {
delete(basefuncFFTfreqs);
basefuncFFTfreqs=NULL;
- };
+ };
+
if (basefuncFFTfreqs==NULL) basefuncFFTfreqs=new REALTYPE[OSCIL_SIZE];
if (Pcurrentbasefunc!=0) {
// I use basefuncfreq for temporary store of the time-domain data
@@ -296,6 +330,9 @@ void OscilGen::changebasefunction(){
oscilprepared=0;
oldbasefunc=Pcurrentbasefunc;
oldbasepar=Pbasefuncpar;
+ oldbasefuncmodulation=Pbasefuncmodulation;
+ oldbasefuncmodulationpar1=Pbasefuncmodulationpar1;
+ oldbasefuncmodulationpar2=Pbasefuncmodulationpar2;
};
@@ -359,7 +396,6 @@ void OscilGen::spectrumadjust(){
REALTYPE mag=sqrt(pow(oscilFFTfreqs[OSCIL_SIZE-i-1],2)+pow(oscilFFTfreqs[i+1],2.0))/max;
REALTYPE phase=atan2(oscilFFTfreqs[i+1],oscilFFTfreqs[OSCIL_SIZE-i-1]);
-
switch (Psatype){
case 1: mag=pow(mag,par);
break;
@@ -379,8 +415,13 @@ void OscilGen::spectrumadjust(){
void OscilGen::prepare(){
int i,j,k;
REALTYPE a,b,c,d,hmagnew;
+
- if ((oldbasepar!=Pbasefuncpar)||(oldbasefunc!=Pcurrentbasefunc)) changebasefunction();
+ if ((oldbasepar!=Pbasefuncpar)||(oldbasefunc!=Pcurrentbasefunc)||
+ (oldbasefuncmodulation!=Pbasefuncmodulation)||
+ (oldbasefuncmodulationpar1!=Pbasefuncmodulationpar1)||
+ (oldbasefuncmodulationpar2!=Pbasefuncmodulationpar2))
+ changebasefunction();
for (i=0;i<MAX_AD_HARMONICS;i++) hphase[i]=(Phphase[i]-64.0)/64.0*PI/(i+1);
@@ -488,6 +529,12 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
oscilprepared=0;
oldsapars=Psatype*256+Psapar;
};
+
+ if ((oldbasefuncmodulation!=Pbasefuncmodulation)||
+ (oldbasefuncmodulationpar1!=Pbasefuncmodulationpar1)||
+ (oldbasefuncmodulationpar2!=Pbasefuncmodulationpar2))
+ oscilprepared=0;
+
if (oscilprepared!=1) prepare();
@@ -572,6 +619,7 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
};
+// for (i=0;i<OSCIL_SIZE/2;i++) outoscilFFTfreqs[i+OSCIL_SIZE/2]*=-1.0;//correct the amplitude
fft->freqs2smps(outoscilFFTfreqs,smps);
@@ -844,6 +892,9 @@ void OscilGen::add2XML(XMLwrapper *xml){
xml->addpar("base_function",Pcurrentbasefunc);
xml->addpar("base_function_par",Pbasefuncpar);
+ xml->addpar("base_function_modulation",Pbasefuncmodulation);
+ xml->addpar("base_function_modulation_par1",Pbasefuncmodulationpar1);
+ xml->addpar("base_function_modulation_par2",Pbasefuncmodulationpar2);
xml->addpar("wave_shaping",Pwaveshaping);
xml->addpar("wave_shaping_function",Pwaveshapingfunction);
@@ -885,8 +936,6 @@ void OscilGen::add2XML(XMLwrapper *xml){
xml->addparreal("sin",xs);
xml->endbranch();
};
-
-
};
xml->endbranch();
};
@@ -901,6 +950,11 @@ void OscilGen::getfromXML(XMLwrapper *xml){
Pcurrentbasefunc=xml->getpar127("base_function",Pcurrentbasefunc);
Pbasefuncpar=xml->getpar127("base_function_par",Pbasefuncpar);
+ Pbasefuncmodulation=xml->getpar127("base_function_modulation",Pbasefuncmodulation);
+ Pbasefuncmodulationpar1=xml->getpar127("base_function_modulation_par1",Pbasefuncmodulationpar1);
+ Pbasefuncmodulationpar2=xml->getpar127("base_function_modulation_par2",Pbasefuncmodulationpar2);
+
+
Pwaveshaping=xml->getpar127("wave_shaping",Pwaveshaping);
Pwaveshapingfunction=xml->getpar127("wave_shaping_function",Pwaveshapingfunction);
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -74,6 +74,10 @@ class OscilGen{
unsigned char Pcurrentbasefunc;//The base function used - 0=sin, 1=...
unsigned char Pbasefuncpar;//the parameter of the base function
+
+ unsigned char Pbasefuncmodulation;//what modulation is applied to the basefunc
+ unsigned char Pbasefuncmodulationpar1,Pbasefuncmodulationpar2;//the parameter of the base functions
+
/*the Randomness:
64=no randomness
63..0 - block type randomness - 0 is maximum
@@ -85,7 +89,7 @@ class OscilGen{
unsigned char Pfilterbeforews;
unsigned char Psatype,Psapar;//spectrum adjust
- unsigned char Pamprandpower, Pamprandtype;
+ unsigned char Pamprandpower, Pamprandtype;//amplitude randomness
private:
REALTYPE hmag[MAX_AD_HARMONICS],hphase[MAX_AD_HARMONICS];//the magnituides and the phases of the sine/nonsine harmonics
@@ -122,7 +126,7 @@ class OscilGen{
//Internal Data
unsigned char oldbasefunc,oldbasepar,oldhmagtype,oldwaveshapingfunction,oldwaveshaping,oldnormalizemethod;
- int oldfilterpars,oldsapars;
+ int oldfilterpars,oldsapars,oldbasefuncmodulation,oldbasefuncmodulationpar1,oldbasefuncmodulationpar2;
/*
The frequencies of wavefroms are stored like this:
c[0],c[1],....,c[OSCIL_SIZE/2],s[OSCIL_SIZE/2-1],...,s[2],s[1]
diff --git a/src/UI/ADnoteUI.fl b/src/UI/ADnoteUI.fl
@@ -289,7 +289,7 @@ class ADOscilEditor {} {
Function {make_window()} {} {
Fl_Window osceditUI {
label {ADsynth Oscillator Editor}
- xywh {121 91 750 590} type Double hide
+ xywh {138 85 750 590} type Double hide
} {
Fl_Group oscildisplaygroup {
xywh {15 5 360 300} box ENGRAVED_FRAME
@@ -359,13 +359,13 @@ oldosc->redraw();}
code1 {osc->init(oscil,1,master);}
} {}
Fl_Choice {} {
- label {Base Func.}
+ label {Base.F..}
callback {oscil->Pcurrentbasefunc=(int) o->value();
basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
oldosc->redraw();}
- xywh {445 280 90 20} down_box BORDER_BOX labelsize 12 textsize 12
+ xywh {380 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 12
code0 {o->value(oscil->Pcurrentbasefunc);}
} {
menuitem {} {
@@ -431,7 +431,7 @@ oldosc->redraw();}
basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Base Function Parameter} xywh {550 285 175 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
+ tooltip {Base Function Parameter} xywh {475 285 135 15} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
code0 {o->value(oscil->Pbasefuncpar-64);}
}
Fl_Group {} {open
@@ -532,10 +532,10 @@ pthread_mutex_unlock(&master->mutex);
oscildisplaygroup->redraw();
oldosc->redraw();}
- xywh {680 335 50 20} box THIN_UP_BOX labelfont 1 labelsize 12
+ xywh {680 340 50 20} box THIN_UP_BOX labelfont 1 labelsize 12
}
Fl_Group {} {
- xywh {145 305 230 30} box ENGRAVED_BOX
+ xywh {145 305 185 30} box ENGRAVED_BOX
} {
Fl_Choice wshbutton {
label {Wsh.}
@@ -608,7 +608,7 @@ oldosc->redraw();}
//basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Waveshaping Parameter} xywh {230 315 140 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
+ tooltip {Waveshaping Parameter} xywh {230 315 95 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
code0 {o->value(oscil->Pwaveshaping-64);}
}
}
@@ -617,14 +617,14 @@ oldosc->redraw();}
tooltip {Auto clear when using the oscillator as base function} xywh {105 310 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
}
Fl_Group {} {
- xywh {375 305 160 30} box ENGRAVED_BOX
+ xywh {330 305 160 30} box ENGRAVED_BOX
} {
Fl_Choice fltbutton {
label Filter
callback {oscil->Pfiltertype=(int) o->value();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Oscillator's filter type} xywh {405 310 50 20} down_box BORDER_BOX labelsize 10 textsize 10
+ tooltip {Oscillator's filter type} xywh {360 310 50 20} down_box BORDER_BOX labelsize 10 textsize 10
code0 {o->value(oscil->Pfiltertype);}
} {
menuitem {} {
@@ -676,7 +676,7 @@ oldosc->redraw();}
callback {oscil->Pfilterpar=(int)o->value();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Oscillator's filter parameter} xywh {460 310 20 20} maximum 127 step 1
+ tooltip {Oscillator's filter parameter} xywh {415 310 20 20} maximum 127 step 1
code0 {o->value(oscil->Pfilterpar);}
class WidgetPDial
}
@@ -685,7 +685,7 @@ oldosc->redraw();}
callback {oscil->Pfilterbeforews=(int)o->value();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Apply the filter before the waveshaping} xywh {490 310 35 20} down_box DOWN_BOX labelsize 10 align 24
+ tooltip {Apply the filter before the waveshaping} xywh {445 310 35 20} down_box DOWN_BOX labelsize 10 align 24
code0 {o->value(oscil->Pfilterbeforews);}
}
}
@@ -697,43 +697,54 @@ oldosc->redraw();}
code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new ADOscilharmonic(0,0,20,o->h(),"");h[i]->init(oscil,i,oscildisplaygroup,oldosc,master);}}
} {}
}
- Fl_Group {} {
- xywh {535 305 120 30} box ENGRAVED_BOX
+ Fl_Group {} {open
+ xywh {615 278 115 25} box ENGRAVED_BOX
} {
- Fl_Choice sabutton {
- label {Sp.adj.}
- callback {oscil->Psatype=(int) o->value();
+ Fl_Choice {} {
+ label {M.}
+ callback {oscil->Pbasefuncmodulation=(int) o->value();
+basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
oldosc->redraw();} open
- tooltip {Oscillator's spectrum adjust} xywh {575 310 50 20} down_box BORDER_BOX labelsize 10 textsize 10
- code0 {o->value(oscil->Psatype);}
+ tooltip {Oscillator's modulation} xywh {635 283 50 15} down_box BORDER_BOX labelsize 10 textsize 10
+ code0 {o->value(oscil->Pbasefuncmodulation);}
} {
menuitem {} {
label None
xywh {45 45 100 20} labelfont 1 labelsize 10
}
menuitem {} {
- label Pow
+ label Rev
xywh {55 55 100 20} labelfont 1 labelsize 10
}
menuitem {} {
- label Thrs
+ label Sine
xywh {65 65 100 20} labelfont 1 labelsize 10
}
}
Fl_Dial {} {
- callback {oscil->Psapar=(int)o->value();
+ callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
+basefuncdisplaygroup->redraw();
+oscildisplaygroup->redraw();
+oldosc->redraw();} selected
+ tooltip {Oscillator's modulation parameter 1} xywh {690 283 15 15} maximum 127 step 1
+ code0 {o->value(oscil->Pbasefuncmodulationpar1);}
+ class WidgetPDial
+ }
+ Fl_Dial {} {
+ callback {oscil->Pbasefuncmodulationpar2=(int)o->value();
+basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Oscillator's spectrum adjust parameter} xywh {630 310 20 20} maximum 127 step 1
- code0 {o->value(oscil->Psapar);}
+ tooltip {Oscillator's modulation parameter 1} xywh {710 283 15 15} maximum 127 step 1
+ code0 {o->value(oscil->Pbasefuncmodulationpar2);}
class WidgetPDial
}
}
Fl_Choice {} {
label Normalize
- callback {oscil->Pnormalizemethod=(int) o->value();} open selected
- tooltip {Normalize type (harmonic's sum/RMS) of the oscillator} xywh {680 370 60 20} down_box BORDER_BOX labelsize 10 align 5 textsize 10
+ callback {oscil->Pnormalizemethod=(int) o->value();}
+ tooltip {Normalize type (harmonic's sum/RMS) of the oscillator} xywh {680 375 60 20} down_box BORDER_BOX labelsize 10 align 5 textsize 10
code0 {o->value(oscil->Pnormalizemethod);}
} {
menuitem {} {
@@ -749,6 +760,39 @@ oldosc->redraw();}
xywh {85 85 100 20} labelfont 1 labelsize 10
}
}
+ Fl_Group {} {
+ xywh {490 305 120 30} box ENGRAVED_BOX
+ } {
+ Fl_Choice sabutton {
+ label {Sp.adj.}
+ callback {oscil->Psatype=(int) o->value();
+oscildisplaygroup->redraw();
+oldosc->redraw();} open
+ tooltip {Oscillator's spectrum adjust} xywh {530 310 50 20} down_box BORDER_BOX labelsize 10 textsize 10
+ code0 {o->value(oscil->Psatype);}
+ } {
+ menuitem {} {
+ label None
+ xywh {55 55 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label Pow
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label Thrs
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial {} {
+ callback {oscil->Psapar=(int)o->value();
+oscildisplaygroup->redraw();
+oldosc->redraw();}
+ tooltip {Oscillator's spectrum adjust parameter} xywh {585 310 20 20} maximum 127 step 1
+ code0 {o->value(oscil->Psapar);}
+ class WidgetPDial
+ }
+ }
}
}
Function {ADOscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Master *master_)} {} {