From 0cd6d22931b2ce5772cb7c0c987bc15bd081315b Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 21 Sep 2009 00:46:22 +0300 Subject: [PATCH] Added GUI to Unison effect in ADsynth (but not finished) (cherry picked from commit 7a4dc58ea1213d1c769b8968f320858dc0fb5d5d) --- plugins/zynaddsubfx/ChangeLog | 3 + .../src/Params/ADnoteParameters.cpp | 19 ++++- .../zynaddsubfx/src/Params/ADnoteParameters.h | 9 +++ plugins/zynaddsubfx/src/Synth/ADnote.cpp | 15 +++- plugins/zynaddsubfx/src/UI/ADnoteUI.fl | 70 +++++++++++++------ 5 files changed, 89 insertions(+), 27 deletions(-) diff --git a/plugins/zynaddsubfx/ChangeLog b/plugins/zynaddsubfx/ChangeLog index f1922e210..0459b7701 100644 --- a/plugins/zynaddsubfx/ChangeLog +++ b/plugins/zynaddsubfx/ChangeLog @@ -892,3 +892,6 @@ 07 Sep 2009 (Mark McCurry) - Fixed glitch in XMLwrapper, which would prevent file loading +20 Sep 2009 (Paul Nasca) + - Started to implement the Unison effect for ADsynth + \ No newline at end of file diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp index 5fb6ce797..8f5c72055 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp @@ -96,6 +96,11 @@ void ADnoteParameters::defaults(int n) { int nvoice=n; VoicePar[nvoice].Enabled=0; + + VoicePar[nvoice].Unison_size=1; + VoicePar[nvoice].Unison_frequency_spread=64; + VoicePar[nvoice].Unison_stereo_spread=100; + VoicePar[nvoice].Type=0; VoicePar[nvoice].Pfixedfreq=0; VoicePar[nvoice].PfixedfreqET=0; @@ -248,8 +253,14 @@ void ADnoteParameters::add2XMLsection(XMLwrapper *xml,int n) xml->addparbool("enabled",VoicePar[nvoice].Enabled); if (((VoicePar[nvoice].Enabled==0)&&(oscilused==0)&&(fmoscilused==0))&&(xml->minimal)) return; + xml->addpar("type",VoicePar[nvoice].Type); - xml->addpar("delay",VoicePar[nvoice].PDelay); + + xml->addpar("unison_size",VoicePar[nvoice].Unison_size); + xml->addpar("unison_frequency_spread",VoicePar[nvoice].Unison_frequency_spread); + xml->addpar("unison_stereo_spread",VoicePar[nvoice].Unison_stereo_spread); + + xml->addpar("delay",VoicePar[nvoice].PDelay); xml->addparbool("resonance",VoicePar[nvoice].Presonance); xml->addpar("ext_oscil",VoicePar[nvoice].Pextoscil); @@ -525,7 +536,11 @@ void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n) VoicePar[nvoice].Enabled=xml->getparbool("enabled",0); - VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type); + VoicePar[nvoice].Unison_size=xml->getpar127("unison_size",VoicePar[nvoice].Unison_size); + VoicePar[nvoice].Unison_frequency_spread=xml->getpar127("unison_frequency_spread",VoicePar[nvoice].Unison_frequency_spread); + VoicePar[nvoice].Unison_stereo_spread=xml->getpar127("unison_stereo_spread",VoicePar[nvoice].Unison_stereo_spread); + + VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type); VoicePar[nvoice].PDelay=xml->getpar127("delay",VoicePar[nvoice].PDelay); VoicePar[nvoice].Presonance=xml->getparbool("resonance",VoicePar[nvoice].Presonance); diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h index 8b35f92c4..86fdc9abb 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h @@ -115,6 +115,15 @@ struct ADnoteVoiceParam { /** If the voice is enabled */ unsigned char Enabled; + /** How many subvoices are used in this voice */ + unsigned char Unison_size; + + /** How subvoices are spread */ + unsigned char Unison_frequency_spread; + + /** Stereo spread of the subvoices*/ + unsigned char Unison_stereo_spread; + /** Type of the voice (0=Sound,1=Noise)*/ unsigned char Type; diff --git a/plugins/zynaddsubfx/src/Synth/ADnote.cpp b/plugins/zynaddsubfx/src/Synth/ADnote.cpp index 883678016..571969802 100644 --- a/plugins/zynaddsubfx/src/Synth/ADnote.cpp +++ b/plugins/zynaddsubfx/src/Synth/ADnote.cpp @@ -97,13 +97,22 @@ ADnote::ADnote(ADnoteParameters *pars,Controller *ctl_,REALTYPE freq,REALTYPE ve continue; //the voice is disabled }; -#warning get from parameter - int unison=30; + int unison=pars->VoicePar[nvoice].Unison_size; + if (unison<1) unison=1; + unison_size[nvoice]=unison; unison_freq_rap[nvoice]=new REALTYPE[unison]; + REALTYPE unison_spread=pars->VoicePar[nvoice].Unison_frequency_spread/127.0; + unison_spread=pow(unison_spread*2.0,4.0)*50.0;//cents + for (int k=0;kVoicePar[nvoice].Enabled==0) o->deactivate();} } { - Fl_Group voicemodegroup { - xywh {0 5 760 515} + Fl_Group voicemodegroup {open + xywh {0 5 760 575} } { Fl_Group voiceFMparametersgroup { label MODULATOR - xywh {530 5 230 515} box THIN_UP_FRAME color 48 labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17 + xywh {530 5 230 565} box THIN_UP_FRAME color 48 labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17 code0 {if (pars->VoicePar[nvoice].PFMEnabled==0) o->deactivate();} } { Fl_Group modfrequency { @@ -209,7 +209,7 @@ class ADvoiceUI {open : {public Fl_Group} callback {pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled=(int)o->value(); if (o->value()==0) voiceFMfreqenvgroup->deactivate(); else voiceFMfreqenvgroup->activate(); -o->redraw();} selected +o->redraw();} tooltip {Forced Relase} xywh {545 295 50 10} down_box DOWN_BOX labelfont 1 labelsize 10 code0 {o->value(pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled);} } @@ -298,10 +298,10 @@ o->redraw();} } } Fl_Group modoscil { - xywh {535 365 220 150} + xywh {535 365 220 200} } { Fl_Group fmoscil {open - xywh {535 405 220 110} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 + xywh {535 425 220 140} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 code0 {oscFM=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");} code1 {int nv=nvoice; if (pars->VoicePar[nvoice].PextFMoscil>=0) nv=pars->VoicePar[nvoice].PextFMoscil;} code2 {oscFM->init(pars->VoicePar[nv].FMSmp,0,pars->VoicePar[nvoice].PFMoscilphase,master);} @@ -326,7 +326,7 @@ oscedit=new OscilEditor(pars->VoicePar[nv].FMSmp,fmoscil,NULL,NULL,master);} callback {pars->VoicePar[nvoice].PFMoscilphase=64-(int)o->value(); oscFM->phase=64-(int) o->value(); fmoscil->redraw();} - xywh {665 395 65 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1 + xywh {665 400 65 10} type {Horz Knob} box FLAT_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1 code0 {o->value(64-pars->VoicePar[nvoice].PFMoscilphase);} } Fl_Choice {} { @@ -340,7 +340,7 @@ if ((int) o->value() != 0) { changeFMoscilbutton->labelcolor(FL_BLACK); }; voiceFMparametersgroup->redraw();} open - xywh {560 390 75 15} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10 + xywh {560 395 75 15} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10 code0 {o->add("Internal");} code1 {char tmp[50]; for (int i=0;iadd(tmp);};} code3 {o->value(pars->VoicePar[nvoice].PextFMoscil+1);} @@ -548,6 +548,32 @@ voiceonbutton->redraw();} open code1 {char tmp[50]; for (int i=0;iadd(tmp);};} code3 {o->value(pars->VoicePar[nvoice].Pextoscil+1);} } {} + Fl_Group {} { + label {Unison:} open + xywh {5 525 520 45} box UP_FRAME labeltype ENGRAVED_LABEL labelsize 15 align 20 + } { + Fl_Counter {} { + label SIze + callback {int k=(int) o->value(); + +pars->VoicePar[nvoice].Unison_size=k;} + tooltip {Unison Size} xywh {85 540 50 20} type Simple labelsize 10 align 1 minimum 1 maximum 8 step 1 value 1 textfont 1 textsize 12 + code0 {int k=pars->VoicePar[nvoice].Unison_size;} + code2 {o->value(k);} + } + Fl_Value_Slider {} { + label {Frequency Spread} + callback {pars->VoicePar[nvoice].Unison_frequency_spread=(int)o->value();} + tooltip {Frequency Spread of the Unison} xywh {155 543 155 17} type {Horz Knob} box FLAT_BOX labelsize 11 align 5 maximum 127 step 1 value 64 + code0 {o->value(pars->VoicePar[nvoice].Unison_frequency_spread);} + } + Fl_Value_Slider {} { + label {Stereo Spread} + callback {pars->VoicePar[nvoice].Unison_stereo_spread=(int)o->value();} + tooltip {Stereo Spread of the Unison} xywh {345 543 155 17} type {Horz Knob} box FLAT_BOX labelsize 11 align 5 maximum 127 step 1 value 100 + code0 {o->value(pars->VoicePar[nvoice].Unison_stereo_spread);} + } + } } Fl_Group {} { label AMPLITUDE @@ -752,7 +778,7 @@ if (oscedit!=NULL) { decl {Master *master;} {} } -class ADnoteUI {: {public PresetsUI_} +class ADnoteUI {open : {public PresetsUI_} } { Function {make_window()} {open private } { @@ -966,11 +992,11 @@ resui->resonancewindow->show();} } } Fl_Window ADnoteVoice { - label {ADsynth Voice Parameters} - xywh {53 58 765 560} type Double hide + label {ADsynth Voice Parameters} selected + xywh {53 58 765 620} type Double visible } { Fl_Group advoice { - xywh {0 0 760 525} box BORDER_BOX + xywh {0 0 760 575} box BORDER_BOX code0 {o->init(pars,nvoice,master);} code1 {o->show();} class ADvoiceUI @@ -978,7 +1004,7 @@ resui->resonancewindow->show();} Fl_Button {} { label {Close Window} callback {ADnoteVoice->hide();} - xywh {300 530 195 25} box THIN_UP_BOX labelfont 1 + xywh {300 585 195 25} box THIN_UP_BOX labelfont 1 } Fl_Counter currentvoicecounter { label {Current Voice} @@ -991,18 +1017,18 @@ ADnoteVoice->add(advoice); advoice->init(pars,nvoice,master); advoice->show(); ADnoteVoice->redraw();} - xywh {5 530 130 25} type Simple labelfont 1 align 8 minimum 0 maximum 2 step 1 value 1 textfont 1 textsize 13 + xywh {5 585 130 25} type Simple labelfont 1 align 8 minimum 0 maximum 2 step 1 value 1 textfont 1 textsize 13 code0 {o->bounds(1,NUM_VOICES);} } Fl_Button {} { label C callback {presetsui->copy(pars,nvoice);} - xywh {700 535 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 + xywh {700 590 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 } Fl_Button {} { label P callback {presetsui->paste(pars,this,nvoice);} - xywh {730 535 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 + xywh {730 590 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 } } Fl_Window ADnoteVoiceList {