Skip to content

Commit

Permalink
Finally the invert stage is done. (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Apr 30, 2024
1 parent a2718fc commit 24a3dea
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 26 deletions.
73 changes: 47 additions & 26 deletions scripts/import.pl
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,6 @@
$pttv .= " case kParam${param}: { auto b = string2float(text, value); if (b) { value = pow(std::max((value/$mul), 0.), (1.0/$exp)); } return b; break; }\n";
$ok = 1;
}
elsif ($formatter =~ m/float2string\s*\(([^,]+),[^;]+;\s*$/)
{
my $arg = $1;
print " CUSTOM ARG :" . $f . "::" . $param . " >> " . $arg . "\n";
print " INPUT : " . $formatter . "\n";

if ($arg =~ m/^\s*\(([${param}\*]+)([0-9.]+)\)\+([0-9.]+)/)
{
print " - GOT $1 $2 $3\n";
}
else
{
print " - UNKNOWN\n"
}
$ok = 0;
}
# db2string
elsif ($formatter =~ m/dB2string\s*\(\s*${param}\s*,[^;]+;\s*$/)
{
Expand All @@ -230,16 +214,52 @@
$pttv .= " case kParam${param}: { auto b = string2float(text, value); if (b) { value = (value + 0.1) / ${scl}; } return b; break; }\n";
$ok = 1;
}
else
{
print " INT BODY: " . $f . "::" . $param . " / " . $body . "\n";
$ok = 0;
}
}
else
elsif ($formatter =~ m/ceil\(\(A\*3.999\)/)
{
# those pesky biquads
$pttv .= " case kParam${param}: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }\n";
$ok = 1;
}


if (!$ok)
{
$printed = 1;
print " Skipping convert :" . $f . "::" . $param . " / " . $formatter . "\n";
# sometimes you just give up you know?
my %specialCases;

$specialCases{"IronOxide5::B"} = "pow(std::max((value - 1.5) / 148.5, 0.), 0.25)";
$specialCases{"IronOxide5::C"} = "pow(std::max((value - 1.5) / 148.5, 0.), 0.25)";
$specialCases{"IronOxideClassic::B"} = "pow(std::max((value - 1.5) / 148.5, 0.), 0.25)";
$specialCases{"IronOxideClassic2::B"} = "pow(std::max((value - 1.5) / 148.5, 0.), 0.25)";
$specialCases{"Pockey2::B"} = "(value - 4.0) / 12.0";
$specialCases{"Compresaturator::C"} = "std::sqrt(std::max(value/5000.0,0.))";
$specialCases{"AQuickVoiceClip::A"} = "std::cbrt((value - 30.)/2070.)";

my $intLike = sub {
my ($b, $o) = @_;
return "(std::round(value) + 0.1 - (${o}))/${b}"
};

$specialCases{"VoiceOfTheStarship::B"} = $intLike->(16.9, 0);
$specialCases{"Ensemble::A"} = $intLike->(46.0, 2.9);
$specialCases{"BitShiftGain::A"} = $intLike->(32, -16);
$specialCases{"Fracture::B"} = $intLike->(2.9999, 1);
$specialCases{"GlitchShifter::A"} = $intLike->(24.9999, -12);
$specialCases{"PitchNasty::A"} = $intLike->(24, -12);
$specialCases{"PitchNasty::C"} = $intLike->(72, -36);
$specialCases{"TapeDelay::F"} = $intLike->(29, 3);
$specialCases{"TapeFat::B"} = $intLike->(29, 3);



my $key = $f . "::" . $param;

if (exists $specialCases{$key})
{
$pttv .= " case kParam${param}: { auto b = string2float(text, value); if (b) { value = std::clamp( $specialCases{$key}, 0., 1. ); } return b; break; }\n";
$ok = 1;
}
}

if ($ok)
Expand All @@ -249,14 +269,15 @@
elsif ($isSwitch)
{
# supress this warning
# print " UNINVERTED SWTCH : " . $f . "::" . $param . "\n";
}
elsif ($formatter =~ m/int2string/)
{
print " INT UNDONE: " . $f . "::" . $param . " / " . $formatter . "\n";
print " UNINVERTED INT : " . $f . "::" . $param . " / " . $formatter . "\n";
}
else
{
print " UNINVERTED: " . $f . "::" . $param . " / " . $formatter . "\n";
print " UNINVERTED FLT : " . $f . "::" . $param . " / " . $formatter . "\n";
}

$pdt =~ s/^.*?case kParam(\S+):(.*?)break;//s;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/AQuickVoiceClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ bool AQuickVoiceClip::getVendorString(char* text) {
}
bool AQuickVoiceClip::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp( std::cbrt((value - 30.)/2070.), 0., 1. ); } return b; break; }

}
return false;
}
bool AQuickVoiceClip::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;

}
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Biquad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool Biquad::getVendorString(char* text) {
}
bool Biquad::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.0001) / (0.9999)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.01) / (29.99)); } return b; break; }
case kParamD: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
Expand All @@ -127,6 +128,7 @@ bool Biquad::parameterTextToValue(VstInt32 index, const char *text, float &value
}
bool Biquad::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Biquad2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ bool Biquad2::getVendorString(char* text) {
}
bool Biquad2::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = sqrt(std::max((value - 0.0001) / (0.9999), 0.)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = sqrt(std::max((value - 0.01) / (49.99), 0.)); } return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
Expand All @@ -146,6 +147,7 @@ bool Biquad2::parameterTextToValue(VstInt32 index, const char *text, float &valu
}
bool Biquad2::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/BiquadDouble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool BiquadDouble::getVendorString(char* text) {
}
bool BiquadDouble::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.0001) / (0.9999)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.01) / (29.99)); } return b; break; }
case kParamD: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
Expand All @@ -127,6 +128,7 @@ bool BiquadDouble::parameterTextToValue(VstInt32 index, const char *text, float
}
bool BiquadDouble::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/BiquadOneHalf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ bool BiquadOneHalf::getVendorString(char* text) {
}
bool BiquadOneHalf::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.0001) / (0.9999)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.01) / (29.99)); } return b; break; }
case kParamD: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
Expand All @@ -128,6 +129,7 @@ bool BiquadOneHalf::parameterTextToValue(VstInt32 index, const char *text, float
}
bool BiquadOneHalf::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/BiquadPlus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool BiquadPlus::getVendorString(char* text) {
}
bool BiquadPlus::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.0001) / (0.9999)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.01) / (29.99)); } return b; break; }
case kParamD: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
Expand All @@ -127,6 +128,7 @@ bool BiquadPlus::parameterTextToValue(VstInt32 index, const char *text, float &v
}
bool BiquadPlus::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/BiquadTriple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool BiquadTriple::getVendorString(char* text) {
}
bool BiquadTriple::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp(std::round(value) * 0.25 - 0.245, 0., 1.); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.0001) / (0.9999)); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::cbrt((value - 0.01) / (29.99)); } return b; break; }
case kParamD: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
Expand All @@ -127,6 +128,7 @@ bool BiquadTriple::parameterTextToValue(VstInt32 index, const char *text, float
}
bool BiquadTriple::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/BitShiftGain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ bool BitShiftGain::getVendorString(char* text) {
}
bool BitShiftGain::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (-16))/32, 0., 1. ); } return b; break; }

}
return false;
}
bool BitShiftGain::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;

}
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Compresaturator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ bool Compresaturator::parameterTextToValue(VstInt32 index, const char *text, flo
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = (value + 12.0) / (24.0); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = value / (100); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::clamp( std::sqrt(std::max(value/5000.0,0.)), 0., 1. ); } return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
case kParamE: { auto b = string2float(text, value); return b; break; }

