From c653c8b38fdc79f61ee191052901ac2012d476b4 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Sun, 5 Jul 2020 22:01:06 -0400 Subject: DeRez Dither Updates (Beam, Dark, NJAD) --- plugins/MacAU/Beam/Beam.cpp | 6 +- .../Beam/Beam.xcodeproj/christopherjohnson.pbxuser | 58 +++--- .../christopherjohnson.perspectivev3 | 37 ++-- plugins/MacAU/Dark/Dark.cpp | 9 +- .../Dark/Dark.xcodeproj/christopherjohnson.pbxuser | 120 +++++++----- .../christopherjohnson.perspectivev3 | 85 +++++--- .../NotJustAnotherDither/NotJustAnotherDither.cpp | 213 ++++++++++----------- .../NotJustAnotherDither/NotJustAnotherDither.h | 15 +- .../christopherjohnson.pbxuser | 65 ++++--- .../christopherjohnson.perspectivev3 | 50 ++--- 10 files changed, 369 insertions(+), 289 deletions(-) (limited to 'plugins/MacAU') diff --git a/plugins/MacAU/Beam/Beam.cpp b/plugins/MacAU/Beam/Beam.cpp index b8079d9..25737f8 100755 --- a/plugins/MacAU/Beam/Beam.cpp +++ b/plugins/MacAU/Beam/Beam.cpp @@ -219,7 +219,9 @@ void Beam::BeamKernel::Process( const Float32 *inSourceP, else scaleFactor = 32768.0; Float32 derez = GetParameter( kParam_Three ); if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); - if (scaleFactor < 1.0) scaleFactor = 1.0; + if (scaleFactor < 0.0001) scaleFactor = 0.0001; + Float32 outScale = scaleFactor; + if (outScale < 8.0) outScale = 8.0; while (nSampleFrames-- > 0) { Float32 inputSample = *sourceP; @@ -260,7 +262,7 @@ void Beam::BeamKernel::Process( const Float32 *inSourceP, } lastSample[0] = inputSample; - inputSample /= scaleFactor; + inputSample /= outScale; *destP = inputSample; diff --git a/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.pbxuser index 6090610..e625ba4 100755 --- a/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.pbxuser @@ -49,13 +49,13 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 613785694; - PBXWorkspaceStateSaveDate = 613785694; + PBXPerProjectTemplateStateSaveDate = 615683094; + PBXWorkspaceStateSaveDate = 615683094; }; perUserProjectItems = { + 8BB9A45624B2942900CD76A8 /* PBXTextBookmark */ = 8BB9A45624B2942900CD76A8 /* PBXTextBookmark */; + 8BB9A45B24B2943A00CD76A8 /* PBXTextBookmark */ = 8BB9A45B24B2943A00CD76A8 /* PBXTextBookmark */; 8BD150E124956DDF00B025B9 /* PBXTextBookmark */ = 8BD150E124956DDF00B025B9 /* PBXTextBookmark */; - 8BD150E324956DDF00B025B9 /* PBXTextBookmark */ = 8BD150E324956DDF00B025B9 /* PBXTextBookmark */; - 8BD151922495B1A800B025B9 /* PBXTextBookmark */ = 8BD151922495B1A800B025B9 /* PBXTextBookmark */; 8BDD3FE42482756800609929 /* PlistBookmark */ = 8BDD3FE42482756800609929 /* PlistBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; @@ -64,9 +64,9 @@ }; 8BA05A660720730100365D66 /* Beam.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {670, 3640}}"; - sepNavSelRange = "{9702, 0}"; - sepNavVisRange = "{8793, 1474}"; + sepNavIntBoundsRect = "{{0, 0}, {691, 3731}}"; + sepNavSelRange = "{11340, 0}"; + sepNavVisRange = "{10187, 1243}"; sepNavWindowFrame = "{{29, 57}, {790, 821}}"; }; }; @@ -78,11 +78,31 @@ sepNavWindowFrame = "{{15, 57}, {790, 821}}"; }; }; + 8BB9A45624B2942900CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Beam.cpp */; + name = "Beam.cpp: 265"; + rLen = 0; + rLoc = 11340; + rType = 0; + vrLen = 1175; + vrLoc = 10255; + }; + 8BB9A45B24B2943A00CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Beam.cpp */; + name = "Beam.cpp: 265"; + rLen = 0; + rLoc = 11340; + rType = 0; + vrLen = 1243; + vrLoc = 10187; + }; 8BC6025B073B072D006C4272 /* Beam.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {894, 1911}}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 1898}}"; sepNavSelRange = "{3452, 0}"; - sepNavVisRange = "{3874, 1297}"; + sepNavVisRange = "{2317, 1514}"; sepNavWindowFrame = "{{631, 57}, {790, 821}}"; }; }; @@ -96,26 +116,6 @@ vrLen = 1297; vrLoc = 3874; }; - 8BD150E324956DDF00B025B9 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BA05A660720730100365D66 /* Beam.cpp */; - name = "Beam.cpp: 217"; - rLen = 0; - rLoc = 9473; - rType = 0; - vrLen = 1546; - vrLoc = 8567; - }; - 8BD151922495B1A800B025B9 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BA05A660720730100365D66 /* Beam.cpp */; - name = "Beam.cpp: 222"; - rLen = 0; - rLoc = 9702; - rType = 0; - vrLen = 1474; - vrLoc = 8793; - }; 8BD3CCB8148830B20062E48C /* Source Control */ = { isa = PBXSourceControlManager; fallbackIsa = XCSourceControlManager; diff --git a/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.perspectivev3 index 0675966..b49ebae 100755 --- a/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Beam/Beam.xcodeproj/christopherjohnson.perspectivev3 @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -302,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 4 + 3 2 1 0 @@ -326,7 +324,7 @@ 288 RubberWindowFrame - 28 202 841 654 0 0 1440 878 + 599 201 841 654 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -354,12 +352,12 @@ _historyCapacity 0 bookmark - 8BD151922495B1A800B025B9 + 8BB9A45B24B2943A00CD76A8 history 8BDD3FE42482756800609929 8BD150E124956DDF00B025B9 - 8BD150E324956DDF00B025B9 + 8BB9A45624B2942900CD76A8 SplitCount @@ -373,18 +371,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 502}} + {{0, 0}, {531, 494}} RubberWindowFrame - 28 202 841 654 0 0 1440 878 + 599 201 841 654 0 0 1440 878 Module PBXNavigatorGroup Proportion - 502pt + 494pt Proportion - 106pt + 114pt Tabs @@ -398,9 +396,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 79}} - RubberWindowFrame - 28 202 841 654 0 0 1440 878 + {{10, 27}, {531, 87}} Module XCDetailModule @@ -454,7 +450,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 339}} + {{10, 27}, {531, 87}} + RubberWindowFrame + 599 201 841 654 0 0 1440 878 Module PBXBuildResultsModule @@ -482,11 +480,11 @@ TableOfContents - 8BD151932495B1A800B025B9 + 8BB9A45C24B2943A00CD76A8 1CA23ED40692098700951B8B - 8BD151942495B1A800B025B9 + 8BB9A45D24B2943A00CD76A8 8BD7274A1D46E5A5000176F0 - 8BD151952495B1A800B025B9 + 8BB9A45E24B2943A00CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -659,7 +657,7 @@ StatusbarIsVisible TimeStamp - 613790120.45657098 + 615683130.465276 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -676,11 +674,10 @@ 5 WindowOrderList - 8BD151962495B1A800B025B9 /Users/christopherjohnson/Desktop/Dithers/MacAU/Beam/Beam.xcodeproj WindowString - 28 202 841 654 0 0 1440 878 + 599 201 841 654 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacAU/Dark/Dark.cpp b/plugins/MacAU/Dark/Dark.cpp index 5f24cd4..f53b842 100755 --- a/plugins/MacAU/Dark/Dark.cpp +++ b/plugins/MacAU/Dark/Dark.cpp @@ -203,6 +203,7 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, int depth = (int)(17.0*overallscale); if (depth < 3) depth = 3; if (depth > 98) depth = 98; + bool highres = false; if (GetParameter( kParam_One ) == 1) highres = true; Float32 scaleFactor; @@ -210,8 +211,10 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, else scaleFactor = 32768.0; Float32 derez = GetParameter( kParam_Two ); if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); - if (scaleFactor < 1.0) scaleFactor = 1.0; - + if (scaleFactor < 0.0001) scaleFactor = 0.0001; + Float32 outScale = scaleFactor; + if (outScale < 8.0) outScale = 8.0; + while (nSampleFrames-- > 0) { Float32 inputSample = *sourceP; if (fabs(inputSample)<1.18e-37) inputSample = fpd * 1.18e-37; @@ -248,7 +251,7 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, } lastSample[0] = inputSample; - inputSample /= scaleFactor; + inputSample /= outScale; *destP = inputSample; diff --git a/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.pbxuser index f8a4499..ae3e8aa 100755 --- a/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.pbxuser @@ -49,15 +49,18 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 613790145; - PBXWorkspaceStateSaveDate = 613790145; + PBXPerProjectTemplateStateSaveDate = 615682975; + PBXWorkspaceStateSaveDate = 615682975; }; perUserProjectItems = { + 8BB06EB9249D96E9000F894A /* PBXTextBookmark */ = 8BB06EB9249D96E9000F894A /* PBXTextBookmark */; + 8BB06EBA249D96E9000F894A /* PBXTextBookmark */ = 8BB06EBA249D96E9000F894A /* PBXTextBookmark */; + 8BB9A43124B293A300CD76A8 /* PBXBookmark */ = 8BB9A43124B293A300CD76A8 /* PBXBookmark */; + 8BB9A43F24B293E100CD76A8 /* PBXTextBookmark */ = 8BB9A43F24B293E100CD76A8 /* PBXTextBookmark */; + 8BB9A44424B293FB00CD76A8 /* PBXTextBookmark */ = 8BB9A44424B293FB00CD76A8 /* PBXTextBookmark */; + 8BB9A44A24B293FB00CD76A8 /* PBXTextBookmark */ = 8BB9A44A24B293FB00CD76A8 /* PBXTextBookmark */; 8BD14F0224842AB600B025B9 /* PlistBookmark */ = 8BD14F0224842AB600B025B9 /* PlistBookmark */; 8BD14F0324842AB600B025B9 /* PBXTextBookmark */ = 8BD14F0324842AB600B025B9 /* PBXTextBookmark */; - 8BD150CD24956DA100B025B9 /* PBXTextBookmark */ = 8BD150CD24956DA100B025B9 /* PBXTextBookmark */; - 8BD1515C2495A6F200B025B9 /* PBXTextBookmark */ = 8BD1515C2495A6F200B025B9 /* PBXTextBookmark */; - 8BD151A22495B1D300B025B9 /* PBXTextBookmark */ = 8BD151A22495B1D300B025B9 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { @@ -65,10 +68,17 @@ }; 8BA05A660720730100365D66 /* Dark.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {656, 3536}}"; - sepNavSelRange = "{10164, 0}"; - sepNavVisRange = "{9020, 1552}"; - sepNavWindowFrame = "{{6, 57}, {790, 821}}"; + sepNavIntBoundsRect = "{{0, 0}, {743, 3588}}"; + sepNavSelRange = "{10714, 0}"; + sepNavVisRange = "{8961, 1843}"; + sepNavWindowFrame = "{{650, 57}, {790, 821}}"; + }; + }; + 8BA05A670720730100365D66 /* Dark.exp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {482, 479}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 11}"; }; }; 8BA05A690720730100365D66 /* DarkVersion.h */ = { @@ -79,12 +89,66 @@ sepNavWindowFrame = "{{15, 57}, {790, 821}}"; }; }; + 8BB06EB9249D96E9000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Dark.cpp */; + name = "Dark.cpp: 238"; + rLen = 0; + rLoc = 10241; + rType = 0; + vrLen = 1542; + vrLoc = 5953; + }; + 8BB06EBA249D96E9000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A670720730100365D66 /* Dark.exp */; + name = "Dark.exp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 11; + vrLoc = 0; + }; + 8BB9A43124B293A300CD76A8 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 8BA05A660720730100365D66 /* Dark.cpp */; + }; + 8BB9A43F24B293E100CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* Dark.h */; + name = "Dark.h: 135"; + rLen = 16; + rLoc = 5249; + rType = 0; + vrLen = 1016; + vrLoc = 4358; + }; + 8BB9A44424B293FB00CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* Dark.h */; + name = "Dark.h: 135"; + rLen = 16; + rLoc = 5249; + rType = 0; + vrLen = 1016; + vrLoc = 4358; + }; + 8BB9A44A24B293FB00CD76A8 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Dark.cpp */; + name = "Dark.cpp: 254"; + rLen = 0; + rLoc = 10714; + rType = 0; + vrLen = 1843; + vrLoc = 8961; + }; 8BC6025B073B072D006C4272 /* Dark.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {824, 1716}}"; - sepNavSelRange = "{5175, 0}"; - sepNavVisRange = "{2696, 815}"; - sepNavWindowFrame = "{{28, 47}, {790, 821}}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 2054}}"; + sepNavSelRange = "{5249, 16}"; + sepNavVisRange = "{4358, 1016}"; + sepNavWindowFrame = "{{687, 57}, {790, 821}}"; }; }; 8BD14F0224842AB600B025B9 /* PlistBookmark */ = { @@ -109,36 +173,6 @@ vrLen = 1283; vrLoc = 1638; }; - 8BD150CD24956DA100B025B9 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BC6025B073B072D006C4272 /* Dark.h */; - name = "Dark.h: 130"; - rLen = 0; - rLoc = 5175; - rType = 0; - vrLen = 815; - vrLoc = 2696; - }; - 8BD1515C2495A6F200B025B9 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BA05A660720730100365D66 /* Dark.cpp */; - name = "Dark.cpp: 213"; - rLen = 0; - rLoc = 9186; - rType = 0; - vrLen = 1424; - vrLoc = 8513; - }; - 8BD151A22495B1D300B025B9 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BA05A660720730100365D66 /* Dark.cpp */; - name = "Dark.cpp: 238"; - rLen = 0; - rLoc = 10164; - rType = 0; - vrLen = 1552; - vrLoc = 9020; - }; 8BD3CCB8148830B20062E48C /* Source Control */ = { isa = PBXSourceControlManager; fallbackIsa = XCSourceControlManager; diff --git a/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.perspectivev3 index 1848996..d9f2308 100755 --- a/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Dark/Dark.xcodeproj/christopherjohnson.perspectivev3 @@ -222,7 +222,48 @@ OpenEditors - + + + Content + + PBXProjectModuleGUID + 8BB9A44824B293FB00CD76A8 + PBXProjectModuleLabel + Dark.cpp + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 8BB9A44924B293FB00CD76A8 + PBXProjectModuleLabel + Dark.cpp + _historyCapacity + 0 + bookmark + 8BB9A44A24B293FB00CD76A8 + history + + 8BB9A43124B293A300CD76A8 + + + SplitCount + 1 + + StatusBarVisibility + + + Geometry + + Frame + {{0, 20}, {790, 724}} + PBXModuleWindowStatusBarHidden2 + + RubberWindowFrame + 650 113 790 765 0 0 1440 878 + + + PerspectiveWidths 841 @@ -324,7 +365,7 @@ 288 RubberWindowFrame - 7 216 841 654 0 0 1440 878 + 596 140 841 654 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -335,14 +376,12 @@ Dock - BecomeActive - ContentConfiguration PBXProjectModuleGUID 8BD7274A1D46E5A5000176F0 PBXProjectModuleLabel - Dark.cpp + Dark.h PBXSplitModuleInNavigatorKey Split0 @@ -350,17 +389,18 @@ PBXProjectModuleGUID 8BD7274B1D46E5A5000176F0 PBXProjectModuleLabel - Dark.cpp + Dark.h _historyCapacity 0 bookmark - 8BD151A22495B1D300B025B9 + 8BB9A44424B293FB00CD76A8 history 8BD14F0224842AB600B025B9 8BD14F0324842AB600B025B9 - 8BD150CD24956DA100B025B9 - 8BD1515C2495A6F200B025B9 + 8BB06EB9249D96E9000F894A + 8BB06EBA249D96E9000F894A + 8BB9A43F24B293E100CD76A8 SplitCount @@ -374,18 +414,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 514}} + {{0, 0}, {531, 508}} RubberWindowFrame - 7 216 841 654 0 0 1440 878 + 596 140 841 654 0 0 1440 878 Module PBXNavigatorGroup Proportion - 514pt + 508pt Proportion - 94pt + 100pt Tabs @@ -399,9 +439,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 67}} - RubberWindowFrame - 7 216 841 654 0 0 1440 878 + {{10, 27}, {531, 73}} Module XCDetailModule @@ -455,7 +493,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 61}} + {{10, 27}, {531, 73}} + RubberWindowFrame + 596 140 841 654 0 0 1440 878 Module PBXBuildResultsModule @@ -483,11 +523,11 @@ TableOfContents - 8BD151A32495B1D300B025B9 + 8BB9A44524B293FB00CD76A8 1CA23ED40692098700951B8B - 8BD151A42495B1D300B025B9 + 8BB9A44624B293FB00CD76A8 8BD7274A1D46E5A5000176F0 - 8BD151A52495B1D300B025B9 + 8BB9A44724B293FB00CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -660,7 +700,7 @@ StatusbarIsVisible TimeStamp - 613790163.86573398 + 615683067.592103 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -677,10 +717,11 @@ 5 WindowOrderList + 8BB9A44824B293FB00CD76A8 /Users/christopherjohnson/Desktop/Dithers/MacAU/Dark/Dark.xcodeproj WindowString - 7 216 841 654 0 0 1440 878 + 596 140 841 654 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.cpp b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.cpp index 2ca3c6f..5ca17fd 100755 --- a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.cpp +++ b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.cpp @@ -59,6 +59,8 @@ NotJustAnotherDither::NotJustAnotherDither(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 NotJustAnotherDither::GetParameterValueStrings(AudioUnitScope 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 NotJustAnotherDither::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; } @@ -150,18 +181,19 @@ ComponentResult NotJustAnotherDither::Initialize() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void NotJustAnotherDither::NotJustAnotherDitherKernel::Reset() { - byn[0] = 1000; - byn[1] = 301; - byn[2] = 176; - byn[3] = 125; - byn[4] = 97; - byn[5] = 79; - byn[6] = 67; - byn[7] = 58; - byn[8] = 51; - byn[9] = 46; - byn[10] = 1000; + byn[0] = 1000.0; + byn[1] = 301.0; + byn[2] = 176.0; + byn[3] = 125.0; + byn[4] = 97.0; + byn[5] = 79.0; + byn[6] = 67.0; + byn[7] = 58.0; + byn[8] = 51.0; + byn[9] = 46.0; + byn[10] = 1000.0; noiseShaping = 0.0; + fpd = 17; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -175,133 +207,82 @@ void NotJustAnotherDither::NotJustAnotherDitherKernel::Process( const Float32 { UInt32 nSampleFrames = inFramesToProcess; const Float32 *sourceP = inSourceP; - Float32 *destP = inDestP; + Float32 *destP = inDestP; - long double inputSample; - Float64 benfordize; - int hotbinA; - int hotbinB; - Float64 totalA; - Float64 totalB; - Float32 drySample; + 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) { - 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. - } - drySample = inputSample; + long double inputSample = *sourceP; + if (fabs(inputSample)<1.18e-37) inputSample = fpd * 1.18e-37; + fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; + inputSample *= scaleFactor; + //0-1 is now one bit, now we dither + bool cutbins; cutbins = false; + long double drySample = inputSample; inputSample -= noiseShaping; - inputSample *= 8388608.0; - //0-1 is now one bit, now we dither - benfordize = floor(inputSample); - while (benfordize >= 1.0) {benfordize /= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - hotbinA = floor(benfordize); + long double benfordize; benfordize = floor(inputSample); + while (benfordize >= 1.0) benfordize /= 10; + while (benfordize < 1.0 && benfordize > 0.0000001) benfordize *= 10; + int hotbinA; hotbinA = floor(benfordize); //hotbin becomes the Benford bin value for this number floored - totalA = 0; + long double totalA; totalA = 0; if ((hotbinA > 0) && (hotbinA < 10)) { - byn[hotbinA] += 1; - totalA += (301-byn[1]); - totalA += (176-byn[2]); - totalA += (125-byn[3]); - totalA += (97-byn[4]); - totalA += (79-byn[5]); - totalA += (67-byn[6]); - totalA += (58-byn[7]); - totalA += (51-byn[8]); - totalA += (46-byn[9]); + byn[hotbinA] += 1; if (byn[hotbinA] > 982) cutbins = true; + totalA += (301-byn[1]); totalA += (176-byn[2]); totalA += (125-byn[3]); + totalA += (97-byn[4]); totalA += (79-byn[5]); totalA += (67-byn[6]); + totalA += (58-byn[7]); totalA += (51-byn[8]); totalA += (46-byn[9]); byn[hotbinA] -= 1; - } else {hotbinA = 10;} + } else hotbinA = 10; //produce total number- smaller is closer to Benford real benfordize = ceil(inputSample); - while (benfordize >= 1.0) {benfordize /= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - if (benfordize < 1.0) {benfordize *= 10;} - hotbinB = floor(benfordize); + while (benfordize >= 1.0) benfordize /= 10; + while (benfordize < 1.0 && benfordize > 0.0000001) benfordize *= 10; + int hotbinB; hotbinB = floor(benfordize); //hotbin becomes the Benford bin value for this number ceiled - totalB = 0; + long double totalB; totalB = 0; if ((hotbinB > 0) && (hotbinB < 10)) { - byn[hotbinB] += 1; - totalB += (301-byn[1]); - totalB += (176-byn[2]); - totalB += (125-byn[3]); - totalB += (97-byn[4]); - totalB += (79-byn[5]); - totalB += (67-byn[6]); - totalB += (58-byn[7]); - totalB += (51-byn[8]); - totalB += (46-byn[9]); + byn[hotbinB] += 1; if (byn[hotbinB] > 982) cutbins = true; + totalB += (301-byn[1]); totalB += (176-byn[2]); totalB += (125-byn[3]); + totalB += (97-byn[4]); totalB += (79-byn[5]); totalB += (67-byn[6]); + totalB += (58-byn[7]); totalB += (51-byn[8]); totalB += (46-byn[9]); byn[hotbinB] -= 1; - } else {hotbinB = 10;} + } else hotbinB = 10; //produce total number- smaller is closer to Benford real - if (totalA < totalB) - { - byn[hotbinA] += 1; - inputSample = floor(inputSample); - } - else - { - byn[hotbinB] += 1; - inputSample = ceil(inputSample); - } + long double outputSample; + if (totalA < totalB) {byn[hotbinA] += 1; outputSample = floor(inputSample);} + else {byn[hotbinB] += 1; outputSample = floor(inputSample+1);} //assign the relevant one to the delay line //and floor/ceil signal accordingly + if (cutbins) { + byn[1] *= 0.99; byn[2] *= 0.99; byn[3] *= 0.99; byn[4] *= 0.99; byn[5] *= 0.99; + byn[6] *= 0.99; byn[7] *= 0.99; byn[8] *= 0.99; byn[9] *= 0.99; byn[10] *= 0.99; + } + noiseShaping += outputSample - drySample; + if (noiseShaping > fabs(inputSample)) noiseShaping = fabs(inputSample); + if (noiseShaping < -fabs(inputSample)) noiseShaping = -fabs(inputSample); - totalA = byn[1] + byn[2] + byn[3] + byn[4] + byn[5] + byn[6] + byn[7] + byn[8] + byn[9]; - totalA /= 1000; - if (totalA = 0) totalA = 1; // spotted by Laserbat: this 'scaling back' code doesn't. It always divides by the fallback of 1. Old NJAD doesn't scale back the things we're comparing against. Kept to retain known behavior, use the one in StudioTan and Monitoring for a tuned-as-intended NJAD. - byn[1] /= totalA; - byn[2] /= totalA; - byn[3] /= totalA; - byn[4] /= totalA; - byn[5] /= totalA; - byn[6] /= totalA; - byn[7] /= totalA; - byn[8] /= totalA; - byn[9] /= totalA; - byn[10] /= 2; //catchall for garbage data - - inputSample /= 8388608.0; - - noiseShaping += inputSample - drySample; + inputSample = outputSample / outScale; + if (inputSample > 1.0) inputSample = 1.0; + if (inputSample < -1.0) inputSample = -1.0; + *destP = inputSample; sourceP += inNumChannels; destP += inNumChannels; } diff --git a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.h b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.h index 87b74c6..d519bfb 100755 --- a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.h +++ b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.h @@ -54,11 +54,21 @@ #pragma mark ____NotJustAnotherDither Parameters // parameters -//Alter the name if desired, but using the plugin name is a start +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 { + kParam_One = 0, + kParam_Two = 1, //Add your parameters here... - kNumberOfParameters=0 + kNumberOfParameters=2 }; #pragma mark ____NotJustAnotherDither @@ -123,6 +133,7 @@ public: private: Float64 byn[13]; long double noiseShaping; + uint32_t fpd; }; }; diff --git a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.pbxuser index 3aee3d6..18ab75c 100755 --- a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.pbxuser @@ -10,7 +10,7 @@ PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, - 292, + 594, 20, 48, 43, @@ -49,13 +49,14 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 568766952; - PBXWorkspaceStateSaveDate = 568766952; + PBXPerProjectTemplateStateSaveDate = 615683941; + PBXWorkspaceStateSaveDate = 615683941; }; perUserProjectItems = { 8B8D6A12207ABF2E0029B7B0 /* PlistBookmark */ = 8B8D6A12207ABF2E0029B7B0 /* PlistBookmark */; - 8BAF09C221E6BA5C00C38394 /* PBXTextBookmark */ = 8BAF09C221E6BA5C00C38394 /* PBXTextBookmark */; - 8BBB2F6D21B620F100825986 /* PBXTextBookmark */ = 8BBB2F6D21B620F100825986 /* PBXTextBookmark */; + 8BB071CA24A94A14000F894A /* PBXTextBookmark */ = 8BB071CA24A94A14000F894A /* PBXTextBookmark */; + 8BB9A46B24B2945000CD76A8 /* PBXTextBookmark */ = 8BB9A46B24B2945000CD76A8 /* PBXTextBookmark */; + 8BB9A55324B2977000CD76A8 /* PBXTextBookmark */ = 8BB9A55324B2977000CD76A8 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { @@ -75,10 +76,10 @@ }; 8BA05A660720730100365D66 /* NotJustAnotherDither.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {691, 4082}}"; - sepNavSelRange = "{8123, 0}"; - sepNavVisRange = "{8086, 233}"; - sepNavWindowFrame = "{{517, 41}, {923, 837}}"; + sepNavIntBoundsRect = "{{0, 0}, {784, 3965}}"; + sepNavSelRange = "{9521, 119}"; + sepNavVisRange = "{11022, 1332}"; + sepNavWindowFrame = "{{743, 57}, {923, 821}}"; }; }; 8BA05A680720730100365D66 /* NotJustAnotherDither.r */ = { @@ -93,36 +94,46 @@ uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {876, 767}}"; sepNavSelRange = "{2971, 0}"; - sepNavVisRange = "{60, 2974}"; - sepNavWindowFrame = "{{15, 39}, {923, 837}}"; + sepNavVisRange = "{45, 2989}"; + sepNavWindowFrame = "{{15, 57}, {923, 821}}"; }; }; - 8BAF09C221E6BA5C00C38394 /* PBXTextBookmark */ = { + 8BB071CA24A94A14000F894A /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* NotJustAnotherDither.h */; + name = "NotJustAnotherDither.h: 136"; + rLen = 16; + rLoc = 5477; + rType = 0; + vrLen = 969; + vrLoc = 4633; + }; + 8BB9A46B24B2945000CD76A8 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* NotJustAnotherDither.cpp */; - name = "NotJustAnotherDither.cpp: 190"; - rLen = 0; - rLoc = 8123; + name = "NotJustAnotherDither.cpp: 219"; + rLen = 119; + rLoc = 9521; rType = 0; - vrLen = 233; - vrLoc = 8086; + vrLen = 1374; + vrLoc = 9281; }; - 8BBB2F6D21B620F100825986 /* PBXTextBookmark */ = { + 8BB9A55324B2977000CD76A8 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* NotJustAnotherDither.cpp */; - name = "NotJustAnotherDither.cpp: 190"; - rLen = 0; - rLoc = 8123; + name = "NotJustAnotherDither.cpp: 219"; + rLen = 119; + rLoc = 9521; rType = 0; - vrLen = 253; - vrLoc = 8066; + vrLen = 1332; + vrLoc = 11022; }; 8BC6025B073B072D006C4272 /* NotJustAnotherDither.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {894, 1716}}"; - sepNavSelRange = "{4975, 0}"; - sepNavVisRange = "{3502, 1743}"; - sepNavWindowFrame = "{{517, 39}, {923, 837}}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 1807}}"; + sepNavSelRange = "{5477, 16}"; + sepNavVisRange = "{3917, 1685}"; + sepNavWindowFrame = "{{0, 57}, {923, 821}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.perspectivev3 index faa330c..84eaaac 100755 --- a/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj/christopherjohnson.perspectivev3 @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -282,7 +280,7 @@ PBXSmartGroupTreeModuleColumnWidthsKey - 288 + 230 PBXSmartGroupTreeModuleColumnsKey_v4 @@ -308,7 +306,7 @@ PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {288, 595}} + {{0, 0}, {230, 605}} PBXTopSmartGroupGIDs @@ -318,24 +316,26 @@ GeometryConfiguration Frame - {{0, 0}, {305, 613}} + {{0, 0}, {247, 623}} GroupTreeTableConfiguration MainColumn - 288 + 230 RubberWindowFrame - 780 134 841 654 0 0 1440 878 + 68 214 1085 664 0 0 1440 878 Module PBXSmartGroupTreeModule Proportion - 305pt + 247pt Dock + BecomeActive + ContentConfiguration PBXProjectModuleGUID @@ -353,11 +353,12 @@ _historyCapacity 0 bookmark - 8BAF09C221E6BA5C00C38394 + 8BB9A55324B2977000CD76A8 history 8B8D6A12207ABF2E0029B7B0 - 8BBB2F6D21B620F100825986 + 8BB071CA24A94A14000F894A + 8BB9A46B24B2945000CD76A8 SplitCount @@ -371,18 +372,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 109}} + {{0, 0}, {833, 470}} RubberWindowFrame - 780 134 841 654 0 0 1440 878 + 68 214 1085 664 0 0 1440 878 Module PBXNavigatorGroup Proportion - 109pt + 470pt Proportion - 499pt + 148pt Tabs @@ -396,9 +397,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 472}} + {{10, 27}, {833, 121}} RubberWindowFrame - 780 134 841 654 0 0 1440 878 + 68 214 1085 664 0 0 1440 878 Module XCDetailModule @@ -452,7 +453,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 315}} + {{10, 27}, {531, 489}} Module PBXBuildResultsModule @@ -461,7 +462,7 @@ Proportion - 531pt + 833pt Name @@ -480,11 +481,11 @@ TableOfContents - 8BAF09C321E6BA5C00C38394 + 8BB9A55424B2977000CD76A8 1CA23ED40692098700951B8B - 8BAF09C421E6BA5C00C38394 + 8BB9A55524B2977000CD76A8 8BD7274A1D46E5A5000176F0 - 8BAF09C521E6BA5C00C38394 + 8BB9A55624B2977000CD76A8 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -657,7 +658,7 @@ StatusbarIsVisible TimeStamp - 568769116.18578196 + 615683952.11029994 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -674,11 +675,10 @@ 5 WindowOrderList - 8BAF09C621E6BA5C00C38394 - /Users/christopherjohnson/Desktop/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj + /Users/christopherjohnson/Desktop/Dithers/MacAU/NotJustAnotherDither/NotJustAnotherDither.xcodeproj WindowString - 780 134 841 654 0 0 1440 878 + 68 214 1085 664 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3