git subrepo clone --branch=sono6good https://github.com/essej/JUCE.git deps/juce

subrepo:
  subdir:   "deps/juce"
  merged:   "b13f9084e"
upstream:
  origin:   "https://github.com/essej/JUCE.git"
  branch:   "sono6good"
  commit:   "b13f9084e"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
This commit is contained in:
essej
2022-04-18 17:51:22 -04:00
parent 63e175fee6
commit 25bd5d8adb
3210 changed files with 1045392 additions and 0 deletions

24
deps/juce/examples/DSP/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,24 @@
# ==============================================================================
#
# This file is part of the JUCE library.
# Copyright (c) 2020 - Raw Material Software Limited
#
# JUCE is an open source library subject to commercial or open-source
# licensing.
#
# By using JUCE, you agree to the terms of both the JUCE 6 End-User License
# Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
#
# End User License Agreement: www.juce.com/juce-6-licence
# Privacy Policy: www.juce.com/juce-privacy-policy
#
# Or: You may also use this code under the terms of the GPL v3 (see
# www.gnu.org/licenses).
#
# JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
# EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
# DISCLAIMED.
#
# ==============================================================================
_juce_add_pips()

203
deps/juce/examples/DSP/ConvolutionDemo.h vendored Normal file
View File

@ -0,0 +1,203 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: ConvolutionDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: Convolution demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: ConvolutionDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct ConvolutionDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
convolution.prepare (spec);
updateParameters();
}
void process (ProcessContextReplacing<float> context)
{
context.isBypassed = bypass;
// Load a new IR if there's one available. Note that this doesn't lock or allocate!
bufferTransfer.get ([this] (BufferWithSampleRate& buf)
{
convolution.loadImpulseResponse (std::move (buf.buffer),
buf.sampleRate,
Convolution::Stereo::yes,
Convolution::Trim::yes,
Convolution::Normalise::yes);
});
convolution.process (context);
}
void reset()
{
convolution.reset();
}
void updateParameters()
{
auto* cabinetTypeParameter = dynamic_cast<ChoiceParameter*> (parameters[0]);
if (cabinetTypeParameter == nullptr)
{
jassertfalse;
return;
}
if (cabinetTypeParameter->getCurrentSelectedID() == 1)
{
bypass = true;
}
else
{
bypass = false;
auto selectedType = cabinetTypeParameter->getCurrentSelectedID();
auto assetName = (selectedType == 2 ? "guitar_amp.wav" : "cassette_recorder.wav");
auto assetInputStream = createAssetInputStream (assetName);
if (assetInputStream == nullptr)
{
jassertfalse;
return;
}
AudioFormatManager manager;
manager.registerBasicFormats();
std::unique_ptr<AudioFormatReader> reader { manager.createReaderFor (std::move (assetInputStream)) };
if (reader == nullptr)
{
jassertfalse;
return;
}
AudioBuffer<float> buffer (static_cast<int> (reader->numChannels),
static_cast<int> (reader->lengthInSamples));
reader->read (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), 0, buffer.getNumSamples());
bufferTransfer.set (BufferWithSampleRate { std::move (buffer), reader->sampleRate });
}
}
//==============================================================================
struct BufferWithSampleRate
{
BufferWithSampleRate() = default;
BufferWithSampleRate (AudioBuffer<float>&& bufferIn, double sampleRateIn)
: buffer (std::move (bufferIn)), sampleRate (sampleRateIn) {}
AudioBuffer<float> buffer;
double sampleRate = 0.0;
};
class BufferTransfer
{
public:
void set (BufferWithSampleRate&& p)
{
const SpinLock::ScopedLockType lock (mutex);
buffer = std::move (p);
newBuffer = true;
}
// Call `fn` passing the new buffer, if there's one available
template <typename Fn>
void get (Fn&& fn)
{
const SpinLock::ScopedTryLockType lock (mutex);
if (lock.isLocked() && newBuffer)
{
fn (buffer);
newBuffer = false;
}
}
private:
BufferWithSampleRate buffer;
bool newBuffer = false;
SpinLock mutex;
};
double sampleRate = 0.0;
bool bypass = false;
MemoryBlock currentCabinetData;
Convolution convolution;
BufferTransfer bufferTransfer;
ChoiceParameter cabinetParam { { "Bypass", "Guitar amplifier 8''", "Cassette recorder" }, 1, "Cabinet Type" };
std::vector<DSPDemoParameterBase*> parameters { &cabinetParam };
};
struct ConvolutionDemo : public Component
{
ConvolutionDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<ConvolutionDemoDSP> fileReaderComponent;
};

