commit 63788eefb32af8b58d62ff4cc5f6b92b7be3bec3
parent db8a029cf8ef00bf2de234272d43e22820235ffd
Author: paulnasca <paulnasca>
Date: Mon, 29 Nov 2004 21:33:28 +0000
*** empty log message ***
Diffstat:
4 files changed, 92 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -739,5 +739,5 @@
- Sortarea nu mai este quicksort la bank si la presets pt. ca am vazut ca nu merge in windows intotdeauna
- Corectata o eroare la egalizator care facea ca sa se aplice si la el par. D/W
29 Nov 2004 - Marita zona de valori la adaptive harmonics power din OscilGen
-
+ - Adaugata posibilitate de a post-procesa la adaptive harmonics(adica a adauga sau a amplifica anumite armonice)
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -98,6 +98,7 @@ void OscilGen::defaults(){
Padaptiveharmonics=0;
Padaptiveharmonicspower=100;
Padaptiveharmonicsbasefreq=128;
+ Padaptiveharmonicspar=50;
for (int i=0;i<OSCIL_SIZE/2;i++) {
oscilFFTfreqs.s[i]=0.0;
@@ -725,6 +726,7 @@ void OscilGen::adaptiveharmonic(FFTFREQS f,REALTYPE freq){
f.s[i]=0.0;
f.c[i]=0.0;
};
+ inf.c[0]=0.0;inf.s[0]=0.0;
REALTYPE hc=0.0,hs=0.0;
REALTYPE basefreq=30.0*pow(10.0,Padaptiveharmonicsbasefreq/128.0);
@@ -771,12 +773,44 @@ void OscilGen::adaptiveharmonic(FFTFREQS f,REALTYPE freq){
};
};
-
f.c[1]+=f.c[0];f.s[1]+=f.s[0];
f.c[0]=0.0;f.s[0]=0.0;
deleteFFTFREQS(&inf);
};
+void OscilGen::adaptiveharmonicpostprocess(REALTYPE *f,int size){
+ if (Padaptiveharmonics<=1) return;
+ REALTYPE *inf=new REALTYPE[size];
+ REALTYPE par=Padaptiveharmonicspar*0.01;
+ par=1.0-pow((1.0-par),1.5);
+
+ for (int i=0;i<size;i++) {
+ inf[i]=f[i]*par;
+ f[i]=f[i]*(1.0-par);
+ };
+
+
+ if (Padaptiveharmonics==2){//2n+1
+ for (int i=0;i<size;i++) if ((i%2)==0) f[i]+=inf[i];//i=0 pt prima armonica,etc.
+ } else{//celelalte moduri
+ int nh=(Padaptiveharmonics-3)/2+2;
+ int sub_vs_add=(Padaptiveharmonics-3)%2;
+ if (sub_vs_add==0){
+ for (int i=0;i<size;i++) {
+ if (((i+1)%nh)==0){
+ f[i]+=inf[i];
+ };
+ };
+ } else {
+ for (int i=0;i<size/nh-1;i++) {
+ f[(i+1)*nh-1]+=inf[i];
+ };
+ };
+ };
+
+ delete(inf);
+};
+
/*
@@ -847,6 +881,8 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
};
adaptiveharmonic(outoscilFFTfreqs,freqHz);
+ adaptiveharmonicpostprocess(&outoscilFFTfreqs.c[1],OSCIL_SIZE/2-1);
+ adaptiveharmonicpostprocess(&outoscilFFTfreqs.s[1],OSCIL_SIZE/2-1);
nyquist=realnyquist;
if (Padaptiveharmonics){//do the antialiasing in the case of adaptive harmonics
@@ -900,7 +936,6 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
srand(realrnd+1);
};
-
if ((freqHz>0.1)&&(resonance!=0)) res->applyres(nyquist-1,outoscilFFTfreqs,freqHz);
//Full RMS normalize
@@ -946,7 +981,8 @@ void OscilGen::getspectrum(int n, REALTYPE *spc,int what){
basefuncFFTfreqs.s[i]*basefuncFFTfreqs.s[i]);
};
};
-}
+ if (what==0) adaptiveharmonicpostprocess(spc,n-1);
+};
/*
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -92,9 +92,10 @@ class OscilGen:public Presets{
int Pharmonicshift;//how the harmonics are shifted
int Pharmonicshiftfirst;//if the harmonic shift is done before waveshaping and filter
- unsigned char Padaptiveharmonics;//the adaptive harmonics status (off=0,on=1)
+ unsigned char Padaptiveharmonics;//the adaptive harmonics status (off=0,on=1,etc..)
unsigned char Padaptiveharmonicsbasefreq;//the base frequency of the adaptive harmonic (30..3000Hz)
unsigned char Padaptiveharmonicspower;//the strength of the effect (0=off,100=full)
+ unsigned char Padaptiveharmonicspar;//the parameters in 2,3,4.. modes of adaptive harmonics
unsigned char Pmodulation;//what modulation is applied to the oscil
unsigned char Pmodulationpar1,Pmodulationpar2,Pmodulationpar3;//the parameter of the parameters
@@ -134,6 +135,11 @@ class OscilGen:public Presets{
//Do the adaptive harmonic stuff
void adaptiveharmonic(FFTFREQS f,REALTYPE freq);
+ //Do the adaptive harmonic postprocessing (2n+1,2xS,2xA,etc..)
+ //this function is called even for the user interface
+ //this can be called for the sine and components, and for the spectrum
+ //(that's why the sine and cosine components should be processed with a separate call)
+ void adaptiveharmonicpostprocess(REALTYPE *f, int size);
//Basic/base functions (Functiile De Baza)
REALTYPE basefunc_pulse(REALTYPE x,REALTYPE a);
diff --git a/src/UI/OscilGenUI.fl b/src/UI/OscilGenUI.fl
@@ -646,7 +646,7 @@ pthread_mutex_lock(&master->mutex);
pthread_mutex_unlock(&master->mutex);
redrawoscil();}
- xywh {680 500 55 20} box THIN_UP_BOX labelfont 1 labelsize 12
+ xywh {680 505 55 15} box THIN_UP_BOX labelfont 1 labelsize 12
}
Fl_Group {} {
xywh {145 308 150 30} box ENGRAVED_BOX
@@ -887,41 +887,71 @@ redrawoscil();}
xywh {680 385 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
}
}
- Fl_Group {} {
- xywh {675 405 65 90} box ENGRAVED_FRAME
+ Fl_Group {} {open
+ xywh {675 410 65 90} box ENGRAVED_FRAME
} {
- Fl_Box {} {
- label {Adaptive Harmonics}
- xywh {678 410 60 25} labelsize 10 align 144
- }
Fl_Choice adhrtype {
+ label {Adpt.Harm.}
callback {oscil->Padaptiveharmonics=(int) o->value();
redrawoscil();} open
- tooltip {The type of the addaptive harmonics} xywh {680 435 55 15} down_box BORDER_BOX labelsize 10 when 6 textsize 10
+ tooltip {The type of the addaptive harmonics} xywh {680 425 55 15} down_box BORDER_BOX labelsize 10 align 129 when 6 textsize 10
} {
menuitem {} {
- label OFF
+ label OFF selected
xywh {80 80 100 20} labelfont 1 labelsize 10
}
menuitem {} {
- label On
+ label ON
xywh {90 90 100 20} labelfont 1 labelsize 10
}
+ menuitem {} {
+ label {2n+1}
+ xywh {100 100 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 2xSub
+ xywh {110 110 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 2xAdd
+ xywh {120 120 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 3xSub
+ xywh {120 120 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 3xAdd
+ xywh {130 130 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 4xSub
+ xywh {130 130 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label 4xAdd
+ xywh {140 140 100 20} labelfont 1 labelsize 10
+ }
}
Fl_Dial adhrpow {
label pow
callback {oscil->Padaptiveharmonicspower=(int)o->value();
-redrawoscil();} selected
- tooltip {Adaptive harmonics power} xywh {710 455 25 25} labelsize 10 maximum 200 step 1
+redrawoscil();}
+ tooltip {Adaptive harmonics power} xywh {710 460 25 25} labelsize 10 maximum 200 step 1
class WidgetPDial
}
Fl_Dial adhrbf {
label baseF
callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();
redrawoscil();}
- tooltip {Adaptive harmonics base frequency} xywh {680 455 25 25} labelsize 10 maximum 255 step 1
+ tooltip {Adaptive harmonics base frequency} xywh {680 460 25 25} labelsize 10 maximum 255 step 1
class WidgetPDial
}
+ Fl_Slider adhrpar {
+ callback {oscil->Padaptiveharmonicspar=(int)o->value();
+redrawoscil();}
+ xywh {680 445 55 10} type {Horz Knob} box FLAT_BOX maximum 100 step 1 value 50
+ }
}
Fl_Group {} {
xywh {450 308 150 30} box ENGRAVED_BOX
@@ -981,7 +1011,7 @@ pthread_mutex_unlock(&master->mutex);
redrawoscil();
refresh();}
- xywh {680 520 55 20} box THIN_UP_BOX labelfont 1 labelsize 12
+ xywh {680 525 55 15} box THIN_UP_BOX labelfont 1 labelsize 12
}
Fl_Button {} {
label C
@@ -1050,6 +1080,7 @@ harmonicshiftpre->value(oscil->Pharmonicshiftfirst);
adhrtype->value(oscil->Padaptiveharmonics);
adhrbf->value(oscil->Padaptiveharmonicsbasefreq);
adhrpow->value(oscil->Padaptiveharmonicspower);
+adhrtype->value(oscil->Padaptiveharmonicspar);
for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();