Added unison invert phase

(cherry picked from commit 5302e6d9c97ae6435bbc0d68a412dbfe3cb03044)
This commit is contained in:
Paul
2009-09-23 20:47:32 +03:00
committed by Tobias Doerffel
parent f8b8ea9686
commit f2362df5fb
6 changed files with 47 additions and 6 deletions

View File

@@ -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

View File

@@ -25,7 +25,7 @@
#include <math.h>
#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);

View File

@@ -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;

View File

@@ -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;k<unison;k++){//reduce the frequency difference for larger vibrattos
unison_base_freq_rap[nvoice][k]=1.0+(unison_base_freq_rap[nvoice][k]-1.0)*(1.0-unison_vibratto_a);
@@ -166,6 +167,21 @@ ADnote::ADnote(ADnoteParameters *pars,Controller *ctl_,REALTYPE freq,REALTYPE ve
unison_vibratto[nvoice].position[0]=0.0;
unison_vibratto[nvoice].amplitude=0.0;
};
//phase invert for unison
unison_invert_phase[nvoice][0]=false;
if (unison!=1){
int inv=pars->VoicePar[nvoice].Unison_invert_phase;
switch(inv){
case 0: for (int k=0;k<unison;k++) unison_invert_phase[nvoice][k]=false;
break;
case 1: for (int k=0;k<unison;k++) unison_invert_phase[nvoice][k]=(RND>0.5);
break;
default:for (int k=0;k<unison;k++) unison_invert_phase[nvoice][k]=(k%inv==0)?true:false;
break;
};
};
oscfreqhi[nvoice]=new int[unison];
oscfreqlo[nvoice]=new REALTYPE[unison];
@@ -513,7 +529,6 @@ void ADnote::ADlegatonote(REALTYPE freq, REALTYPE velocity, int portamento_, int
if ((NoteVoicePar[i].FMVoice==nvoice)&&(tmp[i]==0)) {
tmp[i]=1;
};
/// if (NoteVoicePar[nvoice].VoiceOut!=NULL) for (i=0;i<SOUND_BUFFER_SIZE;i++) NoteVoicePar[nvoice].VoiceOut[i]=0.0;
};
///////////////
@@ -539,6 +554,7 @@ void ADnote::KillVoice(int nvoice)
delete []NoteVoicePar[nvoice].OscilSmp;
delete []unison_base_freq_rap[nvoice];
delete []unison_freq_rap[nvoice];
delete []unison_invert_phase[nvoice];
delete []FMoldsmp[nvoice];
delete []unison_vibratto[nvoice].step;
delete []unison_vibratto[nvoice].position;
@@ -1325,7 +1341,7 @@ int ADnote::noteout(REALTYPE *outl,REALTYPE *outr)
// Voice Processing
//mix subvoices into
//mix subvoices into voice
for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpwavel[i]=0.0;
if (stereo) for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpwaver[i]=0.0;
for (int k=0;k<unison_size[nvoice];k++){
@@ -1350,6 +1366,11 @@ int ADnote::noteout(REALTYPE *outl,REALTYPE *outr)
REALTYPE rvol=panning*2.0;
if (rvol>1.0) rvol=1.0;
if (unison_invert_phase[nvoice][k]) {
lvol=-lvol;
rvol=-rvol;
};
for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpwavel[i]+=tw[i]*lvol;
for (i=0;i<SOUND_BUFFER_SIZE;i++) tmpwaver[i]+=tw[i]*rvol;
}else{

View File

@@ -239,6 +239,9 @@ private:
//how the unison subvoice's frequency is changed (1.0 for no change)
REALTYPE *unison_freq_rap[NUM_VOICES];
//which subvoice has phase inverted
bool *unison_invert_phase[NUM_VOICES];
//unison vibratto
struct {

View File

@@ -549,7 +549,7 @@ voiceonbutton->redraw();} 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 {} {