115
deps/juce/examples/DSP/FIRFilterDemo.h vendored Normal file
View File

@ -0,0 +1,115 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: FIRFilterDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: FIR filter demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: FIRFilterDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct FIRFilterDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
fir.state = FilterDesign<float>::designFIRLowpassWindowMethod (440.0f, sampleRate, 21,
WindowingFunction<float>::blackman);
fir.prepare (spec);
}
void process (const ProcessContextReplacing<float>& context)
{
fir.process (context);
}
void reset()
{
fir.reset();
}
void updateParameters()
{
if (sampleRate != 0.0)
{
auto cutoff = static_cast<float> (cutoffParam.getCurrentValue());
auto windowingMethod = static_cast<WindowingFunction<float>::WindowingMethod> (typeParam.getCurrentSelectedID() - 1);
*fir.state = *FilterDesign<float>::designFIRLowpassWindowMethod (cutoff, sampleRate, 21, windowingMethod);
}
}
//==============================================================================
ProcessorDuplicator<FIR::Filter<float>, FIR::Coefficients<float>> fir;
double sampleRate = 0.0;
SliderParameter cutoffParam { { 20.0, 20000.0 }, 0.4, 440.0f, "Cutoff", "Hz" };
ChoiceParameter typeParam { { "Rectangular", "Triangular", "Hann", "Hamming", "Blackman", "Blackman-Harris", "Flat Top", "Kaiser" },
5, "Windowing Function" };
std::vector<DSPDemoParameterBase*> parameters { &cutoffParam, &typeParam };
};
struct FIRFilterDemo : public Component
{
FIRFilterDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<FIRFilterDemoDSP> fileReaderComponent;
};

100
deps/juce/examples/DSP/GainDemo.h vendored Normal file
View File

@ -0,0 +1,100 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: GainDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: Gain demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: GainDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct GainDemoDSP
{
void prepare (const ProcessSpec&)
{
gain.setGainDecibels (-6.0f);
}
void process (const ProcessContextReplacing<float>& context)
{
gain.process (context);
}
void reset()
{
gain.reset();
}
void updateParameters()
{
gain.setGainDecibels (static_cast<float> (gainParam.getCurrentValue()));
}
//==============================================================================
Gain<float> gain;
SliderParameter gainParam { { -100.0, 20.0 }, 3.0, -6.0, "Gain", "dB" };
std::vector<DSPDemoParameterBase*> parameters { &gainParam };
};
struct GainDemo : public Component
{
GainDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<GainDemoDSP> fileReaderComponent;
};

119
deps/juce/examples/DSP/IIRFilterDemo.h vendored Normal file
View File

@ -0,0 +1,119 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: IIRFilterDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: IIR filter demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: IIRFilterDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct IIRFilterDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
iir.state = IIR::Coefficients<float>::makeLowPass (sampleRate, 440.0);
iir.prepare (spec);
}
void process (const ProcessContextReplacing<float>& context)
{
iir.process (context);
}
void reset()
{
iir.reset();
}
void updateParameters()
{
if (sampleRate != 0.0)
{
auto cutoff = static_cast<float> (cutoffParam.getCurrentValue());
auto qVal = static_cast<float> (qParam.getCurrentValue());
switch (typeParam.getCurrentSelectedID())
{
case 1: *iir.state = IIR::ArrayCoefficients<float>::makeLowPass (sampleRate, cutoff, qVal); break;
case 2: *iir.state = IIR::ArrayCoefficients<float>::makeHighPass (sampleRate, cutoff, qVal); break;
case 3: *iir.state = IIR::ArrayCoefficients<float>::makeBandPass (sampleRate, cutoff, qVal); break;
default: break;
}
}
}
//==============================================================================
ProcessorDuplicator<IIR::Filter<float>, IIR::Coefficients<float>> iir;
ChoiceParameter typeParam { { "Low-pass", "High-pass", "Band-pass" }, 1, "Type" };
SliderParameter cutoffParam { { 20.0, 20000.0 }, 0.5, 440.0f, "Cutoff", "Hz" };
SliderParameter qParam { { 0.3, 20.0 }, 0.5, 1.0 / std::sqrt(2.0), "Q" };
std::vector<DSPDemoParameterBase*> parameters { &typeParam, &cutoffParam, &qParam };
double sampleRate = 0.0;
};
struct IIRFilterDemo : public Component
{
IIRFilterDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<IIRFilterDemoDSP> fileReaderComponent;
};

