mirror of
https://github.com/airwindows/airwindows.git
synced 2026-05-21 06:46:21 -06:00
Big Double/Denormalization Update
This commit is contained in:
parent
47e16fec36
commit
54fd8c7a18
3302 changed files with 52490 additions and 63509 deletions
|
|
@ -174,7 +174,7 @@ ComponentResult PyewacketMono::Initialize()
|
|||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void PyewacketMono::PyewacketMonoKernel::Reset()
|
||||
{
|
||||
fpNShape = 0.0;
|
||||
fpd = 1.0; while (fpd < 16386) fpd = rand()*UINT32_MAX;
|
||||
chase = 1.0;
|
||||
lastrectifier = 0.0;
|
||||
}
|
||||
|
|
@ -196,10 +196,10 @@ void PyewacketMono::PyewacketMonoKernel::Process( const Float32 *inSourceP,
|
|||
overallscale *= GetSampleRate();
|
||||
if (overallscale < 0.1) overallscale = 1.0;
|
||||
//insanity check
|
||||
long double fpOld = 0.618033988749894848204586; //golden ratio!
|
||||
long double fpNew = 1.0 - fpOld;
|
||||
long double inputSample;
|
||||
long double drySample;
|
||||
double fpOld = 0.618033988749894848204586; //golden ratio!
|
||||
double fpNew = 1.0 - fpOld;
|
||||
double inputSample;
|
||||
double drySample;
|
||||
Float64 bridgerectifier;
|
||||
Float64 temprectifier;
|
||||
Float64 inputSense;
|
||||
|
|
@ -217,30 +217,7 @@ void PyewacketMono::PyewacketMonoKernel::Process( const Float32 *inSourceP,
|
|||
|
||||
while (nSampleFrames-- > 0) {
|
||||
inputSample = *sourceP;
|
||||
if (inputSample<1.2e-38 && -inputSample<1.2e-38) {
|
||||
static int noisesource = 0;
|
||||
//this declares a variable before anything else is compiled. It won't keep assigning
|
||||
//it to 0 for every sample, it's as if the declaration doesn't exist in this context,
|
||||
//but it lets me add this denormalization fix in a single place rather than updating
|
||||
//it in three different locations. The variable isn't thread-safe but this is only
|
||||
//a random seed and we can share it with whatever.
|
||||
noisesource = noisesource % 1700021; noisesource++;
|
||||
int residue = noisesource * noisesource;
|
||||
residue = residue % 170003; residue *= residue;
|
||||
residue = residue % 17011; residue *= residue;
|
||||
residue = residue % 1709; residue *= residue;
|
||||
residue = residue % 173; residue *= residue;
|
||||
residue = residue % 17;
|
||||
double applyresidue = residue;
|
||||
applyresidue *= 0.00000001;
|
||||
applyresidue *= 0.00000001;
|
||||
inputSample = applyresidue;
|
||||
//this denormalization routine produces a white noise at -300 dB which the noise
|
||||
//shaping will interact with to produce a bipolar output, but the noise is actually
|
||||
//all positive. That should stop any variables from going denormal, and the routine
|
||||
//only kicks in if digital black is input. As a final touch, if you save to 24-bit
|
||||
//the silence will return to being digital black again.
|
||||
}
|
||||
if (fabs(inputSample)<1.18e-23) inputSample = fpd * 1.18e-17;
|
||||
|
||||
|
||||
|
||||
|
|
@ -280,11 +257,11 @@ void PyewacketMono::PyewacketMonoKernel::Process( const Float32 *inSourceP,
|
|||
inputSample *= outputGain;
|
||||
}
|
||||
|
||||
//32 bit dither, made small and tidy.
|
||||
int expon; frexpf((Float32)inputSample, &expon);
|
||||
long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
|
||||
inputSample += (dither-fpNShape); fpNShape = dither;
|
||||
//end 32 bit dither
|
||||
//begin 32 bit floating point dither
|
||||
int expon; frexpf((float)inputSample, &expon);
|
||||
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
|
||||
inputSample += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
|
||||
//end 32 bit floating point dither
|
||||
|
||||
*destP = inputSample;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue