Capacitor2

This commit is contained in:
Chris Johnson 2020-07-26 20:05:11 -04:00
parent b2d6f1fe6c
commit e9c834e51f
61 changed files with 12427 additions and 440 deletions

View file

@ -0,0 +1,131 @@
// !$*UTF8*$!
{
089C1669FE841209C02AAC07 /* Project object */ = {
activeBuildConfigurationName = Release;
activeTarget = 8D01CCC60486CAD60068D4B7 /* Capacitor2 */;
codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */;
perUserDictionary = {
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
364,
20,
48,
43,
43,
20,
);
PBXFileTableDataSourceColumnsKey = (
PBXFileDataSource_FiletypeID,
PBXFileDataSource_Filename_ColumnID,
PBXFileDataSource_Built_ColumnID,
PBXFileDataSource_ObjectSize_ColumnID,
PBXFileDataSource_Errors_ColumnID,
PBXFileDataSource_Warnings_ColumnID,
PBXFileDataSource_Target_ColumnID,
);
};
PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
324,
60,
20,
48,
43,
43,
);
PBXFileTableDataSourceColumnsKey = (
PBXFileDataSource_FiletypeID,
PBXFileDataSource_Filename_ColumnID,
PBXTargetDataSource_PrimaryAttribute,
PBXFileDataSource_Built_ColumnID,
PBXFileDataSource_ObjectSize_ColumnID,
PBXFileDataSource_Errors_ColumnID,
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 617484448;
PBXWorkspaceStateSaveDate = 617484448;
};
perUserProjectItems = {
8B602BDF24CE1DAD0007F4A4 /* XCBuildMessageTextBookmark */ = 8B602BDF24CE1DAD0007F4A4 /* XCBuildMessageTextBookmark */;
8B602BE024CE1DAD0007F4A4 /* PBXTextBookmark */ = 8B602BE024CE1DAD0007F4A4 /* PBXTextBookmark */;
};
sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */;
userBuildSettings = {
};
};
2407DEB6089929BA00EB68BF /* Capacitor2.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {848, 2483}}";
sepNavSelRange = "{1127, 0}";
sepNavVisRange = "{542, 1811}";
sepNavWindowFrame = "{{12, 57}, {895, 821}}";
};
};
245463B80991757100464AD3 /* Capacitor2.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {866, 1404}}";
sepNavSelRange = "{3108, 0}";
sepNavVisRange = "{2341, 949}";
sepNavWindowFrame = "{{20, 57}, {895, 821}}";
};
};
24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {838, 19747}}";
sepNavSelRange = "{10616, 0}";
sepNavVisRange = "{10459, 399}";
sepNavWindowFrame = "{{15, 42}, {895, 831}}";
};
};
24D8286F09A914000093AEF8 /* Capacitor2Proc.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1270, 7345}}";
sepNavSelRange = "{12658, 0}";
sepNavVisRange = "{10992, 1908}";
sepNavWindowFrame = "{{35, 57}, {1317, 821}}";
};
};
8B02375E1D42B1C400E1E8C8 /* Source Control */ = {
isa = PBXSourceControlManager;
fallbackIsa = XCSourceControlManager;
isSCMEnabled = 0;
scmConfiguration = {
repositoryNamesForRoots = {
"" = "";
};
};
};
8B02375F1D42B1C400E1E8C8 /* Code sense */ = {
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
8B602BDF24CE1DAD0007F4A4 /* XCBuildMessageTextBookmark */ = {
isa = PBXTextBookmark;
comments = "Deprecated conversion from string constant to 'char*'";
fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */;
fallbackIsa = XCBuildMessageTextBookmark;
rLen = 1;
rLoc = 306;
rType = 1;
};
8B602BE024CE1DAD0007F4A4 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */;
name = "audioeffectx.cpp: 307";
rLen = 0;
rLoc = 10616;
rType = 0;
vrLen = 399;
vrLoc = 10459;
};
8D01CCC60486CAD60068D4B7 /* Capacitor2 */ = {
activeExec = 0;
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Sample.xcodeproj">
</FileRef>
</Workspace>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,143 @@
// !$*UTF8*$!
{
089C1669FE841209C02AAC07 /* Project object */ = {
activeBuildConfigurationName = Release;
activeTarget = 8D01CCC60486CAD60068D4B7 /* Gain */;
codeSenseManager = 91857D95148EF55400AAA11B /* Code sense */;
perUserDictionary = {
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
829,
20,
48,
43,
43,
20,
);
PBXFileTableDataSourceColumnsKey = (
PBXFileDataSource_FiletypeID,
PBXFileDataSource_Filename_ColumnID,
PBXFileDataSource_Built_ColumnID,
PBXFileDataSource_ObjectSize_ColumnID,
PBXFileDataSource_Errors_ColumnID,
PBXFileDataSource_Warnings_ColumnID,
PBXFileDataSource_Target_ColumnID,
);
};
PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
789,
60,
20,
48,
43,
43,
);
PBXFileTableDataSourceColumnsKey = (
PBXFileDataSource_FiletypeID,
PBXFileDataSource_Filename_ColumnID,
PBXTargetDataSource_PrimaryAttribute,
PBXFileDataSource_Built_ColumnID,
PBXFileDataSource_ObjectSize_ColumnID,
PBXFileDataSource_Errors_ColumnID,
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 345089498;
PBXWorkspaceStateSaveDate = 345089498;
};
perUserProjectItems = {
911C2A9D1491A5F600A430AF /* PBXTextBookmark */ = 911C2A9D1491A5F600A430AF /* PBXTextBookmark */;
915DCCBB1491A5B8008574E6 /* PBXTextBookmark */ = 915DCCBB1491A5B8008574E6 /* PBXTextBookmark */;
};
sourceControlManager = 91857D94148EF55400AAA11B /* Source Control */;
userBuildSettings = {
};
};
2407DEB6089929BA00EB68BF /* Gain.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {992, 1768}}";
sepNavSelRange = "{247, 0}";
sepNavVisRange = "{0, 1657}";
};
};
245463B80991757100464AD3 /* Gain.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {992, 975}}";
sepNavSelRange = "{1552, 0}";
sepNavVisRange = "{796, 1857}";
sepNavWindowFrame = "{{15, 465}, {750, 558}}";
};
};
24A2FF9A0F90D1DD003BB5A7 /* adelaymain.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {992, 488}}";
sepNavSelRange = "{0, 0}";
sepNavVisRange = "{0, 798}";
};
};
24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {859, 19825}}";
sepNavSelRange = "{10641, 0}";
sepNavVisRange = "{10076, 1095}";
};
};
24D8286F09A914000093AEF8 /* GainProc.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {992, 482}}";
sepNavSelRange = "{239, 0}";
sepNavVisRange = "{0, 950}";
};
};
24D8287E09A9164A0093AEF8 /* xcode_vst_prefix.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {992, 493}}";
sepNavSelRange = "{249, 0}";
sepNavVisRange = "{0, 249}";
};
};
8D01CCC60486CAD60068D4B7 /* Gain */ = {
activeExec = 0;
};
911C2A9D1491A5F600A430AF /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 2407DEB6089929BA00EB68BF /* Gain.cpp */;
name = "Gain.cpp: 10";
rLen = 0;
rLoc = 247;
rType = 0;
vrLen = 1657;
vrLoc = 0;
};
915DCCBB1491A5B8008574E6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 2407DEB6089929BA00EB68BF /* Gain.cpp */;
name = "Gain.cpp: 10";
rLen = 0;
rLoc = 247;
rType = 0;
vrLen = 1625;
vrLoc = 0;
};
91857D94148EF55400AAA11B /* Source Control */ = {
isa = PBXSourceControlManager;
fallbackIsa = XCSourceControlManager;
isSCMEnabled = 0;
scmConfiguration = {
repositoryNamesForRoots = {
"" = "";
};
};
};
91857D95148EF55400AAA11B /* Code sense */ = {
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
}

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D01CCC60486CAD60068D4B7"
BuildableName = "Gain.vst"
BlueprintName = "Gain"
ReferencedContainer = "container:Gain.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D01CCC60486CAD60068D4B7"
BuildableName = "Gain.vst"
BlueprintName = "Gain"
ReferencedContainer = "container:Gain.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D01CCC60486CAD60068D4B7"
BuildableName = "Gain.vst"
BlueprintName = "Gain"
ReferencedContainer = "container:Gain.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Gain.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>8</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>8D01CCC60486CAD60068D4B7</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>«PROJECTNAME».xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>8D01CCC60486CAD60068D4B7</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D01CCC60486CAD60068D4B7"
BuildableName = "&#171;PROJECTNAME&#187;.vst"
BlueprintName = "&#171;PROJECTNAME&#187;"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Capacitor2</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.airwindows.Capacitor2</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>Dthr</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>