151
deps/juce/examples/DSP/OscillatorDemo.h vendored Normal file
View File

@ -0,0 +1,151 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: OscillatorDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: Oscillator demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: OscillatorDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct OscillatorDemoDSP
{
void prepare (const ProcessSpec& spec)
{
gain.setGainDecibels (-6.0f);
for (auto&& oscillator : oscillators)
{
oscillator.setFrequency (440.f);
oscillator.prepare (spec);
}
updateParameters();
tempBuffer = AudioBlock<float> (tempBufferMemory, spec.numChannels, spec.maximumBlockSize);
}
void process (const ProcessContextReplacing<float>& context)
{
tempBuffer.copyFrom (context.getInputBlock());
tempBuffer.multiplyBy (static_cast<float> (fileMix));
oscillators[currentOscillatorIdx].process (context);
context.getOutputBlock().multiplyBy (static_cast<float> (1.0 - fileMix));
context.getOutputBlock().add (tempBuffer);
gain.process (context);
}
void reset()
{
oscillators[currentOscillatorIdx].reset();
}
void updateParameters()
{
currentOscillatorIdx = jmin (numElementsInArray (oscillators),
3 * (accuracy.getCurrentSelectedID() - 1) + (typeParam.getCurrentSelectedID() - 1));
auto freq = static_cast<float> (freqParam.getCurrentValue());
for (auto&& oscillator : oscillators)
oscillator.setFrequency (freq);
gain.setGainDecibels (static_cast<float> (gainParam.getCurrentValue()));
fileMix = mixParam.getCurrentValue();
}
//==============================================================================
Oscillator<float> oscillators[6] =
{
// No Approximation
{[] (float x) { return std::sin (x); }}, // sine
{[] (float x) { return x / MathConstants<float>::pi; }}, // saw
{[] (float x) { return x < 0.0f ? -1.0f : 1.0f; }}, // square
// Approximated by a wave-table
{[] (float x) { return std::sin (x); }, 100}, // sine
{[] (float x) { return x / MathConstants<float>::pi; }, 100}, // saw
{[] (float x) { return x < 0.0f ? -1.0f : 1.0f; }, 100} // square
};
int currentOscillatorIdx = 0;
Gain<float> gain;
ChoiceParameter typeParam { {"sine", "saw", "square"}, 1, "Type" };
ChoiceParameter accuracy { {"No Approximation", "Use Wavetable"}, 1, "Accuracy" };
SliderParameter freqParam { { 20.0, 24000.0 }, 0.4, 440.0, "Frequency", "Hz" };
SliderParameter gainParam { { -100.0, 20.0 }, 3.0, -20.0, "Gain", "dB" };
SliderParameter mixParam { { 0.0, 1.0 }, 1.0, 0.0, "File mix" };
HeapBlock<char> tempBufferMemory;
AudioBlock<float> tempBuffer;
double fileMix;
std::vector<DSPDemoParameterBase*> parameters { &typeParam, &accuracy, &freqParam, &gainParam, &mixParam };
};
struct OscillatorDemo : public Component
{
OscillatorDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<OscillatorDemoDSP> fileReaderComponent;
};

130
deps/juce/examples/DSP/OverdriveDemo.h vendored Normal file
View File

