aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp')
-rwxr-xr-xplugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp242
1 files changed, 74 insertions, 168 deletions
diff --git a/plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp b/plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp
index b5a5070..101c931 100755
--- a/plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp
+++ b/plugins/LinuxVST/src/PurestWarm/PurestWarmProc.cpp
@@ -14,9 +14,6 @@ void PurestWarm::processReplacing(float **inputs, float **outputs, VstInt32 samp
float* out1 = outputs[0];
float* out2 = outputs[1];
- float fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
int polarity = (int) ( A * 1.999 );
@@ -71,103 +68,55 @@ void PurestWarm::processReplacing(float **inputs, float **outputs, VstInt32 samp
if (inputSampleL < 0)
{
inputSampleL = -(sin(-inputSampleL*1.57079634)/1.57079634);
- //noise shaping to 32-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- }
+ //stereo 32 bit dither, made small and tidy.
+ int expon; frexpf((float)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexpf((float)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 32 bit dither
}
-
if (inputSampleR < 0)
{
inputSampleR = -(sin(-inputSampleR*1.57079634)/1.57079634);
- //noise shaping to 32-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- }
+ //stereo 32 bit dither, made small and tidy.
+ int expon; frexpf((float)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexpf((float)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 32 bit dither
}
-
} else {
-
if (inputSampleL > 0)
{
inputSampleL = sin(inputSampleL*1.57079634)/1.57079634;
- //noise shaping to 32-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- }
- }
+ //stereo 32 bit dither, made small and tidy.
+ int expon; frexpf((float)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexpf((float)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 32 bit dither
+ }
if (inputSampleR > 0)
{
inputSampleR = sin(inputSampleR*1.57079634)/1.57079634;
- //noise shaping to 32-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- }
- }
-
+ //stereo 32 bit dither, made small and tidy.
+ int expon; frexpf((float)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexpf((float)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 32 bit dither
+ }
}
//that's it. Only applies on one half of the waveform, other half is passthrough untouched.
- //even the floating point noise shaping to the 32 bit buss is only applied as needed.
-
- fpFlip = !fpFlip;
- //end noise shaping on 32 bit output
*out1 = inputSampleL;
*out2 = inputSampleR;
@@ -186,9 +135,6 @@ void PurestWarm::processDoubleReplacing(double **inputs, double **outputs, VstIn
double* out1 = outputs[0];
double* out2 = outputs[1];
- double fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
int polarity = (int) ( A * 1.999 );
@@ -243,103 +189,63 @@ void PurestWarm::processDoubleReplacing(double **inputs, double **outputs, VstIn
if (inputSampleL < 0)
{
inputSampleL = -(sin(-inputSampleL*1.57079634)/1.57079634);
- //noise shaping to 64-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- }
+ //stereo 64 bit dither, made small and tidy.
+ int expon; frexp((double)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexp((double)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 64 bit dither
}
if (inputSampleR < 0)
{
inputSampleR = -(sin(-inputSampleR*1.57079634)/1.57079634);
- //noise shaping to 64-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- }
+ //stereo 64 bit dither, made small and tidy.
+ int expon; frexp((double)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexp((double)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 64 bit dither
}
-
} else {
-
if (inputSampleL > 0)
{
inputSampleL = sin(inputSampleL*1.57079634)/1.57079634;
- //noise shaping to 64-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- }
+ //stereo 64 bit dither, made small and tidy.
+ int expon; frexp((double)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexp((double)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 64 bit dither
}
-
if (inputSampleR > 0)
{
inputSampleR = sin(inputSampleR*1.57079634)/1.57079634;
- //noise shaping to 64-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
- } else {
- if (fpFlip) {
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- } else {
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- }
+ //stereo 64 bit dither, made small and tidy.
+ int expon; frexp((double)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexp((double)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 64 bit dither
}
-
}
//that's it. Only applies on one half of the waveform, other half is passthrough untouched.
- //even the floating point noise shaping to the 32 bit buss is only applied as needed.
-
- fpFlip = !fpFlip;
- //end noise shaping on 64 bit output
*out1 = inputSampleL;
*out2 = inputSampleR;