RawTimbers Redux

This commit is contained in:
Chris Johnson 2020-09-20 20:41:06 -04:00
parent 94fd1a76ee
commit 91b0ca3ecc
16 changed files with 487 additions and 109 deletions

View file

@ -49,8 +49,8 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 566520818;
PBXWorkspaceStateSaveDate = 566520818;
PBXPerProjectTemplateStateSaveDate = 615684415;
PBXWorkspaceStateSaveDate = 615684415;
};
sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */;
userBuildSettings = {
@ -58,18 +58,18 @@
};
2407DEB6089929BA00EB68BF /* RawTimbers.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {848, 1092}}";
sepNavSelRange = "{2350, 0}";
sepNavVisRange = "{1077, 1857}";
sepNavWindowFrame = "{{12, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {848, 1755}}";
sepNavSelRange = "{4449, 0}";
sepNavVisRange = "{2690, 2222}";
sepNavWindowFrame = "{{12, 57}, {895, 821}}";
};
};
245463B80991757100464AD3 /* RawTimbers.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {866, 793}}";
sepNavSelRange = "{2468, 0}";
sepNavVisRange = "{217, 2262}";
sepNavWindowFrame = "{{20, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {866, 884}}";
sepNavSelRange = "{2556, 0}";
sepNavVisRange = "{337, 2230}";
sepNavWindowFrame = "{{20, 57}, {895, 821}}";
};
};
24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = {
@ -82,10 +82,10 @@
};
24D8286F09A914000093AEF8 /* RawTimbersProc.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {848, 1131}}";
sepNavSelRange = "{1914, 0}";
sepNavVisRange = "{1116, 1548}";
sepNavWindowFrame = "{{472, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {848, 1638}}";
sepNavSelRange = "{3958, 0}";
sepNavVisRange = "{2282, 1732}";
sepNavWindowFrame = "{{23, 57}, {895, 821}}";
};
};
8B02375E1D42B1C400E1E8C8 /* Source Control */ = {

View file

@ -469,11 +469,11 @@
</array>
<key>TableOfContents</key>
<array>
<string>8BBB34DC21C46FAF00825986</string>
<string>8BB9A66724B2998000CD76A8</string>
<string>1CA23ED40692098700951B8B</string>
<string>8BBB34DD21C46FAF00825986</string>
<string>8BB9A66824B2998000CD76A8</string>
<string>8B0237581D42B1C400E1E8C8</string>
<string>8BBB34DE21C46FAF00825986</string>
<string>8BB9A66924B2998000CD76A8</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@ -626,7 +626,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>566521775.93071496</real>
<real>615684480.34935999</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@ -643,6 +643,7 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>8BB9A66A24B2998000CD76A8</string>
<string>/Users/christopherjohnson/Desktop/RawTimbers/RawTimbers.xcodeproj</string>
</array>
<key>WindowString</key>

View file

@ -12,6 +12,9 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new R
RawTimbers::RawTimbers(audioMasterCallback audioMaster) :
AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
{
A = 1.0;
B = 0.0;
fpd = 17;
lastSampleL = 0.0;
lastSample2L = 0.0;
lastSampleR = 0.0;
@ -37,32 +40,80 @@ void RawTimbers::getProgramName(char *name) {vst_strncpy (name, _programName, kV
//airwindows likes to ignore this stuff. Make your own programs, and make a different plugin rather than
//trying to do versioning and preventing people from using older versions. Maybe they like the old one!
static float pinParameter(float data)
{
if (data < 0.0f) return 0.0f;
if (data > 1.0f) return 1.0f;
return data;
}
VstInt32 RawTimbers::getChunk (void** data, bool isPreset)
{
float *chunkData = (float *)calloc(kNumParameters, sizeof(float));
chunkData[0] = A;
chunkData[1] = B;
/* Note: The way this is set up, it will break if you manage to save settings on an Intel
machine and load them on a PPC Mac. However, it's fine if you stick to the machine you
started with. */
*data = chunkData;
return kNumParameters * sizeof(float);
}
VstInt32 RawTimbers::setChunk (void* data, VstInt32 byteSize, bool isPreset)
{
float *chunkData = (float *)data;
A = pinParameter(chunkData[0]);
B = pinParameter(chunkData[1]);
/* We're ignoring byteSize as we found it to be a filthy liar */
/* calculate any other fields you need here - you could copy in
code from setParameter() here. */
return 0;
}
void RawTimbers::setParameter(VstInt32 index, float value) {
switch (index) {
case kParamA: A = value; break;
case kParamB: B = value; break;
default: throw; // unknown parameter, shouldn't happen!
}
}
float RawTimbers::getParameter(VstInt32 index) {
return 0.0; //we only need to update the relevant name, this is simple to manage
switch (index) {
case kParamA: return A; break;
case kParamB: return B; break;
default: break; // unknown parameter, shouldn't happen!
} return 0.0; //we only need to update the relevant name, this is simple to manage
}
void RawTimbers::getParameterName(VstInt32 index, char *text) {
switch (index) {
case kParamA: vst_strncpy (text, "Quant", kVstMaxParamStrLen); break;
case kParamB: vst_strncpy (text, "DeRez", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} //this is our labels for displaying in the VST host
}
void RawTimbers::getParameterDisplay(VstInt32 index, char *text) {
switch (index) {
case kParamA: switch((VstInt32)( A * 1.999 )) //0 to almost edge of # of params
{ case 0: vst_strncpy (text, "CD 16", kVstMaxParamStrLen); break;
case 1: vst_strncpy (text, "HD 24", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} break; //completed consoletype 'popup' parameter, exit
case kParamB: float2string (B, text, kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} //this displays the values and handles 'popups' where it's discrete choices
}
void RawTimbers::getParameterLabel(VstInt32 index, char *text) {
switch (index) {
case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break;
case kParamB: vst_strncpy (text, "", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
}
}
VstInt32 RawTimbers::canDo(char *text)

View file

@ -16,7 +16,9 @@
#include <math.h>
enum {
kNumParameters = 0
kParamA = 0,
kParamB = 1,
kNumParameters = 2
}; //
const int kNumPrograms = 0;
@ -55,6 +57,11 @@ private:
double lastSample2L;
double lastSampleR;
double lastSample2R;
uint32_t fpd;
//default stuff
float A;
float B;
};
#endif

View file

@ -14,10 +14,30 @@ void RawTimbers::processReplacing(float **inputs, float **outputs, VstInt32 samp
float* out1 = outputs[0];
float* out2 = outputs[1];
int processing = (VstInt32)( A * 1.999 );
bool highres = false;
if (processing == 1) highres = true;
float scaleFactor;
if (highres) scaleFactor = 8388608.0;
else scaleFactor = 32768.0;
float derez = B;
if (derez > 0.0) scaleFactor *= pow(1.0-derez,6);
if (scaleFactor < 0.0001) scaleFactor = 0.0001;
float outScale = scaleFactor;
if (outScale < 8.0) outScale = 8.0;
while (--sampleFrames >= 0)
{
double inputSampleL = *in1 * 8388608.0;
double inputSampleR = *in2 * 8388608.0;
long double inputSampleL = *in1;
long double inputSampleR = *in2;
if (fabs(inputSampleL)<1.18e-37) inputSampleL = fpd * 1.18e-37;
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
if (fabs(inputSampleR)<1.18e-37) inputSampleR = fpd * 1.18e-37;
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleL *= scaleFactor;
inputSampleR *= scaleFactor;
double outputSampleL;
double outputSampleR;
@ -36,8 +56,8 @@ void RawTimbers::processReplacing(float **inputs, float **outputs, VstInt32 samp
lastSample2R = lastSampleR;
lastSampleR = inputSampleR; //we retain three samples in a row
*out1 = outputSampleL / 8388608.0;
*out2 = outputSampleR / 8388608.0;
*out1 = outputSampleL / outScale;
*out2 = outputSampleR / outScale;
*in1++;
*in2++;
@ -52,11 +72,30 @@ void RawTimbers::processDoubleReplacing(double **inputs, double **outputs, VstIn
double* in2 = inputs[1];
double* out1 = outputs[0];
double* out2 = outputs[1];
int processing = (VstInt32)( A * 1.999 );
bool highres = false;
if (processing == 1) highres = true;
float scaleFactor;
if (highres) scaleFactor = 8388608.0;
else scaleFactor = 32768.0;
float derez = B;
if (derez > 0.0) scaleFactor *= pow(1.0-derez,6);
if (scaleFactor < 0.0001) scaleFactor = 0.0001;
float outScale = scaleFactor;
if (outScale < 8.0) outScale = 8.0;
while (--sampleFrames >= 0)
{
double inputSampleL = *in1 * 8388608.0;
double inputSampleR = *in2 * 8388608.0;
long double inputSampleL = *in1;
long double inputSampleR = *in2;
if (fabs(inputSampleL)<1.18e-43) inputSampleL = fpd * 1.18e-43;
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
if (fabs(inputSampleR)<1.18e-43) inputSampleR = fpd * 1.18e-43;
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleL *= scaleFactor;
inputSampleR *= scaleFactor;
double outputSampleL;
double outputSampleR;
@ -75,8 +114,8 @@ void RawTimbers::processDoubleReplacing(double **inputs, double **outputs, VstIn
lastSample2R = lastSampleR;
lastSampleR = inputSampleR; //we retain three samples in a row
*out1 = outputSampleL / 8388608.0;
*out2 = outputSampleR / 8388608.0;
*out1 = outputSampleL / outScale;
*out2 = outputSampleR / outScale;
*in1++;
*in2++;