@ -0,0 +1,130 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: OverdriveDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: Overdrive demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: OverdriveDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct OverdriveDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
auto& gainUp = overdrive.get<0>();
gainUp.setGainDecibels (24);
auto& bias = overdrive.get<1>();
bias.setBias (0.4f);
auto& wavShaper = overdrive.get<2>();
wavShaper.functionToUse = std::tanh;
auto& dcFilter = overdrive.get<3>();
dcFilter.state = IIR::Coefficients<float>::makeHighPass (sampleRate, 5.0);
auto& gainDown = overdrive.get<4>();
gainDown.setGainDecibels (-18.0f);
overdrive.prepare (spec);
}
void process (const ProcessContextReplacing<float>& context)
{
overdrive.process (context);
}
void reset()
{
overdrive.reset();
}
void updateParameters()
{
if (sampleRate != 0.0)
{
overdrive.get<0>().setGainDecibels (static_cast<float> (inGainParam.getCurrentValue()));
overdrive.get<4>().setGainDecibels (static_cast<float> (outGainParam.getCurrentValue()));
}
}
//==============================================================================
using GainProcessor = Gain<float>;
using BiasProcessor = Bias<float>;
using DriveProcessor = WaveShaper<float>;
using DCFilter = ProcessorDuplicator<IIR::Filter<float>,
IIR::Coefficients<float>>;
ProcessorChain<GainProcessor, BiasProcessor, DriveProcessor, DCFilter, GainProcessor> overdrive;
SliderParameter inGainParam { { -100.0, 60.0 }, 3, 24.0, "Input Gain", "dB" };
SliderParameter outGainParam { { -100.0, 20.0 }, 3, -18.0, "Output Gain", "dB" };
std::vector<DSPDemoParameterBase*> parameters { &inGainParam, &outGainParam };
double sampleRate = 0.0;
};
struct OverdriveDemo : public Component
{
OverdriveDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<OverdriveDemoDSP> fileReaderComponent;
};

View File

@ -0,0 +1,159 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: SIMDRegisterDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: SIMD register demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: SIMDRegisterDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct SIMDRegisterDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
iirCoefficients = IIR::Coefficients<float>::makeLowPass (sampleRate, 440.0f);
iir.reset (new IIR::Filter<SIMDRegister<float>> (iirCoefficients));
interleaved = AudioBlock<SIMDRegister<float>> (interleavedBlockData, 1, spec.maximumBlockSize);
zero = AudioBlock<float> (zeroData, SIMDRegister<float>::size(), spec.maximumBlockSize);
zero.clear();
auto monoSpec = spec;
monoSpec.numChannels = 1;
iir->prepare (monoSpec);
}
void process (const ProcessContextReplacing<float>& context)
{
jassert (context.getInputBlock().getNumSamples() == context.getOutputBlock().getNumSamples());
jassert (context.getInputBlock().getNumChannels() == context.getOutputBlock().getNumChannels());
auto& input = context.getInputBlock();
auto& output = context.getOutputBlock();
auto n = (int) input.getNumSamples();
auto* inout = channelPointers.getData();
for (size_t ch = 0; ch < SIMDRegister<float>::size(); ++ch)
inout[ch] = (ch < input.getNumChannels() ? const_cast<float*> (input.getChannelPointer (ch)) : zero.getChannelPointer (ch));
using DstSampleType = AudioData::Pointer<AudioData::Float32, AudioData::NativeEndian, AudioData::Interleaved, AudioData::NonConst>;
using SrcSampleType = AudioData::Pointer<AudioData::Float32, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::NonConst>;
DstSampleType dstData (interleaved.getChannelPointer (0), (int) interleaved.getNumChannels());
SrcSampleType srcData (inout);
dstData.convertSamples (srcData, n);
iir->process (ProcessContextReplacing<SIMDRegister<float>> (interleaved));
for (size_t ch = 0; ch < input.getNumChannels(); ++ch)
inout[ch] = output.getChannelPointer (ch);
srcData.convertSamples (dstData, n);
}
void reset()
{
iir.reset();
}
void updateParameters()
{
if (sampleRate != 0.0)
{
auto cutoff = static_cast<float> (cutoffParam.getCurrentValue());
auto qVal = static_cast<float> (qParam.getCurrentValue());
switch (typeParam.getCurrentSelectedID())
{
case 1: *iirCoefficients = IIR::ArrayCoefficients<float>::makeLowPass (sampleRate, cutoff, qVal); break;
case 2: *iirCoefficients = IIR::ArrayCoefficients<float>::makeHighPass (sampleRate, cutoff, qVal); break;
case 3: *iirCoefficients = IIR::ArrayCoefficients<float>::makeBandPass (sampleRate, cutoff, qVal); break;
default: break;
}
}
}
//==============================================================================
IIR::Coefficients<float>::Ptr iirCoefficients;
std::unique_ptr<IIR::Filter<SIMDRegister<float>>> iir;
AudioBlock<SIMDRegister<float>> interleaved;
AudioBlock<float> zero;
HeapBlock<char> interleavedBlockData, zeroData;
HeapBlock<const float*> channelPointers { SIMDRegister<float>::size() };
ChoiceParameter typeParam { { "Low-pass", "High-pass", "Band-pass" }, 1, "Type" };
SliderParameter cutoffParam { { 20.0, 20000.0 }, 0.5, 440.0f, "Cutoff", "Hz" };
SliderParameter qParam { { 0.3, 20.0 }, 0.5, 0.7, "Q" };
std::vector<DSPDemoParameterBase*> parameters { &typeParam, &cutoffParam, &qParam };
double sampleRate = 0.0;
};
struct SIMDRegisterDemo : public Component
{
SIMDRegisterDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<SIMDRegisterDemoDSP> fileReaderComponent;
};