View file

@ -0,0 +1 @@
BNDL????

View file

@ -0,0 +1,17 @@
#define MAC 1
#define MACX 1
#define USE_NAMESPACE 0
#define TARGET_API_MAC_CARBON 1
#define USENAVSERVICES 1
#define __CF_USE_FRAMEWORK_INCLUDES__
#if __MWERKS__
#define __NOEXTENSIONS__
#endif
#define QUARTZ 1
#include <AvailabilityMacros.h>

View file

@ -0,0 +1,178 @@
/* ========================================
* Capacitor2 - Capacitor2.h
* Copyright (c) 2016 airwindows, All rights reserved
* ======================================== */
#ifndef __Capacitor2_H
#include "Capacitor2.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Capacitor2(audioMaster);}
Capacitor2::Capacitor2(audioMasterCallback audioMaster) :
AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
{
A = 1.0;
B = 0.0;
C = 0.0;
D = 1.0;
iirHighpassAL = 0.0;
iirHighpassBL = 0.0;
iirHighpassCL = 0.0;
iirHighpassDL = 0.0;
iirHighpassEL = 0.0;
iirHighpassFL = 0.0;
iirLowpassAL = 0.0;
iirLowpassBL = 0.0;
iirLowpassCL = 0.0;
iirLowpassDL = 0.0;
iirLowpassEL = 0.0;
iirLowpassFL = 0.0;
iirHighpassAR = 0.0;
iirHighpassBR = 0.0;
iirHighpassCR = 0.0;
iirHighpassDR = 0.0;
iirHighpassER = 0.0;
iirHighpassFR = 0.0;
iirLowpassAR = 0.0;
iirLowpassBR = 0.0;
iirLowpassCR = 0.0;
iirLowpassDR = 0.0;
iirLowpassER = 0.0;
iirLowpassFR = 0.0;
count = 0;
lowpassChase = 0.0;
highpassChase = 0.0;
wetChase = 0.0;
lowpassBaseAmount = 1.0;
highpassBaseAmount = 0.0;
wet = 1.0;
lastLowpass = 1000.0;
lastHighpass = 1000.0;
lastWet = 1000.0;
fpd = 17;
//this is reset: values being initialized only once. Startup values, whatever they are.
_canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect.
_canDo.insert("plugAsSend"); // plug-in can be used as a send effect.
_canDo.insert("x2in2out");
setNumInputs(kNumInputs);
setNumOutputs(kNumOutputs);
setUniqueID(kUniqueId);
canProcessReplacing(); // supports output replacing
canDoubleReplacing(); // supports double precision processing
programsAreChunks(true);
vst_strncpy (_programName, "Default", kVstMaxProgNameLen); // default program name
}
Capacitor2::~Capacitor2() {}
VstInt32 Capacitor2::getVendorVersion () {return 1000;}
void Capacitor2::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);}
void Capacitor2::getProgramName(char *name) {vst_strncpy (name, _programName, kVstMaxProgNameLen);}
//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 Capacitor2::getChunk (void** data, bool isPreset)
{
float *chunkData = (float *)calloc(kNumParameters, sizeof(float));
chunkData[0] = A;
chunkData[1] = B;
chunkData[2] = C;
chunkData[3] = D;
/* 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 Capacitor2::setChunk (void* data, VstInt32 byteSize, bool isPreset)
{
float *chunkData = (float *)data;
A = pinParameter(chunkData[0]);
B = pinParameter(chunkData[1]);
C = pinParameter(chunkData[2]);
D = pinParameter(chunkData[3]);
/* 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 Capacitor2::setParameter(VstInt32 index, float value) {
switch (index) {
case kParamA: A = value; break;
case kParamB: B = value; break;
case kParamC: C = value; break;
case kParamD: D = value; break;
default: throw; // unknown parameter, shouldn't happen!
}
}
float Capacitor2::getParameter(VstInt32 index) {
switch (index) {
case kParamA: return A; break;
case kParamB: return B; break;
case kParamC: return C; break;
case kParamD: return D; 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 Capacitor2::getParameterName(VstInt32 index, char *text) {
switch (index) {
case kParamA: vst_strncpy (text, "Lowpass", kVstMaxParamStrLen); break;
case kParamB: vst_strncpy (text, "Highpass", kVstMaxParamStrLen); break;
case kParamC: vst_strncpy (text, "NonLin", kVstMaxParamStrLen); break;
case kParamD: vst_strncpy (text, "Dry/Wet", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} //this is our labels for displaying in the VST host
}
void Capacitor2::getParameterDisplay(VstInt32 index, char *text) {
switch (index) {
case kParamA: float2string (A, text, kVstMaxParamStrLen); break;
case kParamB: float2string (B, text, kVstMaxParamStrLen); break;
case kParamC: float2string (C, text, kVstMaxParamStrLen); break;
case kParamD: float2string (D, text, kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} //this displays the values and handles 'popups' where it's discrete choices
}
void Capacitor2::getParameterLabel(VstInt32 index, char *text) {
switch (index) {
case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break;
case kParamB: vst_strncpy (text, "", kVstMaxParamStrLen); break;
case kParamC: vst_strncpy (text, "", kVstMaxParamStrLen); break;
case kParamD: vst_strncpy (text, "", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
}
}
VstInt32 Capacitor2::canDo(char *text)
{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know
bool Capacitor2::getEffectName(char* name) {
vst_strncpy(name, "Capacitor2", kVstMaxProductStrLen); return true;
}
VstPlugCategory Capacitor2::getPlugCategory() {return kPlugCategEffect;}
bool Capacitor2::getProductString(char* text) {
vst_strncpy (text, "airwindows Capacitor2", kVstMaxProductStrLen); return true;
}
bool Capacitor2::getVendorString(char* text) {
vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true;
}

View file

@ -0,0 +1,107 @@
/* ========================================
* Capacitor2 - Capacitor2.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, All rights reserved
* ======================================== */
#ifndef __Capacitor2_H
#define __Capacitor2_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#endif
#include <set>
#include <string>
#include <math.h>
enum {
kParamA = 0,
kParamB = 1,
kParamC = 2,
kParamD = 3,
kNumParameters = 4
}; //
const int kNumPrograms = 0;
const int kNumInputs = 2;
const int kNumOutputs = 2;
const unsigned long kUniqueId = 'capb'; //Change this to what the AU identity is!
class Capacitor2 :
public AudioEffectX
{
public:
Capacitor2(audioMasterCallback audioMaster);
~Capacitor2();
virtual bool getEffectName(char* name); // The plug-in name
virtual VstPlugCategory getPlugCategory(); // The general category for the plug-in
virtual bool getProductString(char* text); // This is a unique plug-in string provided by Steinberg
virtual bool getVendorString(char* text); // Vendor info
virtual VstInt32 getVendorVersion(); // Version number
virtual void processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames);
virtual void processDoubleReplacing (double** inputs, double** outputs, VstInt32 sampleFrames);
virtual void getProgramName(char *name); // read the name from the host
virtual void setProgramName(char *name); // changes the name of the preset displayed in the host
virtual VstInt32 getChunk (void** data, bool isPreset);
virtual VstInt32 setChunk (void* data, VstInt32 byteSize, bool isPreset);
virtual float getParameter(VstInt32 index); // get the parameter value at the specified index
virtual void setParameter(VstInt32 index, float value); // set the parameter at index to value
virtual void getParameterLabel(VstInt32 index, char *text); // label for the parameter (eg dB)
virtual void getParameterName(VstInt32 index, char *text); // name of the parameter
virtual void getParameterDisplay(VstInt32 index, char *text); // text description of the current value
virtual VstInt32 canDo(char *text);
private:
char _programName[kVstMaxProgNameLen + 1];
std::set< std::string > _canDo;
double iirHighpassAL;
double iirHighpassBL;
double iirHighpassCL;
double iirHighpassDL;
double iirHighpassEL;
double iirHighpassFL;
double iirLowpassAL;
double iirLowpassBL;
double iirLowpassCL;
double iirLowpassDL;
double iirLowpassEL;
double iirLowpassFL;
double iirHighpassAR;
double iirHighpassBR;
double iirHighpassCR;
double iirHighpassDR;
double iirHighpassER;
double iirHighpassFR;
double iirLowpassAR;
double iirLowpassBR;
double iirLowpassCR;
double iirLowpassDR;
double iirLowpassER;
double iirLowpassFR;
int count;
double lowpassChase;
double highpassChase;
double wetChase;
double lowpassBaseAmount;
double highpassBaseAmount;
double wet;
double lastLowpass;
double lastHighpass;
double lastWet;
uint32_t fpd;
//default stuff
float A;
float B;
float C;
float D;
};
#endif

