commit 9b87526e1565c137d2a330d6cec1d2c544f64546
parent deaa5ba46b070deaeb79c5abdfc91bca0a909788
Author: paulnasca <paulnasca>
Date: Tue, 15 Jun 2004 21:33:18 +0000
*** empty log message ***
Diffstat:
5 files changed, 166 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -577,3 +577,6 @@
- Modificat interfata la PartUI
- Imbunatatit modulatia basefunc la OscilGen (adaugat inca un parametru si inca un tip de modulatie ("power"))
- Adaugat inca o noua functie basefunc la OscilGen (sqr=atan(sin(x)*a))
+15 Iun 2004 - Adaugat posibilitatea de a face armonicele ca sa depinda de frecventa ("adaptive") si rezultatul suna foarte frumos pentru ca tendinta este de pastrare a frecventelor armonicelor si nu a numarului de ordine al lor
+
+
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -82,6 +82,10 @@ void OscilGen::defaults(){
Pharmonicshift=0;
Pharmonicshiftfirst=0;
+
+ Padaptiveharmonics=0;
+ Padaptiveharmonicspower=100;
+ Padaptiveharmonicsbasefreq=128;
if (basefuncFFTfreqsQ!=NULL) {
delete(basefuncFFTfreqsQ);
@@ -571,6 +575,65 @@ void OscilGen::prepare(){
oscilprepared=1;
};
+void OscilGen::adaptiveharmonic(REALTYPE *freqs,REALTYPE freq){
+ if ((Padaptiveharmonics==0)||(freq<1.0)) return;
+
+ REALTYPE *infreqs=new REALTYPE[OSCIL_SIZE];
+ for (int i=0;i<OSCIL_SIZE;i++) {
+ infreqs[i]=freqs[i];
+ freqs[i]=0.0;
+ };
+
+ REALTYPE hc=0.0,hs=0.0;
+ REALTYPE basefreq=30.0*pow(10.0,Padaptiveharmonicsbasefreq/128.0);
+ REALTYPE power=(Padaptiveharmonicspower+1.0)/101.0;
+
+ REALTYPE rap=freq/basefreq;
+
+ rap=pow(rap,power);
+
+// printf("bf=%g (%d) pow=%g(%d)\n",basefreq,Padaptiveharmonicsbasefreq,power,Padaptiveharmonicspower);
+
+ bool down=false;
+ if (rap>1.0) {
+ rap=1.0/rap;
+ down=true;
+ };
+
+ for (int i=0;i<OSCIL_SIZE/2-2;i++){
+ REALTYPE h=i*rap;
+ int high=(int)(i*rap);
+ REALTYPE low=fmod(h,1.0);
+
+ if (high>=(OSCIL_SIZE/2-2)){
+ break;
+ } else {
+ if (down){
+ freqs[high+1]+=infreqs[i+1];
+ freqs[OSCIL_SIZE-high-1]+=infreqs[OSCIL_SIZE-i-1];
+ } else {
+ hc=infreqs[high+1]*(1.0-low)+infreqs[high+2]*low;
+ hs=infreqs[OSCIL_SIZE-high-1]*(1.0-low)+infreqs[OSCIL_SIZE-high-2]*low;
+ };
+ if (fabs(hc)<0.000001) hc=0.0;
+ if (fabs(hs)<0.000001) hs=0.0;
+ };
+
+ if (!down){
+ if (i==0) {//corect the aplitude of the first harmonic
+ hc*=rap;
+ hs*=rap;
+ };
+ freqs[i+1]=hc;
+ freqs[OSCIL_SIZE-i-1]=hs;
+ };
+ };
+
+ delete(infreqs);
+};
+
+
+
/*
* Get the oscillator function
*/
@@ -618,10 +681,13 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
//Anti-Aliasing ON
outoscilFFTfreqs=new REALTYPE[OSCIL_SIZE];
+ for (i=0;i<OSCIL_SIZE;i++) outoscilFFTfreqs[i]=0.0;
+
nyquist=(int)(0.5*SAMPLE_RATE/fabs(freqHz))+2;
if (nyquist>OSCIL_SIZE/2) nyquist=OSCIL_SIZE/2;
+ int realnyquist=nyquist;
- for (i=0;i<OSCIL_SIZE;i++) outoscilFFTfreqs[i]=0.0;
+ if (Padaptiveharmonics!=0) nyquist=OSCIL_SIZE/2;
// Randomness (each harmonic), the block type is computed
// in ADnote by setting start position according to this setting
@@ -644,6 +710,16 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
};
};
+ adaptiveharmonic(outoscilFFTfreqs,freqHz);
+ nyquist=realnyquist;
+ if (Padaptiveharmonics){//do the antialiasing in the case of adaptive harmonics
+ for (i=nyquist;i<OSCIL_SIZE/2;i++) {
+ outoscilFFTfreqs[i]=0;
+ outoscilFFTfreqs[OSCIL_SIZE-i]=0;
+ };
+ };
+
+
//Harmonic Amplitude Randomness
if (freqHz>0.1) {
REALTYPE power=Pamprandpower/127.0;
@@ -983,6 +1059,10 @@ void OscilGen::add2XML(XMLwrapper *xml){
xml->addpar("harmonic_shift",Pharmonicshift);
xml->addparbool("harmonic_shift_first",Pharmonicshiftfirst);
+ xml->addpar("adaptive_harmonics",Padaptiveharmonics);
+ xml->addpar("adaptive_harmonics_base_frequency",Padaptiveharmonicsbasefreq);
+ xml->addpar("adaptive_harmonics_power",Padaptiveharmonicspower);
+
xml->beginbranch("HARMONICS");
for (int n=0;n<MAX_AD_HARMONICS;n++){
if ((Phmag[n]==64)&&(Phphase[n]==64)) continue;
@@ -1046,6 +1126,11 @@ void OscilGen::getfromXML(XMLwrapper *xml){
Pharmonicshift=xml->getpar("harmonic_shift",Pharmonicshift,-64,64);
Pharmonicshiftfirst=xml->getparbool("harmonic_shift_first",Pharmonicshiftfirst);
+ Padaptiveharmonics=xml->getpar("adaptive_harmonics",Padaptiveharmonics,0,127);
+ Padaptiveharmonicsbasefreq=xml->getpar("adaptive_harmonics_base_frequency",Padaptiveharmonicsbasefreq,0,255);
+ Padaptiveharmonicspower=xml->getpar("adaptive_harmonics_power",Padaptiveharmonicspower,0,100);
+
+
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
@@ -92,6 +92,10 @@ class OscilGen{
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
+
+ unsigned char Padaptiveharmonics;//the adaptive harmonics status (off=0,on=1)
+ unsigned char Padaptiveharmonicsbasefreq;//the base frequency of the adaptive harmonic (30..3000Hz)
+ unsigned char Padaptiveharmonicspower;//the strength of the effect (0=off,100=full)
private:
@@ -112,6 +116,9 @@ class OscilGen{
//Shift the harmonics
void shiftharmonics();
+ //Do the adaptive harmonic stuff
+ void adaptiveharmonic(REALTYPE *freqs,REALTYPE freq);
+
//Base function saveto/loadfrom quantised data
void savebasefuncQ();
void loadbasefuncQ();
diff --git a/src/UI/ADnoteUI.fl b/src/UI/ADnoteUI.fl
@@ -285,11 +285,13 @@ delete(harmonic);} {}
decl {Master *master;} {}
}
-class ADOscilEditor {} {
- Function {make_window()} {} {
+class ADOscilEditor {open
+} {
+ Function {make_window()} {open
+ } {
Fl_Window osceditUI {
- label {ADsynth Oscillator Editor}
- xywh {96 94 750 590} type Double visible
+ label {ADsynth Oscillator Editor} open
+ xywh {66 94 750 590} type Double visible
} {
Fl_Group oscildisplaygroup {
xywh {15 5 360 300} box ENGRAVED_FRAME
@@ -434,7 +436,7 @@ if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodula
xywh {112 112 100 20} labelfont 1 labelsize 12
}
menuitem {} {
- label Sqr selected
+ label Sqr
xywh {122 122 100 20} labelfont 1 labelsize 12
}
}
@@ -607,7 +609,7 @@ pthread_mutex_unlock(&master->mutex);
oscildisplaygroup->redraw();
oldosc->redraw();}
- xywh {680 340 50 20} box THIN_UP_BOX labelfont 1 labelsize 12
+ xywh {685 310 50 20} box THIN_UP_BOX labelfont 1 labelsize 12
}
Fl_Group {} {
xywh {145 305 185 30} box ENGRAVED_BOX
@@ -783,7 +785,7 @@ oldosc->redraw();}
Fl_Choice {} {
label Normalize
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
+ tooltip {Normalize type (harmonic's sum/RMS) of the oscillator} xywh {680 420 60 20} down_box BORDER_BOX labelsize 10 align 5 textsize 10
code0 {o->value(oscil->Pnormalizemethod);}
} {
menuitem {} {
@@ -833,14 +835,14 @@ oldosc->redraw();}
}
}
Fl_Group {} {
- xywh {675 405 75 65} box ENGRAVED_BOX
+ xywh {675 335 70 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
+ xywh {680 360 60 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 {} {
@@ -848,7 +850,7 @@ oldosc->redraw();}
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
+ tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {706 380 35 15} down_box DOWN_BOX labelsize 10 align 24
code0 {o->value(oscil->Pharmonicshiftfirst);}
}
Fl_Button {} {
@@ -857,7 +859,43 @@ oldosc->redraw();}
harmonicshiftcounter->value(0);
oscildisplaygroup->redraw();
oldosc->redraw();}
- xywh {680 450 25 15} box THIN_UP_BOX labelfont 1 labelsize 10
+ xywh {680 380 25 15} box THIN_UP_BOX labelfont 1 labelsize 10
+ }
+ }
+ Fl_Group {} {open
+ xywh {675 445 65 90} box ENGRAVED_FRAME
+ } {
+ Fl_Box {} {
+ label {Adaptive Harmonics}
+ xywh {680 445 55 25} labelsize 10 align 144
+ }
+ Fl_Choice {} {
+ callback {oscil->Padaptiveharmonics=(int) o->value();} open
+ tooltip {The type of the addaptive harmonics} xywh {680 470 55 15} down_box BORDER_BOX labelsize 10 textsize 10
+ code0 {o->value(oscil->Padaptiveharmonics);}
+ } {
+ menuitem {} {
+ label OFF
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label On
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial {} {
+ label pow
+ callback {oscil->Padaptiveharmonicspower=(int)o->value();} selected
+ tooltip {Adaptive harmonics power} xywh {710 495 25 25} labelsize 6 maximum 100 step 1
+ code0 {o->value(oscil->Padaptiveharmonicspower);}
+ class WidgetPDial
+ }
+ Fl_Dial {} {
+ label baseF
+ callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();}
+ tooltip {Adaptive harmonics base frequency} xywh {680 495 25 25} labelsize 9 maximum 255 step 1
+ code0 {o->value(oscil->Padaptiveharmonicsbasefreq);}
+ class WidgetPDial
}
}
}
diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl
@@ -255,9 +255,9 @@ delete(partkititem);} {}
decl {PartUI_ *partui;} {}
}
-class PartUI {: {public Fl_Group,PartUI_}
+class PartUI {open : {public Fl_Group,PartUI_}
} {
- Function {make_window()} {private
+ Function {make_window()} {open private
} {
Fl_Window partgroup {
private xywh {149 400 385 180} type Double hide
@@ -823,86 +823,86 @@ subsynenabledcheck->value(part->kit[0].Psubenabled);}
}
}
Fl_Window instrumenteditwindow {
- label {Instrument Edit}
- xywh {60 156 395 465} type Double hide
+ label {Instrument Edit} selected
+ xywh {60 156 395 360} type Double hide
} {
Fl_Group {} {
- xywh {0 320 395 110} box ENGRAVED_FRAME
+ xywh {0 220 395 110} box ENGRAVED_FRAME
} {
Fl_Group {} {
label PADsynth
- xywh {205 345 100 80} box ENGRAVED_FRAME labelfont 1
+ xywh {205 245 100 80} box ENGRAVED_FRAME labelfont 1
} {
Fl_Button {} {
label Edit
callback {//showparameters(0,1);
fl_alert("Oops... try again...")}
- xywh {215 380 80 35} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
+ xywh {215 280 80 35} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
}
Fl_Check_Button padsynenabledcheck {
label Enabled
callback {//part->kit[0].Padenabled=(int) o->value();}
- tooltip {enable/disable PADsynth} xywh {215 355 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
+ tooltip {enable/disable PADsynth} xywh {215 255 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
code1 {//o->value(part->kit[0].Padenabled);}
}
}
Fl_Group {} {
label ADDsynth
- xywh {5 345 100 80} box ENGRAVED_FRAME labelfont 1
+ xywh {5 245 100 80} box ENGRAVED_FRAME labelfont 1
} {
Fl_Check_Button adsynenabledcheck {
label Enabled
callback {part->kit[0].Padenabled=(int) o->value();}
- tooltip {enable/disable ADsynth} xywh {15 355 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
+ tooltip {enable/disable ADsynth} xywh {15 255 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
code1 {o->value(part->kit[0].Padenabled);}
}
Fl_Button {} {
label Edit
callback {showparameters(0,0);}
- xywh {15 381 80 34} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
+ xywh {15 281 80 34} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
}
}
Fl_Group {} {
label SUBsynth
- xywh {105 345 100 80} box ENGRAVED_FRAME labelfont 1
+ xywh {105 245 100 80} box ENGRAVED_FRAME labelfont 1
} {
Fl_Check_Button subsynenabledcheck {
label Enabled
callback {part->kit[0].Psubenabled=(int) o->value();}
- tooltip {enable/disable SUBsynth} xywh {115 355 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
+ tooltip {enable/disable SUBsynth} xywh {115 255 80 20} box PLASTIC_UP_BOX down_box DOWN_BOX color 222 selection_color 218 labelfont 1 labelsize 12
code1 {o->value(part->kit[0].Psubenabled);}
}
Fl_Button {} {
label Edit
callback {showparameters(0,1);}
- xywh {115 380 80 35} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
+ xywh {115 280 80 35} box PLASTIC_UP_BOX color 222 selection_color 220 labelfont 1 labelsize 12 align 128
}
}
Fl_Button {} {
label {Kit Edit}
callback {instrumentkitlist->show();}
- xywh {310 345 80 35} box PLASTIC_UP_BOX color 238 selection_color 220 labelfont 1 align 128
+ xywh {310 245 80 35} box PLASTIC_UP_BOX color 238 selection_color 220 labelfont 1 align 128
}
Fl_Button {} {
label Effects
callback {partfx->show();}
- xywh {310 390 80 35} box PLASTIC_UP_BOX labelfont 1 labelsize 16
+ xywh {310 290 80 35} box PLASTIC_UP_BOX labelfont 1 labelsize 16
}
}
- Fl_Group {} {selected
- xywh {0 5 395 315} box ENGRAVED_FRAME
+ Fl_Group {} {
+ xywh {0 5 395 215} box ENGRAVED_FRAME
} {
Fl_Input {} {
label {Author and Copyright}
callback {snprintf((char *)part->info.Pauthor,MAX_INFO_TEXT_SIZE,"%s",o->value());}
- xywh {5 60 385 100} type Multiline labelsize 10 align 5
+ xywh {5 60 385 50} type Multiline color 26 labelsize 10 align 5
code0 {o->maximum_size(MAX_INFO_TEXT_SIZE);}
code1 {o->value((char *) &part->info.Pauthor);}
}
Fl_Input {} {
label Comments
callback {snprintf((char *)part->info.Pcomments,MAX_INFO_TEXT_SIZE,"%s",o->value());}
- xywh {5 175 385 140} type Multiline labelsize 12 align 5
+ xywh {5 125 385 90} type Multiline color 26 labelsize 12 align 5
code0 {o->maximum_size(MAX_INFO_TEXT_SIZE);}
code1 {o->value((char *) &part->info.Pcomments);}
}
@@ -985,7 +985,7 @@ fl_alert("Oops... try again...")}
Fl_Button {} {
label Close
callback {instrumenteditwindow->hide();}
- xywh {150 435 95 25} box THIN_UP_BOX
+ xywh {150 335 95 25} box THIN_UP_BOX
}
}
}