View File

@ -0,0 +1,117 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: StateVariableFilterDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: State variable filter demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: StateVariableFilterDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct StateVariableFilterDemoDSP
{
void prepare (const ProcessSpec& spec)
{
sampleRate = spec.sampleRate;
filter.prepare (spec);
}
void process (const ProcessContextReplacing<float>& context)
{
filter.process (context);
}
void reset()
{
filter.reset();
}
void updateParameters()
{
if (sampleRate != 0.0)
{
filter.setCutoffFrequency (static_cast<float> (cutoffParam.getCurrentValue()));
filter.setResonance (static_cast<float> (qParam.getCurrentValue()));
switch (typeParam.getCurrentSelectedID() - 1)
{
case 0: filter.setType (StateVariableTPTFilterType::lowpass); break;
case 1: filter.setType (StateVariableTPTFilterType::bandpass); break;
case 2: filter.setType (StateVariableTPTFilterType::highpass); break;
default: jassertfalse; break;
};
}
}
//==============================================================================
StateVariableTPTFilter<float> filter;
ChoiceParameter typeParam {{ "Low-pass", "Band-pass", "High-pass" }, 1, "Type" };
SliderParameter cutoffParam {{ 20.0, 20000.0 }, 0.5, 440.0f, "Cutoff", "Hz" };
SliderParameter qParam {{ 0.3, 20.0 }, 0.5, 1.0 / MathConstants<double>::sqrt2, "Resonance" };
std::vector<DSPDemoParameterBase*> parameters { &typeParam, &cutoffParam, &qParam };
double sampleRate = 0.0;
};
struct StateVariableFilterDemo : public Component
{
StateVariableFilterDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<StateVariableFilterDemoDSP> fileReaderComponent;
};

View File

@ -0,0 +1,99 @@
/*
==============================================================================
This file is part of the JUCE examples.
Copyright (c) 2020 - Raw Material Software Limited
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: WaveShaperTanhDemo
version: 1.0.0
vendor: JUCE
website: http://juce.com
description: Wave shaper tanh demo using the DSP module.
dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
juce_audio_processors, juce_audio_utils, juce_core,
juce_data_structures, juce_dsp, juce_events, juce_graphics,
juce_gui_basics, juce_gui_extra
exporters: xcode_mac, vs2019, linux_make
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: WaveShaperTanhDemo
useLocalCopy: 1
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
#include "../Assets/DemoUtilities.h"
#include "../Assets/DSPDemos_Common.h"
using namespace dsp;
//==============================================================================
struct WaveShaperTanhDemoDSP
{
void prepare (const ProcessSpec&) {}
void process (const ProcessContextReplacing<float>& context)
{
shapers[currentShaperIdx].process (context);
}
void reset()
{
for (auto&& shaper : shapers)
shaper.reset();
}
void updateParameters()
{
currentShaperIdx = jmin (numElementsInArray (shapers), accuracy.getCurrentSelectedID() - 1);
}
//==============================================================================
WaveShaper<float> shapers[2] { { std::tanh }, { FastMathApproximations::tanh } };
int currentShaperIdx = 0;
ChoiceParameter accuracy {{ "No Approximation", "Use fast-math approximation" }, 1, "Accuracy" };
std::vector<DSPDemoParameterBase*> parameters { &accuracy }; // no params for this demo
};
struct WaveShaperTanhDemo : public Component
{
WaveShaperTanhDemo()
{
addAndMakeVisible (fileReaderComponent);
setSize (750, 500);
}
void resized() override
{
fileReaderComponent.setBounds (getLocalBounds());
}
AudioFileReaderComponent<WaveShaperTanhDemoDSP> fileReaderComponent;
};