commit 23d9fe996ee3ac19f8d78806d050510b9b0a5231
parent 4bd0ea6052648d1b133b2aad305f0df97c07d0bb
Author: paulnasca <paulnasca>
Date: Thu, 11 Dec 2003 19:40:02 +0000
Added randomness to harmonics amplitudes
Diffstat:
5 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -501,4 +501,5 @@
- Inceput sa pun pe cvs la cvs.sourceforge.net
01 Dec 2003 - Am facut niste mici modificari ca urmare a unui bug-report
05 Dec 2003 - Facute cateva modificari la jack
-08 Dec 2003 - Inceput sa incerc sa fac rt-safe sub jack, dar in stadiul actual suportul jack este nefunctional
-\ No newline at end of file
+08 Dec 2003 - Inceput sa incerc sa fac rt-safe sub jack, dar in stadiul actual suportul jack este nefunctional
+11 Dec 2003 - Adaugat aleatorism la amplitudinile armonicelor
diff --git a/examples/analogpiano.mas_zyn b/examples/analogpiano.mas_zyn
Binary files differ.
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -56,6 +56,9 @@ OscilGen::OscilGen(FFTwrapper *fft_,Resonance *res_){
Pfilterbeforews=0;
Psatype=0;
Psapar=64;
+
+ Pamprandpower=64;
+ Pamprandtype=0;
basefuncFFTfreqsQ=NULL;
basefuncFFTfreqs=NULL;
@@ -509,8 +512,33 @@ short int OscilGen::get(REALTYPE *smps,REALTYPE freqHz,int resonance){
};
};
+ //Harmonic Amplitude Randomness
+ if (freqHz>0.1) {
+ REALTYPE power=Pamprandpower/127.0;
+ REALTYPE normalize=1.0/(1.2-power);
+ switch (Pamprandtype){
+ case 1: power=power*2.0-0.5;
+ power=pow(15.0,power);
+ for (i=1;i<nyquist-1;i++){
+ REALTYPE amp=pow(RND,power)*normalize;
+ outoscilFFTfreqs[i]*=amp;
+ outoscilFFTfreqs[OSCIL_SIZE-i]*=amp;
+ };
+ break;
+ case 2: power=power*2.0-0.5;
+ power=pow(15.0,power)*2.0;
+ REALTYPE rndfreq=2*PI*RND;
+ for (i=1;i<nyquist-1;i++){
+ REALTYPE amp=pow(fabs(sin(i*rndfreq)),power)*normalize;
+ outoscilFFTfreqs[i]*=amp;
+ outoscilFFTfreqs[OSCIL_SIZE-i]*=amp;
+ };
+ break;
+ };
+ };
+
+
if ((freqHz>0.1)&&(resonance!=0)) res->applyres(nyquist-1,outoscilFFTfreqs,freqHz);
-
fft->freqs2smps(outoscilFFTfreqs,smps);
for (i=0;i<OSCIL_SIZE;i++) smps[i]*=0.25;//correct the amplitude
@@ -754,6 +782,11 @@ void OscilGen::saveloadbuf(Buffer *buf){
case 0x8C: buf->rwbytepar(n,&Psatype);
break;
case 0x8D: buf->rwbytepar(n,&Psapar);
+ break;
+ case 0x8E: buf->rwbytepar(n,&Pamprandtype);
+ break;
+ case 0x8F: buf->rwbytepar(n,&Pamprandpower);
+ break;
};
};
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -79,6 +79,8 @@ class OscilGen{
unsigned char Pfiltertype,Pfilterpar;
unsigned char Pfilterbeforews;
unsigned char Psatype,Psapar;//spectrum adjust
+
+ unsigned char Pamprandpower, Pamprandtype;
REALTYPE hmag[MAX_AD_HARMONICS],hphase[MAX_AD_HARMONICS];//the magnituides and the phases of the sine/nonsine harmonics
//this is public because I get it from interface and show to the user
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 {41 111 750 590} hide
+ xywh {121 91 750 590} hide
} {
Fl_Group oscildisplaygroup {
xywh {15 5 360 300} box ENGRAVED_FRAME
@@ -308,7 +308,7 @@ class ADOscilEditor {} {
callback {oscil->Prand=(int)o->value()+64;
oscildisplaygroup->redraw();
oldosc->redraw();}
- tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {180 285 175 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
+ tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {150 285 100 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
code0 {o->value(oscil->Prand-64);}
}
Fl_Group {} {open
@@ -316,6 +316,35 @@ oldosc->redraw();}
code0 {ADSpectrum *spc=new ADSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
code1 {spc->init(oscil,0,master);}
} {}
+ Fl_Group {} {
+ xywh {256 277 115 25} box ENGRAVED_BOX
+ } {
+ Fl_Choice {} {
+ label {H.rnd}
+ callback {oscil->Pamprandtype=(int) o->value();} selected
+ tooltip {Harmonic Amplitude Randomness} xywh {291 282 50 15} down_box BORDER_BOX labelsize 10 textsize 10
+ code0 {o->value(oscil->Pamprandtype);}
+ } {
+ menuitem {} {
+ label None
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label Pow
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ menuitem {} {
+ label Sin
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial {} {
+ callback {oscil->Pamprandpower=(int) o->value();}
+ tooltip {Oscillator's spectrum adjust parameter} xywh {348 280 18 18} maximum 127 step 1
+ code0 {o->value(oscil->Pamprandpower);}
+ class WidgetPDial
+ }
+ }
}
Fl_Box {} {
label {Base Func.}
@@ -1434,7 +1463,7 @@ class ADnoteUI {} {
Function {make_window()} {private
} {
Fl_Window ADnoteGlobalParameters {
- label {ADsynth Global Parameters of the Instrument} selected
+ label {ADsynth Global Parameters of the Instrument}
xywh {112 194 535 405} hide
} {
Fl_Group {} {