commit 80d823bce167fb2d09a77a419884e7f0c9fbf908
parent b6ab241303f1016c90c8da3c34f2c782b82df0a9
Author: paulnasca <paulnasca>
Date: Sat, 13 Mar 2004 10:24:39 +0000
*** empty log message ***
Diffstat:
4 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -557,6 +557,7 @@
08 Mar 2004 - Corectat o mica eroare la OscilGen (se aplica gain-ul rezonantei incorect)
09 Mar 2004 - Adaugata posibilitatea de stretch la LFO in functie de frecventa notei
12 Mar 2004 - Adaugata modulatie la OscilGen (functia de baza)
+13 Mar 2004 - Adaugat HarmonicShift la oscilgen
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -49,7 +49,7 @@ OscilGen::~OscilGen(){
void OscilGen::defaults(){
oldbasefunc=0;oldbasepar=64;oldhmagtype=0;oldwaveshapingfunction=0;oldwaveshaping=64,oldnormalizemethod=0;
- oldbasefuncmodulation=0;
+ oldbasefuncmodulation=0;oldharmonicshift=0;
for (int i=0;i<MAX_AD_HARMONICS;i++){
hmag[i]=0.0;
hphase[i]=0.0;
@@ -79,6 +79,9 @@ void OscilGen::defaults(){
Pamprandpower=64;
Pamprandtype=0;
+ Pharmonicshift=0;
+ Pharmonicshiftfirst=0;
+
if (basefuncFFTfreqsQ!=NULL) {
delete(basefuncFFTfreqsQ);
basefuncFFTfreqsQ=NULL;
@@ -408,6 +411,45 @@ void OscilGen::spectrumadjust(){
};
+void OscilGen::shiftharmonics(){
+ if (Pharmonicshift==0) return;
+
+ REALTYPE hc,hs;
+ int harmonicshift=-Pharmonicshift;
+
+ if (harmonicshift>0){
+ for (int i=OSCIL_SIZE/2-2;i>=0;i--){
+ int oldh=i-harmonicshift;
+ if (oldh<0){
+ hc=0.0;
+ hs=0.0;
+ } else {
+ hc=oscilFFTfreqs[oldh+1];
+ hs=oscilFFTfreqs[OSCIL_SIZE-oldh-1];
+ };
+ oscilFFTfreqs[i+1]=hc;
+ oscilFFTfreqs[OSCIL_SIZE-i-1]=hs;
+ };
+ } else {
+ for (int i=0;i<OSCIL_SIZE/2-1;i++){
+ int oldh=i+abs(harmonicshift);
+ if (oldh>=(OSCIL_SIZE/2-1)){
+ hc=0.0;
+ hs=0.0;
+ } else {
+ hc=oscilFFTfreqs[oldh+1];
+ hs=oscilFFTfreqs[OSCIL_SIZE-oldh-1];
+ if (fabs(hc)<0.000001) hc=0.0;
+ if (fabs(hs)<0.000001) hs=0.0;
+ };
+
+ oscilFFTfreqs[i+1]=hc;
+ oscilFFTfreqs[OSCIL_SIZE-i-1]=hs;
+ };
+ };
+
+ oscilFFTfreqs[0]=0.0;
+};
/*
* Prepare the Oscillator
@@ -465,6 +507,8 @@ void OscilGen::prepare(){
};
+ if (Pharmonicshiftfirst!=0) shiftharmonics();
+
if (Pfilterbeforews==0){
waveshape();
oscilfilter();
@@ -474,6 +518,7 @@ void OscilGen::prepare(){
};
spectrumadjust();
+ if (Pharmonicshiftfirst==0) shiftharmonics();
//normalize (sum or RMS) - the "Full RMS" normalisation is located in the "::get()" function
if ((Pnormalizemethod==0)||(Pnormalizemethod==1)){
@@ -501,6 +546,8 @@ void OscilGen::prepare(){
};
oldhmagtype=Phmagtype;
oldnormalizemethod=Pnormalizemethod;
+ oldharmonicshift=Pharmonicshift+Pharmonicshiftfirst*256;
+
oscilprepared=1;
};
@@ -535,6 +582,7 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
(oldbasefuncmodulationpar2!=Pbasefuncmodulationpar2))
oscilprepared=0;
+ if (oldharmonicshift!=Pharmonicshift+Pharmonicshiftfirst*256) oscilprepared=0;
if (oscilprepared!=1) prepare();
@@ -910,6 +958,9 @@ void OscilGen::add2XML(XMLwrapper *xml){
xml->addpar("amp_rand_type",Pamprandtype);
xml->addpar("amp_rand_power",Pamprandpower);
+ xml->addpar("harmonic_shift",Pharmonicshift);
+ xml->addparbool("harmonic_shift_first",Pharmonicshiftfirst);
+
xml->beginbranch("HARMONICS");
for (int n=0;n<MAX_AD_HARMONICS;n++){
if ((Phmag[n]==64)&&(Phphase[n]==64)) continue;
@@ -969,6 +1020,9 @@ void OscilGen::getfromXML(XMLwrapper *xml){
Pamprandtype=xml->getpar127("amp_rand_type",Pamprandtype);
Pamprandpower=xml->getpar127("amp_rand_power",Pamprandpower);
+ Pharmonicshift=xml->getpar("harmonic_shift",Pharmonicshift,-64,64);
+ Pharmonicshiftfirst=xml->getparbool("harmonic_shift_first",Pharmonicshiftfirst);
+
if (xml->enterbranch("HARMONICS")){
Phmag[0]=64;Phphase[0]=64;
for (int n=0;n<MAX_AD_HARMONICS;n++){
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -90,6 +90,9 @@ class OscilGen{
unsigned char Psatype,Psapar;//spectrum adjust
unsigned char Pamprandpower, Pamprandtype;//amplitude randomness
+ int Pharmonicshift;//how the harmonics are shifted
+ int Pharmonicshiftfirst;//if the harmonic shift is done before waveshaping and filter
+
private:
REALTYPE hmag[MAX_AD_HARMONICS],hphase[MAX_AD_HARMONICS];//the magnituides and the phases of the sine/nonsine harmonics
@@ -106,6 +109,9 @@ class OscilGen{
//Adjust the spectrum
void spectrumadjust();
+ //Shift the harmonics
+ void shiftharmonics();
+
//Base function saveto/loadfrom quantised data
void savebasefuncQ();
void loadbasefuncQ();
@@ -126,7 +132,7 @@ class OscilGen{
//Internal Data
unsigned char oldbasefunc,oldbasepar,oldhmagtype,oldwaveshapingfunction,oldwaveshaping,oldnormalizemethod;
- int oldfilterpars,oldsapars,oldbasefuncmodulation,oldbasefuncmodulationpar1,oldbasefuncmodulationpar2;
+ int oldfilterpars,oldsapars,oldbasefuncmodulation,oldbasefuncmodulationpar1,oldbasefuncmodulationpar2,oldharmonicshift;
/*
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
@@ -288,8 +288,8 @@ delete(harmonic);} {}
class ADOscilEditor {} {
Function {make_window()} {} {
Fl_Window osceditUI {
- label {ADsynth Oscillator Editor}
- xywh {138 85 750 590} type Double hide
+ label {ADsynth Oscillator Editor} selected
+ xywh {17 85 750 590} type Double hide
} {
Fl_Group oscildisplaygroup {
xywh {15 5 360 300} box ENGRAVED_FRAME
@@ -364,7 +364,10 @@ oldosc->redraw();}
basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
-oldosc->redraw();}
+oldosc->redraw();
+
+if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
+ else basefuncmodulation->activate();}
xywh {380 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 12
code0 {o->value(oscil->Pcurrentbasefunc);}
} {
@@ -481,6 +484,8 @@ if (autoclearbutton->value()){
oscil->Phphase[i]=64;
};
oscil->Phmag[0]=127;
+
+ oscil->Pharmonicshift=0;
h[0]->mag->value(0);
wshbutton->value(0);
wshbutton->do_callback();
@@ -697,8 +702,9 @@ 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 {} {open
+ Fl_Group basefuncmodulation {open
xywh {615 278 115 25} box ENGRAVED_BOX
+ code0 {if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
} {
Fl_Choice {} {
label {M.}
@@ -726,7 +732,7 @@ oldosc->redraw();} open
callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
basefuncdisplaygroup->redraw();
oscildisplaygroup->redraw();
-oldosc->redraw();} selected
+oldosc->redraw();}
tooltip {Oscillator's modulation parameter 1} xywh {690 283 15 15} maximum 127 step 1
code0 {o->value(oscil->Pbasefuncmodulationpar1);}
class WidgetPDial
@@ -793,6 +799,34 @@ oldosc->redraw();}
class WidgetPDial
}
}
+ Fl_Group {} {open
+ xywh {675 405 75 65} box ENGRAVED_BOX
+ } {
+ Fl_Counter harmonicshiftcounter {
+ label {Harmonic Shift}
+ callback {oscil->Pharmonicshift=(int)o->value();
+oscildisplaygroup->redraw();
+oldosc->redraw();}
+ xywh {680 430 65 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
+ code0 {o->value(oscil->Pharmonicshift);}
+ }
+ Fl_Check_Button {} {
+ label preH
+ callback {oscil->Pharmonicshiftfirst=(int)o->value();
+oscildisplaygroup->redraw();
+oldosc->redraw();}
+ tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {710 450 35 15} down_box DOWN_BOX labelsize 10 align 24
+ code0 {o->value(oscil->Pharmonicshiftfirst);}
+ }
+ Fl_Button {} {
+ label R
+ callback {oscil->Pharmonicshift=0;
+harmonicshiftcounter->value(0);
+oscildisplaygroup->redraw();
+oldosc->redraw();}
+ xywh {680 450 25 15} box THIN_UP_BOX labelfont 1 labelsize 10
+ }
+ }
}
}
Function {ADOscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Master *master_)} {} {