From f2362df5fb6e2c74a65e11cf58fec6267e9a67f2 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 23 Sep 2009 20:47:32 +0300 Subject: [PATCH] Added unison invert phase (cherry picked from commit 5302e6d9c97ae6435bbc0d68a412dbfe3cb03044) --- plugins/zynaddsubfx/ChangeLog | 4 +++ .../src/Params/ADnoteParameters.cpp | 5 +++- .../zynaddsubfx/src/Params/ADnoteParameters.h | 3 +++ plugins/zynaddsubfx/src/Synth/ADnote.cpp | 27 ++++++++++++++++--- plugins/zynaddsubfx/src/Synth/ADnote.h | 3 +++ plugins/zynaddsubfx/src/UI/ADnoteUI.fl | 11 ++++++-- 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/plugins/zynaddsubfx/ChangeLog b/plugins/zynaddsubfx/ChangeLog index b2a0c66d2..161dce552 100644 --- a/plugins/zynaddsubfx/ChangeLog +++ b/plugins/zynaddsubfx/ChangeLog @@ -898,3 +898,7 @@ 22 Sep 2009 (Paul Nasca) - Added vibratto and other features to Unison effect + +23 Sep 2009 (Paul Nasca) + - Added unison invert phase + \ No newline at end of file diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp index 13143a1a2..ce7ed6f17 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp @@ -25,7 +25,7 @@ #include #include "ADnoteParameters.h" -int ADnote_unison_sizes[]={1,2,3,4,6,8,12,16,24,32,48,64,0}; +int ADnote_unison_sizes[]={1,2,3,4,5,6,8,10,12,15,20,25,30,40,50,0}; ADnoteParameters::ADnoteParameters(FFTwrapper *fft_):Presets() { @@ -102,6 +102,7 @@ void ADnoteParameters::defaults(int n) VoicePar[nvoice].Unison_frequency_spread=30; VoicePar[nvoice].Unison_stereo_spread=64; VoicePar[nvoice].Unison_vibratto=64; + VoicePar[nvoice].Unison_invert_phase=0; VoicePar[nvoice].Type=0; VoicePar[nvoice].Pfixedfreq=0; @@ -285,6 +286,7 @@ void ADnoteParameters::add2XMLsection(XMLwrapper *xml,int n) xml->addpar("unison_frequency_spread",VoicePar[nvoice].Unison_frequency_spread); xml->addpar("unison_stereo_spread",VoicePar[nvoice].Unison_stereo_spread); xml->addpar("unison_vibratto",VoicePar[nvoice].Unison_vibratto); + xml->addpar("unison_invert_phase",VoicePar[nvoice].Unison_invert_phase); xml->addpar("delay",VoicePar[nvoice].PDelay); xml->addparbool("resonance",VoicePar[nvoice].Presonance); @@ -566,6 +568,7 @@ void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n) 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].Unison_vibratto=xml->getpar127("unison_vibratto",VoicePar[nvoice].Unison_vibratto); + VoicePar[nvoice].Unison_invert_phase=xml->getpar127("Unison_invert_phase",VoicePar[nvoice].Unison_invert_phase); VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type); VoicePar[nvoice].PDelay=xml->getpar127("delay",VoicePar[nvoice].PDelay); diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h index 17b39e232..b2abf152d 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h @@ -128,6 +128,9 @@ struct ADnoteVoiceParam { /** Vibratto of the subvoices (which makes the unison more "natural")*/ unsigned char Unison_vibratto; + /** Unison invert phase */ + unsigned char Unison_invert_phase;//0=none,1=random,2=50%,3=33%,4=25% + /** 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 cb17e45a4..b3fdbfe11 100644 --- a/plugins/zynaddsubfx/src/Synth/ADnote.cpp +++ b/plugins/zynaddsubfx/src/Synth/ADnote.cpp @@ -106,10 +106,12 @@ ADnote::ADnote(ADnoteParameters *pars,Controller *ctl_,REALTYPE freq,REALTYPE ve unison_base_freq_rap[nvoice]=new REALTYPE[unison]; unison_freq_rap[nvoice]=new REALTYPE[unison]; + unison_invert_phase[nvoice]=new bool[unison]; REALTYPE unison_spread=pars->VoicePar[nvoice].Unison_frequency_spread/127.0; unison_spread=pow(unison_spread*2.0,2.0)*100.0;//cents REALTYPE unison_real_spread=pow(2.0,(unison_spread*0.5)/1200.0); REALTYPE unison_vibratto_a=pars->VoicePar[nvoice].Unison_vibratto/127.0;//0.0 .. 1.0 + switch (unison){ case 1: @@ -139,7 +141,6 @@ ADnote::ADnote(ADnoteParameters *pars,Controller *ctl_,REALTYPE freq,REALTYPE ve }; //unison vibrattos - if (unison>1){ for (int k=0;kVoicePar[nvoice].Unison_invert_phase; + switch(inv){ + case 0: for (int k=0;k0.5); + break; + default:for (int k=0;k1.0) rvol=1.0; + if (unison_invert_phase[nvoice][k]) { + lvol=-lvol; + rvol=-rvol; + }; + for (i=0;iredraw();} open code3 {o->value(pars->VoicePar[nvoice].Pextoscil+1);} } {} Fl_Group {} {open - xywh {5 525 475 45} box ENGRAVED_BOX + xywh {5 525 515 45} box ENGRAVED_BOX } { Fl_Dial {} { label Stereo @@ -573,11 +573,18 @@ voiceonbutton->redraw();} open } {} Fl_Dial {} { label Vibratto - callback {pars->VoicePar[nvoice].Unison_vibratto=(int)o->value();} selected + callback {pars->VoicePar[nvoice].Unison_vibratto=(int)o->value();} tooltip Vibratto xywh {340 540 25 25} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 code0 {o->value(pars->VoicePar[nvoice].Unison_vibratto);} class WidgetPDial } + Fl_Choice {} { + label Invert + callback {pars->VoicePar[nvoice].Unison_invert_phase=(int) o->value();} open selected + tooltip {Phase Invert} xywh {425 545 70 15} down_box BORDER_BOX labelsize 11 align 5 textfont 1 textsize 10 + code0 {o->add("None");o->add("Random");char tmp[100];for (int i=2;i<=5;i++){snprintf(tmp,100,"%d %%",100/i);o->add(tmp);};} + code1 {o->value(pars->VoicePar[nvoice].Unison_invert_phase);} + } {} } } Fl_Group {} {