|
|
@@ -1184,7 +1184,7 @@ class WAHWAH extends Shader { |
|
|
|
lfoskip = freq * 2 * PI / mCurRate; |
|
|
|
skipcount = xn1 = xn2 = yn1 = yn2 = b0 = b1 = b2 = a0 = a1 = a2 = 0; |
|
|
|
sequence = startsequence; |
|
|
|
|
|
|
|
|
|
|
|
renderer.beginDraw(); |
|
|
|
renderer.colorMode(RGB); |
|
|
|
renderer.loadPixels(); |
|
|
@@ -1224,8 +1224,125 @@ class WAHWAH extends Shader { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
PHASER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class PHASER extends Shader { |
|
|
|
float samplerate = 92230.0; // try setting this to 44100.0 or 2048.5 for kicks |
|
|
|
int mode; |
|
|
|
PHASER() { |
|
|
|
name ="fxPhaser"; |
|
|
|
params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); |
|
|
|
params.add(new Param ("frequency", FLOATVAL, 0.4, 4.0, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("dry/wet", INTVAL, 0, 255, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("depth", INTVAL, 0, 255, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("feedback", INTVAL, -100, 100, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("phase", FLOATVAL, 0, TWO_PI, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("stages", INTVAL, 1, 24, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
params.add(new Param ("sample rate", FLOATVAL, 512, 92230, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
|
|
|
|
|
|
|
|
//params.add(new Param ("frequency offset", FLOATVAL, 0, 1, new int[]{TRIANG, SINE, RAMPUPDOWN })); |
|
|
|
} |
|
|
|
/* |
|
|
|
mDepth = (int) map(knobZero, 0, 255, 255, 0); |
|
|
|
mFeedback = (int) map(knobOne, 0, 255, -100, 100); |
|
|
|
// enable these for some more fun :) |
|
|
|
if (mode == 1) { |
|
|
|
mSampleRate = map(knobTwo, 0, 255, 1, 512); |
|
|
|
mStages = (int) ( 2*map(knobThree, 0, 255, 1, 12)); |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
void apply() { |
|
|
|
mode = (int)params.get(0).value; |
|
|
|
float mFreq = params.get(1).value; |
|
|
|
int mDryWet = (int)params.get(2).value; |
|
|
|
int mDepth = (int)params.get(3).value; |
|
|
|
int mFeedback = (int)params.get(4).value; |
|
|
|
float mPhase = params.get(5).value; |
|
|
|
|
|
|
|
//these two are only changed if mode = 1 |
|
|
|
int mStages = 2; |
|
|
|
float mSampleRate = samplerate; |
|
|
|
|
|
|
|
renderer.beginDraw(); |
|
|
|
renderer.colorMode(RGB); |
|
|
|
renderer.loadPixels(); |
|
|
|
|
|
|
|
|
|
|
|
//constants |
|
|
|
float phaserlfoshape = 4.0; |
|
|
|
int lfoskipsamples = 20; //how many samples are processed before recomputing lfo |
|
|
|
int numStages = 24; |
|
|
|
|
|
|
|
|
|
|
|
//getParams |
|
|
|
/* |
|
|
|
Phaser Parameters |
|
|
|
mFreq - Phaser's LFO frequency |
|
|
|
mPhase - Phaser's LFO startsequence (radians), needed for stereo Phasers |
|
|
|
mDepth - Phaser depth (0 - no depth, 255 - max depth) |
|
|
|
mStages - Phaser stages (recomanded from 2 to 16-24, and EVEN NUMBER) |
|
|
|
mDryWet - Dry/wet mix, (0 - dry, 128 - dry=wet, 255 - wet) |
|
|
|
mFeedback - Phaser FeedBack (0 - no feedback, 100 = 100% Feedback, |
|
|
|
-100 = -100% FeedBack) |
|
|
|
*/ |
|
|
|
// enable these for some more fun :) |
|
|
|
if (mode == 1) { |
|
|
|
mStages = (int)params.get(6).value; |
|
|
|
mSampleRate = params.get(7).value; |
|
|
|
} |
|
|
|
//init |
|
|
|
float gain = 0, fbout = 0; |
|
|
|
float lfoskip = mFreq * 2 * PI / mSampleRate; |
|
|
|
float sequence = mPhase * PI / 180; |
|
|
|
|
|
|
|
float[] old = new float[mStages]; |
|
|
|
for ( int j = 0; j < mStages; j++) { |
|
|
|
old[j] = 0.0; |
|
|
|
} |
|
|
|
|
|
|
|
/* EffectPhaser::ProcessBlock */ |
|
|
|
int skipcount = 0; |
|
|
|
|
|
|
|
float[] rgb = new float[3]; |
|
|
|
for ( int i = 0, l = renderer.pixels.length; i<l; i++ ) { |
|
|
|
color c = renderer.pixels[i]; |
|
|
|
rgb[0] = map(red(c), 0, 255, 0, 1); |
|
|
|
rgb[1] = map(green(c), 0, 255, 0, 1); |
|
|
|
rgb[2] = map(blue(c), 0, 255, 0, 1); |
|
|
|
for ( int ci = 0; ci < 3; ci++) { |
|
|
|
float in = rgb[ci]; |
|
|
|
float m = in + fbout * mFeedback / 100; |
|
|
|
if ( (( skipcount++) % lfoskipsamples ) == 0 ) { //recomopute lfo |
|
|
|
gain = (1.0 + cos(skipcount * lfoskip + sequence)) / 2.0; //compute sine between 0 and 1 |
|
|
|
gain = exp(gain * phaserlfoshape) / exp(phaserlfoshape); // change lfo shape |
|
|
|
gain = 1.0 - gain / 255.0 * mDepth; // attenuate the lfo |
|
|
|
} |
|
|
|
//phasing routine |
|
|
|
for ( int j = 0; j<mStages; j++) { |
|
|
|
float tmp = old[j]; |
|
|
|
old[j] = gain * tmp + m; |
|
|
|
m = tmp - gain * old[j]; |
|
|
|
} |
|
|
|
fbout = m; |
|
|
|
rgb[ci] = (float) (( m * mDryWet + in * (255-mDryWet)) / 255); |
|
|
|
} |
|
|
|
color rc = color( |
|
|
|
map(rgb[0], 0, 1, 0, 255), |
|
|
|
map(rgb[1], 0, 1, 0, 255), |
|
|
|
map(rgb[2], 0, 1, 0, 255)); |
|
|
|
renderer.pixels[i] = rc; |
|
|
|
} |
|
|
|
renderer.updatePixels(); |
|
|
|
renderer.endDraw(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|