commit 080289bc32f48dac8b847265b655523b9597cfa6
parent 0999dda74d419fb97bf0d4474d8f3d5abf977570
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Mon, 22 Aug 2011 08:30:08 -0400
Effects: imported equal power panning from yoshimi
- Panning is now in Effect rather than subclasses
- Panning is power equal
Diffstat:
18 files changed, 64 insertions(+), 145 deletions(-)
diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp
@@ -67,7 +67,7 @@ void Alienwah::out(const Stereo<float *> &smp)
complex<float> tmp = clfol * x + oldclfol * x1;
complex<float>out = tmp * oldl[oldk];
- out.real() += (1 - fabs(fb)) * smp.l[i] * (1.0 - panning);
+ out.real() += (1 - fabs(fb)) * smp.l[i] * pangainL;
oldl[oldk] = out;
float l = out.real() * 10.0 * (fb + 0.1);
@@ -76,7 +76,7 @@ void Alienwah::out(const Stereo<float *> &smp)
tmp = clfor * x + oldclfor * x1;
out = tmp * oldr[oldk];
- out.real() += (1 - fabs(fb)) * smp.r[i] * (1.0 - panning);
+ out.real() += (1 - fabs(fb)) * smp.r[i] * pangainR;
oldr[oldk] = out;
float r = out.real() * 10.0 * (fb + 0.1);
@@ -137,18 +137,6 @@ void Alienwah::setvolume(unsigned char Pvolume)
volume = outvolume;
}
-void Alienwah::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = Ppanning / 127.0;
-}
-
-void Alienwah::setlrcross(unsigned char Plrcross)
-{
- this->Plrcross = Plrcross;
- lrcross = Plrcross / 127.0;
-}
-
void Alienwah::setphase(unsigned char Pphase)
{
this->Pphase = Pphase;
diff --git a/src/Effects/Alienwah.h b/src/Effects/Alienwah.h
@@ -57,25 +57,21 @@ class Alienwah:public Effect
//Alienwah Parameters
EffectLFO lfo; //lfo-ul Alienwah
unsigned char Pvolume;
- unsigned char Ppanning;
unsigned char Pdepth; //the depth of the Alienwah
unsigned char Pfb; //feedback
- unsigned char Plrcross; //feedback
unsigned char Pdelay;
unsigned char Pphase;
//Control Parameters
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setfb(unsigned char Pfb);
- void setlrcross(unsigned char Plrcross);
void setdelay(unsigned char Pdelay);
void setphase(unsigned char Pphase);
//Internal Values
- float panning, fb, depth, lrcross, phase;
+ float fb, depth, phase;
complex<float> *oldl, *oldr;
complex<float> oldclfol, oldclfor;
int oldk;
diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp
@@ -79,11 +79,11 @@ void Chorus::out(const Stereo<float *> &input)
dr2 = getdelay(lfor);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
+
float inl = input.l[i];
float inr = input.r[i];
//LRcross
Stereo<float> tmpc(inl, inr);
- //float r=inr;
inl = tmpc.l * (1.0 - lrcross) + tmpc.r * lrcross;
inr = tmpc.r * (1.0 - lrcross) + tmpc.l * lrcross;
@@ -129,8 +129,8 @@ void Chorus::out(const Stereo<float *> &input)
}
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- efxoutl[i] *= panning;
- efxoutr[i] *= (1.0 - panning);
+ efxoutl[i] *= pangainL;
+ efxoutr[i] *= pangainR;
}
}
@@ -173,17 +173,6 @@ void Chorus::setvolume(unsigned char Pvolume)
volume = outvolume;
}
-void Chorus::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = Ppanning / 127.0;
-}
-
-void Chorus::setlrcross(unsigned char Plrcross)
-{
- this->Plrcross = Plrcross;
- lrcross = Plrcross / 127.0;
-}
void Chorus::setpreset(unsigned char npreset)
{
diff --git a/src/Effects/Chorus.h b/src/Effects/Chorus.h
@@ -83,25 +83,21 @@ class Chorus:public Effect
//Chorus Parameters
EffectLFO lfo; //lfo-ul chorus
unsigned char Pvolume;
- unsigned char Ppanning;
unsigned char Pdepth; //the depth of the Chorus(ms)
unsigned char Pdelay; //the delay (ms)
unsigned char Pfb; //feedback
- unsigned char Plrcross; //feedback
unsigned char Pflangemode; //how the LFO is scaled, to result chorus or flange
unsigned char Poutsub; //if I wish to substract the output instead of the adding it
//Parameter Controls
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setdelay(unsigned char Pdelay);
void setfb(unsigned char Pfb);
- void setlrcross(unsigned char Plrcross);
//Internal Values
- float depth, delay, fb, lrcross, panning;
+ float depth, delay, fb;
float dl1, dl2, dr1, dr2, lfol, lfor;
int maxdelay;
Stereo<Sample> delaySample;
diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp
@@ -38,7 +38,6 @@ Distorsion::Distorsion(const int &insertion_,
//default values
Pvolume = 50;
- Plrcross = 40;
Pdrive = 90;
Plevel = 64;
Ptype = 0;
@@ -101,15 +100,13 @@ void Distorsion::out(const Stereo<float *> &smp)
if(Pstereo != 0) { //Stereo
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
- efxoutl[i] = smp.l[i] * inputvol * panning;
- efxoutr[i] = smp.r[i] * inputvol * (1.0 - panning);
+ efxoutl[i] = smp.l[i] * inputvol * pangainL;
+ efxoutr[i] = smp.r[i] * inputvol * pangainR;
}
}
else {
for(i = 0; i < SOUND_BUFFER_SIZE; i++)
- efxoutl[i] =
- (smp.l[i] * panning + smp.r[i] * (1.0 - panning)) * inputvol;
- ;
+ efxoutl[i] = (smp.l[i] * pangainL + smp.r[i] * pangainR) * inputvol;
}
if(Pprefiltering != 0)
@@ -160,19 +157,6 @@ void Distorsion::setvolume(unsigned char Pvolume)
cleanup();
}
-void Distorsion::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = (Ppanning + 0.5) / 127.0;
-}
-
-
-void Distorsion::setlrcross(unsigned char Plrcross)
-{
- this->Plrcross = Plrcross;
- lrcross = Plrcross / 127.0 * 1.0;
-}
-
void Distorsion::setlpf(unsigned char Plpf)
{
this->Plpf = Plpf;
diff --git a/src/Effects/Distorsion.h b/src/Effects/Distorsion.h
@@ -42,8 +42,6 @@ class Distorsion:public Effect
private:
//Parametrii
unsigned char Pvolume; //Volume or E/R
- unsigned char Ppanning; //Panning
- unsigned char Plrcross; // L/R Mixing
unsigned char Pdrive; //the input amplification
unsigned char Plevel; //the output amplification
unsigned char Ptype; //Distorsion type
@@ -54,13 +52,10 @@ class Distorsion:public Effect
unsigned char Pprefiltering; //if you want to do the filtering before the distorsion
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
- void setlrcross(unsigned char Plrcross);
void setlpf(unsigned char Plpf);
void sethpf(unsigned char Phpf);
//Real Parameters
- float panning, lrcross;
class AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
};
diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp
@@ -28,7 +28,7 @@ DynamicFilter::DynamicFilter(int insertion_,
float *efxoutl_,
float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, new FilterParams(0, 64, 64), 0),
- Pvolume(110), Ppanning(64), Pdepth(0), Pampsns(90),
+ Pvolume(110), Pdepth(0), Pampsns(90),
Pampsnsinv(0), Pampsmooth(60),
filterl(NULL), filterr(NULL)
{
@@ -87,8 +87,8 @@ void DynamicFilter::out(const Stereo<float *> &smp)
//panning
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- efxoutl[i] *= panning;
- efxoutr[i] *= (1.0 - panning);
+ efxoutl[i] *= pangainL;
+ efxoutr[i] *= pangainR;
}
}
@@ -126,13 +126,6 @@ void DynamicFilter::setvolume(unsigned char Pvolume)
volume = outvolume;
}
-void DynamicFilter::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = Ppanning / 127.0;
-}
-
-
void DynamicFilter::setampsns(unsigned char Pampsns)
{
ampsns = pow(Pampsns / 127.0, 2.5) * 10.0;
diff --git a/src/Effects/DynamicFilter.h b/src/Effects/DynamicFilter.h
@@ -43,7 +43,6 @@ class DynamicFilter:public Effect
//Parametrii DynamicFilter
EffectLFO lfo; //lfo-ul DynamicFilter
unsigned char Pvolume; //Volume
- unsigned char Ppanning; //Pan
unsigned char Pdepth; //the depth of the lfo of the DynamicFilter
unsigned char Pampsns; //how the filter varies according to the input amplitude
unsigned char Pampsnsinv; //if the filter freq is lowered if the input amplitude rises
@@ -51,14 +50,13 @@ class DynamicFilter:public Effect
//Parameter Control
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setampsns(unsigned char Pampsns);
void reinitfilter();
//Internal Values
- float panning, depth, ampsns, ampsmooth;
+ float depth, ampsns, ampsmooth;
class Filter *filterl, *filterr;
diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp
@@ -31,8 +31,8 @@ Echo::Echo(const int &insertion_,
float *const efxoutl_,
float *const efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0),
- Pvolume(50), Ppanning(64), Pdelay(60),
- Plrdelay(100), Plrcross(100), Pfb(40), Phidamp(60),
+ Pvolume(50), Pdelay(60),
+ Plrdelay(100), Pfb(40), Phidamp(60),
delayTime(1), lrdelay(0), avgDelay(0),
delay(new float[(int)(MAX_DELAY * SAMPLE_RATE)],
new float[(int)(MAX_DELAY * SAMPLE_RATE)]),
@@ -92,8 +92,8 @@ void Echo::out(const Stereo<float *> &input)
efxoutl[i] = ldl * 2.0;
efxoutr[i] = rdl * 2.0;
- ldl = input.l[i] * panning - ldl * fb;
- rdl = input.r[i] * (1.0 - panning) - rdl * fb;
+ ldl = input.l[i] * pangainL - ldl * fb;
+ rdl = input.r[i] * pangainR - rdl * fb;
//LowPass Filter
old.l = delay.l[(pos.l+delta.l)%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l * (1.0 - hidamp);
@@ -127,17 +127,10 @@ void Echo::setvolume(unsigned char Pvolume)
}
else
volume = outvolume = Pvolume / 127.0;
- ;
if(Pvolume == 0)
cleanup();
}
-void Echo::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = (Ppanning + 0.5) / 127.0;
-}
-
void Echo::setdelay(unsigned char Pdelay)
{
this->Pdelay=Pdelay;
@@ -157,12 +150,6 @@ void Echo::setlrdelay(unsigned char Plrdelay)
initdelays();
}
-void Echo::setlrcross(unsigned char Plrcross)
-{
- this->Plrcross = Plrcross;
- lrcross = Plrcross / 127.0 * 1.0;
-}
-
void Echo::setfb(unsigned char Pfb)
{
this->Pfb = Pfb;
diff --git a/src/Effects/Echo.h b/src/Effects/Echo.h
@@ -100,23 +100,19 @@ class Echo:public Effect
private:
//Parameters
char Pvolume; /**<#1 Volume or Dry/Wetness*/
- char Ppanning; /**<#2 Panning*/
char Pdelay; /**<#3 Delay of the Echo*/
char Plrdelay; /**<#4 L/R delay difference*/
- char Plrcross; /**<#5 L/R Mixing*/
char Pfb; /**<#6Feedback*/
char Phidamp; /**<#7Dampening of the Echo*/
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
void setdelay(unsigned char Pdelay);
void setlrdelay(unsigned char Plrdelay);
- void setlrcross(unsigned char Plrcross);
void setfb(unsigned char Pfb);
void sethidamp(unsigned char Phidamp);
//Real Parameters
- float panning, lrcross, fb, hidamp;
+ float fb, hidamp;
//Left/Right delay lengths
Stereo<int> delayTime;
float lrdelay;
diff --git a/src/Effects/Effect.cpp b/src/Effects/Effect.cpp
@@ -3,6 +3,7 @@
Effect.cpp - this class is inherited by the all effects(Reverb, Echo, ..)
Copyright (C) 2002-2005 Nasca Octavian Paul
+ Copyright 2011, Alan Calvert
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
@@ -22,6 +23,7 @@
#include "Effect.h"
#include "../Params/FilterParams.h"
+#include <cmath>
Effect::Effect(bool insertion_, float *const efxoutl_,
float *const efxoutr_, FilterParams *filterpars_,
@@ -33,5 +35,26 @@ Effect::Effect(bool insertion_, float *const efxoutl_,
void Effect::out(float *const smpsl, float *const smpsr)
{
out(Stereo<float *>(smpsl,smpsr));
-};
+}
+void Effect::crossover(float &a, float &b, float crossover)
+{
+ float tmpa = a;
+ float tmpb = b;
+ a = tmpa * (1.0 - crossover) + tmpb * crossover;
+ b = tmpb * (1.0 - crossover) + tmpa * crossover;
+}
+
+void Effect::setpanning(char Ppanning_)
+{
+ Ppanning = Ppanning_;
+ float t = (Ppanning > 0) ? (float)(Ppanning - 1) / 126.0f : 0.0f;
+ pangainL = cos(t * PI / 2.0f);
+ pangainR = cos((1.0f - t) * PI / 2.0f);
+}
+
+void Effect::setlrcross(char Plrcross_)
+{
+ Plrcross = Plrcross_;
+ lrcross = (float)Plrcross / 127.0f;
+}
diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h
@@ -96,10 +96,22 @@ class Effect
float volume;
FilterParams *filterpars; /**<Parameters for filters used by Effect*/
+
+ //Perform L/R crossover
+ static void crossover(float &a, float &b, float crossover);
+
protected:
+ void setpanning(char Ppanning_);
+ void setlrcross(char Plrcross_);
const bool insertion;/**<If Effect is an insertion effect, insertion=1
*otherwise, it should be insertion=0*/
+ //panning parameters
+ char Ppanning;
+ float pangainL;
+ float pangainR;
+ char Plrcross; // L/R mix
+ float lrcross;
};
#endif
diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp
@@ -132,8 +132,7 @@ void Phaser::AnalogPhase(const Stereo<float *> &input)
g.l += diff.l;// Linear interpolation between LFO samples
g.r += diff.r;
- Stereo<float> xn(input.l[i] * panning,
- input.r[i] * (1.0f - panning));
+ Stereo<float> xn(input.l[i] * pangainL, input.r[i] * pangainR);
if (barber) {
g.l = fmodf((g.l + 0.25f), ONE_);
@@ -202,8 +201,8 @@ void Phaser::normalPhase(const Stereo<float *> &input)
float x = (float) i / SOUND_BUFFER_SIZE;
float x1 = 1.0 - x;
//TODO think about making panning an external feature
- Stereo<float> xn(input.l[i] * panning + fb.l,
- input.r[i] * (1.0 - panning) + fb.r);
+ Stereo<float> xn(input.l[i] * pangainL + fb.l,
+ input.r[i] * pangainR + fb.r);
Stereo<float> g(gain.l * x + oldgain.l * x1,
gain.r * x + oldgain.r * x1);
@@ -281,18 +280,6 @@ void Phaser::setvolume(unsigned char Pvolume)
volume = outvolume;
}
-void Phaser::setpanning(unsigned char Ppanning)
-{
- this->Ppanning = Ppanning;
- panning = (float)Ppanning / 127.0;
-}
-
-void Phaser::setlrcross(unsigned char Plrcross)
-{
- this->Plrcross = Plrcross;
- lrcross = Plrcross / 127.0;
-}
-
void Phaser::setdistortion(unsigned char Pdistortion)
{
this->Pdistortion = Pdistortion;
diff --git a/src/Effects/Phaser.h b/src/Effects/Phaser.h
@@ -47,13 +47,11 @@ class Phaser:public Effect
//Phaser parameters
EffectLFO lfo; //Phaser modulator
unsigned char Pvolume; //Used to set wet/dry mix
- unsigned char Ppanning;
unsigned char Pdistortion; //Model distortion added by FET element
unsigned char Pdepth; //Depth of phaser sweep
unsigned char Pwidth; //Phaser width (LFO amplitude)
unsigned char Pfb; //feedback
unsigned char Poffset; //Model mismatch between variable resistors
- unsigned char Plrcross; //crossover
unsigned char Pstages; //Number of first-order All-Pass stages
unsigned char Poutsub; //if I wish to subtract the output instead of adding
unsigned char Pphase;
@@ -62,20 +60,18 @@ class Phaser:public Effect
//Control parameters
void setvolume(unsigned char Pvolume);
- void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setfb(unsigned char Pfb);
void setdistortion(unsigned char Pdistortion);
void setwidth(unsigned char Pwidth);
void setoffset(unsigned char Poffset);
- void setlrcross(unsigned char Plrcross);
void setstages(unsigned char Pstages);
void setphase(unsigned char Pphase);
//Internal Variables
bool barber; //Barber pole phasing flag
float distortion, width, offsetpct;
- float panning, feedback, depth, lrcross, phase;
+ float feedback, depth, phase;
Stereo<float *> old, xn1, yn1;
Stereo<float> diff, oldgain, fb;
float invperiod;
diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp
@@ -34,7 +34,6 @@ Reverb::Reverb(const int &insertion_, float *efxoutl_, float *efxoutr_)
//defaults
Pvolume = 48;
- Ppan = 64;
Ptime = 64;
Pidelay = 40;
Pidelayfb = 0;
@@ -190,8 +189,8 @@ void Reverb::out(const Stereo<float *> &smp)
processmono(1, efxoutr, inputbuf); //right
returnTmpBuffer(inputbuf);
- float lvol = rs / REV_COMBS * pan;
- float rvol = rs / REV_COMBS * (1.0 - pan);
+ float lvol = rs / REV_COMBS * pangainL;
+ float rvol = rs / REV_COMBS * pangainR;
if(insertion != 0) {
lvol *= 2;
rvol *= 2;
@@ -220,12 +219,6 @@ void Reverb::setvolume(unsigned char Pvolume)
}
}
-void Reverb::setpan(unsigned char Ppan)
-{
- this->Ppan = Ppan;
- pan = (float)Ppan / 127.0;
-}
-
void Reverb::settime(unsigned char Ptime)
{
int i;
@@ -463,7 +456,7 @@ void Reverb::changepar(int npar, unsigned char value)
setvolume(value);
break;
case 1:
- setpan(value);
+ setpanning(value);
break;
case 2:
settime(value);
@@ -505,7 +498,7 @@ unsigned char Reverb::getpar(int npar) const
{
switch(npar) {
case 0: return Pvolume;
- case 1: return Ppan;
+ case 1: return Ppanning;
case 2: return Ptime;
case 3: return Pidelay;
case 4: return Pidelayfb;
diff --git a/src/Effects/Reverb.h b/src/Effects/Reverb.h
@@ -51,9 +51,6 @@ class Reverb:public Effect
/**Amount of the reverb*/
unsigned char Pvolume;
- /**Left/Right Panning*/
- unsigned char Ppan;
-
/**duration of reverb*/
unsigned char Ptime;
@@ -90,7 +87,6 @@ class Reverb:public Effect
//parameter control
void setvolume(unsigned char Pvolume);
- void setpan(unsigned char Ppan);
void settime(unsigned char Ptime);
void setlohidamp(unsigned char Plohidamp);
void setidelay(unsigned char Pidelay);
@@ -101,7 +97,7 @@ class Reverb:public Effect
void setroomsize(unsigned char Proomsize);
void setbandwidth(unsigned char Pbandwidth);
- float pan, erbalance;
+ float erbalance;
//Parameters
int lohidamptype; /**<0=disable,1=highdamp(lowpass),2=lowdamp(highpass)*/
int idelaylen, rdelaylen;
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
@@ -147,14 +147,6 @@ void invSignal(float *sig, size_t len)
sig[i] *= -1.0f;
}
-void crossover(float &a, float &b, float crossover)
-{
- float tmpa = a;
- float tmpb = b;
- a = tmpa * (1.0 - crossover) + tmpb * crossover;
- b = tmpb * (1.0 - crossover) + tmpa * crossover;
-}
-
//Some memory pools for short term buffer use
//(avoid the use of new in RT thread(s))
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
@@ -55,8 +55,6 @@ extern class Config config;
void invSignal(float *sig, size_t len);
-void crossover(float &a, float &b, float crossover);
-
//Memory pool for temporary buffers
//No allocation in *normal* case
//All should be sized to SOUND_BUFFER_SIZE