Expand All @@ -143,6 +144,7 @@ bool Compresaturator::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
case kParamE: return true;

Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Ensemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ bool Ensemble::getVendorString(char* text) {
}
bool Ensemble::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (2.9))/46, 0., 1. ); } return b; break; }
case kParamB: { auto b = string2float(text, value); return b; break; }
case kParamC: { auto b = string2float(text, value); return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
Expand All @@ -139,6 +140,7 @@ bool Ensemble::parameterTextToValue(VstInt32 index, const char *text, float &val
}
bool Ensemble::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Fracture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool Fracture::getVendorString(char* text) {
bool Fracture::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = value / (4); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (1))/2.9999, 0., 1. ); } return b; break; }
case kParamC: { auto b = string2dBNorm(text, value); return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }

Expand All @@ -127,6 +128,7 @@ bool Fracture::parameterTextToValue(VstInt32 index, const char *text, float &val
bool Fracture::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;

Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/GlitchShifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ bool GlitchShifter::getVendorString(char* text) {
}
bool GlitchShifter::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (-12))/24.9999, 0., 1. ); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = (value + 1.0) / (2.0); } return b; break; }
case kParamC: { auto b = string2float(text, value); return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
Expand All @@ -169,6 +170,7 @@ bool GlitchShifter::parameterTextToValue(VstInt32 index, const char *text, float
}
bool GlitchShifter::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
Expand Down
4 changes: 4 additions & 0 deletions src/autogen_airwin/IronOxide5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ bool IronOxide5::getVendorString(char* text) {
bool IronOxide5::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::clamp( pow(std::max((value - 1.5) / 148.5, 0.), 0.25), 0., 1. ); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::clamp( pow(std::max((value - 1.5) / 148.5, 0.), 0.25), 0., 1. ); } return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
case kParamE: { auto b = string2float(text, value); return b; break; }
case kParamF: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }
Expand All @@ -173,6 +175,8 @@ bool IronOxide5::parameterTextToValue(VstInt32 index, const char *text, float &v
bool IronOxide5::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
case kParamE: return true;
case kParamF: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/IronOxideClassic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ bool IronOxideClassic::getVendorString(char* text) {
bool IronOxideClassic::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::clamp( pow(std::max((value - 1.5) / 148.5, 0.), 0.25), 0., 1. ); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }

}
Expand All @@ -128,6 +129,7 @@ bool IronOxideClassic::parameterTextToValue(VstInt32 index, const char *text, fl
bool IronOxideClassic::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;

}
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/IronOxideClassic2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ bool IronOxideClassic2::getVendorString(char* text) {
bool IronOxideClassic2::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::clamp( pow(std::max((value - 1.5) / 148.5, 0.), 0.25), 0., 1. ); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = (value + 18.0) / (36.0); } return b; break; }

}
Expand All @@ -131,6 +132,7 @@ bool IronOxideClassic2::parameterTextToValue(VstInt32 index, const char *text, f
bool IronOxideClassic2::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;

}
Expand Down
4 changes: 4 additions & 0 deletions src/autogen_airwin/PitchNasty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ bool PitchNasty::getVendorString(char* text) {
}
bool PitchNasty::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (-12))/24, 0., 1. ); } return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = (value + 12.0) / (24.0); } return b; break; }
case kParamC: { auto b = string2float(text, value); if (b) { value = std::clamp( (std::round(value) + 0.1 - (-36))/72, 0., 1. ); } return b; break; }
case kParamD: { auto b = string2float(text, value); return b; break; }
case kParamE: { auto b = string2float(text, value); return b; break; }
case kParamF: { auto b = string2float(text, value); return b; break; }
Expand All @@ -147,7 +149,9 @@ bool PitchNasty::parameterTextToValue(VstInt32 index, const char *text, float &v
}
bool PitchNasty::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;
case kParamD: return true;
case kParamE: return true;
case kParamF: return true;
Expand Down
2 changes: 2 additions & 0 deletions src/autogen_airwin/Pockey2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ bool Pockey2::getVendorString(char* text) {
bool Pockey2::parameterTextToValue(VstInt32 index, const char *text, float &value) {
switch(index) {
case kParamA: { auto b = string2float(text, value); return b; break; }
case kParamB: { auto b = string2float(text, value); if (b) { value = std::clamp( (value - 4.0) / 12.0, 0., 1. ); } return b; break; }
case kParamC: { auto b = string2float(text, value); return b; break; }

}
Expand All @@ -131,6 +132,7 @@ bool Pockey2::parameterTextToValue(VstInt32 index, const char *text, float &valu
bool Pockey2::canConvertParameterTextToValue(VstInt32 index) {
switch(index) {
case kParamA: return true;
case kParamB: return true;
case kParamC: return true;

}
Expand Down
Loading

0 comments on commit 24a3dea

Please sign in to comment.