View file

@ -0,0 +1,334 @@
/* ========================================
* Capacitor2 - Capacitor2.h
* Copyright (c) 2016 airwindows, All rights reserved
* ======================================== */
#ifndef __Capacitor2_H
#include "Capacitor2.h"
#endif
void Capacitor2::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
{
float* in1 = inputs[0];
float* in2 = inputs[1];
float* out1 = outputs[0];
float* out2 = outputs[1];
lowpassChase = pow(A,2);
highpassChase = pow(B,2);
double nonLin = 1.0+((1.0-C)*6.0);
double nonLinTrim = 1.5/cbrt(nonLin);
wetChase = D;
//should not scale with sample rate, because values reaching 1 are important
//to its ability to bypass when set to max
double lowpassSpeed = 300 / (fabs( lastLowpass - lowpassChase)+1.0);
double highpassSpeed = 300 / (fabs( lastHighpass - highpassChase)+1.0);
double wetSpeed = 300 / (fabs( lastWet - wetChase)+1.0);
lastLowpass = lowpassChase;
lastHighpass = highpassChase;
lastWet = wetChase;
while (--sampleFrames >= 0)
{
long double inputSampleL = *in1;
long double inputSampleR = *in2;
if (fabs(inputSampleL)<1.18e-37) inputSampleL = fpd * 1.18e-37;
if (fabs(inputSampleR)<1.18e-37) inputSampleR = fpd * 1.18e-37;
long double drySampleL = inputSampleL;
long double drySampleR = inputSampleR;
double dielectricScaleL = fabs(2.0-((inputSampleL+nonLin)/nonLin));
double dielectricScaleR = fabs(2.0-((inputSampleR+nonLin)/nonLin));
lowpassBaseAmount = (((lowpassBaseAmount*lowpassSpeed)+lowpassChase)/(lowpassSpeed + 1.0));
//positive voltage will mean lower capacitance when capacitor is barium titanate
//on the lowpass, higher pressure means positive swings/smaller cap/larger value for lowpassAmount
double lowpassAmountL = lowpassBaseAmount * dielectricScaleL;
double invLowpassL = 1.0 - lowpassAmountL;
double lowpassAmountR = lowpassBaseAmount * dielectricScaleR;
double invLowpassR = 1.0 - lowpassAmountR;
highpassBaseAmount = (((highpassBaseAmount*highpassSpeed)+highpassChase)/(highpassSpeed + 1.0));
//positive voltage will mean lower capacitance when capacitor is barium titanate
//on the highpass, higher pressure means positive swings/smaller cap/larger value for highpassAmount
double highpassAmountL = highpassBaseAmount * dielectricScaleL;
double invHighpassL = 1.0 - highpassAmountL;
double highpassAmountR = highpassBaseAmount * dielectricScaleR;
double invHighpassR = 1.0 - highpassAmountR;
wet = (((wet*wetSpeed)+wetChase)/(wetSpeed+1.0));
count++; if (count > 5) count = 0; switch (count)
{
case 0:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassDL = (iirHighpassDL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassDL;
iirLowpassDL = (iirLowpassDL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassDL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassDR = (iirHighpassDR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassDR;
iirLowpassDR = (iirLowpassDR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassDR;
break;
case 1:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassEL = (iirHighpassEL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassEL;
iirLowpassEL = (iirLowpassEL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassEL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassER = (iirHighpassER * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassER;
iirLowpassER = (iirLowpassER * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassER;
break;
case 2:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassFL = (iirHighpassFL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassFL;
iirLowpassFL = (iirLowpassFL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassFL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassFR = (iirHighpassFR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassFR;
iirLowpassFR = (iirLowpassFR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassFR;
break;
case 3:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassDL = (iirHighpassDL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassDL;
iirLowpassDL = (iirLowpassDL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassDL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassDR = (iirHighpassDR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassDR;
iirLowpassDR = (iirLowpassDR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassDR;
break;
case 4:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassEL = (iirHighpassEL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassEL;
iirLowpassEL = (iirLowpassEL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassEL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassER = (iirHighpassER * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassER;
iirLowpassER = (iirLowpassER * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassER;
break;
case 5:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassFL = (iirHighpassFL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassFL;
iirLowpassFL = (iirLowpassFL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassFL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassFR = (iirHighpassFR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassFR;
iirLowpassFR = (iirLowpassFR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassFR;
break;
}
//Highpass Filter chunk. This is three poles of IIR highpass, with a 'gearbox' that progressively
//steepens the filter after minimizing artifacts.
inputSampleL = (drySampleL * (1.0-wet)) + (inputSampleL * nonLinTrim * wet);
inputSampleR = (drySampleR * (1.0-wet)) + (inputSampleR * nonLinTrim * wet);
//begin 32 bit stereo floating point dither
int expon; frexpf((float)inputSampleL, &expon);
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
frexpf((float)inputSampleR, &expon);
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
//end 32 bit stereo floating point dither
*out1 = inputSampleL;
*out2 = inputSampleR;
*in1++;
*in2++;
*out1++;
*out2++;
}
}
void Capacitor2::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames)
{
double* in1 = inputs[0];
double* in2 = inputs[1];
double* out1 = outputs[0];
double* out2 = outputs[1];
lowpassChase = pow(A,2);
highpassChase = pow(B,2);
double nonLin = 1.0+((1.0-C)*6.0);
double nonLinTrim = 1.5/cbrt(nonLin);
wetChase = D;
//should not scale with sample rate, because values reaching 1 are important
//to its ability to bypass when set to max
double lowpassSpeed = 300 / (fabs( lastLowpass - lowpassChase)+1.0);
double highpassSpeed = 300 / (fabs( lastHighpass - highpassChase)+1.0);
double wetSpeed = 300 / (fabs( lastWet - wetChase)+1.0);
lastLowpass = lowpassChase;
lastHighpass = highpassChase;
lastWet = wetChase;
while (--sampleFrames >= 0)
{
long double inputSampleL = *in1;
long double inputSampleR = *in2;
if (fabs(inputSampleL)<1.18e-43) inputSampleL = fpd * 1.18e-43;
if (fabs(inputSampleR)<1.18e-43) inputSampleR = fpd * 1.18e-43;
long double drySampleL = inputSampleL;
long double drySampleR = inputSampleR;
double dielectricScaleL = fabs(2.0-((inputSampleL+nonLin)/nonLin));
double dielectricScaleR = fabs(2.0-((inputSampleR+nonLin)/nonLin));
lowpassBaseAmount = (((lowpassBaseAmount*lowpassSpeed)+lowpassChase)/(lowpassSpeed + 1.0));
//positive voltage will mean lower capacitance when capacitor is barium titanate
//on the lowpass, higher pressure means positive swings/smaller cap/larger value for lowpassAmount
double lowpassAmountL = lowpassBaseAmount * dielectricScaleL;
double invLowpassL = 1.0 - lowpassAmountL;
double lowpassAmountR = lowpassBaseAmount * dielectricScaleR;
double invLowpassR = 1.0 - lowpassAmountR;
highpassBaseAmount = (((highpassBaseAmount*highpassSpeed)+highpassChase)/(highpassSpeed + 1.0));
//positive voltage will mean lower capacitance when capacitor is barium titanate
//on the highpass, higher pressure means positive swings/smaller cap/larger value for highpassAmount
double highpassAmountL = highpassBaseAmount * dielectricScaleL;
double invHighpassL = 1.0 - highpassAmountL;
double highpassAmountR = highpassBaseAmount * dielectricScaleR;
double invHighpassR = 1.0 - highpassAmountR;
wet = (((wet*wetSpeed)+wetChase)/(wetSpeed+1.0));
count++; if (count > 5) count = 0; switch (count)
{
case 0:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassDL = (iirHighpassDL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassDL;
iirLowpassDL = (iirLowpassDL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassDL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassDR = (iirHighpassDR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassDR;
iirLowpassDR = (iirLowpassDR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassDR;
break;
case 1:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassEL = (iirHighpassEL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassEL;
iirLowpassEL = (iirLowpassEL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassEL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassER = (iirHighpassER * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassER;
iirLowpassER = (iirLowpassER * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassER;
break;
case 2:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassFL = (iirHighpassFL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassFL;
iirLowpassFL = (iirLowpassFL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassFL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassFR = (iirHighpassFR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassFR;
iirLowpassFR = (iirLowpassFR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassFR;
break;
case 3:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassDL = (iirHighpassDL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassDL;
iirLowpassDL = (iirLowpassDL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassDL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassDR = (iirHighpassDR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassDR;
iirLowpassDR = (iirLowpassDR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassDR;
break;
case 4:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassBL = (iirHighpassBL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassBL;
iirLowpassBL = (iirLowpassBL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassBL;
iirHighpassEL = (iirHighpassEL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassEL;
iirLowpassEL = (iirLowpassEL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassEL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassBR = (iirHighpassBR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassBR;
iirLowpassBR = (iirLowpassBR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassBR;
iirHighpassER = (iirHighpassER * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassER;
iirLowpassER = (iirLowpassER * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassER;
break;
case 5:
iirHighpassAL = (iirHighpassAL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassAL;
iirLowpassAL = (iirLowpassAL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassAL;
iirHighpassCL = (iirHighpassCL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassCL;
iirLowpassCL = (iirLowpassCL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassCL;
iirHighpassFL = (iirHighpassFL * invHighpassL) + (inputSampleL * highpassAmountL); inputSampleL -= iirHighpassFL;
iirLowpassFL = (iirLowpassFL * invLowpassL) + (inputSampleL * lowpassAmountL); inputSampleL = iirLowpassFL;
iirHighpassAR = (iirHighpassAR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassAR;
iirLowpassAR = (iirLowpassAR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassAR;
iirHighpassCR = (iirHighpassCR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassCR;
iirLowpassCR = (iirLowpassCR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassCR;
iirHighpassFR = (iirHighpassFR * invHighpassR) + (inputSampleR * highpassAmountR); inputSampleR -= iirHighpassFR;
iirLowpassFR = (iirLowpassFR * invLowpassR) + (inputSampleR * lowpassAmountR); inputSampleR = iirLowpassFR;
break;
}
//Highpass Filter chunk. This is three poles of IIR highpass, with a 'gearbox' that progressively
//steepens the filter after minimizing artifacts.
inputSampleL = (drySampleL * (1.0-wet)) + (inputSampleL * nonLinTrim * wet);
inputSampleR = (drySampleR * (1.0-wet)) + (inputSampleR * nonLinTrim * wet);
//begin 64 bit stereo floating point dither
int expon; frexp((double)inputSampleL, &expon);
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
frexp((double)inputSampleR, &expon);
fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
//end 64 bit stereo floating point dither
*out1 = inputSampleL;
*out2 = inputSampleR;
*in1++;
*in2++;
*out1++;
*out2++;
}
}

View file

@ -2,7 +2,9 @@
{
089C1669FE841209C02AAC07 /* Project object */ = {
activeBuildConfigurationName = Release;
activeTarget = 8D01CCC60486CAD60068D4B7 /* AudioUnit */;
activeTarget = 8D01CCC60486CAD60068D4B7 /* VinylDither */;
breakpoints = (
);
codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */;
perUserDictionary = {
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
@ -49,8 +51,12 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 528463877;
PBXWorkspaceStateSaveDate = 528463877;
PBXPerProjectTemplateStateSaveDate = 615684287;
PBXWorkspaceStateSaveDate = 615684287;
};
perUserProjectItems = {
8BB9A36F24B2817400CD76A8 /* PBXTextBookmark */ = 8BB9A36F24B2817400CD76A8 /* PBXTextBookmark */;
8BB9A5F924B298CE00CD76A8 /* PBXTextBookmark */ = 8BB9A5F924B298CE00CD76A8 /* PBXTextBookmark */;
};
sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */;
userBuildSettings = {
@ -58,18 +64,18 @@
};
2407DEB6089929BA00EB68BF /* VinylDither.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {848, 1482}}";
sepNavSelRange = "{2683, 0}";
sepNavVisRange = "{0, 1241}";
sepNavWindowFrame = "{{12, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {848, 2145}}";
sepNavSelRange = "{4873, 0}";
sepNavVisRange = "{3110, 2232}";
sepNavWindowFrame = "{{12, 57}, {895, 821}}";
};
};
245463B80991757100464AD3 /* VinylDither.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {866, 832}}";
sepNavSelRange = "{2479, 0}";
sepNavVisRange = "{268, 2230}";
sepNavWindowFrame = "{{20, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {866, 910}}";
sepNavSelRange = "{2573, 0}";
sepNavVisRange = "{377, 2207}";
sepNavWindowFrame = "{{20, 57}, {895, 821}}";
};
};
24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = {
@ -82,10 +88,10 @@
};
24D8286F09A914000093AEF8 /* VinylDitherProc.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {848, 4719}}";
sepNavSelRange = "{614, 1892}";
sepNavVisRange = "{470, 2349}";
sepNavWindowFrame = "{{429, 47}, {895, 831}}";
sepNavIntBoundsRect = "{{0, 0}, {554, 3809}}";
sepNavSelRange = "{5856, 0}";
sepNavVisRange = "{0, 0}";
sepNavWindowFrame = "{{545, 57}, {895, 821}}";
};
};
8B02375E1D42B1C400E1E8C8 /* Source Control */ = {
@ -102,7 +108,27 @@
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
8D01CCC60486CAD60068D4B7 /* AudioUnit */ = {
8BB9A36F24B2817400CD76A8 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 24D8286F09A914000093AEF8 /* VinylDitherProc.cpp */;
name = "VinylDitherProc.cpp: 158";
rLen = 0;
rLoc = 5856;
rType = 0;
vrLen = 20;
vrLoc = 5835;
};
8BB9A5F924B298CE00CD76A8 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 24D8286F09A914000093AEF8 /* VinylDitherProc.cpp */;
name = "VinylDitherProc.cpp: 158";
rLen = 0;
rLoc = 5856;
rType = 0;
vrLen = 0;
vrLoc = 0;
};
8D01CCC60486CAD60068D4B7 /* VinylDither */ = {
activeExec = 0;
};
}

View file

@ -323,7 +323,7 @@
<real>185</real>
</array>
<key>RubberWindowFrame</key>
<string>419 306 810 487 0 0 1440 878 </string>
<string>627 289 810 487 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@ -339,7 +339,7 @@
<key>PBXProjectModuleGUID</key>
<string>8B0237581D42B1C400E1E8C8</string>
<key>PBXProjectModuleLabel</key>
<string>Gain.h</string>
<string>VinylDitherProc.cpp</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@ -347,7 +347,15 @@
<key>PBXProjectModuleGUID</key>
<string>8B0237591D42B1C400E1E8C8</string>
<key>PBXProjectModuleLabel</key>
<string>Gain.h</string>
<string>VinylDitherProc.cpp</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>8BB9A5F924B298CE00CD76A8</string>
<key>history</key>
<array>
<string>8BB9A36F24B2817400CD76A8</string>
</array>
</dict>
<key>SplitCount</key>
<string>1</string>
@ -360,18 +368,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {603, 0}}</string>
<string>{{0, 0}, {603, 32}}</string>
<key>RubberWindowFrame</key>
<string>419 306 810 487 0 0 1440 878 </string>
<string>627 289 810 487 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>0pt</string>
<string>32pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>441pt</string>
<string>409pt</string>
<key>Tabs</key>
<array>
<dict>
@ -385,9 +393,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {603, 414}}</string>
<string>{{10, 27}, {603, 382}}</string>
<key>RubberWindowFrame</key>
<string>419 306 810 487 0 0 1440 878 </string>
<string>627 289 810 487 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@ -469,11 +477,11 @@
</array>
<key>TableOfContents</key>
<array>
<string>8B9D7FDF1F7FB820007AB60F</string>
<string>8BB9A5FA24B298CE00CD76A8</string>
<string>1CA23ED40692098700951B8B</string>
<string>8B9D7FE01F7FB820007AB60F</string>
<string>8BB9A5FB24B298CE00CD76A8</string>
<string>8B0237581D42B1C400E1E8C8</string>
<string>8B9D7FE11F7FB820007AB60F</string>
<string>8BB9A5FC24B298CE00CD76A8</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@ -510,7 +518,7 @@
<key>Identifier</key>
<string>perspective.debug</string>
<key>IsVertical</key>
<integer>1</integer>
<true/>
<key>Layout</key>
<array>
<dict>
@ -524,12 +532,12 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {810, 0}}</string>
<string>{{0, 0}, {424, 270}}</string>
</dict>
<key>Module</key>
<string>PBXDebugCLIModule</string>
<key>Proportion</key>
<string>0%</string>
<string>270pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@ -578,8 +586,6 @@
</dict>
<key>GeometryConfiguration</key>
<dict>
<key>DebugConsoleDrawerSize</key>
<string>{100, 120}</string>
<key>DebugConsoleVisible</key>
<string>None</string>
<key>DebugConsoleWindowFrame</key>
@ -588,31 +594,53 @@
<string>{{200, 200}, {500, 300}}</string>
<key>Frame</key>
<string>{{0, 7}, {810, 438}}</string>
<key>PBXDebugSessionStackFrameViewKey</key>
<dict>
<key>DebugVariablesTableConfiguration</key>
<array>
<string>Name</string>
<real>120</real>
<string>Value</string>
<real>85</real>
<string>Summary</string>
<real>185</real>
</array>
<key>Frame</key>
<string>{{395, 0}, {415, 213}}</string>
</dict>
</dict>
<key>Module</key>
<string>PBXDebugSessionModule</string>
<key>Proportion</key>
<string>443pt</string>
<string>438pt</string>
</dict>
</array>
<key>Name</key>
<string>Debug</string>
<key>ServiceClasses</key>
<array>
<string>XCModuleDock</string>
<string>XCModuleDock</string>
<string>PBXDebugCLIModule</string>
<string>PBXDebugSessionModule</string>
<string>XCConsole</string>
<string>PBXDebugProcessAndThreadModule</string>
<string>PBXDebugProcessViewModule</string>
<string>PBXDebugThreadViewModule</string>
<string>PBXDebugStackFrameViewModule</string>
<string>PBXNavigatorGroup</string>
</array>
<key>TableOfContents</key>
<array>
<string>1CC8E6A5069209BD00BB180A</string>
<string>1CC8E6A6069209BD00BB180A</string>
<string>8BB0745024B12D71000F894A</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
<string>1CC8E6A7069209BD00BB180A</string>
<string>8BB0745124B12D71000F894A</string>
<string>8BB0745224B12D71000F894A</string>
<string>8BB0745324B12D71000F894A</string>
<string>8BB0745424B12D71000F894A</string>
<string>8BB0745524B12D71000F894A</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debugV3</string>
</dict>
@ -626,7 +654,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>528463904.983908</real>
<real>615684302.64082897</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@ -643,11 +671,11 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>8B9D7FE21F7FB820007AB60F</string>
<string>/Users/christopherjohnson/Desktop/MacVST/VinylDither/VinylDither.xcodeproj</string>
<string>8BB9A5FD24B298CE00CD76A8</string>
<string>/Users/christopherjohnson/Desktop/VinylDither/VinylDither.xcodeproj</string>
</array>
<key>WindowString</key>
<string>419 306 810 487 0 0 1440 878 </string>
<string>627 289 810 487 0 0 1440 878 </string>
<key>WindowToolsV3</key>
<array>
<dict>

View file

@ -1894,7 +1894,7 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
8D01CCC60486CAD60068D4B7 /* AudioUnit */ = {
8D01CCC60486CAD60068D4B7 /* VinylDither */ = {
isa = PBXNativeTarget;
buildConfigurationList = 24BEAAED08919AE700E695F9 /* Build configuration list for PBXNativeTarget "VinylDither" */;
buildPhases = (
@ -1947,7 +1947,7 @@
);
projectRoot = "";
targets = (
8D01CCC60486CAD60068D4B7 /* AudioUnit */,
8D01CCC60486CAD60068D4B7 /* VinylDither */,
);
};
/* End PBXProject section */

View file

@ -12,6 +12,9 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new V
VinylDither::VinylDither(audioMasterCallback audioMaster) :
AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
{
A = 1.0;
B = 0.0;
fpd = 17;
NSOddL = 0.0;
prevL = 0.0;
nsL[0] = 0;
@ -69,30 +72,80 @@ void VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::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 VinylDither::canDo(char *text)

View file

@ -16,7 +16,9 @@
#include <math.h>
enum {
kNumParameters = 0
kParamA = 0,
kParamB = 1,
kNumParameters = 2
}; //
const int kNumPrograms = 0;
@ -57,7 +59,11 @@ private:
double NSOddR;
double prevR;
double nsR[16];
uint32_t fpd;
//default stuff
float A;
float B;
};
#endif

View file

@ -16,54 +16,29 @@ void VinylDither::processReplacing(float **inputs, float **outputs, VstInt32 sam
double absSample;
long double inputSampleL;
long double inputSampleR;
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)
{
inputSampleL = *in1;
inputSampleR = *in2;
if (inputSampleL<1.2e-38 && -inputSampleL<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;
inputSampleL = applyresidue;
}
if (inputSampleR<1.2e-38 && -inputSampleR<1.2e-38) {
static int noisesource = 0;
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;
inputSampleR = 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.
}
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 *= 8388608.0;
inputSampleR *= 8388608.0;
inputSampleL *= scaleFactor;
inputSampleR *= scaleFactor;
//0-1 is now one bit, now we dither
absSample = ((rand()/(double)RAND_MAX) - 0.5);
@ -111,7 +86,6 @@ void VinylDither::processReplacing(float **inputs, float **outputs, VstInt32 sam
prevL = floor(absSample) - inputSampleL;
inputSampleL = floor(absSample);
//TenNines dither L
absSample = ((rand()/(double)RAND_MAX) - 0.5);
nsR[0] += absSample; nsR[0] /= 2; absSample -= nsR[0];
@ -159,9 +133,8 @@ void VinylDither::processReplacing(float **inputs, float **outputs, VstInt32 sam
inputSampleR = floor(absSample);
//TenNines dither R
inputSampleL /= 8388608.0;
inputSampleR /= 8388608.0;
inputSampleL /= outScale;
inputSampleR /= outScale;
*out1 = inputSampleL;
*out2 = inputSampleR;
@ -182,54 +155,29 @@ void VinylDither::processDoubleReplacing(double **inputs, double **outputs, VstI
double absSample;
long double inputSampleL;
long double inputSampleR;
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)
{
inputSampleL = *in1;
inputSampleR = *in2;
if (inputSampleL<1.2e-38 && -inputSampleL<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;
inputSampleL = applyresidue;
}
if (inputSampleR<1.2e-38 && -inputSampleR<1.2e-38) {
static int noisesource = 0;
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;
inputSampleR = 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.
}
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 *= 8388608.0;
inputSampleR *= 8388608.0;
inputSampleL *= scaleFactor;
inputSampleR *= scaleFactor;
//0-1 is now one bit, now we dither
absSample = ((rand()/(double)RAND_MAX) - 0.5);
@ -278,7 +226,6 @@ void VinylDither::processDoubleReplacing(double **inputs, double **outputs, VstI
inputSampleL = floor(absSample);
//TenNines dither L
absSample = ((rand()/(double)RAND_MAX) - 0.5);
nsR[0] += absSample; nsR[0] /= 2; absSample -= nsR[0];
absSample += ((rand()/(double)RAND_MAX) - 0.5);
@ -325,9 +272,8 @@ void VinylDither::processDoubleReplacing(double **inputs, double **outputs, VstI
inputSampleR = floor(absSample);
//TenNines dither R
inputSampleL /= 8388608.0;
inputSampleR /= 8388608.0;
inputSampleL /= outScale;
inputSampleR /= outScale;
*out1 = inputSampleL;
*out2 = inputSampleR;