zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit ab6a012b3323d45b31958b76dd7b00847e2b4ccd
parent 903aba9451f3dcbf0136ee3de459f89326fc045b
Author: paulnasca <paulnasca>
Date:   Wed, 28 Jul 2004 17:45:22 +0000

*** empty log message ***

Diffstat:
MChangeLog | 2+-
Msrc/Params/PADnoteParameters.C | 35+++++++++++++++++++++++++++++------
Msrc/Params/PADnoteParameters.h | 2++
Msrc/UI/PADnoteUI.fl | 19++++++++++++++-----
Msrc/UI/WidgetPDial.fl | 11++++++-----
5 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -662,4 +662,4 @@ - Corectata o eroare care facea ca sample-ul la PADnote sa nu fie ales in functie de frecventa reala de baza (cu detune) - Mutat functiile de waveshaping in Distorsion.C/.h 27 Iul 2004 - Corectata o eroare foarte suparatoare care bloca uneori calculatorul - + - Adaugat inca un nou parametru la PADsynth la base function diff --git a/src/Params/PADnoteParameters.C b/src/Params/PADnoteParameters.C @@ -68,9 +68,10 @@ PADnoteParameters::~PADnoteParameters(){ void PADnoteParameters::defaults(){ Php.base.type=0; Php.base.par1=80; + Php.freqmult=0; Php.modulator.par1=0; Php.modulator.freq=30; - Php.freqmult=0; + Php.width=127; Php.amp.type=0; Php.amp.mode=0; Php.amp.par1=80; @@ -152,11 +153,25 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp,int size){ REALTYPE modpar1=pow(Php.modulator.par1/127.0,4.0)*5.0/sqrt(modfreq); REALTYPE amppar1=pow(2.0,pow(Php.amp.par1/127.0,2.0)*10.0)-0.999; REALTYPE amppar2=(1.0-Php.amp.par2/127.0)*0.998+0.001; - + REALTYPE width=pow(150.0/(Php.width+22.0),2.0); + for (int i=0;i<size*supersample;i++){ + bool makezero=false; REALTYPE x=i*1.0/(size*(REALTYPE) supersample); REALTYPE origx=x; + + //do the sizing (width) + x=(x-0.5)*width+0.5; + if (x<0.0) { + x=0.0; + makezero=true; + } else { + if (x>1.0) { + x=1.0; + makezero=true; + }; + }; //compute the full profile or one half switch(Php.onehalf){ @@ -165,14 +180,17 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp,int size){ case 2:x=x*0.5; break; }; - + REALTYPE x_before_freq_mult=x; - + + //do the frequency multiplier x*=freqmult; - //do the modulation of the profile + + //do the modulation of the profile x+=sin(x_before_freq_mult*3.1415926*modfreq)*modpar1; x=fmod(x+1000.0,1.0)*2.0-1.0; + //this is the base function of the profile REALTYPE f; switch (Php.base.type){ @@ -183,9 +201,11 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp,int size){ default:f=exp(-(x*x)*basepar); break; }; + if (makezero) f=0.0; REALTYPE amp=1.0; origx=origx*2.0-1.0; + //compute the amplitude multiplier switch(Php.amp.type){ case 1:amp=exp(-(origx*origx)*10.0*amppar1); @@ -210,6 +230,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp,int size){ break; }; }; + smp[i/supersample]+=finalsmp/supersample; }; @@ -437,7 +458,7 @@ void PADnoteParameters::applyparameters(bool lockmutex){ }; delete(fft); - //delete the additional samples that might exists and are not usefull + //delete the additional samples that might exists and are not useful for (int i=samplemax;i<PAD_MAX_SAMPLES;i++) deletesample(i); }; @@ -454,6 +475,7 @@ void PADnoteParameters::add2XML(XMLwrapper *xml){ xml->addpar("frequency_multiplier",Php.freqmult); xml->addpar("modulator_par1",Php.modulator.par1); xml->addpar("modulator_frequency",Php.modulator.freq); + xml->addpar("width",Php.width); xml->addpar("amplitude_multiplier_type",Php.amp.type); xml->addpar("amplitude_multiplier_mode",Php.amp.mode); xml->addpar("amplitude_multiplier_par1",Php.amp.par1); @@ -548,6 +570,7 @@ void PADnoteParameters::getfromXML(XMLwrapper *xml){ Php.freqmult=xml->getpar127("frequency_multiplier",Php.freqmult); Php.modulator.par1=xml->getpar127("modulator_par1",Php.modulator.par1); Php.modulator.freq=xml->getpar127("modulator_frequency",Php.modulator.freq); + Php.width=xml->getpar127("width",Php.width); Php.amp.type=xml->getpar127("amplitude_multiplier_type",Php.amp.type); Php.amp.mode=xml->getpar127("amplitude_multiplier_mode",Php.amp.mode); Php.amp.par1=xml->getpar127("amplitude_multiplier_par1",Php.amp.par1); diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h @@ -60,6 +60,8 @@ class PADnoteParameters{ unsigned char par1; unsigned char freq; }modulator; + + unsigned char width;//the width of the resulting function after the modulation struct{//the amplitude multiplier of the harmonic profile unsigned char mode; unsigned char type; diff --git a/src/UI/PADnoteUI.fl b/src/UI/PADnoteUI.fl @@ -230,11 +230,11 @@ cbwidget->do_callback();} class WidgetPDial } Fl_Dial {} { - label Stretch + label Str callback {pars->Php.modulator.par1=(int) o->value(); hprofile->redraw(); cbwidget->do_callback();} - xywh {20 115 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1 + xywh {15 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1 code0 {o->value(pars->Php.modulator.par1);} class WidgetPDial } @@ -243,7 +243,7 @@ cbwidget->do_callback();} callback {pars->Php.modulator.freq=(int) o->value(); hprofile->redraw(); cbwidget->do_callback();} - xywh {55 115 25 25} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1 + xywh {40 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1 code0 {o->value(pars->Php.modulator.freq);} class WidgetPDial } @@ -331,7 +331,7 @@ cbwidget->do_callback();} callback {pars->Php.onehalf=o->value(); hprofile->redraw(); cbwidget->do_callback();} - xywh {15 143 75 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 + xywh {10 143 80 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 code0 {o->value(pars->Php.onehalf);} } { menuitem {} { @@ -347,6 +347,15 @@ cbwidget->do_callback();} xywh {35 35 100 20} labelfont 1 labelsize 10 } } + Fl_Dial {} { + label Size + callback {pars->Php.width=(int) o->value(); +hprofile->redraw(); +cbwidget->do_callback();} selected + xywh {65 115 20 20} box ROUND_UP_BOX labelsize 11 align 1 maximum 127 step 1 + code0 {o->value(pars->Php.width);} + class WidgetPDial + } } Fl_Group {} { xywh {100 155 270 135} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 align 6 @@ -835,7 +844,7 @@ o->color(FL_GRAY);} } Fl_Button {} { label Close - callback {padnotewindow->hide();} selected + callback {padnotewindow->hide();} xywh {300 405 195 40} box THIN_UP_BOX labelsize 20 } } diff --git a/src/UI/WidgetPDial.fl b/src/UI/WidgetPDial.fl @@ -25,7 +25,7 @@ class WidgetPDial {: {public Fl_Dial} } Function {handle(int event)} {return_type int } { - code {double dragsize,v; + code {double dragsize,v,min=minimum(),max=maximum(); int my; switch (event){ @@ -35,10 +35,11 @@ case FL_DRAG: dragsize=200.0; if (Fl::event_state(FL_BUTTON1)==0) dragsize*=10; - v=oldvalue+my/dragsize*(maximum()-minimum()); - if (v<minimum()) v=minimum(); - else if (v>maximum()) v=maximum(); - + v=oldvalue+my/dragsize*(max-min); + if (v<min) v=min; + else if (v>max) v=max; + + //printf("%d %g %g\\n",my,v,oldvalue); value(v); value_damage(); if (this->when()!=0) do_callback();