diff --git a/plugins/LinuxVST/src/RawTimbers/RawTimbers.cpp b/plugins/LinuxVST/src/RawTimbers/RawTimbers.cpp index d1fde12da..65ad02672 100755 --- a/plugins/LinuxVST/src/RawTimbers/RawTimbers.cpp +++ b/plugins/LinuxVST/src/RawTimbers/RawTimbers.cpp @@ -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) diff --git a/plugins/LinuxVST/src/RawTimbers/RawTimbers.h b/plugins/LinuxVST/src/RawTimbers/RawTimbers.h index 6d9f64699..9aea03dec 100755 --- a/plugins/LinuxVST/src/RawTimbers/RawTimbers.h +++ b/plugins/LinuxVST/src/RawTimbers/RawTimbers.h @@ -16,7 +16,9 @@ #include 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 diff --git a/plugins/LinuxVST/src/RawTimbers/RawTimbersProc.cpp b/plugins/LinuxVST/src/RawTimbers/RawTimbersProc.cpp index 56472598e..78e012e26 100755 --- a/plugins/LinuxVST/src/RawTimbers/RawTimbersProc.cpp +++ b/plugins/LinuxVST/src/RawTimbers/RawTimbersProc.cpp @@ -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++; diff --git a/plugins/MacAU/RawTimbers/RawTimbers.cpp b/plugins/MacAU/RawTimbers/RawTimbers.cpp index 34d5d2db0..008f68840 100755 --- a/plugins/MacAU/RawTimbers/RawTimbers.cpp +++ b/plugins/MacAU/RawTimbers/RawTimbers.cpp @@ -59,6 +59,8 @@ RawTimbers::RawTimbers(AudioUnit component) { CreateElements(); Globals()->UseIndexedParameters(kNumberOfParameters); + SetParameter(kParam_One, kDefaultValue_ParamOne ); + SetParameter(kParam_Two, kDefaultValue_ParamTwo ); #if AU_DEBUG_DISPATCHER mDebugDispatcher = new AUDebugDispatcher (this); @@ -74,7 +76,22 @@ ComponentResult RawTimbers::GetParameterValueStrings(AudioUnitScope inScope, AudioUnitParameterID inParameterID, CFArrayRef * outStrings) { - + if ((inScope == kAudioUnitScope_Global) && (inParameterID == kParam_One)) //ID must be actual name of parameter identifier, not number + { + if (outStrings == NULL) return noErr; + CFStringRef strings [] = + { + kMenuItem_CD, + kMenuItem_HD, + }; + *outStrings = CFArrayCreate ( + NULL, + (const void **) strings, + (sizeof (strings) / sizeof (strings [0])), + NULL + ); + return noErr; + } return kAudioUnitErr_InvalidProperty; } @@ -95,10 +112,24 @@ ComponentResult RawTimbers::GetParameterInfo(AudioUnitScope inScope, if (inScope == kAudioUnitScope_Global) { switch(inParameterID) { - default: + case kParam_One: + AUBase::FillInParameterName (outParameterInfo, kParameterOneName, false); + outParameterInfo.unit = kAudioUnitParameterUnit_Indexed; + outParameterInfo.minValue = kCD; + outParameterInfo.maxValue = kHD; + outParameterInfo.defaultValue = kDefaultValue_ParamOne; + break; + case kParam_Two: + AUBase::FillInParameterName (outParameterInfo, kParameterTwoName, false); + outParameterInfo.unit = kAudioUnitParameterUnit_Generic; + outParameterInfo.minValue = 0.0; + outParameterInfo.maxValue = 1.0; + outParameterInfo.defaultValue = kDefaultValue_ParamTwo; + break; + default: result = kAudioUnitErr_InvalidParameter; break; - } + } } else { result = kAudioUnitErr_InvalidParameter; } @@ -152,6 +183,7 @@ void RawTimbers::RawTimbersKernel::Reset() { lastSample = 0.0; lastSample2 = 0.0; + fpd = 17; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -167,11 +199,30 @@ void RawTimbers::RawTimbersKernel::Process( const Float32 *inSourceP, const Float32 *sourceP = inSourceP; Float32 *destP = inDestP; + bool highres = false; + if (GetParameter( kParam_One ) == 1) highres = true; + Float32 scaleFactor; + if (highres) scaleFactor = 8388608.0; + else scaleFactor = 32768.0; + Float32 derez = GetParameter( kParam_Two ); + if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); + if (scaleFactor < 0.0001) scaleFactor = 0.0001; + Float32 outScale = scaleFactor; + if (outScale < 8.0) outScale = 8.0; + + while (nSampleFrames-- > 0) { - Float64 inputSample = *sourceP * 8388608.0; //0-1 is now one bit + Float64 inputSample = *sourceP; + + + if (fabs(inputSample)<1.18e-37) inputSample = fpd * 1.18e-37; + fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; + Float64 outputSample; + inputSample *= scaleFactor; //0-1 is now one bit + inputSample += 0.381966011250105; if ((lastSample+lastSample) >= (inputSample+lastSample2)) outputSample = floor(lastSample); @@ -180,7 +231,9 @@ void RawTimbers::RawTimbersKernel::Process( const Float32 *inSourceP, lastSample2 = lastSample; lastSample = inputSample; //we retain three samples in a row - *destP = outputSample / 8388608.0; //scale it back down to 24 bit resolution + outputSample /= outScale; + + *destP = outputSample; //scale it back down to 24 bit resolution sourceP += inNumChannels; destP += inNumChannels; diff --git a/plugins/MacAU/RawTimbers/RawTimbers.h b/plugins/MacAU/RawTimbers/RawTimbers.h index 288c515ff..16567b680 100755 --- a/plugins/MacAU/RawTimbers/RawTimbers.h +++ b/plugins/MacAU/RawTimbers/RawTimbers.h @@ -53,8 +53,22 @@ #pragma mark ____RawTimbers Parameters +// parameters +static CFStringRef kParameterOneName = CFSTR("Quantizer"); +static const int kCD = 0; +static const int kHD = 1; +static const int kDefaultValue_ParamOne = kHD; +static CFStringRef kMenuItem_CD = CFSTR ("CD 16 bit"); +static CFStringRef kMenuItem_HD = CFSTR ("HD 24 bit"); + +static CFStringRef kParameterTwoName = CFSTR("DeRez"); +static const float kDefaultValue_ParamTwo = 0.0; + enum { - kNumberOfParameters=0 + kParam_One = 0, + kParam_Two = 1, + //Add your parameters here... + kNumberOfParameters=2 }; #pragma mark ____RawTimbers @@ -119,6 +133,7 @@ public: private: Float64 lastSample; Float64 lastSample2; + uint32_t fpd; }; }; diff --git a/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser index 535a8195e..be3ecae51 100755 --- a/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser @@ -10,7 +10,7 @@ PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, - 292, + 556, 20, 48, 43, @@ -49,13 +49,14 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 566520870; - PBXWorkspaceStateSaveDate = 566520870; + PBXPerProjectTemplateStateSaveDate = 615683325; + PBXWorkspaceStateSaveDate = 615683325; }; perUserProjectItems = { + 8BB0710324A947ED000F894A /* PBXTextBookmark */ = 8BB0710324A947ED000F894A /* PBXTextBookmark */; + 8BB9A4A324B294FA00CD76A8 /* PBXTextBookmark */ = 8BB9A4A324B294FA00CD76A8 /* PBXTextBookmark */; + 8BB9A4B224B2950200CD76A8 /* PBXTextBookmark */ = 8BB9A4B224B2950200CD76A8 /* PBXTextBookmark */; 8BBB34C721C46EBD00825986 /* PlistBookmark */ = 8BBB34C721C46EBD00825986 /* PlistBookmark */; - 8BBB34C821C46EBD00825986 /* PBXBookmark */ = 8BBB34C821C46EBD00825986 /* PBXBookmark */; - 8BBB34C921C46EBD00825986 /* PBXTextBookmark */ = 8BBB34C921C46EBD00825986 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { @@ -63,10 +64,10 @@ }; 8BA05A660720730100365D66 /* RawTimbers.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1082, 2496}}"; - sepNavSelRange = "{7672, 36}"; - sepNavVisRange = "{6327, 1825}"; - sepNavWindowFrame = "{{197, 44}, {1129, 834}}"; + sepNavIntBoundsRect = "{{0, 0}, {789, 3315}}"; + sepNavSelRange = "{9845, 0}"; + sepNavVisRange = "{8989, 993}"; + sepNavWindowFrame = "{{197, 57}, {1129, 821}}"; }; }; 8BA05A690720730100365D66 /* RawTimbersVersion.h */ = { @@ -77,6 +78,36 @@ sepNavWindowFrame = "{{358, 44}, {1129, 834}}"; }; }; + 8BB0710324A947ED000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* RawTimbers.h */; + name = "RawTimbers.h: 137"; + rLen = 0; + rLoc = 5362; + rType = 0; + vrLen = 1139; + vrLoc = 4325; + }; + 8BB9A4A324B294FA00CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* RawTimbers.cpp */; + name = "RawTimbers.cpp: 234"; + rLen = 0; + rLoc = 9845; + rType = 0; + vrLen = 948; + vrLoc = 9034; + }; + 8BB9A4B224B2950200CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* RawTimbers.cpp */; + name = "RawTimbers.cpp: 234"; + rLen = 0; + rLoc = 9845; + rType = 0; + vrLen = 993; + vrLoc = 8989; + }; 8BBB34C721C46EBD00825986 /* PlistBookmark */ = { isa = PlistBookmark; fRef = 8D01CCD10486CAD60068D4B7 /* Info.plist */; @@ -87,27 +118,13 @@ ); name = /Users/christopherjohnson/Desktop/MacAU/RawTimbers/Info.plist; rLen = 0; - rLoc = 9223372036854775807; - }; - 8BBB34C821C46EBD00825986 /* PBXBookmark */ = { - isa = PBXBookmark; - fRef = 8BC6025B073B072D006C4272 /* RawTimbers.h */; - }; - 8BBB34C921C46EBD00825986 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BC6025B073B072D006C4272 /* RawTimbers.h */; - name = "RawTimbers.h: 57"; - rLen = 0; - rLoc = 2817; - rType = 0; - vrLen = 583; - vrLoc = 3291; + rLoc = 9223372036854775808; }; 8BC6025B073B072D006C4272 /* RawTimbers.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {894, 1794}}"; - sepNavSelRange = "{2817, 0}"; - sepNavVisRange = "{3291, 583}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 2080}}"; + sepNavSelRange = "{5362, 0}"; + sepNavVisRange = "{4325, 1139}"; sepNavWindowFrame = "{{15, 39}, {1129, 834}}"; }; }; diff --git a/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 index dbf2f9bf7..4f00f7ea7 100755 --- a/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - 841 - 841 + 1105 + 1105 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -309,7 +307,7 @@ PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {288, 595}} + {{0, 0}, {288, 655}} PBXTopSmartGroupGIDs @@ -319,14 +317,14 @@ GeometryConfiguration Frame - {{0, 0}, {305, 613}} + {{0, 0}, {305, 673}} GroupTreeTableConfiguration MainColumn 288 RubberWindowFrame - 651 78 841 654 0 0 1440 878 + 51 154 1105 714 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -337,12 +335,14 @@ Dock + BecomeActive + ContentConfiguration PBXProjectModuleGUID 8BD7274A1D46E5A5000176F0 PBXProjectModuleLabel - RawTimbers.h + RawTimbers.cpp PBXSplitModuleInNavigatorKey Split0 @@ -350,15 +350,16 @@ PBXProjectModuleGUID 8BD7274B1D46E5A5000176F0 PBXProjectModuleLabel - RawTimbers.h + RawTimbers.cpp _historyCapacity 0 bookmark - 8BBB34C921C46EBD00825986 + 8BB9A4B224B2950200CD76A8 history 8BBB34C721C46EBD00825986 - 8BBB34C821C46EBD00825986 + 8BB0710324A947ED000F894A + 8BB9A4A324B294FA00CD76A8 SplitCount @@ -372,18 +373,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 229}} + {{0, 0}, {795, 514}} RubberWindowFrame - 651 78 841 654 0 0 1440 878 + 51 154 1105 714 0 0 1440 878 Module PBXNavigatorGroup Proportion - 229pt + 514pt Proportion - 379pt + 154pt Tabs @@ -397,9 +398,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 352}} + {{10, 27}, {795, 127}} RubberWindowFrame - 651 78 841 654 0 0 1440 878 + 51 154 1105 714 0 0 1440 878 Module XCDetailModule @@ -453,7 +454,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 339}} + {{10, 27}, {795, 117}} Module PBXBuildResultsModule @@ -462,7 +463,7 @@ Proportion - 531pt + 795pt Name @@ -481,11 +482,11 @@ TableOfContents - 8BBB34CA21C46EBD00825986 + 8BB9A4B324B2950200CD76A8 1CA23ED40692098700951B8B - 8BBB34CB21C46EBD00825986 + 8BB9A4B424B2950200CD76A8 8BD7274A1D46E5A5000176F0 - 8BBB34CC21C46EBD00825986 + 8BB9A4B524B2950200CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -658,7 +659,7 @@ StatusbarIsVisible TimeStamp - 566521533.78701496 + 615683330.83857298 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -675,10 +676,10 @@ 5 WindowOrderList - /Users/christopherjohnson/Desktop/MacAU/RawTimbers/RawTimbers.xcodeproj + /Users/christopherjohnson/Desktop/Dithers/MacAU/RawTimbers/RawTimbers.xcodeproj WindowString - 651 78 841 654 0 0 1440 878 + 51 154 1105 714 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser index 9ee052abe..aa15e8fb6 100755 --- a/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.pbxuser @@ -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 */ = { diff --git a/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 index 40cdf5a26..d8cbe64be 100755 --- a/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/RawTimbers/RawTimbers.xcodeproj/christopherjohnson.perspectivev3 @@ -469,11 +469,11 @@ TableOfContents - 8BBB34DC21C46FAF00825986 + 8BB9A66724B2998000CD76A8 1CA23ED40692098700951B8B - 8BBB34DD21C46FAF00825986 + 8BB9A66824B2998000CD76A8 8B0237581D42B1C400E1E8C8 - 8BBB34DE21C46FAF00825986 + 8BB9A66924B2998000CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +626,7 @@ StatusbarIsVisible TimeStamp - 566521775.93071496 + 615684480.34935999 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -643,6 +643,7 @@ 5 WindowOrderList + 8BB9A66A24B2998000CD76A8 /Users/christopherjohnson/Desktop/RawTimbers/RawTimbers.xcodeproj WindowString diff --git a/plugins/MacVST/RawTimbers/source/RawTimbers.cpp b/plugins/MacVST/RawTimbers/source/RawTimbers.cpp index d1fde12da..65ad02672 100755 --- a/plugins/MacVST/RawTimbers/source/RawTimbers.cpp +++ b/plugins/MacVST/RawTimbers/source/RawTimbers.cpp @@ -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) diff --git a/plugins/MacVST/RawTimbers/source/RawTimbers.h b/plugins/MacVST/RawTimbers/source/RawTimbers.h index 6d9f64699..9aea03dec 100755 --- a/plugins/MacVST/RawTimbers/source/RawTimbers.h +++ b/plugins/MacVST/RawTimbers/source/RawTimbers.h @@ -16,7 +16,9 @@ #include 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 diff --git a/plugins/MacVST/RawTimbers/source/RawTimbersProc.cpp b/plugins/MacVST/RawTimbers/source/RawTimbersProc.cpp index 56472598e..78e012e26 100755 --- a/plugins/MacVST/RawTimbers/source/RawTimbersProc.cpp +++ b/plugins/MacVST/RawTimbers/source/RawTimbersProc.cpp @@ -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++; diff --git a/plugins/WinVST/RawTimbers/.vs/VSTProject/v14/.suo b/plugins/WinVST/RawTimbers/.vs/VSTProject/v14/.suo index 9d32d6459..0bcfdb5f3 100755 Binary files a/plugins/WinVST/RawTimbers/.vs/VSTProject/v14/.suo and b/plugins/WinVST/RawTimbers/.vs/VSTProject/v14/.suo differ diff --git a/plugins/WinVST/RawTimbers/RawTimbers.cpp b/plugins/WinVST/RawTimbers/RawTimbers.cpp index d1fde12da..65ad02672 100755 --- a/plugins/WinVST/RawTimbers/RawTimbers.cpp +++ b/plugins/WinVST/RawTimbers/RawTimbers.cpp @@ -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) diff --git a/plugins/WinVST/RawTimbers/RawTimbers.h b/plugins/WinVST/RawTimbers/RawTimbers.h index 6d9f64699..9aea03dec 100755 --- a/plugins/WinVST/RawTimbers/RawTimbers.h +++ b/plugins/WinVST/RawTimbers/RawTimbers.h @@ -16,7 +16,9 @@ #include 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 diff --git a/plugins/WinVST/RawTimbers/RawTimbersProc.cpp b/plugins/WinVST/RawTimbers/RawTimbersProc.cpp index 56472598e..78e012e26 100755 --- a/plugins/WinVST/RawTimbers/RawTimbersProc.cpp +++ b/plugins/WinVST/RawTimbers/RawTimbersProc.cpp @@ -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++;