Gjorde en enkel körbar EXE för Windows av allt detta

This commit is contained in:
crille committed 2026-11-21 18:23:26 +01:00
1 parent 3f3fdeddf3
commit ee80ef7d89
15 files changed
+180 -498

No files matched your search

+95 -27
View File
@@ -10,8 +10,9 @@ constexpr float meterFloorDb = -80.0f;
}
CrilleBassStripAudioProcessor::CrilleBassStripAudioProcessor()
: AudioProcessor(BusesProperties().withInput("Input", juce::AudioChannelSet::stereo(), true)
.withOutput("Output", juce::AudioChannelSet::stereo(), true)),
: AudioProcessor(BusesProperties()
.withInput("Input", juce::AudioChannelSet::mono(), true)
.withOutput("Output", juce::AudioChannelSet::stereo(), true)),
apvts(*this, nullptr, "PARAMETERS", createParameterLayout())
{
}
@@ -58,11 +59,13 @@ void CrilleBassStripAudioProcessor::prepareToPlay(double sr, int block)
updateFilters();
}
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& l) const
bool CrilleBassStripAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
{
const auto out = l.getMainOutputChannelSet();
return (out == juce::AudioChannelSet::mono() || out == juce::AudioChannelSet::stereo())
&& out == l.getMainInputChannelSet();
const auto input = layouts.getMainInputChannelSet();
const auto output = layouts.getMainOutputChannelSet();
return input == juce::AudioChannelSet::mono()
&& output == juce::AudioChannelSet::stereo();
}
float CrilleBassStripAudioProcessor::getBufferPeak(const juce::AudioBuffer<float>& buffer) noexcept
@@ -88,69 +91,134 @@ void CrilleBassStripAudioProcessor::updateFilters()
void CrilleBassStripAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&)
{
juce::ScopedNoDenormals noDenormals;
// Clear output channels that do not contain input data.
for (int c = getTotalNumInputChannels(); c < getTotalNumOutputChannels(); ++c)
buffer.clear(c, 0, buffer.getNumSamples());
const float gateInputPeak = getBufferPeak(buffer);
gateInputLevelDb.store(juce::Decibels::gainToDecibels(gateInputPeak, meterFloorDb), std::memory_order_relaxed);
// Copy mono bass input to both stereo output channels.
if (buffer.getNumChannels() >= 2)
buffer.copyFrom(1, 0, buffer, 0, 0, buffer.getNumSamples());
const float threshold = dbToGain(apvts.getRawParameterValue("gateThreshold")->load());
const float releaseMs = apvts.getRawParameterValue("gateRelease")->load();
const float releaseCoeff = std::exp(-1.f / (0.001f * releaseMs * static_cast<float>(currentSampleRate)));
const float gateGain = dbToGain(apvts.getRawParameterValue("gateGain")->load());
// Measure input level before the noise gate.
const float gateInputPeak = getBufferPeak(buffer);
gateInputLevelDb.store(
juce::Decibels::gainToDecibels(gateInputPeak, meterFloorDb),
std::memory_order_relaxed);
// Noise gate
const float threshold =
dbToGain(apvts.getRawParameterValue("gateThreshold")->load());
const float releaseMs =
apvts.getRawParameterValue("gateRelease")->load();
const float releaseCoeff =
std::exp(-1.f / (0.001f * releaseMs *
static_cast<float>(currentSampleRate)));
const float gateGain =
dbToGain(apvts.getRawParameterValue("gateGain")->load());
for (int c = 0; c < buffer.getNumChannels(); ++c)
{
auto* x = buffer.getWritePointer(c);
auto& env = gateEnvelope[static_cast<size_t>(c)];
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
const float target = std::abs(x[i]) >= threshold ? 1.f : 0.f;
env = target > env ? target : releaseCoeff * env;
const float target =
std::abs(x[i]) >= threshold ? 1.f : 0.f;
env = target > env
? target
: releaseCoeff * env;
x[i] *= env * gateGain;
}
}
// Measure compressor input level.
const float compressorInputPeak = getBufferPeak(buffer);
compressorInputLevelDb.store(juce::Decibels::gainToDecibels(compressorInputPeak, meterFloorDb), std::memory_order_relaxed);
compressor.setThreshold(apvts.getRawParameterValue("compThreshold")->load());
compressor.setRatio(apvts.getRawParameterValue("compRatio")->load());
compressorInputLevelDb.store(
juce::Decibels::gainToDecibels(
compressorInputPeak,
meterFloorDb),
std::memory_order_relaxed);
// Compressor
compressor.setThreshold(
apvts.getRawParameterValue("compThreshold")->load());
compressor.setRatio(
apvts.getRawParameterValue("compRatio")->load());
compressor.setAttack(15.f);
compressor.setRelease(100.f);
juce::dsp::AudioBlock<float> block(buffer);
juce::dsp::ProcessContextReplacing<float> context(block);
compressor.process(context);
// Calculate compressor gain reduction.
const float compressorOutputPeak = getBufferPeak(buffer);
const float gainReduction = compressorInputPeak > 0.0f
? juce::jmax(0.0f, juce::Decibels::gainToDecibels(compressorInputPeak / juce::jmax(compressorOutputPeak, 1.0e-9f)))
: 0.0f;
compressorGainReductionDb.store(juce::jlimit(0.0f, 24.0f, gainReduction), std::memory_order_relaxed);
buffer.applyGain(dbToGain(apvts.getRawParameterValue("compGain")->load()));
const float gainReduction =
compressorInputPeak > 0.0f
? juce::jmax(
0.0f,
juce::Decibels::gainToDecibels(
compressorInputPeak /
juce::jmax(compressorOutputPeak, 1.0e-9f)))
: 0.0f;
compressorGainReductionDb.store(
juce::jlimit(0.0f, 24.0f, gainReduction),
std::memory_order_relaxed);
// Compressor makeup gain.
buffer.applyGain(
dbToGain(
apvts.getRawParameterValue("compGain")->load()));
// Distortion
const float drive =
dbToGain(apvts.getRawParameterValue("drive")->load());
const float mix =
apvts.getRawParameterValue("mix")->load() * 0.01f;
const float dg =
dbToGain(apvts.getRawParameterValue("distGain")->load());
const float drive = dbToGain(apvts.getRawParameterValue("drive")->load());
const float mix = apvts.getRawParameterValue("mix")->load() * 0.01f;
const float dg = dbToGain(apvts.getRawParameterValue("distGain")->load());
for (int c = 0; c < buffer.getNumChannels(); ++c)
{
auto* x = buffer.getWritePointer(c);
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
const float dry = x[i];
const float wet = std::tanh(dry * drive);
x[i] = ((1.f - mix) * dry + mix * wet) * dg;
x[i] =
((1.f - mix) * dry + mix * wet) * dg;
}
}
// EQ
updateFilters();
lowShelf.process(context);
lowMid.process(context);
mid.process(context);
highShelf.process(context);
buffer.applyGain(dbToGain(apvts.getRawParameterValue("output")->load()));
// Final output gain.
buffer.applyGain(
dbToGain(
apvts.getRawParameterValue("output")->load()));
}
void CrilleBassStripAudioProcessor::getStateInformation(juce::MemoryBlock& dest)
+1 -1
View File
@@ -15,7 +15,7 @@ public:
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override { return true; }
const juce::String getName() const override { return JucePlugin_Name; }
const juce::String getName() const override { return "Crille Bass Strip"; }
bool acceptsMidi() const override { return false; }
bool producesMidi() const override { return false; }
bool isMidiEffect() const override { return false; }