diff --git a/plugins/LinuxVST/src/RawGlitters/RawGlitters.cpp b/plugins/LinuxVST/src/RawGlitters/RawGlitters.cpp index 0429460c0..30804e218 100755 --- a/plugins/LinuxVST/src/RawGlitters/RawGlitters.cpp +++ b/plugins/LinuxVST/src/RawGlitters/RawGlitters.cpp @@ -12,6 +12,9 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new R RawGlitters::RawGlitters(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 RawGlitters::getProgramName(char *name) {vst_strncpy (name, _programName, k //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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::canDo(char *text) diff --git a/plugins/LinuxVST/src/RawGlitters/RawGlitters.h b/plugins/LinuxVST/src/RawGlitters/RawGlitters.h index 1a8752d3f..7c43c675a 100755 --- a/plugins/LinuxVST/src/RawGlitters/RawGlitters.h +++ b/plugins/LinuxVST/src/RawGlitters/RawGlitters.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/RawGlitters/RawGlittersProc.cpp b/plugins/LinuxVST/src/RawGlitters/RawGlittersProc.cpp index 41d2bf724..4ee485fa4 100755 --- a/plugins/LinuxVST/src/RawGlitters/RawGlittersProc.cpp +++ b/plugins/LinuxVST/src/RawGlitters/RawGlittersProc.cpp @@ -13,11 +13,29 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam float* in2 = inputs[1]; 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 +54,8 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam 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 +70,29 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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 +111,8 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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/RawGlitters/RawGlitters.cpp b/plugins/MacAU/RawGlitters/RawGlitters.cpp index 291aed40b..1ae2c2bb1 100755 --- a/plugins/MacAU/RawGlitters/RawGlitters.cpp +++ b/plugins/MacAU/RawGlitters/RawGlitters.cpp @@ -59,6 +59,8 @@ RawGlitters::RawGlitters(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 RawGlitters::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 RawGlitters::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 RawGlitters::RawGlittersKernel::Reset() { lastSample = 0.0; lastSample2 = 0.0; + fpd = 17; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -167,11 +199,27 @@ void RawGlitters::RawGlittersKernel::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 +228,9 @@ void RawGlitters::RawGlittersKernel::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/RawGlitters/RawGlitters.h b/plugins/MacAU/RawGlitters/RawGlitters.h index 2c12c0b92..03ef50ab5 100755 --- a/plugins/MacAU/RawGlitters/RawGlitters.h +++ b/plugins/MacAU/RawGlitters/RawGlitters.h @@ -53,8 +53,22 @@ #pragma mark ____RawGlitters 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 ____RawGlitters @@ -119,6 +133,7 @@ public: private: Float64 lastSample; Float64 lastSample2; + uint32_t fpd; }; }; diff --git a/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser index 51e08fe0a..d0c3004a7 100755 --- a/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser @@ -10,7 +10,7 @@ PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, - 292, + 603, 20, 48, 43, @@ -49,12 +49,14 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 566521060; - PBXWorkspaceStateSaveDate = 566521060; + PBXPerProjectTemplateStateSaveDate = 615683338; + PBXWorkspaceStateSaveDate = 615683338; }; perUserProjectItems = { - 8BBB331821C4572000825986 /* PlistBookmark */ = 8BBB331821C4572000825986 /* PlistBookmark */; - 8BBB34B521C46CEE00825986 /* PlistBookmark */ = 8BBB34B521C46CEE00825986 /* PlistBookmark */; + 8BB06F1124A93B6C000F894A /* PlistBookmark */ = 8BB06F1124A93B6C000F894A /* PlistBookmark */; + 8BB0711024A947FF000F894A /* PBXTextBookmark */ = 8BB0711024A947FF000F894A /* PBXTextBookmark */; + 8BB072A924B11046000F894A /* PBXTextBookmark */ = 8BB072A924B11046000F894A /* PBXTextBookmark */; + 8BB9A4C324B2952400CD76A8 /* PBXTextBookmark */ = 8BB9A4C324B2952400CD76A8 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { @@ -62,10 +64,10 @@ }; 8BA05A660720730100365D66 /* RawGlitters.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1082, 2756}}"; - sepNavSelRange = "{7569, 0}"; - sepNavVisRange = "{6345, 1836}"; - sepNavWindowFrame = "{{15, 39}, {1129, 834}}"; + sepNavIntBoundsRect = "{{0, 0}, {793, 3380}}"; + sepNavSelRange = "{9865, 0}"; + sepNavVisRange = "{8847, 1155}"; + sepNavWindowFrame = "{{15, 57}, {1129, 821}}"; }; }; 8BA05A690720730100365D66 /* RawGlittersVersion.h */ = { @@ -76,7 +78,7 @@ sepNavWindowFrame = "{{15, 39}, {1129, 834}}"; }; }; - 8BBB331821C4572000825986 /* PlistBookmark */ = { + 8BB06F1124A93B6C000F894A /* PlistBookmark */ = { isa = PlistBookmark; fRef = 8D01CCD10486CAD60068D4B7 /* Info.plist */; fallbackIsa = PBXBookmark; @@ -88,24 +90,42 @@ rLen = 0; rLoc = 9223372036854775808; }; - 8BBB34B521C46CEE00825986 /* PlistBookmark */ = { - isa = PlistBookmark; - fRef = 8D01CCD10486CAD60068D4B7 /* Info.plist */; - fallbackIsa = PBXBookmark; - isK = 0; - kPath = ( - CFBundleName, - ); - name = /Users/christopherjohnson/Desktop/MacAU/RawGlitters/Info.plist; + 8BB0711024A947FF000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* RawGlitters.h */; + name = "RawGlitters.h: 137"; rLen = 0; - rLoc = 9223372036854775807; + rLoc = 5375; + rType = 0; + vrLen = 1316; + vrLoc = 4161; + }; + 8BB072A924B11046000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* RawGlitters.cpp */; + name = "RawGlitters.cpp: 214"; + rLen = 0; + rLoc = 9302; + rType = 0; + vrLen = 1261; + vrLoc = 8666; + }; + 8BB9A4C324B2952400CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* RawGlitters.cpp */; + name = "RawGlitters.cpp: 231"; + rLen = 0; + rLoc = 9865; + rType = 0; + vrLen = 1155; + vrLoc = 8847; }; 8BC6025B073B072D006C4272 /* RawGlitters.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1082, 1664}}"; - sepNavSelRange = "{2814, 0}"; - sepNavVisRange = "{3301, 1714}"; - sepNavWindowFrame = "{{15, 39}, {1129, 834}}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 1976}}"; + sepNavSelRange = "{5375, 0}"; + sepNavVisRange = "{4161, 1316}"; + sepNavWindowFrame = "{{15, 57}, {1129, 821}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 index 5f17fac08..fa45ee6f4 100755 --- a/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - 841 - 841 + 1152 + 1152 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -302,14 +300,14 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 7 + 4 2 1 0 PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {288, 595}} + {{0, 0}, {288, 704}} PBXTopSmartGroupGIDs @@ -319,14 +317,14 @@ GeometryConfiguration Frame - {{0, 0}, {305, 613}} + {{0, 0}, {305, 722}} GroupTreeTableConfiguration MainColumn 288 RubberWindowFrame - 698 185 841 654 0 0 1440 878 + 27 107 1152 763 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -337,12 +335,14 @@ Dock + BecomeActive + ContentConfiguration PBXProjectModuleGUID 8BD7274A1D46E5A5000176F0 PBXProjectModuleLabel - Info.plist + RawGlitters.cpp PBXSplitModuleInNavigatorKey Split0 @@ -350,14 +350,16 @@ PBXProjectModuleGUID 8BD7274B1D46E5A5000176F0 PBXProjectModuleLabel - Info.plist + RawGlitters.cpp _historyCapacity 0 bookmark - 8BBB34B521C46CEE00825986 + 8BB9A4C324B2952400CD76A8 history - 8BBB331821C4572000825986 + 8BB06F1124A93B6C000F894A + 8BB0711024A947FF000F894A + 8BB072A924B11046000F894A SplitCount @@ -371,18 +373,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 229}} + {{0, 0}, {842, 571}} RubberWindowFrame - 698 185 841 654 0 0 1440 878 + 27 107 1152 763 0 0 1440 878 Module PBXNavigatorGroup Proportion - 229pt + 571pt Proportion - 379pt + 146pt Tabs @@ -396,9 +398,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 352}} + {{10, 27}, {842, 119}} RubberWindowFrame - 698 185 841 654 0 0 1440 878 + 27 107 1152 763 0 0 1440 878 Module XCDetailModule @@ -452,7 +454,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 339}} + {{10, 27}, {842, 115}} Module PBXBuildResultsModule @@ -461,7 +463,7 @@ Proportion - 531pt + 842pt Name @@ -480,11 +482,11 @@ TableOfContents - 8BBB34B621C46CEE00825986 + 8BB9A4C424B2952400CD76A8 1CA23ED40692098700951B8B - 8BBB34B721C46CEE00825986 + 8BB9A4C524B2952400CD76A8 8BD7274A1D46E5A5000176F0 - 8BBB34B821C46CEE00825986 + 8BB9A4C624B2952400CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -657,7 +659,7 @@ StatusbarIsVisible TimeStamp - 566521070.73037803 + 615683364.94321096 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -674,11 +676,10 @@ 5 WindowOrderList - 8BBB34B921C46CEE00825986 - /Users/christopherjohnson/Desktop/MacAU/RawGlitters/RawGlitters.xcodeproj + /Users/christopherjohnson/Desktop/Dithers/MacAU/RawGlitters/RawGlitters.xcodeproj WindowString - 698 185 841 654 0 0 1440 878 + 27 107 1152 763 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser index 27015c932..180fbdb6e 100755 --- a/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.pbxuser @@ -49,8 +49,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 566521028; - PBXWorkspaceStateSaveDate = 566521028; + PBXPerProjectTemplateStateSaveDate = 615684485; + PBXWorkspaceStateSaveDate = 615684485; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -58,18 +58,18 @@ }; 2407DEB6089929BA00EB68BF /* RawGlitters.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 1092}}"; - sepNavSelRange = "{2370, 0}"; - sepNavVisRange = "{1084, 1877}"; - sepNavWindowFrame = "{{12, 47}, {895, 831}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 1755}}"; + sepNavSelRange = "{4469, 0}"; + sepNavVisRange = "{2706, 2232}"; + sepNavWindowFrame = "{{12, 57}, {895, 821}}"; }; }; 245463B80991757100464AD3 /* RawGlitters.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {866, 793}}"; - sepNavSelRange = "{2475, 0}"; - sepNavVisRange = "{219, 2267}"; - sepNavWindowFrame = "{{20, 47}, {895, 831}}"; + sepNavIntBoundsRect = "{{0, 0}, {866, 884}}"; + sepNavSelRange = "{2563, 0}"; + sepNavVisRange = "{341, 2233}"; + sepNavWindowFrame = "{{20, 57}, {895, 821}}"; }; }; 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = { @@ -82,10 +82,10 @@ }; 24D8286F09A914000093AEF8 /* RawGlittersProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 1131}}"; - sepNavSelRange = "{2168, 0}"; - sepNavVisRange = "{0, 1674}"; - sepNavWindowFrame = "{{4, 47}, {895, 831}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 1599}}"; + sepNavSelRange = "{3950, 0}"; + sepNavVisRange = "{2248, 1757}"; + sepNavWindowFrame = "{{4, 57}, {895, 821}}"; }; }; 8B02375E1D42B1C400E1E8C8 /* Source Control */ = { diff --git a/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 index ba8d79be8..18439cf3e 100755 --- a/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/RawGlitters/RawGlitters.xcodeproj/christopherjohnson.perspectivev3 @@ -323,7 +323,7 @@ 185 RubberWindowFrame - 18 209 810 487 0 0 1440 878 + 16 381 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -362,7 +362,7 @@ Frame {{0, 0}, {603, 0}} RubberWindowFrame - 18 209 810 487 0 0 1440 878 + 16 381 810 487 0 0 1440 878 Module PBXNavigatorGroup @@ -387,7 +387,7 @@ Frame {{10, 27}, {603, 414}} RubberWindowFrame - 18 209 810 487 0 0 1440 878 + 16 381 810 487 0 0 1440 878 Module XCDetailModule @@ -469,11 +469,11 @@ TableOfContents - 8BBB34D921C46FAE00825986 + 8BB9A68824B299B000CD76A8 1CA23ED40692098700951B8B - 8BBB34DA21C46FAE00825986 + 8BB9A68924B299B000CD76A8 8B0237581D42B1C400E1E8C8 - 8BBB34DB21C46FAE00825986 + 8BB9A68A24B299B000CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +626,7 @@ StatusbarIsVisible TimeStamp - 566521774.15421402 + 615684528.19873798 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -643,10 +643,11 @@ 5 WindowOrderList + 8BB9A68B24B299B000CD76A8 /Users/christopherjohnson/Desktop/RawGlitters/RawGlitters.xcodeproj WindowString - 18 209 810 487 0 0 1440 878 + 16 381 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/RawGlitters/source/RawGlitters.cpp b/plugins/MacVST/RawGlitters/source/RawGlitters.cpp index 0429460c0..30804e218 100755 --- a/plugins/MacVST/RawGlitters/source/RawGlitters.cpp +++ b/plugins/MacVST/RawGlitters/source/RawGlitters.cpp @@ -12,6 +12,9 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new R RawGlitters::RawGlitters(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 RawGlitters::getProgramName(char *name) {vst_strncpy (name, _programName, k //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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::canDo(char *text) diff --git a/plugins/MacVST/RawGlitters/source/RawGlitters.h b/plugins/MacVST/RawGlitters/source/RawGlitters.h index 1a8752d3f..7c43c675a 100755 --- a/plugins/MacVST/RawGlitters/source/RawGlitters.h +++ b/plugins/MacVST/RawGlitters/source/RawGlitters.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/RawGlitters/source/RawGlittersProc.cpp b/plugins/MacVST/RawGlitters/source/RawGlittersProc.cpp index 41d2bf724..4ee485fa4 100755 --- a/plugins/MacVST/RawGlitters/source/RawGlittersProc.cpp +++ b/plugins/MacVST/RawGlitters/source/RawGlittersProc.cpp @@ -13,11 +13,29 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam float* in2 = inputs[1]; 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 +54,8 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam 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 +70,29 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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 +111,8 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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/RawGlitters/.vs/VSTProject/v14/.suo b/plugins/WinVST/RawGlitters/.vs/VSTProject/v14/.suo index 51a36cac4..784a0750e 100755 Binary files a/plugins/WinVST/RawGlitters/.vs/VSTProject/v14/.suo and b/plugins/WinVST/RawGlitters/.vs/VSTProject/v14/.suo differ diff --git a/plugins/WinVST/RawGlitters/RawGlitters.cpp b/plugins/WinVST/RawGlitters/RawGlitters.cpp index 0429460c0..30804e218 100755 --- a/plugins/WinVST/RawGlitters/RawGlitters.cpp +++ b/plugins/WinVST/RawGlitters/RawGlitters.cpp @@ -12,6 +12,9 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new R RawGlitters::RawGlitters(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 RawGlitters::getProgramName(char *name) {vst_strncpy (name, _programName, k //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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::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 RawGlitters::canDo(char *text) diff --git a/plugins/WinVST/RawGlitters/RawGlitters.h b/plugins/WinVST/RawGlitters/RawGlitters.h index 1a8752d3f..7c43c675a 100755 --- a/plugins/WinVST/RawGlitters/RawGlitters.h +++ b/plugins/WinVST/RawGlitters/RawGlitters.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/RawGlitters/RawGlittersProc.cpp b/plugins/WinVST/RawGlitters/RawGlittersProc.cpp index 41d2bf724..4ee485fa4 100755 --- a/plugins/WinVST/RawGlitters/RawGlittersProc.cpp +++ b/plugins/WinVST/RawGlitters/RawGlittersProc.cpp @@ -13,11 +13,29 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam float* in2 = inputs[1]; 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 +54,8 @@ void RawGlitters::processReplacing(float **inputs, float **outputs, VstInt32 sam 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 +70,29 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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 +111,8 @@ void RawGlitters::processDoubleReplacing(double **inputs, double **outputs, VstI 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++;