id
int64
0
877k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
66
repo_stars
int64
94
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
11 values
repo_extraction_date
stringclasses
197 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
1,534,643
PluginEditor.cpp
belangeo_plugex/Plugex_31_FFTFilter/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_31_fftFilterAudioProcessorEditor::Plugex_31_fftFilterAudioProcessorEditor (Plugex_31_fftFilterAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { setSize (400, 300); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("steal"); title.setText("Plugex - 31 - FFT Filter", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); orderLabel.setText("FFT Size", NotificationType::dontSendNotification); orderLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&orderLabel); orderCombo.setLookAndFeel(&plugexLookAndFeel); orderCombo.addItemList({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384"}, 6); orderCombo.setSelectedId(10); addAndMakeVisible(&orderCombo); orderAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "order", orderCombo)); overlapsLabel.setText("FFT Overlaps", NotificationType::dontSendNotification); overlapsLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&overlapsLabel); overlapsCombo.setLookAndFeel(&plugexLookAndFeel); overlapsCombo.addItemList({"2", "4", "8"}, 1); overlapsCombo.setSelectedId(2); addAndMakeVisible(&overlapsCombo); overlapsAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "overlaps", overlapsCombo)); wintypeLabel.setText("Window Type", NotificationType::dontSendNotification); wintypeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&wintypeLabel); wintypeCombo.setLookAndFeel(&plugexLookAndFeel); wintypeCombo.addItemList({"Rectangular", "Triangular", "Hanning", "Hamming", "Blackman", "Blackman-Harris 4 terms", "Blackman-Harris 7 terms", "Flat Top", "Half Sine"}, 1); wintypeCombo.setSelectedId(3); addAndMakeVisible(&wintypeCombo); wintypeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "wintype", wintypeCombo)); filterLabel.setText("Draw frequency amplitudes", NotificationType::dontSendNotification); filterLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&filterLabel); filterMultiSlider.setup(filterNumberOfPoints); filterMultiSlider.addListener(this); filterMultiSlider.setLookAndFeel(&plugexLookAndFeel); filterMultiSlider.setPoints(processor.fftFilterPoints); addAndMakeVisible(&filterMultiSlider); startTimer(0.05); } Plugex_31_fftFilterAudioProcessorEditor::~Plugex_31_fftFilterAudioProcessorEditor() { orderCombo.setLookAndFeel(nullptr); overlapsCombo.setLookAndFeel(nullptr); wintypeCombo.setLookAndFeel(nullptr); filterMultiSlider.setLookAndFeel(nullptr); } void Plugex_31_fftFilterAudioProcessorEditor::timerCallback() { if (processor.fftFilterPointsChanged) { filterMultiSlider.setPoints(processor.fftFilterPoints); processor.fftFilterPointsChanged = false; } } void Plugex_31_fftFilterAudioProcessorEditor::multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) { processor.setFFTFilterPoints(value); } //============================================================================== void Plugex_31_fftFilterAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_31_fftFilterAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(60); auto orderArea = area2.removeFromLeft(width / 3.0f); orderLabel.setBounds(orderArea.removeFromTop(20)); orderCombo.setBounds(orderArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); auto overlapsArea = area2.removeFromLeft(width / 3.0f); overlapsLabel.setBounds(overlapsArea.removeFromTop(20)); overlapsCombo.setBounds(overlapsArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); wintypeLabel.setBounds(area2.removeFromTop(20)); wintypeCombo.setBounds(area2.removeFromTop(60).withSizeKeepingCentre(120, 24)); area.removeFromTop(12); filterLabel.setBounds(area.removeFromTop(20).withSizeKeepingCentre(getWidth() - 20, 20)); filterMultiSlider.setBounds(area.removeFromTop(120).withSizeKeepingCentre(filterNumberOfPoints, 100)); }
5,398
C++
.cpp
99
48.959596
126
0.722349
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,644
PluginProcessor.cpp
belangeo_plugex/Plugex_31_FFTFilter/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("order"), String("Order"), String(), NormalisableRange<float>(6.0f, 14.0f, 1.f, 1.0f), 10.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("overlaps"), String("Overlaps"), String(), NormalisableRange<float>(1.0f, 3.0f, 1.f, 1.0f), 2.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("wintype"), String("Wintype"), String(), NormalisableRange<float>(1.0f, 9.0f, 1.f, 1.0f), 3.0f, nullptr, nullptr)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_31_fftFilterAudioProcessor::Plugex_31_fftFilterAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { orderParameter = parameters.getRawParameterValue("order"); overlapsParameter = parameters.getRawParameterValue("overlaps"); wintypeParameter = parameters.getRawParameterValue("wintype"); lastOrder = (int)*orderParameter; lastOverlaps = 1 << (int)*overlapsParameter; lastWintype = (int)*overlapsParameter; ValueTree filterNode(Identifier("filterSavedPoints")); for (int i = 0; i < filterNumberOfPoints; i++) { filterNode.setProperty(Identifier(String(i)), 0.0f, nullptr); } parameters.state.addChild(filterNode, -1, nullptr); for (auto channel = 0; channel < 2; channel++) { fftEngine[channel].setup(lastOrder, lastOverlaps, lastWintype); fftEngine[channel].addListener(this); } zeromem (fftFilter, sizeof (fftFilter)); fftFilterPoints.resize(filterNumberOfPoints); fftFilterPoints.fill(0.0f); } Plugex_31_fftFilterAudioProcessor::~Plugex_31_fftFilterAudioProcessor() { } //============================================================================== const String Plugex_31_fftFilterAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_31_fftFilterAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_31_fftFilterAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_31_fftFilterAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_31_fftFilterAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_31_fftFilterAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_31_fftFilterAudioProcessor::getCurrentProgram() { return 0; } void Plugex_31_fftFilterAudioProcessor::setCurrentProgram (int index) { } const String Plugex_31_fftFilterAudioProcessor::getProgramName (int index) { return {}; } void Plugex_31_fftFilterAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_31_fftFilterAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { // Use this method as the place to do any pre-playback // initialisation that you need.. } void Plugex_31_fftFilterAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_31_fftFilterAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_31_fftFilterAudioProcessor::computeFFTFilter() { int filterSize = fftEngine[0].getSize() / 2 + 1; for (int i = 0; i < filterSize; i++) { float index = sinf(i / (float)filterSize * M_PI / 2.0f) * filterNumberOfPoints; int ipart = (int)index; float fpart = index - ipart; fftFilter[i] = fftFilterPoints[ipart] + (fftFilterPoints[ipart+1] - fftFilterPoints[ipart]) * fpart; } } void Plugex_31_fftFilterAudioProcessor::setFFTFilterPoints(const Array<float> &value) { for (int i = 0; i < filterNumberOfPoints; i++) { fftFilterPoints.set(i, value[i]); } ValueTree filterNode = parameters.state.getChildWithName(Identifier("filterSavedPoints")); for (int i = 0; i < filterNumberOfPoints; i++) { filterNode.setProperty(Identifier(String(i)), fftFilterPoints[i], nullptr); } computeFFTFilter(); } void Plugex_31_fftFilterAudioProcessor::fftEngineFrameReady(FFTEngine *engine, float *fftData, int fftSize) { for (int j = 0; j < fftSize / 2 + 1; j++) { float gain = fftFilter[j]; fftData[j*2] *= gain; fftData[j*2+1] *= gain; } } void Plugex_31_fftFilterAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); int order = (int) *orderParameter; int overlaps = 1 << (int) *overlapsParameter; int wintype = (int) *wintypeParameter; for (auto channel = 0; channel < totalNumInputChannels; channel++) { if (order != lastOrder || overlaps != lastOverlaps) { fftEngine[channel].setup(order, overlaps, wintype); computeFFTFilter(); } if (wintype != lastWintype) { fftEngine[channel].setWintype(wintype); } auto *channelData = buffer.getWritePointer(channel); for (int i = 0; i < buffer.getNumSamples(); i++) { channelData[i] = fftEngine[channel].process(channelData[i]); } } lastOrder = order; lastOverlaps = overlaps; lastWintype = wintype; } //============================================================================== bool Plugex_31_fftFilterAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_31_fftFilterAudioProcessor::createEditor() { return new Plugex_31_fftFilterAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_31_fftFilterAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. auto state = parameters.copyState(); std::unique_ptr<XmlElement> xml (state.createXml()); copyXmlToBinary (*xml, destData); } void Plugex_31_fftFilterAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. std::unique_ptr<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes)); if (xmlState.get() != nullptr) { if (xmlState->hasTagName (parameters.state.getType())) { ValueTree state = ValueTree::fromXml (*xmlState); parameters.replaceState (state); } } ValueTree filterNode = parameters.state.getChildWithName(Identifier("filterSavedPoints")); if (filterNode.isValid()) { for (int i = 0; i < filterNumberOfPoints; i++) { fftFilterPoints.set(i, (float) filterNode.getProperty(Identifier(String(i)), 0.0f)); } computeFFTFilter(); fftFilterPointsChanged = true; } } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_31_fftFilterAudioProcessor(); }
10,530
C++
.cpp
247
35.453441
110
0.62992
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,645
PluginEditor.cpp
belangeo_plugex/Plugex_34_GranularStretcher/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_34_granularStretcherAudioProcessorEditor::Plugex_34_granularStretcherAudioProcessorEditor (Plugex_34_granularStretcherAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 220); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("lightblue"); title.setText("Plugex - 34 - Granular Stretcher", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); activeButton.setLookAndFeel(&plugexLookAndFeel); activeButton.setButtonText("Active"); activeButton.setClickingTogglesState(true); addAndMakeVisible(&activeButton); activeAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "active", activeButton)); durationLabel.setText("Duration", NotificationType::dontSendNotification); durationLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&durationLabel); durationKnob.setLookAndFeel(&plugexLookAndFeel); durationKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); durationKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&durationKnob); durationAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "duration", durationKnob)); pitchLabel.setText("Pitch", NotificationType::dontSendNotification); pitchLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&pitchLabel); pitchKnob.setLookAndFeel(&plugexLookAndFeel); pitchKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); pitchKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&pitchKnob); pitchAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "pitch", pitchKnob)); speedLabel.setText("Speed", NotificationType::dontSendNotification); speedLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&speedLabel); speedKnob.setLookAndFeel(&plugexLookAndFeel); speedKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); speedKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&speedKnob); speedAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "speed", speedKnob)); jitterLabel.setText("Jitter", NotificationType::dontSendNotification); jitterLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&jitterLabel); jitterKnob.setLookAndFeel(&plugexLookAndFeel); jitterKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); jitterKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&jitterKnob); jitterAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "jitter", jitterKnob)); } Plugex_34_granularStretcherAudioProcessorEditor::~Plugex_34_granularStretcherAudioProcessorEditor() { activeButton.setLookAndFeel(nullptr); durationKnob.setLookAndFeel(nullptr); pitchKnob.setLookAndFeel(nullptr); speedKnob.setLookAndFeel(nullptr); jitterKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_34_granularStretcherAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_34_granularStretcherAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); activeButton.setBounds(area.removeFromTop(24)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto durationArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); durationLabel.setBounds(durationArea.removeFromTop(20)); durationKnob.setBounds(durationArea); auto pitchArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); pitchLabel.setBounds(pitchArea.removeFromTop(20)); pitchKnob.setBounds(pitchArea); auto speedArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); speedLabel.setBounds(speedArea.removeFromTop(20)); speedKnob.setBounds(speedArea); auto jitterArea = area2.withSizeKeepingCentre(80, 100); jitterLabel.setBounds(jitterArea.removeFromTop(20)); jitterKnob.setBounds(jitterArea); area.removeFromTop(12); }
5,560
C++
.cpp
101
50.455446
179
0.750323
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,646
PluginProcessor.cpp
belangeo_plugex/Plugex_34_GranularStretcher/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String durationSliderValueToText(float value) { return String(value, 2) + String(" sec"); } static float durationSliderTextToValue(const String& text) { return text.getFloatValue(); } static String pitchSliderValueToText(float value) { return String(value, 3) + String(" x"); } static float pitchSliderTextToValue(const String& text) { return text.getFloatValue(); } static String speedSliderValueToText(float value) { return String(value, 2) + String(" x"); } static float speedSliderTextToValue(const String& text) { return text.getFloatValue(); } static String jitterSliderValueToText(float value) { return String(value, 3) + String(" %"); } static float jitterSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("active"), String("Active"), String(), NormalisableRange<float>(0.f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("duration"), String("Duration"), String(), NormalisableRange<float>(0.25f, 10.f, 0.01f, 0.5f), 1.f, durationSliderValueToText, durationSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("pitch"), String("Pitch"), String(), NormalisableRange<float>(0.1f, 2.0f, 0.001f, 1.0f), 1.0f, pitchSliderValueToText, pitchSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("speed"), String("Speed"), String(), NormalisableRange<float>(.1f, 4.0f, 0.01f, 0.3f), 1.0f, speedSliderValueToText, speedSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("jitter"), String("Jitter"), String(), NormalisableRange<float>(0.f, 100.0f, 0.001f, 0.3f), 5.0f, jitterSliderValueToText, jitterSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_34_granularStretcherAudioProcessor::Plugex_34_granularStretcherAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { activeParameter = parameters.getRawParameterValue("active"); durationParameter = parameters.getRawParameterValue("duration"); pitchParameter = parameters.getRawParameterValue("pitch"); speedParameter = parameters.getRawParameterValue("speed"); jitterParameter = parameters.getRawParameterValue("jitter"); } Plugex_34_granularStretcherAudioProcessor::~Plugex_34_granularStretcherAudioProcessor() { } //============================================================================== const String Plugex_34_granularStretcherAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_34_granularStretcherAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_34_granularStretcherAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_34_granularStretcherAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_34_granularStretcherAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_34_granularStretcherAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_34_granularStretcherAudioProcessor::getCurrentProgram() { return 0; } void Plugex_34_granularStretcherAudioProcessor::setCurrentProgram (int index) { } const String Plugex_34_granularStretcherAudioProcessor::getProgramName (int index) { return {}; } void Plugex_34_granularStretcherAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_34_granularStretcherAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { m_sampleRate = sampleRate; granulator[0].setup(sampleRate, 10.f); granulator[1].setup(sampleRate, 10.f); granulator[0].setRecording(false); granulator[1].setRecording(false); portLastSample = *activeParameter; durationSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); durationSmoothed.setCurrentAndTargetValue(*durationParameter); pitchSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); pitchSmoothed.setCurrentAndTargetValue(*pitchParameter); speedSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); speedSmoothed.setCurrentAndTargetValue(*speedParameter); jitterSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); jitterSmoothed.setCurrentAndTargetValue(*jitterParameter); } void Plugex_34_granularStretcherAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_34_granularStretcherAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_34_granularStretcherAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); durationSmoothed.setTargetValue(*durationParameter); pitchSmoothed.setTargetValue(*pitchParameter); speedSmoothed.setTargetValue(*speedParameter); jitterSmoothed.setTargetValue(*jitterParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float jitter = jitterSmoothed.getNextValue() * 0.01f; float duration = durationSmoothed.getNextValue(); float grainDuration = 0.15 * ((jitterRandom.nextFloat() - 0.5f) * 0.05f * jitter + 1.f); float pitch = pitchSmoothed.getNextValue() * ((jitterRandom.nextFloat() - 0.5f) * 0.05f * jitter + 1.f); float deviation = jitterRandom.nextFloat() * 0.05f * jitter; float density = 100.f + jitterRandom.nextFloat() * 5.f * jitter; float speed = speedSmoothed.getNextValue() * ((jitterRandom.nextFloat() - 0.5f) * 0.05f * jitter + 1.f); float position = readerIndex * ((jitterRandom.nextFloat() - 0.5f) * 0.05f * jitter + 1.f); readerIndex += readerBaseInc * speed; if (readerIndex >= 1.f) readerIndex -= 1.f; bool activateRecording = (bool)*activeParameter && !isActive; if (activateRecording) readerBaseInc = (1.f / duration) / m_sampleRate; if (!isActive || granulator[0].getIsRecording()) { portLastSample = 0.f + (portLastSample - 0.f) * 0.9999; } else { portLastSample = 1.f + (portLastSample - 1.f) * 0.9999; } if (isRecording && !granulator[0].getIsRecording()) readerIndex = 0.f; for (int channel = 0; channel < totalNumInputChannels; ++channel) { float stretchSample = 0.f; auto* channelData = buffer.getWritePointer (channel); if (activateRecording) { granulator[channel].setRecordingSize(duration); granulator[channel].setRecording(true); } granulator[channel].setDensity(density); granulator[channel].setPitch(pitch); granulator[channel].setDuration(grainDuration); granulator[channel].setPosition(position); granulator[channel].setDeviation(deviation); if (isActive) stretchSample = granulator[channel].process(channelData[i]); channelData[i] = channelData[i] + (stretchSample - channelData[i]) * portLastSample; } isActive = (bool)*activeParameter; isRecording = granulator[0].getIsRecording(); } } //============================================================================== bool Plugex_34_granularStretcherAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_34_granularStretcherAudioProcessor::createEditor() { return new Plugex_34_granularStretcherAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_34_granularStretcherAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_34_granularStretcherAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_34_granularStretcherAudioProcessor(); }
11,935
C++
.cpp
260
38.365385
116
0.649159
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,647
PluginEditor.cpp
belangeo_plugex/Plugex_33_GranularFreeze/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_33_granularFreezeAudioProcessorEditor::Plugex_33_granularFreezeAudioProcessorEditor (Plugex_33_granularFreezeAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 220); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("lightblue"); title.setText("Plugex - 33 - Granular Freeze", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); activeButton.setLookAndFeel(&plugexLookAndFeel); activeButton.setButtonText("Active"); activeButton.setClickingTogglesState(true); addAndMakeVisible(&activeButton); activeAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "active", activeButton)); densityLabel.setText("Density", NotificationType::dontSendNotification); densityLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&densityLabel); densityKnob.setLookAndFeel(&plugexLookAndFeel); densityKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); densityKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&densityKnob); densityAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "density", densityKnob)); pitchLabel.setText("Pitch", NotificationType::dontSendNotification); pitchLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&pitchLabel); pitchKnob.setLookAndFeel(&plugexLookAndFeel); pitchKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); pitchKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&pitchKnob); pitchAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "pitch", pitchKnob)); durationLabel.setText("Gr. Dur", NotificationType::dontSendNotification); durationLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&durationLabel); durationKnob.setLookAndFeel(&plugexLookAndFeel); durationKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); durationKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&durationKnob); durationAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "duration", durationKnob)); jitterLabel.setText("Jitter", NotificationType::dontSendNotification); jitterLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&jitterLabel); jitterKnob.setLookAndFeel(&plugexLookAndFeel); jitterKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); jitterKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&jitterKnob); jitterAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "jitter", jitterKnob)); } Plugex_33_granularFreezeAudioProcessorEditor::~Plugex_33_granularFreezeAudioProcessorEditor() { activeButton.setLookAndFeel(nullptr); densityKnob.setLookAndFeel(nullptr); pitchKnob.setLookAndFeel(nullptr); durationKnob.setLookAndFeel(nullptr); jitterKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_33_granularFreezeAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_33_granularFreezeAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); activeButton.setBounds(area.removeFromTop(24)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto densityArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); densityLabel.setBounds(densityArea.removeFromTop(20)); densityKnob.setBounds(densityArea); auto pitchArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); pitchLabel.setBounds(pitchArea.removeFromTop(20)); pitchKnob.setBounds(pitchArea); auto durationArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); durationLabel.setBounds(durationArea.removeFromTop(20)); durationKnob.setBounds(durationArea); auto jitterArea = area2.withSizeKeepingCentre(80, 100); jitterLabel.setBounds(jitterArea.removeFromTop(20)); jitterKnob.setBounds(jitterArea); area.removeFromTop(12); }
5,569
C++
.cpp
101
50.544554
170
0.750368
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,648
PluginProcessor.cpp
belangeo_plugex/Plugex_33_GranularFreeze/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String densitySliderValueToText(float value) { return String(value, 2) + String(" x"); } static float densitySliderTextToValue(const String& text) { return text.getFloatValue(); } static String pitchSliderValueToText(float value) { return String(value, 3) + String(" x"); } static float pitchSliderTextToValue(const String& text) { return text.getFloatValue(); } static String durationSliderValueToText(float value) { return String(value, 3) + String(" sec"); } static float durationSliderTextToValue(const String& text) { return text.getFloatValue(); } static String jitterSliderValueToText(float value) { return String(value, 3) + String(" %"); } static float jitterSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("active"), String("Active"), String(), NormalisableRange<float>(0.f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("density"), String("Density"), String(), NormalisableRange<float>(1.f, 500.0f, 0.01f, 0.3f), 50.0f, densitySliderValueToText, densitySliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("pitch"), String("Pitch"), String(), NormalisableRange<float>(0.1f, 2.0f, 0.001f, 1.0f), 1.0f, pitchSliderValueToText, pitchSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("duration"), String("Duration"), String(), NormalisableRange<float>(0.001f, 0.25f, 0.001f, 0.5f), 0.1f, durationSliderValueToText, durationSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("jitter"), String("Jitter"), String(), NormalisableRange<float>(0.f, 100.0f, 0.001f, 0.3f), 5.0f, jitterSliderValueToText, jitterSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_33_granularFreezeAudioProcessor::Plugex_33_granularFreezeAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { activeParameter = parameters.getRawParameterValue("active"); densityParameter = parameters.getRawParameterValue("density"); pitchParameter = parameters.getRawParameterValue("pitch"); durationParameter = parameters.getRawParameterValue("duration"); jitterParameter = parameters.getRawParameterValue("jitter"); } Plugex_33_granularFreezeAudioProcessor::~Plugex_33_granularFreezeAudioProcessor() { } //============================================================================== const String Plugex_33_granularFreezeAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_33_granularFreezeAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_33_granularFreezeAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_33_granularFreezeAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_33_granularFreezeAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_33_granularFreezeAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_33_granularFreezeAudioProcessor::getCurrentProgram() { return 0; } void Plugex_33_granularFreezeAudioProcessor::setCurrentProgram (int index) { } const String Plugex_33_granularFreezeAudioProcessor::getProgramName (int index) { return {}; } void Plugex_33_granularFreezeAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_33_granularFreezeAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { granulator[0].setup(sampleRate, 0.5); granulator[1].setup(sampleRate, 0.5); granulator[0].setRecording(false); granulator[1].setRecording(false); portLastSample = *activeParameter; densitySmoothed.reset(sampleRate, samplesPerBlock/sampleRate); densitySmoothed.setCurrentAndTargetValue(*densityParameter); pitchSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); pitchSmoothed.setCurrentAndTargetValue(*pitchParameter); durationSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); durationSmoothed.setCurrentAndTargetValue(*durationParameter); jitterSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); jitterSmoothed.setCurrentAndTargetValue(*jitterParameter); } void Plugex_33_granularFreezeAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_33_granularFreezeAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_33_granularFreezeAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); densitySmoothed.setTargetValue(*densityParameter); pitchSmoothed.setTargetValue(*pitchParameter); durationSmoothed.setTargetValue(*durationParameter); jitterSmoothed.setTargetValue(*jitterParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float jitter = jitterSmoothed.getNextValue() * 0.01f; float density = densitySmoothed.getNextValue() + jitterRandom.nextFloat() * 10.f * jitter; float pitch = pitchSmoothed.getNextValue() * ((jitterRandom.nextFloat() - 0.5f) * 0.25f * jitter + 1.f); float duration = durationSmoothed.getNextValue() * ((jitterRandom.nextFloat() - 0.5f) * 0.25f * jitter + 1.f); float position = jitterRandom.nextFloat() * 0.8f * jitter; float deviation = jitterRandom.nextFloat() * 0.2f * jitter; bool activateRecording = (bool)*activeParameter && !isActive; portLastSample = *activeParameter + (portLastSample - *activeParameter) * 0.9999; for (int channel = 0; channel < totalNumInputChannels; ++channel) { float freezeSample = 0.f; auto* channelData = buffer.getWritePointer (channel); if (activateRecording) granulator[channel].setRecording(true); granulator[channel].setDensity(density); granulator[channel].setPitch(pitch); granulator[channel].setDuration(duration); granulator[channel].setPosition(position); granulator[channel].setDeviation(deviation); if (isActive) freezeSample = granulator[channel].process(channelData[i]); channelData[i] = channelData[i] + (freezeSample - channelData[i]) * portLastSample; } isActive = (bool)*activeParameter; } } //============================================================================== bool Plugex_33_granularFreezeAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_33_granularFreezeAudioProcessor::createEditor() { return new Plugex_33_granularFreezeAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_33_granularFreezeAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_33_granularFreezeAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_33_granularFreezeAudioProcessor(); }
11,145
C++
.cpp
243
38.522634
118
0.654803
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,649
PluginEditor.cpp
belangeo_plugex/Plugex_12_Equalizer/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_12_equalizerAudioProcessorEditor::Plugex_12_equalizerAudioProcessorEditor (Plugex_12_equalizerAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("green"); title.setText("Plugex - 12 - Equalizer", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); freqLabel.setText("Freq", NotificationType::dontSendNotification); freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&freqLabel); freqKnob.setLookAndFeel(&plugexLookAndFeel); freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&freqKnob); freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob)); qLabel.setText("Q", NotificationType::dontSendNotification); qLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&qLabel); qKnob.setLookAndFeel(&plugexLookAndFeel); qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&qKnob); qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob)); boostLabel.setText("Boost", NotificationType::dontSendNotification); boostLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&boostLabel); boostKnob.setLookAndFeel(&plugexLookAndFeel); boostKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); boostKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&boostKnob); boostAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "boost", boostKnob)); typeLabel.setText("Filter Type", NotificationType::dontSendNotification); typeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&typeLabel); typeCombo.setLookAndFeel(&plugexLookAndFeel); typeCombo.addItemList({"Peak/Notch", "Lowshelf", "Highshelf"}, 1); typeCombo.setSelectedId(1); addAndMakeVisible(&typeCombo); typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type", typeCombo)); } Plugex_12_equalizerAudioProcessorEditor::~Plugex_12_equalizerAudioProcessorEditor() { freqKnob.setLookAndFeel(nullptr); qKnob.setLookAndFeel(nullptr); boostKnob.setLookAndFeel(nullptr); typeCombo.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_12_equalizerAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_12_equalizerAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto freqArea = area2.removeFromLeft(width/4.44f).withSizeKeepingCentre(80, 100); freqLabel.setBounds(freqArea.removeFromTop(20)); freqKnob.setBounds(freqArea); auto qArea = area2.removeFromLeft(width/4.44f).withSizeKeepingCentre(80, 100); qLabel.setBounds(qArea.removeFromTop(20)); qKnob.setBounds(qArea); auto boostArea = area2.removeFromLeft(width/4.44f).withSizeKeepingCentre(80, 100); boostLabel.setBounds(boostArea.removeFromTop(20)); boostKnob.setBounds(boostArea); auto typeArea = area2.withSizeKeepingCentre(120, 100); typeLabel.setBounds(typeArea.removeFromTop(20)); typeCombo.setBounds(typeArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); area.removeFromTop(12); }
4,931
C++
.cpp
93
48.494624
155
0.7325
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,650
PluginProcessor.cpp
belangeo_plugex/Plugex_12_Equalizer/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String freqSliderValueToText(float value) { return String(value, 2) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } static String qSliderValueToText(float value) { return String(value, 2) + String(" Q"); } static float qSliderTextToValue(const String& text) { return text.getFloatValue(); } static String boostSliderValueToText(float value) { return String(value, 2) + String(" dB"); } static float boostSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(), NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f), 1000.0f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(), NormalisableRange<float>(1.0f, 50.0f, 0.01f, 0.5f), 1.0f, qSliderValueToText, qSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("boost"), String("Boost"), String(), NormalisableRange<float>(-24.0f, 24.0f, 0.01f, 1.0f), 0.0f, boostSliderValueToText, boostSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("type"), String("Type"), String(), NormalisableRange<float>(0.0f, 2.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_12_equalizerAudioProcessor::Plugex_12_equalizerAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { freqParameter = parameters.getRawParameterValue("freq"); qParameter = parameters.getRawParameterValue("q"); boostParameter = parameters.getRawParameterValue("boost"); typeParameter = parameters.getRawParameterValue("type"); } Plugex_12_equalizerAudioProcessor::~Plugex_12_equalizerAudioProcessor() { } //============================================================================== const String Plugex_12_equalizerAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_12_equalizerAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_12_equalizerAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_12_equalizerAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_12_equalizerAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_12_equalizerAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_12_equalizerAudioProcessor::getCurrentProgram() { return 0; } void Plugex_12_equalizerAudioProcessor::setCurrentProgram (int index) { } const String Plugex_12_equalizerAudioProcessor::getProgramName (int index) { return {}; } void Plugex_12_equalizerAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_12_equalizerAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; memset(lastInputSample1, 0, sizeof(float) * 2); memset(lastInputSample2, 0, sizeof(float) * 2); memset(lastFilteredSample1, 0, sizeof(float) * 2); memset(lastFilteredSample2, 0, sizeof(float) * 2); freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); freqSmoothed.setCurrentAndTargetValue(*freqParameter); qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); qSmoothed.setCurrentAndTargetValue(*qParameter); boostSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); boostSmoothed.setCurrentAndTargetValue(*boostParameter); } void Plugex_12_equalizerAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_12_equalizerAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_12_equalizerAudioProcessor::compute_coeffs_peak() { float alphaMul = alpha * A; float alphaDiv = alpha / A; b0 = 1.0f + alphaMul; b1 = a1 = -2.0f * c; b2 = 1.0f - alphaMul; a0 = 1.0f / (1.0f + alphaDiv); a2 = 1.0f - alphaDiv; } void Plugex_12_equalizerAudioProcessor::compute_coeffs_lowshelf() { float twoSqrtAAlpha = sqrtf(A * 2.0f) * alpha; float AminOneC = (A - 1.0f) * c; float AAddOneC = (A + 1.0f) * c; b0 = A * ((A + 1.0f) - AminOneC + twoSqrtAAlpha); b1 = 2.0f * A * ((A - 1.0f) - AAddOneC); b2 = A * ((A + 1.0f) - AminOneC - twoSqrtAAlpha); a0 = 1.0f / ((A + 1.0f) + AminOneC + twoSqrtAAlpha); a1 = -2.0f * ((A - 1.0f) + AAddOneC); a2 = (A + 1.0f) + AminOneC - twoSqrtAAlpha; } void Plugex_12_equalizerAudioProcessor::compute_coeffs_highshelf() { float twoSqrtAAlpha = sqrtf(A * 2.0f) * alpha; float AminOneC = (A - 1.0f) * c; float AAddOneC = (A + 1.0f) * c; b0 = A * ((A + 1.0f) + AminOneC + twoSqrtAAlpha); b1 = -2.0f * A * ((A - 1.0f) + AAddOneC); b2 = A * ((A + 1.0f) + AminOneC - twoSqrtAAlpha); a0 = 1.0f / ((A + 1.0f) - AminOneC + twoSqrtAAlpha); a1 = 2.0f * ((A - 1.0f) - AAddOneC); a2 = (A + 1.0f) - AminOneC - twoSqrtAAlpha; } void Plugex_12_equalizerAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); freqSmoothed.setTargetValue(*freqParameter); qSmoothed.setTargetValue(*qParameter); boostSmoothed.setTargetValue(*boostParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float cf = freqSmoothed.getNextValue(); float q = qSmoothed.getNextValue(); float boo = boostSmoothed.getNextValue(); A = powf(10.0f, boo / 40.0f); w0 = cf * 2.0f * M_PI / currentSampleRate; c = cosf(w0); alpha = sinf(w0) / (2.0f * q); int type = (int) *typeParameter; switch (type) { case 0: compute_coeffs_peak(); break; case 1: compute_coeffs_lowshelf(); break; case 2: compute_coeffs_highshelf(); break; } for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); float filtered = ( b0 * channelData[i] + b1 * lastInputSample1[channel] + b2 * lastInputSample2[channel] - a1 * lastFilteredSample1[channel] - a2 * lastFilteredSample2[channel] ) * a0; lastInputSample2[channel] = lastInputSample1[channel]; lastInputSample1[channel] = channelData[i]; lastFilteredSample2[channel] = lastFilteredSample1[channel]; channelData[i] = lastFilteredSample1[channel] = filtered; } } } //============================================================================== bool Plugex_12_equalizerAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_12_equalizerAudioProcessor::createEditor() { return new Plugex_12_equalizerAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_12_equalizerAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_12_equalizerAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_12_equalizerAudioProcessor(); }
11,185
C++
.cpp
266
35.225564
119
0.628184
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,651
PluginEditor.cpp
belangeo_plugex/Plugex_11_Biquad/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_11_biquadAudioProcessorEditor::Plugex_11_biquadAudioProcessorEditor (Plugex_11_biquadAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("green"); title.setText("Plugex - 11 - Biquad Filter", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); freqLabel.setText("Freq", NotificationType::dontSendNotification); freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&freqLabel); freqKnob.setLookAndFeel(&plugexLookAndFeel); freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&freqKnob); freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob)); qLabel.setText("Resonance", NotificationType::dontSendNotification); qLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&qLabel); qKnob.setLookAndFeel(&plugexLookAndFeel); qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&qKnob); qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob)); typeLabel.setText("Filter Type", NotificationType::dontSendNotification); typeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&typeLabel); typeCombo.setLookAndFeel(&plugexLookAndFeel); typeCombo.addItemList({"Lowpass", "Highpass", "Bandpass", "Bandstop", "Allpass"}, 1); typeCombo.setSelectedId(1); addAndMakeVisible(&typeCombo); typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type", typeCombo)); } Plugex_11_biquadAudioProcessorEditor::~Plugex_11_biquadAudioProcessorEditor() { freqKnob.setLookAndFeel(nullptr); qKnob.setLookAndFeel(nullptr); typeCombo.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_11_biquadAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_11_biquadAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto freqArea = area2.removeFromLeft(width/3.5f).withSizeKeepingCentre(80, 100); freqLabel.setBounds(freqArea.removeFromTop(20)); freqKnob.setBounds(freqArea); auto qArea = area2.removeFromLeft(width/3.5f).withSizeKeepingCentre(80, 100); qLabel.setBounds(qArea.removeFromTop(20)); qKnob.setBounds(qArea); auto typeArea = area2.withSizeKeepingCentre(120, 100); typeLabel.setBounds(typeArea.removeFromTop(20)); typeCombo.setBounds(typeArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); area.removeFromTop(12); }
4,199
C++
.cpp
81
47.444444
146
0.717993
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,652
PluginProcessor.cpp
belangeo_plugex/Plugex_11_Biquad/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String freqSliderValueToText(float value) { return String(value, 2) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } static String qSliderValueToText(float value) { return String(value, 2) + String(" Q"); } static float qSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(), NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f), 1000.0f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(), NormalisableRange<float>(1.0f, 50.0f, 0.01f, 0.5f), 1.0f, qSliderValueToText, qSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("type"), String("Type"), String(), NormalisableRange<float>(0.0f, 4.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_11_biquadAudioProcessor::Plugex_11_biquadAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { freqParameter = parameters.getRawParameterValue("freq"); qParameter = parameters.getRawParameterValue("q"); typeParameter = parameters.getRawParameterValue("type"); } Plugex_11_biquadAudioProcessor::~Plugex_11_biquadAudioProcessor() { } //============================================================================== const String Plugex_11_biquadAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_11_biquadAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_11_biquadAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_11_biquadAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_11_biquadAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_11_biquadAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_11_biquadAudioProcessor::getCurrentProgram() { return 0; } void Plugex_11_biquadAudioProcessor::setCurrentProgram (int index) { } const String Plugex_11_biquadAudioProcessor::getProgramName (int index) { return {}; } void Plugex_11_biquadAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_11_biquadAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; memset(lastInputSample1, 0, sizeof(float) * 2); memset(lastInputSample2, 0, sizeof(float) * 2); memset(lastFilteredSample1, 0, sizeof(float) * 2); memset(lastFilteredSample2, 0, sizeof(float) * 2); freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); freqSmoothed.setCurrentAndTargetValue(*freqParameter); qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); qSmoothed.setCurrentAndTargetValue(*qParameter); } void Plugex_11_biquadAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_11_biquadAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_11_biquadAudioProcessor::compute_coeffs_lp() { b0 = b2 = (1 - c) / 2; b1 = 1 - c; a0 = 1.0 / (1 + alpha); a1 = -2 * c; a2 = 1 - alpha; } void Plugex_11_biquadAudioProcessor::compute_coeffs_hp() { b0 = (1 + c) / 2; b1 = -(1 + c); b2 = b0; a0 = 1.0 / (1 + alpha); a1 = -2 * c; a2 = 1 - alpha; } void Plugex_11_biquadAudioProcessor::compute_coeffs_bp() { b0 = alpha; b1 = 0; b2 = -alpha; a0 = 1.0 / (1 + alpha); a1 = -2 * c; a2 = 1 - alpha; } void Plugex_11_biquadAudioProcessor::compute_coeffs_bs() { b0 = 1; b1 = a1 = -2 * c; b2 = 1; a0 = 1.0 / (1 + alpha); a2 = 1 - alpha; } void Plugex_11_biquadAudioProcessor::compute_coeffs_ap() { b0 = a2 = 1 - alpha; b1 = a1 = -2 * c; b2 = 1 + alpha; a0 = 1.0 / (1 + alpha); } void Plugex_11_biquadAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); freqSmoothed.setTargetValue(*freqParameter); qSmoothed.setTargetValue(*qParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float cf = freqSmoothed.getNextValue(); float q = qSmoothed.getNextValue(); w0 = cf * 2.0f * M_PI / currentSampleRate; c = cosf(w0); alpha = sinf(w0) / (2.0f * q); int type = (int) *typeParameter; switch (type) { case 0: compute_coeffs_lp(); break; case 1: compute_coeffs_hp(); break; case 2: compute_coeffs_bp(); break; case 3: compute_coeffs_bs(); break; case 4: compute_coeffs_ap(); break; } for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); float filtered = ( b0 * channelData[i] + b1 * lastInputSample1[channel] + b2 * lastInputSample2[channel] - a1 * lastFilteredSample1[channel] - a2 * lastFilteredSample2[channel] ) * a0; lastInputSample2[channel] = lastInputSample1[channel]; lastInputSample1[channel] = channelData[i]; lastFilteredSample2[channel] = lastFilteredSample1[channel]; channelData[i] = lastFilteredSample1[channel] = filtered; } } } //============================================================================== bool Plugex_11_biquadAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_11_biquadAudioProcessor::createEditor() { return new Plugex_11_biquadAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_11_biquadAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_11_biquadAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_11_biquadAudioProcessor(); }
9,961
C++
.cpp
262
31.465649
119
0.617672
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,653
PluginEditor.cpp
belangeo_plugex/Plugex_06_SecondOrderBP/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_06_secondOrderBpAudioProcessorEditor::Plugex_06_secondOrderBpAudioProcessorEditor (Plugex_06_secondOrderBpAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("green"); title.setText("Plugex - 06 - Second Order Bandpass Filter", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); freqLabel.setText("Freq", NotificationType::dontSendNotification); freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&freqLabel); freqKnob.setLookAndFeel(&plugexLookAndFeel); freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&freqKnob); freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob)); qLabel.setText("Resonance", NotificationType::dontSendNotification); qLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&qLabel); qKnob.setLookAndFeel(&plugexLookAndFeel); qKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); qKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&qKnob); qAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "q", qKnob)); } Plugex_06_secondOrderBpAudioProcessorEditor::~Plugex_06_secondOrderBpAudioProcessorEditor() { freqKnob.setLookAndFeel(nullptr); qKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_06_secondOrderBpAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_06_secondOrderBpAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto freqArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100); freqLabel.setBounds(freqArea.removeFromTop(20)); freqKnob.setBounds(freqArea); auto qArea = area2.withSizeKeepingCentre(80, 100); qLabel.setBounds(qArea.removeFromTop(20)); qKnob.setBounds(qArea); area.removeFromTop(12); }
3,264
C++
.cpp
66
45.318182
167
0.706625
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,654
PluginProcessor.cpp
belangeo_plugex/Plugex_06_SecondOrderBP/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include <cmath> #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String freqSliderValueToText(float value) { return String(value, 2) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } static String qSliderValueToText(float value) { return String(value, 2) + String(" Q"); } static float qSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(), NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f), 1000.0f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("q"), String("Q"), String(), NormalisableRange<float>(0.5f, 50.0f, 0.01f, 0.5f), 1.0f, qSliderValueToText, qSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_06_secondOrderBpAudioProcessor::Plugex_06_secondOrderBpAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { freqParameter = parameters.getRawParameterValue("freq"); qParameter = parameters.getRawParameterValue("q"); } Plugex_06_secondOrderBpAudioProcessor::~Plugex_06_secondOrderBpAudioProcessor() { } //============================================================================== const String Plugex_06_secondOrderBpAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_06_secondOrderBpAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_06_secondOrderBpAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_06_secondOrderBpAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_06_secondOrderBpAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_06_secondOrderBpAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_06_secondOrderBpAudioProcessor::getCurrentProgram() { return 0; } void Plugex_06_secondOrderBpAudioProcessor::setCurrentProgram (int index) { } const String Plugex_06_secondOrderBpAudioProcessor::getProgramName (int index) { return {}; } void Plugex_06_secondOrderBpAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_06_secondOrderBpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; memset(lastInputSample1, 0, sizeof(float) * 2); memset(lastInputSample2, 0, sizeof(float) * 2); memset(lastFilteredSample1, 0, sizeof(float) * 2); memset(lastFilteredSample2, 0, sizeof(float) * 2); freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); freqSmoothed.setCurrentAndTargetValue(*freqParameter); qSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); qSmoothed.setCurrentAndTargetValue(*qParameter); } void Plugex_06_secondOrderBpAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_06_secondOrderBpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_06_secondOrderBpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); freqSmoothed.setTargetValue(*freqParameter); qSmoothed.setTargetValue(*qParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float cf = freqSmoothed.getNextValue(); float bw = cf / qSmoothed.getNextValue(); float b2 = expf(-2.0f * M_PI / currentSampleRate * bw); float b1 = (-4.0f * b2) / (1.0f + b2) * cosf(2.0 * M_PI * cf / currentSampleRate); float a1 = 1.0f - sqrtf(b2); for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); float filtered = a1 * channelData[i] - a1 * lastInputSample2[channel] - b1 * lastFilteredSample1[channel] - b2 * lastFilteredSample2[channel]; lastInputSample2[channel] = lastInputSample1[channel]; lastInputSample1[channel] = channelData[i]; lastFilteredSample2[channel] = lastFilteredSample1[channel]; channelData[i] = lastFilteredSample1[channel] = filtered; } } } //============================================================================== bool Plugex_06_secondOrderBpAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_06_secondOrderBpAudioProcessor::createEditor() { return new Plugex_06_secondOrderBpAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_06_secondOrderBpAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_06_secondOrderBpAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_06_secondOrderBpAudioProcessor(); }
8,594
C++
.cpp
204
36.029412
154
0.651442
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,655
PluginEditor.cpp
belangeo_plugex/Plugex_02_AmplitudeDB/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_02_amplitudeDbAudioProcessorEditor::Plugex_02_amplitudeDbAudioProcessorEditor (Plugex_02_amplitudeDbAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("blue"); title.setText("Plugex - 02 - Amplitude in dB", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); gainLabel.setText("Gain", NotificationType::dontSendNotification); gainLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&gainLabel); gainKnob.setLookAndFeel(&plugexLookAndFeel); gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&gainKnob); gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob)); } Plugex_02_amplitudeDbAudioProcessorEditor::~Plugex_02_amplitudeDbAudioProcessorEditor() { } //============================================================================== void Plugex_02_amplitudeDbAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_02_amplitudeDbAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto gainArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100); gainLabel.setBounds(gainArea.removeFromTop(20)); gainKnob.setBounds(gainArea); area.removeFromTop(12); }
2,520
C++
.cpp
51
43.960784
125
0.65671
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,657
PluginEditor.cpp
belangeo_plugex/Plugex_08_ButterworthHP/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_08_butterworthHpAudioProcessorEditor::Plugex_08_butterworthHpAudioProcessorEditor (Plugex_08_butterworthHpAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("green"); title.setText("Plugex - 08 - Butterworth Highpass", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); freqLabel.setText("Freq", NotificationType::dontSendNotification); freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&freqLabel); freqKnob.setLookAndFeel(&plugexLookAndFeel); freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&freqKnob); freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "freq", freqKnob)); } Plugex_08_butterworthHpAudioProcessorEditor::~Plugex_08_butterworthHpAudioProcessorEditor() { freqKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_08_butterworthHpAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_08_butterworthHpAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto freqArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100); freqLabel.setBounds(freqArea.removeFromTop(20)); freqKnob.setBounds(freqArea); area.removeFromTop(12); }
2,744
C++
.cpp
55
45.945455
167
0.688297
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,658
PluginProcessor.cpp
belangeo_plugex/Plugex_08_ButterworthHP/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String freqSliderValueToText(float value) { return String(value, 2) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("freq"), String("Freq"), String(), NormalisableRange<float>(20.0f, 18000.0f, 0.01f, 0.3f), 1000.0f, freqSliderValueToText, freqSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_08_butterworthHpAudioProcessor::Plugex_08_butterworthHpAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { freqParameter = parameters.getRawParameterValue("freq"); } Plugex_08_butterworthHpAudioProcessor::~Plugex_08_butterworthHpAudioProcessor() { } //============================================================================== const String Plugex_08_butterworthHpAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_08_butterworthHpAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_08_butterworthHpAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_08_butterworthHpAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_08_butterworthHpAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_08_butterworthHpAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_08_butterworthHpAudioProcessor::getCurrentProgram() { return 0; } void Plugex_08_butterworthHpAudioProcessor::setCurrentProgram (int index) { } const String Plugex_08_butterworthHpAudioProcessor::getProgramName (int index) { return {}; } void Plugex_08_butterworthHpAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_08_butterworthHpAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; memset(lastInputSample1, 0, sizeof(float) * 2); memset(lastInputSample2, 0, sizeof(float) * 2); memset(lastFilteredSample1, 0, sizeof(float) * 2); memset(lastFilteredSample2, 0, sizeof(float) * 2); freqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); freqSmoothed.setCurrentAndTargetValue(*freqParameter); } void Plugex_08_butterworthHpAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_08_butterworthHpAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_08_butterworthHpAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); freqSmoothed.setTargetValue(*freqParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float cf = freqSmoothed.getNextValue(); float sqrt2 = sqrtf(2.0f); float c = tanf(M_PI / currentSampleRate * cf); float c2 = c * c; float a0 = 1.0f / (1.0f + sqrt2 * c + c2); float a1 = -2.0f * a0; float a2 = a0; float b1 = 2.0f * a0 * (c2 - 1.0f); float b2 = a0 * (1.0f - sqrt2 * c + c2); for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); float filtered = a0 * channelData[i] + a1 * lastInputSample1[channel] + a2 * lastInputSample2[channel] - b1 * lastFilteredSample1[channel] - b2 * lastFilteredSample2[channel]; lastInputSample2[channel] = lastInputSample1[channel]; lastInputSample1[channel] = channelData[i]; lastFilteredSample2[channel] = lastFilteredSample1[channel]; channelData[i] = lastFilteredSample1[channel] = filtered; } } } //============================================================================== bool Plugex_08_butterworthHpAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_08_butterworthHpAudioProcessor::createEditor() { return new Plugex_08_butterworthHpAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_08_butterworthHpAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_08_butterworthHpAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_08_butterworthHpAudioProcessor(); }
8,022
C++
.cpp
195
35.174359
117
0.646368
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,659
PluginEditor.cpp
belangeo_plugex/Plugex_17_FullDistortion/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_17_fullDistortionAudioProcessorEditor::Plugex_17_fullDistortionAudioProcessorEditor (Plugex_17_fullDistortionAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 300); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("red"); title.setText("Plugex - 17 - Full Distortion", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); highpassFreqLabel.setText("Highpass Freq", NotificationType::dontSendNotification); highpassFreqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&highpassFreqLabel); highpassFreqKnob.setLookAndFeel(&plugexLookAndFeel); highpassFreqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); highpassFreqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&highpassFreqKnob); highpassFreqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "highpassFreq", highpassFreqKnob)); highpassQLabel.setText("Highpass Q", NotificationType::dontSendNotification); highpassQLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&highpassQLabel); highpassQKnob.setLookAndFeel(&plugexLookAndFeel); highpassQKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); highpassQKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&highpassQKnob); highpassQAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "highpassQ", highpassQKnob)); driveLabel.setText("Drive", NotificationType::dontSendNotification); driveLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&driveLabel); driveKnob.setLookAndFeel(&plugexLookAndFeel); driveKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); driveKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&driveKnob); driveAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "drive", driveKnob)); lowpassFreqLabel.setText("Lowpass Freq", NotificationType::dontSendNotification); lowpassFreqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lowpassFreqLabel); lowpassFreqKnob.setLookAndFeel(&plugexLookAndFeel); lowpassFreqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lowpassFreqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lowpassFreqKnob); lowpassFreqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lowpassFreq", lowpassFreqKnob)); lowpassQLabel.setText("Lowpass Q", NotificationType::dontSendNotification); lowpassQLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lowpassQLabel); lowpassQKnob.setLookAndFeel(&plugexLookAndFeel); lowpassQKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lowpassQKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lowpassQKnob); lowpassQAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lowpassQ", lowpassQKnob)); balanceLabel.setText("Balance", NotificationType::dontSendNotification); balanceLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&balanceLabel); balanceKnob.setLookAndFeel(&plugexLookAndFeel); balanceKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); balanceKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&balanceKnob); balanceAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "balance", balanceKnob)); } Plugex_17_fullDistortionAudioProcessorEditor::~Plugex_17_fullDistortionAudioProcessorEditor() { highpassFreqKnob.setLookAndFeel(nullptr); highpassQKnob.setLookAndFeel(nullptr); driveKnob.setLookAndFeel(nullptr); lowpassFreqKnob.setLookAndFeel(nullptr); lowpassQKnob.setLookAndFeel(nullptr); balanceKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_17_fullDistortionAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_17_fullDistortionAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto areaTop = area.removeFromTop(120); auto highpassFreqArea = areaTop.removeFromLeft(width/3.0f).withSizeKeepingCentre(100, 100); highpassFreqLabel.setBounds(highpassFreqArea.removeFromTop(20)); highpassFreqKnob.setBounds(highpassFreqArea); auto highpassQArea = areaTop.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); highpassQLabel.setBounds(highpassQArea.removeFromTop(20)); highpassQKnob.setBounds(highpassQArea); auto driveArea = areaTop.withSizeKeepingCentre(80, 100); driveLabel.setBounds(driveArea.removeFromTop(20)); driveKnob.setBounds(driveArea); auto areaBottom = area.removeFromTop(120); auto lowpassFreqArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(100, 100); lowpassFreqLabel.setBounds(lowpassFreqArea.removeFromTop(20)); lowpassFreqKnob.setBounds(lowpassFreqArea); auto lowpassQArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); lowpassQLabel.setBounds(lowpassQArea.removeFromTop(20)); lowpassQKnob.setBounds(lowpassQArea); auto balanceArea = areaBottom.withSizeKeepingCentre(80, 100); balanceLabel.setBounds(balanceArea.removeFromTop(20)); balanceKnob.setBounds(balanceArea); }
6,904
C++
.cpp
117
54.34188
170
0.769573
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,660
PluginProcessor.cpp
belangeo_plugex/Plugex_17_FullDistortion/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String freqSliderValueToText(float value) { return String(value, 2) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } static String qSliderValueToText(float value) { return String(value, 2) + String(" Q"); } static float qSliderTextToValue(const String& text) { return text.getFloatValue(); } static String driveSliderValueToText(float value) { return String(value, 3) + String(" x"); } static float driveSliderTextToValue(const String& text) { return text.getFloatValue(); } static String balanceSliderValueToText(float value) { return String(value, 2) + String(" %"); } static float balanceSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("highpassFreq"), String("Highpass Freq"), String(), NormalisableRange<float>(20.0f, 1000.0f, 0.01f, 0.3f), 100.0f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("highpassQ"), String("Highpass Q"), String(), NormalisableRange<float>(0.5f, 20.0f, 0.01f, 1.0f), 1.0f, qSliderValueToText, qSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("drive"), String("Drive"), String(), NormalisableRange<float>(0.0f, 1.0f, 0.001f, 1.0f), 0.75f, driveSliderValueToText, driveSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lowpassFreq"), String("Lowpass Freq"), String(), NormalisableRange<float>(100.0f, 15000.0f, 0.01f, 0.3f), 4000.0f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lowpassQ"), String("Lowpass Q"), String(), NormalisableRange<float>(0.5f, 20.0f, 0.01f, 1.0f), 1.0f, qSliderValueToText, qSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("balance"), String("Balance"), String(), NormalisableRange<float>(0.0f, 100.0f, 0.01f, 1.0f), 50.0f, balanceSliderValueToText, balanceSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_17_fullDistortionAudioProcessor::Plugex_17_fullDistortionAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { highpassFreqParameter = parameters.getRawParameterValue("highpassFreq"); highpassQParameter = parameters.getRawParameterValue("highpassQ"); driveParameter = parameters.getRawParameterValue("drive"); lowpassFreqParameter = parameters.getRawParameterValue("lowpassFreq"); lowpassQParameter = parameters.getRawParameterValue("lowpassQ"); balanceParameter = parameters.getRawParameterValue("balance"); } Plugex_17_fullDistortionAudioProcessor::~Plugex_17_fullDistortionAudioProcessor() { } //============================================================================== const String Plugex_17_fullDistortionAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_17_fullDistortionAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_17_fullDistortionAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_17_fullDistortionAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_17_fullDistortionAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_17_fullDistortionAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_17_fullDistortionAudioProcessor::getCurrentProgram() { return 0; } void Plugex_17_fullDistortionAudioProcessor::setCurrentProgram (int index) { } const String Plugex_17_fullDistortionAudioProcessor::getProgramName (int index) { return {}; } void Plugex_17_fullDistortionAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_17_fullDistortionAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; highpassFreqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); highpassFreqSmoothed.setCurrentAndTargetValue(*highpassFreqParameter); highpassQSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); highpassQSmoothed.setCurrentAndTargetValue(*highpassQParameter); driveSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); driveSmoothed.setCurrentAndTargetValue(*driveParameter); lowpassFreqSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); lowpassFreqSmoothed.setCurrentAndTargetValue(*lowpassFreqParameter); lowpassQSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); lowpassQSmoothed.setCurrentAndTargetValue(*lowpassQParameter); balanceSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); balanceSmoothed.setCurrentAndTargetValue(*balanceParameter); for (int channel = 0; channel < 2; channel++) { highpassFilter[channel].setup(sampleRate); lowpassFilter[channel].setup(sampleRate); } } void Plugex_17_fullDistortionAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_17_fullDistortionAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_17_fullDistortionAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); highpassFreqSmoothed.setTargetValue(*highpassFreqParameter); highpassQSmoothed.setTargetValue(*highpassQParameter); driveSmoothed.setTargetValue(*driveParameter); lowpassFreqSmoothed.setTargetValue(*lowpassFreqParameter); lowpassQSmoothed.setTargetValue(*lowpassQParameter); balanceSmoothed.setTargetValue(*balanceParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float currentHighpassFreq = highpassFreqSmoothed.getNextValue(); float currentHighpassQ = highpassQSmoothed.getNextValue(); float currentDrive = driveSmoothed.getNextValue() * 0.998; float currentLowpassFreq = lowpassFreqSmoothed.getNextValue(); float currentLowpassQ = lowpassQSmoothed.getNextValue(); float currentBalance = balanceSmoothed.getNextValue() * 0.01; float shapeFactor = (2.0f * currentDrive) / (1.0f - currentDrive); for (int channel = 0; channel < totalNumInputChannels; ++channel) { highpassFilter[channel].setParameters(currentHighpassFreq, currentHighpassQ, 1); lowpassFilter[channel].setParameters(currentLowpassFreq, currentLowpassQ, 0); auto* channelData = buffer.getWritePointer (channel); float channelInput = channelData[i]; channelData[i] = highpassFilter[channel].process(channelData[i]); channelData[i] = (1.0f + shapeFactor) * channelData[i] / (1.0f + shapeFactor * fabsf(channelData[i])) * 0.7; channelData[i] = lowpassFilter[channel].process(channelData[i]); channelData[i] = channelInput + (channelData[i] - channelInput) * currentBalance; } } } //============================================================================== bool Plugex_17_fullDistortionAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_17_fullDistortionAudioProcessor::createEditor() { return new Plugex_17_fullDistortionAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_17_fullDistortionAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_17_fullDistortionAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_17_fullDistortionAudioProcessor(); }
11,768
C++
.cpp
247
40.121457
120
0.66422
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,661
PluginEditor.cpp
belangeo_plugex/Plugex_16_Waveshapping/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_16_waveshappingAudioProcessorEditor::Plugex_16_waveshappingAudioProcessorEditor (Plugex_16_waveshappingAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("red"); title.setText("Plugex - 16 - Wave Shapper", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); driveLabel.setText("Drive", NotificationType::dontSendNotification); driveLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&driveLabel); driveKnob.setLookAndFeel(&plugexLookAndFeel); driveKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); driveKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&driveKnob); driveAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "drive", driveKnob)); cutoffLabel.setText("Cutoff", NotificationType::dontSendNotification); cutoffLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&cutoffLabel); cutoffKnob.setLookAndFeel(&plugexLookAndFeel); cutoffKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); cutoffKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&cutoffKnob); cutoffAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "cutoff", cutoffKnob)); } Plugex_16_waveshappingAudioProcessorEditor::~Plugex_16_waveshappingAudioProcessorEditor() { driveKnob.setLookAndFeel(nullptr); cutoffKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_16_waveshappingAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_16_waveshappingAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto driveArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100); driveLabel.setBounds(driveArea.removeFromTop(20)); driveKnob.setBounds(driveArea); auto cutoffArea = area2.withSizeKeepingCentre(80, 100); cutoffLabel.setBounds(cutoffArea.removeFromTop(20)); cutoffKnob.setBounds(cutoffArea); area.removeFromTop(12); }
3,558
C++
.cpp
69
47.347826
164
0.713667
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,663
PluginEditor.cpp
belangeo_plugex/Plugex_35_GranularSoundcloud/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_35_granularSoundcloudAudioProcessorEditor::Plugex_35_granularSoundcloudAudioProcessorEditor (Plugex_35_granularSoundcloudAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 220); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("lightblue"); title.setText("Plugex - 35 - Granular Soundcloud", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); activeButton.setLookAndFeel(&plugexLookAndFeel); activeButton.setButtonText("Active"); activeButton.setClickingTogglesState(true); addAndMakeVisible(&activeButton); activeAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "active", activeButton)); densityLabel.setText("Density", NotificationType::dontSendNotification); densityLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&densityLabel); densityKnob.setLookAndFeel(&plugexLookAndFeel); densityKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); densityKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&densityKnob); densityAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "density", densityKnob)); rndpitLabel.setText("Rnd Pit", NotificationType::dontSendNotification); rndpitLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&rndpitLabel); rndpitKnob.setLookAndFeel(&plugexLookAndFeel); rndpitKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); rndpitKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&rndpitKnob); rndpitAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "rndpit", rndpitKnob)); rndposLabel.setText("Rnd Pos", NotificationType::dontSendNotification); rndposLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&rndposLabel); rndposKnob.setLookAndFeel(&plugexLookAndFeel); rndposKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); rndposKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&rndposKnob); rndposAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "rndpos", rndposKnob)); rnddurLabel.setText("Rnd Dur", NotificationType::dontSendNotification); rnddurLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&rnddurLabel); rnddurKnob.setLookAndFeel(&plugexLookAndFeel); rnddurKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); rnddurKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&rnddurKnob); rnddurAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "rnddur", rnddurKnob)); } Plugex_35_granularSoundcloudAudioProcessorEditor::~Plugex_35_granularSoundcloudAudioProcessorEditor() { activeButton.setLookAndFeel(nullptr); densityKnob.setLookAndFeel(nullptr); rndpitKnob.setLookAndFeel(nullptr); rndposKnob.setLookAndFeel(nullptr); rnddurKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_35_granularSoundcloudAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_35_granularSoundcloudAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); activeButton.setBounds(area.removeFromTop(24)); area.removeFromTop(12); auto area2 = area.removeFromTop(100); auto densityArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); densityLabel.setBounds(densityArea.removeFromTop(20)); densityKnob.setBounds(densityArea); auto rndpitArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); rndpitLabel.setBounds(rndpitArea.removeFromTop(20)); rndpitKnob.setBounds(rndpitArea); auto rndposArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); rndposLabel.setBounds(rndposArea.removeFromTop(20)); rndposKnob.setBounds(rndposArea); auto rnddurArea = area2.withSizeKeepingCentre(80, 100); rnddurLabel.setBounds(rnddurArea.removeFromTop(20)); rnddurKnob.setBounds(rnddurArea); area.removeFromTop(12); }
5,588
C++
.cpp
101
50.732673
182
0.751056
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,664
PluginProcessor.cpp
belangeo_plugex/Plugex_35_GranularSoundcloud/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String densitySliderValueToText(float value) { return String(value, 2) + String(" x"); } static float densitySliderTextToValue(const String& text) { return text.getFloatValue(); } static String sliderValueToText(float value) { return String(value, 2) + String(" %"); } static float sliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("active"), String("Active"), String(), NormalisableRange<float>(0.f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("density"), String("Density"), String(), NormalisableRange<float>(1.f, 250.f, 0.01f, .3f), 50.f, densitySliderValueToText, densitySliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("rndpit"), String("RndPit"), String(), NormalisableRange<float>(0.f, 100.f, 0.01f, 1.f), 50.f, sliderValueToText, sliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("rndpos"), String("RndPos"), String(), NormalisableRange<float>(0.f, 100.f, 0.01f, 1.f), 50.f, sliderValueToText, sliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("rnddur"), String("RndDur"), String(), NormalisableRange<float>(0.f, 100.f, 0.01f, 1.f), 50.f, sliderValueToText, sliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_35_granularSoundcloudAudioProcessor::Plugex_35_granularSoundcloudAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { activeParameter = parameters.getRawParameterValue("active"); densityParameter = parameters.getRawParameterValue("density"); rndpitParameter = parameters.getRawParameterValue("rndpit"); rndposParameter = parameters.getRawParameterValue("rndpos"); rnddurParameter = parameters.getRawParameterValue("rnddur"); } Plugex_35_granularSoundcloudAudioProcessor::~Plugex_35_granularSoundcloudAudioProcessor() { } //============================================================================== const String Plugex_35_granularSoundcloudAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_35_granularSoundcloudAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_35_granularSoundcloudAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_35_granularSoundcloudAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_35_granularSoundcloudAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_35_granularSoundcloudAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_35_granularSoundcloudAudioProcessor::getCurrentProgram() { return 0; } void Plugex_35_granularSoundcloudAudioProcessor::setCurrentProgram (int index) { } const String Plugex_35_granularSoundcloudAudioProcessor::getProgramName (int index) { return {}; } void Plugex_35_granularSoundcloudAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_35_granularSoundcloudAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { m_sampleRate = sampleRate; granulator[0].setup(sampleRate, 2.f); granulator[1].setup(sampleRate, 2.f); granulator[0].setRecording(false); granulator[1].setRecording(false); portLastSample = *activeParameter; densitySmoothed.reset(sampleRate, samplesPerBlock/sampleRate); densitySmoothed.setCurrentAndTargetValue(*densityParameter); rndpitSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); rndpitSmoothed.setCurrentAndTargetValue(*rndpitParameter); rndposSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); rndposSmoothed.setCurrentAndTargetValue(*rndposParameter); rnddurSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); rnddurSmoothed.setCurrentAndTargetValue(*rnddurParameter); } void Plugex_35_granularSoundcloudAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_35_granularSoundcloudAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_35_granularSoundcloudAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); densitySmoothed.setTargetValue(*densityParameter); rndpitSmoothed.setTargetValue(*rndpitParameter); rndposSmoothed.setTargetValue(*rndposParameter); rnddurSmoothed.setTargetValue(*rnddurParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float rndpit = rndpitSmoothed.getNextValue() * 0.019f; float rndpos = rndposSmoothed.getNextValue() * 0.019f; float rnddur = rnddurSmoothed.getNextValue() * 0.019f; float density = densitySmoothed.getNextValue(); float pitch = 1.f * (jitterRandom.nextFloat() * rndpit - (rndpit * 0.5f) + 1.f); float position = 0.5f * (jitterRandom.nextFloat() * rndpos - (rndpos * 0.5f) + 1.f); float duration = 0.2f * (jitterRandom.nextFloat() * rnddur - (rnddur * 0.5f) + 1.f); bool activateRecording = (bool)*activeParameter && !isActive; if (!isActive || granulator[0].getIsRecording()) { portLastSample = 0.f + (portLastSample - 0.f) * 0.9999; } else { portLastSample = 1.f + (portLastSample - 1.f) * 0.9999; } for (int channel = 0; channel < totalNumInputChannels; ++channel) { float cloudSample = 0.f; auto* channelData = buffer.getWritePointer (channel); if (activateRecording) { granulator[channel].setRecording(true); } granulator[channel].setDensity(density); granulator[channel].setPitch(pitch); granulator[channel].setDuration(duration); granulator[channel].setPosition(position); if (isActive) cloudSample = granulator[channel].process(channelData[i]); channelData[i] = channelData[i] + (cloudSample - channelData[i]) * portLastSample; } isActive = (bool)*activeParameter; } } //============================================================================== bool Plugex_35_granularSoundcloudAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_35_granularSoundcloudAudioProcessor::createEditor() { return new Plugex_35_granularSoundcloudAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_35_granularSoundcloudAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_35_granularSoundcloudAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_35_granularSoundcloudAudioProcessor(); }
10,880
C++
.cpp
237
38.295359
117
0.646007
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,665
PluginEditor.cpp
belangeo_plugex/Plugex_38_WaveformMidiSynth/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_38_waveformMidiSynthAudioProcessorEditor::Plugex_38_waveformMidiSynthAudioProcessorEditor (Plugex_38_waveformMidiSynthAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts), keyboardComponent (p.keyboardState, MidiKeyboardComponent::horizontalKeyboard) { setSize (500, 400); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("lightgreen"); title.setText("Plugex - 38 - Waveform Midi Synth", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); attackLabel.setText("Attack", NotificationType::dontSendNotification); attackLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&attackLabel); attackKnob.setLookAndFeel(&plugexLookAndFeel); attackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); attackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&attackKnob); attackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "attack", attackKnob)); decayLabel.setText("Decay", NotificationType::dontSendNotification); decayLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&decayLabel); decayKnob.setLookAndFeel(&plugexLookAndFeel); decayKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); decayKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&decayKnob); decayAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "decay", decayKnob)); sustainLabel.setText("Sustain", NotificationType::dontSendNotification); sustainLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&sustainLabel); sustainKnob.setLookAndFeel(&plugexLookAndFeel); sustainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); sustainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&sustainKnob); sustainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sustain", sustainKnob)); releaseLabel.setText("Release", NotificationType::dontSendNotification); releaseLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&releaseLabel); releaseKnob.setLookAndFeel(&plugexLookAndFeel); releaseKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); releaseKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&releaseKnob); releaseAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "release", releaseKnob)); typeLabel.setText("Wave Type", NotificationType::dontSendNotification); typeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&typeLabel); typeCombo.setLookAndFeel(&plugexLookAndFeel); typeCombo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1); typeCombo.setSelectedId(1); addAndMakeVisible(&typeCombo); typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type", typeCombo)); sharpLabel.setText("Bright", NotificationType::dontSendNotification); sharpLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&sharpLabel); sharpKnob.setLookAndFeel(&plugexLookAndFeel); sharpKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); sharpKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&sharpKnob); sharpAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sharp", sharpKnob)); gainLabel.setText("Gain", NotificationType::dontSendNotification); gainLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&gainLabel); gainKnob.setLookAndFeel(&plugexLookAndFeel); gainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); gainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&gainKnob); gainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain", gainKnob)); addAndMakeVisible(keyboardComponent); } Plugex_38_waveformMidiSynthAudioProcessorEditor::~Plugex_38_waveformMidiSynthAudioProcessorEditor() { attackKnob.setLookAndFeel(nullptr); decayKnob.setLookAndFeel(nullptr); sustainKnob.setLookAndFeel(nullptr); releaseKnob.setLookAndFeel(nullptr); typeCombo.setLookAndFeel(nullptr); sharpKnob.setLookAndFeel(nullptr); gainKnob.setLookAndFeel(nullptr); } //============================================================================== void Plugex_38_waveformMidiSynthAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_38_waveformMidiSynthAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area1 = area.removeFromTop(100); auto attackArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); attackLabel.setBounds(attackArea.removeFromTop(20)); attackKnob.setBounds(attackArea); auto decayArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); decayLabel.setBounds(decayArea.removeFromTop(20)); decayKnob.setBounds(decayArea); auto sustainArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); sustainLabel.setBounds(sustainArea.removeFromTop(20)); sustainKnob.setBounds(sustainArea); auto releaseArea = area1.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); releaseLabel.setBounds(releaseArea.removeFromTop(20)); releaseKnob.setBounds(releaseArea); auto area2 = area.removeFromTop(140); auto typeArea = area2.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100); typeLabel.setBounds(typeArea.removeFromTop(20)); typeCombo.setBounds(typeArea.removeFromTop(60).withSizeKeepingCentre(200, 24)); auto sharpArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); sharpLabel.setBounds(sharpArea.removeFromTop(20)); sharpKnob.setBounds(sharpArea); auto gainArea = area2.removeFromLeft(width/4.0f).withSizeKeepingCentre(80, 100); gainLabel.setBounds(gainArea.removeFromTop(20)); gainKnob.setBounds(gainArea); area.removeFromTop(12); keyboardComponent.setBounds(area.removeFromBottom(80)); }
7,522
C++
.cpp
130
52.369231
143
0.754223
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,667
PluginEditor.cpp
belangeo_plugex/Plugex_25_Balance/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_25_balanceAudioProcessorEditor::Plugex_25_balanceAudioProcessorEditor (Plugex_25_balanceAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { setSize (400, 200); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("purple"); title.setText("Plugex - 25 - Stereo Balance", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); balLabel.setText("Balance", NotificationType::dontSendNotification); balLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&balLabel); balKnob.setLookAndFeel(&plugexLookAndFeel); balKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); balKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&balKnob); balAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "bal", balKnob)); } Plugex_25_balanceAudioProcessorEditor::~Plugex_25_balanceAudioProcessorEditor() { balKnob.setLookAndFeel(nullptr); } //============================================================================== void Plugex_25_balanceAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_25_balanceAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto balArea = area.removeFromTop(100).withSizeKeepingCentre(80, 100); balLabel.setBounds(balArea.removeFromTop(20)); balKnob.setBounds(balArea); area.removeFromTop(12); }
2,526
C++
.cpp
52
42.980769
129
0.651286
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,669
PluginEditor.cpp
belangeo_plugex/Plugex_40_TwoOscMidiSynth/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_40_twoOscMidiSynthAudioProcessorEditor::Plugex_40_twoOscMidiSynthAudioProcessorEditor (Plugex_40_twoOscMidiSynthAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts), keyboardComponent (p.keyboardState, MidiKeyboardComponent::horizontalKeyboard) { setSize (980, 750); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("lightgreen"); title.setText("Plugex - 40 - Two Osc Midi Synth", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); attackLabel.setText("Attack", NotificationType::dontSendNotification); attackLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&attackLabel); attackKnob.setLookAndFeel(&plugexLookAndFeel); attackKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); attackKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&attackKnob); attackAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "attack", attackKnob)); decayLabel.setText("Decay", NotificationType::dontSendNotification); decayLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&decayLabel); decayKnob.setLookAndFeel(&plugexLookAndFeel); decayKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); decayKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&decayKnob); decayAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "decay", decayKnob)); sustainLabel.setText("Sustain", NotificationType::dontSendNotification); sustainLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&sustainLabel); sustainKnob.setLookAndFeel(&plugexLookAndFeel); sustainKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); sustainKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&sustainKnob); sustainAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sustain", sustainKnob)); releaseLabel.setText("Release", NotificationType::dontSendNotification); releaseLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&releaseLabel); releaseKnob.setLookAndFeel(&plugexLookAndFeel); releaseKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); releaseKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&releaseKnob); releaseAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "release", releaseKnob)); //------------------------------------------------------------------------------------------------------------------ lfo1typeLabel.setText("LFO 1 Wave Type", NotificationType::dontSendNotification); lfo1typeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo1typeLabel); lfo1typeCombo.setLookAndFeel(&plugexLookAndFeel); lfo1typeCombo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1); lfo1typeCombo.setSelectedId(1); addAndMakeVisible(&lfo1typeCombo); lfo1typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "lfo1type", lfo1typeCombo)); lfo1freqLabel.setText("LFO 1 Freq", NotificationType::dontSendNotification); lfo1freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo1freqLabel); lfo1freqKnob.setLookAndFeel(&plugexLookAndFeel); lfo1freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lfo1freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lfo1freqKnob); lfo1freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfo1freq", lfo1freqKnob)); lfo1depthLabel.setText("LFO 1 Depth", NotificationType::dontSendNotification); lfo1depthLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo1depthLabel); lfo1depthKnob.setLookAndFeel(&plugexLookAndFeel); lfo1depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lfo1depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lfo1depthKnob); lfo1depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfo1depth", lfo1depthKnob)); lfo1RouteLfo2Freq.setLookAndFeel(&plugexLookAndFeel); lfo1RouteLfo2Freq.setButtonText("LFO 2 Freq"); addAndMakeVisible(&lfo1RouteLfo2Freq); lfo1RouteLfo2FreqAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteLfo2Freq", lfo1RouteLfo2Freq)); lfo1RouteLfo2FreqInv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteLfo2FreqInv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteLfo2FreqInv); lfo1RouteLfo2FreqInvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteLfo2FreqInv", lfo1RouteLfo2FreqInv)); lfo1RouteLfo2Depth.setLookAndFeel(&plugexLookAndFeel); lfo1RouteLfo2Depth.setButtonText("LFO 2 Depth"); addAndMakeVisible(&lfo1RouteLfo2Depth); lfo1RouteLfo2DepthAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteLfo2Depth", lfo1RouteLfo2Depth)); lfo1RouteLfo2DepthInv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteLfo2DepthInv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteLfo2DepthInv); lfo1RouteLfo2DepthInvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteLfo2DepthInv", lfo1RouteLfo2DepthInv)); lfo1RouteFreq1.setLookAndFeel(&plugexLookAndFeel); lfo1RouteFreq1.setButtonText("OSC 1 Freq"); addAndMakeVisible(&lfo1RouteFreq1); lfo1RouteFreq1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteFreq1", lfo1RouteFreq1)); lfo1RouteFreq1Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteFreq1Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteFreq1Inv); lfo1RouteFreq1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteFreq1Inv", lfo1RouteFreq1Inv)); lfo1RouteSharp1.setLookAndFeel(&plugexLookAndFeel); lfo1RouteSharp1.setButtonText("OSC 1 Bright"); addAndMakeVisible(&lfo1RouteSharp1); lfo1RouteSharp1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteSharp1", lfo1RouteSharp1)); lfo1RouteSharp1Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteSharp1Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteSharp1Inv); lfo1RouteSharp1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteSharp1Inv", lfo1RouteSharp1Inv)); lfo1RouteGain1.setLookAndFeel(&plugexLookAndFeel); lfo1RouteGain1.setButtonText("OSC 1 Gain"); addAndMakeVisible(&lfo1RouteGain1); lfo1RouteGain1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteGain1", lfo1RouteGain1)); lfo1RouteGain1Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteGain1Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteGain1Inv); lfo1RouteGain1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteGain1Inv", lfo1RouteGain1Inv)); lfo1RouteFreq2.setLookAndFeel(&plugexLookAndFeel); lfo1RouteFreq2.setButtonText("OSC 2 Freq"); addAndMakeVisible(&lfo1RouteFreq2); lfo1RouteFreq2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteFreq2", lfo1RouteFreq2)); lfo1RouteFreq2Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteFreq2Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteFreq2Inv); lfo1RouteFreq2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteFreq2Inv", lfo1RouteFreq2Inv)); lfo1RouteSharp2.setLookAndFeel(&plugexLookAndFeel); lfo1RouteSharp2.setButtonText("OSC 2 Bright"); addAndMakeVisible(&lfo1RouteSharp2); lfo1RouteSharp2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteSharp2", lfo1RouteSharp2)); lfo1RouteSharp2Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteSharp2Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteSharp2Inv); lfo1RouteSharp2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteSharp2Inv", lfo1RouteSharp2Inv)); lfo1RouteGain2.setLookAndFeel(&plugexLookAndFeel); lfo1RouteGain2.setButtonText("OSC 2 Gain"); addAndMakeVisible(&lfo1RouteGain2); lfo1RouteGain2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteGain2", lfo1RouteGain2)); lfo1RouteGain2Inv.setLookAndFeel(&plugexLookAndFeel); lfo1RouteGain2Inv.setButtonText("inv"); addAndMakeVisible(&lfo1RouteGain2Inv); lfo1RouteGain2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo1RouteGain2Inv", lfo1RouteGain2Inv)); //------------------------------------------------------------------------------------------------------------------ lfo2typeLabel.setText("LFO 2 Wave Type", NotificationType::dontSendNotification); lfo2typeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo2typeLabel); lfo2typeCombo.setLookAndFeel(&plugexLookAndFeel); lfo2typeCombo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1); lfo2typeCombo.setSelectedId(1); addAndMakeVisible(&lfo2typeCombo); lfo2typeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "lfo2type", lfo2typeCombo)); lfo2freqLabel.setText("LFO 2 Freq", NotificationType::dontSendNotification); lfo2freqLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo2freqLabel); lfo2freqKnob.setLookAndFeel(&plugexLookAndFeel); lfo2freqKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lfo2freqKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lfo2freqKnob); lfo2freqAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfo2freq", lfo2freqKnob)); lfo2depthLabel.setText("LFO 2 Depth", NotificationType::dontSendNotification); lfo2depthLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lfo2depthLabel); lfo2depthKnob.setLookAndFeel(&plugexLookAndFeel); lfo2depthKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lfo2depthKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lfo2depthKnob); lfo2depthAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lfo2depth", lfo2depthKnob)); lfo2RouteFreq1.setLookAndFeel(&plugexLookAndFeel); lfo2RouteFreq1.setButtonText("OSC 1 Freq"); addAndMakeVisible(&lfo2RouteFreq1); lfo2RouteFreq1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteFreq1", lfo2RouteFreq1)); lfo2RouteFreq1Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteFreq1Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteFreq1Inv); lfo2RouteFreq1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteFreq1Inv", lfo2RouteFreq1Inv)); lfo2RouteSharp1.setLookAndFeel(&plugexLookAndFeel); lfo2RouteSharp1.setButtonText("OSC 1 Bright"); addAndMakeVisible(&lfo2RouteSharp1); lfo2RouteSharp1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteSharp1", lfo2RouteSharp1)); lfo2RouteSharp1Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteSharp1Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteSharp1Inv); lfo2RouteSharp1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteSharp1Inv", lfo2RouteSharp1Inv)); lfo2RouteGain1.setLookAndFeel(&plugexLookAndFeel); lfo2RouteGain1.setButtonText("OSC 1 Gain"); addAndMakeVisible(&lfo2RouteGain1); lfo2RouteGain1Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteGain1", lfo2RouteGain1)); lfo2RouteGain1Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteGain1Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteGain1Inv); lfo2RouteGain1InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteGain1Inv", lfo2RouteGain1Inv)); lfo2RouteFreq2.setLookAndFeel(&plugexLookAndFeel); lfo2RouteFreq2.setButtonText("OSC 2 Freq"); addAndMakeVisible(&lfo2RouteFreq2); lfo2RouteFreq2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteFreq2", lfo2RouteFreq2)); lfo2RouteFreq2Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteFreq2Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteFreq2Inv); lfo2RouteFreq2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteFreq2Inv", lfo2RouteFreq2Inv)); lfo2RouteSharp2.setLookAndFeel(&plugexLookAndFeel); lfo2RouteSharp2.setButtonText("OSC 2 Bright"); addAndMakeVisible(&lfo2RouteSharp2); lfo2RouteSharp2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteSharp2", lfo2RouteSharp2)); lfo2RouteSharp2Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteSharp2Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteSharp2Inv); lfo2RouteSharp2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteSharp2Inv", lfo2RouteSharp2Inv)); lfo2RouteGain2.setLookAndFeel(&plugexLookAndFeel); lfo2RouteGain2.setButtonText("OSC 2 Gain"); addAndMakeVisible(&lfo2RouteGain2); lfo2RouteGain2Attachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteGain2", lfo2RouteGain2)); lfo2RouteGain2Inv.setLookAndFeel(&plugexLookAndFeel); lfo2RouteGain2Inv.setButtonText("inv"); addAndMakeVisible(&lfo2RouteGain2Inv); lfo2RouteGain2InvAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "lfo2RouteGain2Inv", lfo2RouteGain2Inv)); //------------------------------------------------------------------------------------------------------------------ type1Label.setText("Osc 1 Wave Type", NotificationType::dontSendNotification); type1Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&type1Label); type1Combo.setLookAndFeel(&plugexLookAndFeel); type1Combo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1); type1Combo.setSelectedId(1); addAndMakeVisible(&type1Combo); type1Attachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type1", type1Combo)); sharp1Label.setText("Bright", NotificationType::dontSendNotification); sharp1Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&sharp1Label); sharp1Knob.setLookAndFeel(&plugexLookAndFeel); sharp1Knob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); sharp1Knob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&sharp1Knob); sharp1Attachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sharp1", sharp1Knob)); gain1Label.setText("Gain", NotificationType::dontSendNotification); gain1Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&gain1Label); gain1Knob.setLookAndFeel(&plugexLookAndFeel); gain1Knob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); gain1Knob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&gain1Knob); gain1Attachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain1", gain1Knob)); stereo1Toggle.setLookAndFeel(&plugexLookAndFeel); stereo1Toggle.setButtonText("Stereo"); addAndMakeVisible(&stereo1Toggle); stereo1ToggleAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "stereo1", stereo1Toggle)); //------------------------------------------------------------------------------------------------------------------ type2Label.setText("Osc 2 Wave Type", NotificationType::dontSendNotification); type2Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&type2Label); type2Combo.setLookAndFeel(&plugexLookAndFeel); type2Combo.addItemList({"Sine", "Triangle", "Square", "Sawtooth", "Ramp", "Pulse", "Bipolar Pulse", "SampleAndHold"}, 1); type2Combo.setSelectedId(1); addAndMakeVisible(&type2Combo); type2Attachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "type2", type2Combo)); sharp2Label.setText("Bright", NotificationType::dontSendNotification); sharp2Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&sharp2Label); sharp2Knob.setLookAndFeel(&plugexLookAndFeel); sharp2Knob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); sharp2Knob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&sharp2Knob); sharp2Attachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "sharp2", sharp2Knob)); gain2Label.setText("Gain", NotificationType::dontSendNotification); gain2Label.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&gain2Label); gain2Knob.setLookAndFeel(&plugexLookAndFeel); gain2Knob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); gain2Knob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&gain2Knob); gain2Attachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "gain2", gain2Knob)); stereo2Toggle.setLookAndFeel(&plugexLookAndFeel); stereo2Toggle.setButtonText("Stereo"); addAndMakeVisible(&stereo2Toggle); stereo2ToggleAttachment.reset(new AudioProcessorValueTreeState::ButtonAttachment(valueTreeState, "stereo2", stereo2Toggle)); //------------------------------------------------------------------------------------------------------------------ addAndMakeVisible(keyboardComponent); } Plugex_40_twoOscMidiSynthAudioProcessorEditor::~Plugex_40_twoOscMidiSynthAudioProcessorEditor() { attackKnob.setLookAndFeel(nullptr); decayKnob.setLookAndFeel(nullptr); sustainKnob.setLookAndFeel(nullptr); releaseKnob.setLookAndFeel(nullptr); lfo1typeCombo.setLookAndFeel(nullptr); lfo1freqKnob.setLookAndFeel(nullptr); lfo1depthKnob.setLookAndFeel(nullptr); lfo1RouteLfo2Freq.setLookAndFeel(nullptr); lfo1RouteLfo2FreqInv.setLookAndFeel(nullptr); lfo1RouteLfo2Depth.setLookAndFeel(nullptr); lfo1RouteLfo2DepthInv.setLookAndFeel(nullptr); lfo1RouteFreq1.setLookAndFeel(nullptr); lfo1RouteFreq1Inv.setLookAndFeel(nullptr); lfo1RouteSharp1.setLookAndFeel(nullptr); lfo1RouteSharp1Inv.setLookAndFeel(nullptr); lfo1RouteGain1.setLookAndFeel(nullptr); lfo1RouteGain1Inv.setLookAndFeel(nullptr); lfo1RouteFreq2.setLookAndFeel(nullptr); lfo1RouteFreq2Inv.setLookAndFeel(nullptr); lfo1RouteSharp2.setLookAndFeel(nullptr); lfo1RouteSharp2Inv.setLookAndFeel(nullptr); lfo1RouteGain2.setLookAndFeel(nullptr); lfo1RouteGain2Inv.setLookAndFeel(nullptr); lfo2typeCombo.setLookAndFeel(nullptr); lfo2freqKnob.setLookAndFeel(nullptr); lfo2depthKnob.setLookAndFeel(nullptr); lfo2RouteFreq1.setLookAndFeel(nullptr); lfo2RouteFreq1Inv.setLookAndFeel(nullptr); lfo2RouteSharp1.setLookAndFeel(nullptr); lfo2RouteSharp1Inv.setLookAndFeel(nullptr); lfo2RouteGain1.setLookAndFeel(nullptr); lfo2RouteGain1Inv.setLookAndFeel(nullptr); lfo2RouteFreq2.setLookAndFeel(nullptr); lfo2RouteFreq2Inv.setLookAndFeel(nullptr); lfo2RouteSharp2.setLookAndFeel(nullptr); lfo2RouteSharp2Inv.setLookAndFeel(nullptr); lfo2RouteGain2.setLookAndFeel(nullptr); lfo2RouteGain2Inv.setLookAndFeel(nullptr); type1Combo.setLookAndFeel(nullptr); sharp1Knob.setLookAndFeel(nullptr); gain1Knob.setLookAndFeel(nullptr); stereo1Toggle.setLookAndFeel(nullptr); type2Combo.setLookAndFeel(nullptr); sharp2Knob.setLookAndFeel(nullptr); gain2Knob.setLookAndFeel(nullptr); stereo2Toggle.setLookAndFeel(nullptr); } //============================================================================== void Plugex_40_twoOscMidiSynthAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_40_twoOscMidiSynthAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area1 = area.removeFromTop(100); auto attackArea = area1.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); attackLabel.setBounds(attackArea.removeFromTop(20)); attackKnob.setBounds(attackArea); auto decayArea = area1.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); decayLabel.setBounds(decayArea.removeFromTop(20)); decayKnob.setBounds(decayArea); auto sustainArea = area1.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); sustainLabel.setBounds(sustainArea.removeFromTop(20)); sustainKnob.setBounds(sustainArea); auto releaseArea = area1.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); releaseLabel.setBounds(releaseArea.removeFromTop(20)); releaseKnob.setBounds(releaseArea); auto area2 = area.removeFromTop(140); auto lfo1typeArea = area2.removeFromLeft(width/4.f).withSizeKeepingCentre(200, 100); lfo1typeLabel.setBounds(lfo1typeArea.removeFromTop(20)); lfo1typeCombo.setBounds(lfo1typeArea.removeFromTop(60).withSizeKeepingCentre(200, 24)); auto lfo1freqArea = area2.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); lfo1freqLabel.setBounds(lfo1freqArea.removeFromTop(20)); lfo1freqKnob.setBounds(lfo1freqArea); auto lfo1depthArea = area2.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); lfo1depthLabel.setBounds(lfo1depthArea.removeFromTop(20)); lfo1depthKnob.setBounds(lfo1depthArea); auto lfo1RouteArea = area2.removeFromLeft(width/2.0f); auto lfo1RouteAreaItemHeight = lfo1RouteArea.getHeight() / 4.f; auto lfo1RouteAreaLeft = lfo1RouteArea.removeFromLeft(lfo1RouteArea.getWidth() / 2.f); auto lfo1RouteLfo2FreqArea = lfo1RouteAreaLeft.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteLfo2Freq.setBounds(lfo1RouteLfo2FreqArea.removeFromLeft(130)); lfo1RouteLfo2FreqInv.setBounds(lfo1RouteLfo2FreqArea); auto lfo1RouteFreq1Area = lfo1RouteAreaLeft.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteFreq1.setBounds(lfo1RouteFreq1Area.removeFromLeft(130)); lfo1RouteFreq1Inv.setBounds(lfo1RouteFreq1Area); auto lfo1RouteSharp1Area = lfo1RouteAreaLeft.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteSharp1.setBounds(lfo1RouteSharp1Area.removeFromLeft(130)); lfo1RouteSharp1Inv.setBounds(lfo1RouteSharp1Area); auto lfo1RouteGain1Area = lfo1RouteAreaLeft.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteGain1.setBounds(lfo1RouteGain1Area.removeFromLeft(130)); lfo1RouteGain1Inv.setBounds(lfo1RouteGain1Area); auto lfo1RouteAreaRight = lfo1RouteArea; auto lfo1RouteLfo2DepthArea = lfo1RouteAreaRight.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteLfo2Depth.setBounds(lfo1RouteLfo2DepthArea.removeFromLeft(130)); lfo1RouteLfo2DepthInv.setBounds(lfo1RouteLfo2DepthArea); auto lfo1RouteFreq2Area = lfo1RouteAreaRight.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteFreq2.setBounds(lfo1RouteFreq2Area.removeFromLeft(130)); lfo1RouteFreq2Inv.setBounds(lfo1RouteFreq2Area); auto lfo1RouteSharp2Area = lfo1RouteAreaRight.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteSharp2.setBounds(lfo1RouteSharp2Area.removeFromLeft(130)); lfo1RouteSharp2Inv.setBounds(lfo1RouteSharp2Area); auto lfo1RouteGain2Area = lfo1RouteAreaRight.removeFromTop(lfo1RouteAreaItemHeight); lfo1RouteGain2.setBounds(lfo1RouteGain2Area.removeFromLeft(130)); lfo1RouteGain2Inv.setBounds(lfo1RouteGain2Area); auto area3 = area.removeFromTop(140); auto lfo2typeArea = area3.removeFromLeft(width/4.f).withSizeKeepingCentre(200, 100); lfo2typeLabel.setBounds(lfo2typeArea.removeFromTop(20)); lfo2typeCombo.setBounds(lfo2typeArea.removeFromTop(60).withSizeKeepingCentre(200, 24)); auto lfo2freqArea = area3.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); lfo2freqLabel.setBounds(lfo2freqArea.removeFromTop(20)); lfo2freqKnob.setBounds(lfo2freqArea); auto lfo2depthArea = area3.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); lfo2depthLabel.setBounds(lfo2depthArea.removeFromTop(20)); lfo2depthKnob.setBounds(lfo2depthArea); auto lfo2RouteArea = area3.removeFromLeft(width/2.0f); auto lfo2RouteAreaItemHeight = lfo2RouteArea.getHeight() / 4.f; auto lfo2RouteAreaLeft = lfo2RouteArea.removeFromLeft(lfo2RouteArea.getWidth() / 2.f); lfo2RouteAreaLeft.removeFromTop(lfo2RouteAreaItemHeight); auto lfo2RouteFreq1Area = lfo2RouteAreaLeft.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteFreq1.setBounds(lfo2RouteFreq1Area.removeFromLeft(130)); lfo2RouteFreq1Inv.setBounds(lfo2RouteFreq1Area); auto lfo2RouteSharp1Area = lfo2RouteAreaLeft.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteSharp1.setBounds(lfo2RouteSharp1Area.removeFromLeft(130)); lfo2RouteSharp1Inv.setBounds(lfo2RouteSharp1Area); auto lfo2RouteGain1Area = lfo2RouteAreaLeft.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteGain1.setBounds(lfo2RouteGain1Area.removeFromLeft(130)); lfo2RouteGain1Inv.setBounds(lfo2RouteGain1Area); auto lfo2RouteAreaRight = lfo2RouteArea; lfo2RouteAreaRight.removeFromTop(lfo2RouteAreaItemHeight); auto lfo2RouteFreq2Area = lfo2RouteAreaRight.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteFreq2.setBounds(lfo2RouteFreq2Area.removeFromLeft(130)); lfo2RouteFreq2Inv.setBounds(lfo2RouteFreq2Area); auto lfo2RouteSharp2Area = lfo2RouteAreaRight.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteSharp2.setBounds(lfo2RouteSharp2Area.removeFromLeft(130)); lfo2RouteSharp2Inv.setBounds(lfo2RouteSharp2Area); auto lfo2RouteGain2Area = lfo2RouteAreaRight.removeFromTop(lfo2RouteAreaItemHeight); lfo2RouteGain2.setBounds(lfo2RouteGain2Area.removeFromLeft(130)); lfo2RouteGain2Inv.setBounds(lfo2RouteGain2Area); auto area4 = area.removeFromTop(100); auto type1Area = area4.removeFromLeft(width/4.0f).withSizeKeepingCentre(200, 100); type1Label.setBounds(type1Area.removeFromTop(20)); type1Combo.setBounds(type1Area.removeFromTop(60).withSizeKeepingCentre(200, 24)); auto sharp1Area = area4.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); sharp1Label.setBounds(sharp1Area.removeFromTop(20)); sharp1Knob.setBounds(sharp1Area); auto gain1Area = area4.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); gain1Label.setBounds(gain1Area.removeFromTop(20)); gain1Knob.setBounds(gain1Area); auto stereo1ToggleArea = area4.removeFromLeft(width/3.0f).withSizeKeepingCentre(200, 100); stereo1Toggle.setBounds(stereo1ToggleArea.withSizeKeepingCentre(stereo1ToggleArea.getWidth(), 20.f)); auto area5 = area.removeFromTop(100); auto type2Area = area5.removeFromLeft(width/4.0f).withSizeKeepingCentre(200, 100); type2Label.setBounds(type2Area.removeFromTop(20)); type2Combo.setBounds(type2Area.removeFromTop(60).withSizeKeepingCentre(200, 24)); auto sharp2Area = area5.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); sharp2Label.setBounds(sharp2Area.removeFromTop(20)); sharp2Knob.setBounds(sharp2Area); auto gain2Area = area5.removeFromLeft(width/8.0f).withSizeKeepingCentre(80, 100); gain2Label.setBounds(gain2Area.removeFromTop(20)); gain2Knob.setBounds(gain2Area); auto stereo2ToggleArea = area5.removeFromLeft(width/3.0f).withSizeKeepingCentre(200, 100); stereo2Toggle.setBounds(stereo2ToggleArea.withSizeKeepingCentre(stereo2ToggleArea.getWidth(), 20.f)); area.removeFromTop(12); keyboardComponent.setBounds(area.removeFromBottom(80)); }
29,755
C++
.cpp
452
60.497788
158
0.790674
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,670
PluginProcessor.cpp
belangeo_plugex/Plugex_40_TwoOscMidiSynth/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" static const int numberOfVoices = 8; //============================================================================== MySynthesiserVoice::MySynthesiserVoice() { lfo1.setup(getSampleRate()); lfo2.setup(getSampleRate()); oscillator1Left.setup(getSampleRate()); oscillator1Right.setup(getSampleRate()); oscillator2Left.setup(getSampleRate()); oscillator2Right.setup(getSampleRate()); envelope.setSampleRate(getSampleRate()); smoothedGain1.reset(256); smoothedGain2.reset(256); } bool MySynthesiserVoice::canPlaySound(SynthesiserSound *sound) { return dynamic_cast<MySynthesiserSound *> (sound) != nullptr; } void MySynthesiserVoice::startNote(int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) { noteFreq = MidiMessage::getMidiNoteInHertz (midiNoteNumber); level = velocity * 0.15; envelope.noteOn(); lfo1.reset(); lfo2.reset(); lfo1.setFreq(lfoFreq1); lfo2.setFreq(lfoFreq2); oscillator1Left.setFreq(noteFreq); oscillator1Left.setSharp(noteSharp1); oscillator1Right.setFreq(noteFreq * 1.003); oscillator1Right.setSharp(noteSharp1); oscillator2Left.setFreq(noteFreq); oscillator2Left.setSharp(noteSharp2); oscillator2Right.setFreq(noteFreq * 1.003); oscillator2Right.setSharp(noteSharp2); } void MySynthesiserVoice::stopNote(float /*velocity*/, bool allowTailOff) { envelope.noteOff(); } void MySynthesiserVoice::renderNextBlock(AudioSampleBuffer& outputBuffer, int startSample, int numSamples) { while (--numSamples >= 0) { auto envAmp = envelope.getNextSample(); auto lfoValue1 = lfo1.process() * lfoDepth1; if (lfo1lfo2freqSwith) { if (lfo1lfo2freqSwithInv) { lfo2.setFreq(lfoFreq2 * (1.f + -lfoValue1)); } else { lfo2.setFreq(lfoFreq2 * (1.f + lfoValue1)); } } float lfoValue2; if (lfo1lfo2depthSwith) { if (lfo1lfo2depthSwithInv) { lfoValue2 = lfo2.process() * lfoDepth2 * (1.f + -lfoValue1); } else { lfoValue2 = lfo2.process() * lfoDepth2 * (1.f + lfoValue1); } } else { lfoValue2 = lfo2.process() * lfoDepth2; } // Oscillator 1 ------------------------------------------------ float osc1freq = noteFreq; if (lfo1freqSwitch1) { if (lfo1freqSwitch1Inv) osc1freq *= (1.f + -lfoValue1 * 0.25f); else osc1freq *= (1.f + lfoValue1 * 0.25f); } if (lfo2freqSwitch1) { if (lfo2freqSwitch1Inv) osc1freq *= (1.f + -lfoValue2 * 0.25f); else osc1freq *= (1.f + lfoValue2 * 0.25f); } oscillator1Left.setFreq(osc1freq); oscillator1Right.setFreq(osc1freq * 1.003); float osc1sharp = noteSharp1; if (lfo1sharpSwitch1) { if (lfo1sharpSwitch1Inv) osc1sharp *= (1.f + -lfoValue1); else osc1sharp *= (1.f + lfoValue1); } if (lfo2sharpSwitch1) { if (lfo2sharpSwitch1Inv) osc1sharp *= (1.f + -lfoValue2); else osc1sharp *= (1.f + lfoValue2); } oscillator1Left.setSharp(osc1sharp); oscillator1Right.setSharp(osc1sharp * 0.99); float currentSample = oscillator1Left.process() * level * envAmp; float currentSample2 = oscillator1Right.process() * level * envAmp; if (lfo1gainSwitch1) { if (lfo1gainSwitch1Inv) { currentSample *= (1.f + -lfoValue1); currentSample2 *= (1.f + -lfoValue1); } else { currentSample *= (1.f + lfoValue1); currentSample2 *= (1.f + lfoValue1); } } if (lfo2gainSwitch1) { if (lfo2gainSwitch1Inv) { currentSample *= (1.f + -lfoValue2); currentSample2 *= (1.f + -lfoValue2); } else { currentSample *= (1.f + lfoValue2); currentSample2 *= (1.f + lfoValue2); } } currentSample *= smoothedGain1.getNextValue(); currentSample2 *= smoothedGain1.getNextValue(); if (! stereoSwitch1) currentSample2 = currentSample; // Oscillator 2 ------------------------------------------------ float osc2freq = noteFreq; if (lfo1freqSwitch2) { if (lfo1freqSwitch2Inv) osc2freq *= (1.f + -lfoValue1 * 0.25f); else osc2freq *= (1.f + lfoValue1 * 0.25f); } if (lfo2freqSwitch2) { if (lfo2freqSwitch2Inv) osc2freq *= (1.f + -lfoValue2 * 0.25f); else osc2freq *= (1.f + lfoValue2 * 0.25f); } oscillator2Left.setFreq(osc2freq); oscillator2Right.setFreq(osc2freq * 1.003); float osc2sharp = noteSharp2; if (lfo1sharpSwitch2) { if (lfo1sharpSwitch2Inv) osc2sharp *= (1.f + -lfoValue1); else osc2sharp *= (1.f + lfoValue1); } if (lfo2sharpSwitch2) { if (lfo2sharpSwitch2Inv) osc2sharp *= (1.f + -lfoValue2); else osc2sharp *= (1.f + lfoValue2); } oscillator2Left.setSharp(osc2sharp); oscillator2Right.setSharp(osc2sharp * 0.99); float osc2Sample = oscillator2Left.process() * level * envAmp; float osc2Sample2 = oscillator2Right.process() * level * envAmp; if (lfo1gainSwitch2) { if (lfo1gainSwitch2Inv) { osc2Sample *= (1.f + -lfoValue1); osc2Sample2 *= (1.f + -lfoValue1); } else { osc2Sample *= (1.f + lfoValue1); osc2Sample2 *= (1.f + lfoValue1); } } if (lfo2gainSwitch2) { if (lfo2gainSwitch2Inv) { osc2Sample *= (1.f + -lfoValue2); osc2Sample2 *= (1.f + -lfoValue2); } else { osc2Sample *= (1.f + lfoValue2); osc2Sample2 *= (1.f + lfoValue2); } } osc2Sample *= smoothedGain2.getNextValue(); osc2Sample2 *= smoothedGain2.getNextValue(); if (! stereoSwitch2) osc2Sample2 = osc2Sample; currentSample += osc2Sample; currentSample2 += osc2Sample2; for (auto i = outputBuffer.getNumChannels(); --i >= 0;) { if (i) outputBuffer.addSample(i, startSample, currentSample2); else outputBuffer.addSample(i, startSample, currentSample); } ++startSample; if (envAmp <= 0.0) { clearCurrentNote(); break; } } } void MySynthesiserVoice::setEnvelopeParameters(ADSR::Parameters params) { envelope.setParameters(params); } void MySynthesiserVoice::setWavetypeParameter(int type1, int type2) { oscillator1Left.setWavetype(type1); oscillator1Right.setWavetype(type1); oscillator2Left.setWavetype(type2); oscillator2Right.setWavetype(type2); } void MySynthesiserVoice::setSharpParameter(float sharp1, float sharp2) { noteSharp1 = sharp1; noteSharp2 = sharp2; } void MySynthesiserVoice::setGainParameter(float gain1, float gain2) { smoothedGain1.setTargetValue(gain1); smoothedGain2.setTargetValue(gain2); } void MySynthesiserVoice::setStereoToggleParameter(int state1, int state2) { stereoSwitch1 = state1; stereoSwitch2 = state2; } void MySynthesiserVoice::setLFOWavetypeParameter(int type1, int type2) { lfo1.setWavetype(type1); lfo2.setWavetype(type2); if (type1 == 7) lfo1.setSharp(.75f); else lfo1.setSharp(1.f); if (type2 == 7) lfo2.setSharp(.75f); else lfo2.setSharp(1.f); } void MySynthesiserVoice::setLFOFreqParameter(float freq1, float freq2) { lfoFreq1 = freq1; lfoFreq2 = freq2; lfo1.setFreq(lfoFreq1); lfo2.setFreq(lfoFreq2); } void MySynthesiserVoice::setLFODepthParameter(float depth1, float depth2) { lfoDepth1 = depth1; lfoDepth2 = depth2; } void MySynthesiserVoice::setLFO1RoutingParameters(int lfo2freq, int lfo2freqInv, int lfo2depth, int lfo2depthInv, int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv) { lfo1lfo2freqSwith = lfo2freq; lfo1lfo2freqSwithInv = lfo2freqInv; lfo1lfo2depthSwith = lfo2depth; lfo1lfo2depthSwithInv = lfo2depthInv; lfo1freqSwitch1 = freq1; lfo1freqSwitch1Inv = freq1Inv; lfo1sharpSwitch1 = sharp1; lfo1sharpSwitch1Inv = sharp1Inv; lfo1gainSwitch1 = gain1; lfo1gainSwitch1Inv = gain1Inv; lfo1freqSwitch2 = freq2; lfo1freqSwitch2Inv = freq2Inv; lfo1sharpSwitch2 = sharp2; lfo1sharpSwitch2Inv = sharp2Inv; lfo1gainSwitch2 = gain2; lfo1gainSwitch2Inv = gain2Inv; } void MySynthesiserVoice::setLFO2RoutingParameters(int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv) { lfo2freqSwitch1 = freq1; lfo2freqSwitch1Inv = freq1Inv; lfo2sharpSwitch1 = sharp1; lfo2sharpSwitch1Inv = sharp1Inv; lfo2gainSwitch1 = gain1; lfo2gainSwitch1Inv = gain1Inv; lfo2freqSwitch2 = freq2; lfo2freqSwitch2Inv = freq2Inv; lfo2sharpSwitch2 = sharp2; lfo2sharpSwitch2Inv = sharp2Inv; lfo2gainSwitch2 = gain2; lfo2gainSwitch2Inv = gain2Inv; } //============================================================================== void MySynthesiser::setEnvelopeParameters(ADSR::Parameters params) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setEnvelopeParameters(params); } void MySynthesiser::setWavetypeParameter(int type1, int type2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setWavetypeParameter(type1, type2); } void MySynthesiser::setSharpParameter(float sharp1, float sharp2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setSharpParameter(sharp1, sharp2); } void MySynthesiser::setGainParameter(float gain1, float gain2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setGainParameter(gain1, gain2); } void MySynthesiser::setStereoToggleParameter(int state1, int state2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setStereoToggleParameter(state1, state2); } void MySynthesiser::setLFOWavetypeParameter(int type1, int type2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setLFOWavetypeParameter(type1, type2); } void MySynthesiser::setLFOFreqParameter(float freq1, float freq2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setLFOFreqParameter(freq1, freq2); } void MySynthesiser::setLFODepthParameter(float depth1, float depth2) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setLFODepthParameter(depth1, depth2); } void MySynthesiser::setLFO1RoutingParameters(int lfo2freq, int lfo2freqInv, int lfo2depth, int lfo2depthInv, int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setLFO1RoutingParameters(lfo2freq, lfo2freqInv, lfo2depth, lfo2depthInv, freq1, freq1Inv, sharp1, sharp1Inv, gain1, gain1Inv, freq2, freq2Inv, sharp2, sharp2Inv, gain2, gain2Inv); } void MySynthesiser::setLFO2RoutingParameters(int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv) { for (int i = 0; i < getNumVoices(); i++) dynamic_cast<MySynthesiserVoice *> (getVoice(i))->setLFO2RoutingParameters(freq1, freq1Inv, sharp1, sharp1Inv, gain1, gain1Inv, freq2, freq2Inv, sharp2, sharp2Inv, gain2, gain2Inv); } //============================================================================== static String freqSliderValueToText(float value) { return String(value, 3) + String(" Hz"); } static float freqSliderTextToValue(const String& text) { return text.getFloatValue(); } static String secondSliderValueToText(float value) { return String(value, 3) + String(" sec"); } static float secondSliderTextToValue(const String& text) { return text.getFloatValue(); } static String sharpSliderValueToText(float value) { return String(value, 3) + String(" x"); } static float sharpSliderTextToValue(const String& text) { return text.getFloatValue(); } static String gainSliderValueToText(float value) { float val = 20.0f * log10f(jmax(0.001f, value)); return String(val, 2) + String(" dB"); } static float gainSliderTextToValue(const String& text) { float val = jlimit(-60.0f, 18.0f, text.getFloatValue()); return powf(10.0f, val * 0.05f); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("attack"), String("Attack"), String(), NormalisableRange<float>(0.001f, 1.f, 0.001f, 0.5f), 0.005f, secondSliderValueToText, secondSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("decay"), String("Decay"), String(), NormalisableRange<float>(0.001f, 1.f, 0.001f, 0.5f), 0.2f, secondSliderValueToText, secondSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("sustain"), String("Sustain"), String(), NormalisableRange<float>(0.001f, 1.f, 0.001f, 0.3f), 0.708f, gainSliderValueToText, gainSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("release"), String("Release"), String(), NormalisableRange<float>(0.001f, 1.f, 0.001f, 0.5f), 0.25f, secondSliderValueToText, secondSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lfo1type"), String("LFO1Type"), String(), NormalisableRange<float>(0.0f, 7.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1freq"), String("LFO1Freq"), String(), NormalisableRange<float>(0.01f, 16.f, 0.001f, 0.3f), 0.5f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lfo1depth"), String("LFO1Depth"), String(), NormalisableRange<float>(0.f, 1.f, 0.001f, 1.f), 0.1f, sharpSliderValueToText, sharpSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteLfo2Freq"), String("LFO1RouteLfo2Freq"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteLfo2FreqInv"), String("LFO1RouteLfo2FreqInv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteLfo2Depth"), String("LFO1RouteLfo2Depth"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteLfo2DepthInv"), String("LFO1RouteLfo2DepthInv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteFreq1"), String("LFO1RouteFreq1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteFreq1Inv"), String("LFO1RouteFreq1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteSharp1"), String("LFO1RouteSharp1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteSharp1Inv"), String("LFO1RouteSharp1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteGain1"), String("LFO1RouteGain1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteGain1Inv"), String("LFO1RouteGain1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteFreq2"), String("LFO1RouteFreq2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteFreq2Inv"), String("LFO1RouteFreq2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteSharp2"), String("LFO1RouteSharp2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteSharp2Inv"), String("LFO1RouteSharp2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteGain2"), String("LFO1RouteGain2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo1RouteGain2Inv"), String("LFO1RouteGain2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2type"), String("LFO2Type"), String(), NormalisableRange<float>(0.0f, 7.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2freq"), String("LFO2Freq"), String(), NormalisableRange<float>(0.01f, 16.f, 0.001f, 0.3f), 0.5f, freqSliderValueToText, freqSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lfo2depth"), String("LFO2Depth"), String(), NormalisableRange<float>(0.f, 1.f, 0.001f, 1.f), 0.1f, sharpSliderValueToText, sharpSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteFreq1"), String("LFO2RouteFreq1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteFreq1Inv"), String("LFO2RouteFreq1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteSharp1"), String("LFO2RouteSharp1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteSharp1Inv"), String("LFO2RouteSharp1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteGain1"), String("LFO2RouteGain1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteGain1Inv"), String("LFO2RouteGain1Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteFreq2"), String("LFO2RouteFreq2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteFreq2Inv"), String("LFO2RouteFreq2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteSharp2"), String("LFO2RouteSharp2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteSharp2Inv"), String("LFO2RouteSharp2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteGain2"), String("LFO2RouteGain2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("lfo2RouteGain2Inv"), String("LFO2RouteGain2Inv"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("type1"), String("Type1"), String(), NormalisableRange<float>(0.0f, 7.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("sharp1"), String("Sharp1"), String(), NormalisableRange<float>(0.f, 1.f, 0.001f, 0.5f), 0.5f, sharpSliderValueToText, sharpSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("gain1"), String("Gain1"), String(), NormalisableRange<float>(0.001f, 7.94f, 0.001f, 0.3f), 1.0f, gainSliderValueToText, gainSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("stereo1"), String("Stereo1"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("type2"), String("Type2"), String(), NormalisableRange<float>(0.0f, 7.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("sharp2"), String("Sharp2"), String(), NormalisableRange<float>(0.f, 1.f, 0.001f, 0.5f), 0.5f, sharpSliderValueToText, sharpSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("gain2"), String("Gain2"), String(), NormalisableRange<float>(0.001f, 7.94f, 0.001f, 0.3f), 1.0f, gainSliderValueToText, gainSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("stereo2"), String("Stereo2"), String(), NormalisableRange<float>(0.0f, 1.0f, 1.f, 1.0f), 0.0f, nullptr, nullptr)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_40_twoOscMidiSynthAudioProcessor::Plugex_40_twoOscMidiSynthAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { for (auto i = 0; i < numberOfVoices; ++i) synthesiser.addVoice(new MySynthesiserVoice()); synthesiser.addSound(new MySynthesiserSound()); attackParameter = parameters.getRawParameterValue("attack"); decayParameter = parameters.getRawParameterValue("decay"); sustainParameter = parameters.getRawParameterValue("sustain"); releaseParameter = parameters.getRawParameterValue("release"); lfo1typeParameter = parameters.getRawParameterValue("lfo1type"); lfo1freqParameter = parameters.getRawParameterValue("lfo1freq"); lfo1depthParameter = parameters.getRawParameterValue("lfo1depth"); lfo1RouteLfo2FreqParameter = parameters.getRawParameterValue("lfo1RouteLfo2Freq"); lfo1RouteLfo2FreqInvParameter = parameters.getRawParameterValue("lfo1RouteLfo2FreqInv"); lfo1RouteLfo2DepthParameter = parameters.getRawParameterValue("lfo1RouteLfo2Depth"); lfo1RouteLfo2DepthInvParameter = parameters.getRawParameterValue("lfo1RouteLfo2DepthInv"); lfo1RouteFreq1Parameter = parameters.getRawParameterValue("lfo1RouteFreq1"); lfo1RouteFreq1InvParameter = parameters.getRawParameterValue("lfo1RouteFreq1Inv"); lfo1RouteSharp1Parameter = parameters.getRawParameterValue("lfo1RouteSharp1"); lfo1RouteSharp1InvParameter = parameters.getRawParameterValue("lfo1RouteSharp1Inv"); lfo1RouteGain1Parameter = parameters.getRawParameterValue("lfo1RouteGain1"); lfo1RouteGain1InvParameter = parameters.getRawParameterValue("lfo1RouteGain1Inv"); lfo1RouteFreq2Parameter = parameters.getRawParameterValue("lfo1RouteFreq2"); lfo1RouteFreq2InvParameter = parameters.getRawParameterValue("lfo1RouteFreq2Inv"); lfo1RouteSharp2Parameter = parameters.getRawParameterValue("lfo1RouteSharp2"); lfo1RouteSharp2InvParameter = parameters.getRawParameterValue("lfo1RouteSharp2Inv"); lfo1RouteGain2Parameter = parameters.getRawParameterValue("lfo1RouteGain2"); lfo1RouteGain2InvParameter = parameters.getRawParameterValue("lfo1RouteGain2Inv"); lfo2typeParameter = parameters.getRawParameterValue("lfo2type"); lfo2freqParameter = parameters.getRawParameterValue("lfo2freq"); lfo2depthParameter = parameters.getRawParameterValue("lfo2depth"); lfo2RouteFreq1Parameter = parameters.getRawParameterValue("lfo2RouteFreq1"); lfo2RouteFreq1InvParameter = parameters.getRawParameterValue("lfo2RouteFreq1Inv"); lfo2RouteSharp1Parameter = parameters.getRawParameterValue("lfo2RouteSharp1"); lfo2RouteSharp1InvParameter = parameters.getRawParameterValue("lfo2RouteSharp1Inv"); lfo2RouteGain1Parameter = parameters.getRawParameterValue("lfo2RouteGain1"); lfo2RouteGain1InvParameter = parameters.getRawParameterValue("lfo2RouteGain1Inv"); lfo2RouteFreq2Parameter = parameters.getRawParameterValue("lfo2RouteFreq2"); lfo2RouteFreq2InvParameter = parameters.getRawParameterValue("lfo2RouteFreq2Inv"); lfo2RouteSharp2Parameter = parameters.getRawParameterValue("lfo2RouteSharp2"); lfo2RouteSharp2InvParameter = parameters.getRawParameterValue("lfo2RouteSharp2Inv"); lfo2RouteGain2Parameter = parameters.getRawParameterValue("lfo2RouteGain2"); lfo2RouteGain2InvParameter = parameters.getRawParameterValue("lfo2RouteGain2Inv"); type1Parameter = parameters.getRawParameterValue("type1"); sharp1Parameter = parameters.getRawParameterValue("sharp1"); gain1Parameter = parameters.getRawParameterValue("gain1"); stereo1Parameter = parameters.getRawParameterValue("stereo1"); type2Parameter = parameters.getRawParameterValue("type2"); sharp2Parameter = parameters.getRawParameterValue("sharp2"); gain2Parameter = parameters.getRawParameterValue("gain2"); stereo2Parameter = parameters.getRawParameterValue("stereo2"); } Plugex_40_twoOscMidiSynthAudioProcessor::~Plugex_40_twoOscMidiSynthAudioProcessor() { } //============================================================================== const String Plugex_40_twoOscMidiSynthAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_40_twoOscMidiSynthAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_40_twoOscMidiSynthAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_40_twoOscMidiSynthAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_40_twoOscMidiSynthAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_40_twoOscMidiSynthAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_40_twoOscMidiSynthAudioProcessor::getCurrentProgram() { return 0; } void Plugex_40_twoOscMidiSynthAudioProcessor::setCurrentProgram (int index) { } const String Plugex_40_twoOscMidiSynthAudioProcessor::getProgramName (int index) { return {}; } void Plugex_40_twoOscMidiSynthAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_40_twoOscMidiSynthAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { // Use this method as the place to do any pre-playback // initialisation that you need.. keyboardState.reset(); synthesiser.setCurrentPlaybackSampleRate(sampleRate); } void Plugex_40_twoOscMidiSynthAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. keyboardState.reset(); } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_40_twoOscMidiSynthAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_40_twoOscMidiSynthAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); keyboardState.processNextMidiBuffer(midiMessages, 0, buffer.getNumSamples(), true); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); synthesiser.setEnvelopeParameters(ADSR::Parameters {*attackParameter, *decayParameter, *sustainParameter, *releaseParameter}); synthesiser.setWavetypeParameter((int)*type1Parameter, (int)*type2Parameter); synthesiser.setSharpParameter(*sharp1Parameter, *sharp2Parameter); synthesiser.setGainParameter(*gain1Parameter, *gain2Parameter); synthesiser.setStereoToggleParameter((int)*stereo1Parameter, (int)*stereo2Parameter); synthesiser.setLFOWavetypeParameter((int)*lfo1typeParameter, (int)*lfo2typeParameter); synthesiser.setLFOFreqParameter(*lfo1freqParameter, *lfo2freqParameter); synthesiser.setLFODepthParameter(*lfo1depthParameter, *lfo2depthParameter); synthesiser.setLFO1RoutingParameters(*lfo1RouteLfo2FreqParameter, *lfo1RouteLfo2FreqInvParameter, *lfo1RouteLfo2DepthParameter, *lfo1RouteLfo2DepthInvParameter, *lfo1RouteFreq1Parameter, *lfo1RouteFreq1InvParameter, *lfo1RouteSharp1Parameter, *lfo1RouteSharp1InvParameter, *lfo1RouteGain1Parameter, *lfo1RouteGain1InvParameter, *lfo1RouteFreq2Parameter, *lfo1RouteFreq2InvParameter, *lfo1RouteSharp2Parameter, *lfo1RouteSharp2InvParameter, *lfo1RouteGain2Parameter, *lfo1RouteGain2InvParameter); synthesiser.setLFO2RoutingParameters(*lfo2RouteFreq1Parameter, *lfo2RouteFreq1InvParameter, *lfo2RouteSharp1Parameter, *lfo2RouteSharp1InvParameter, *lfo2RouteGain1Parameter, *lfo2RouteGain1InvParameter, *lfo2RouteFreq2Parameter, *lfo2RouteFreq2InvParameter, *lfo2RouteSharp2Parameter, *lfo2RouteSharp2InvParameter, *lfo2RouteGain2Parameter, *lfo2RouteGain2InvParameter); synthesiser.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples()); } //============================================================================== bool Plugex_40_twoOscMidiSynthAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_40_twoOscMidiSynthAudioProcessor::createEditor() { return new Plugex_40_twoOscMidiSynthAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_40_twoOscMidiSynthAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_40_twoOscMidiSynthAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_40_twoOscMidiSynthAudioProcessor(); }
39,972
C++
.cpp
682
44.281525
139
0.593989
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,671
PluginEditor.cpp
belangeo_plugex/Plugex_29_Compressor/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_29_compressorAudioProcessorEditor::Plugex_29_compressorAudioProcessorEditor (Plugex_29_compressorAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 300); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("grey"); title.setText("Plugex - 29 - Compressor", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); threshLabel.setText("Threshold", NotificationType::dontSendNotification); threshLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&threshLabel); threshKnob.setLookAndFeel(&plugexLookAndFeel); threshKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); threshKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&threshKnob); threshAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "thresh", threshKnob)); ratioLabel.setText("Ratio", NotificationType::dontSendNotification); ratioLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&ratioLabel); ratioKnob.setLookAndFeel(&plugexLookAndFeel); ratioKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); ratioKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&ratioKnob); ratioAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "ratio", ratioKnob)); risetimeLabel.setText("Rise TIme", NotificationType::dontSendNotification); risetimeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&risetimeLabel); risetimeKnob.setLookAndFeel(&plugexLookAndFeel); risetimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); risetimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&risetimeKnob); risetimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "risetime", risetimeKnob)); falltimeLabel.setText("Fall Time", NotificationType::dontSendNotification); falltimeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&falltimeLabel); falltimeKnob.setLookAndFeel(&plugexLookAndFeel); falltimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); falltimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&falltimeKnob); falltimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "falltime", falltimeKnob)); lookaheadLabel.setText("Look Ahead", NotificationType::dontSendNotification); lookaheadLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lookaheadLabel); lookaheadKnob.setLookAndFeel(&plugexLookAndFeel); lookaheadKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lookaheadKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lookaheadKnob); lookaheadAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lookahead", lookaheadKnob)); } Plugex_29_compressorAudioProcessorEditor::~Plugex_29_compressorAudioProcessorEditor() { threshKnob.setLookAndFeel(nullptr); ratioKnob.setLookAndFeel(nullptr); risetimeKnob.setLookAndFeel(nullptr); falltimeKnob.setLookAndFeel(nullptr); lookaheadKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_29_compressorAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_29_compressorAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto areaTop = area.removeFromTop(120); auto threshArea = areaTop.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100); threshLabel.setBounds(threshArea.removeFromTop(20)); threshKnob.setBounds(threshArea); auto ratioArea = areaTop.removeFromLeft(width/2.0f).withSizeKeepingCentre(80, 100); ratioLabel.setBounds(ratioArea.removeFromTop(20)); ratioKnob.setBounds(ratioArea); auto areaBottom = area.removeFromTop(120); auto risetimeArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); risetimeLabel.setBounds(risetimeArea.removeFromTop(20)); risetimeKnob.setBounds(risetimeArea); auto falltimeArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); falltimeLabel.setBounds(falltimeArea.removeFromTop(20)); falltimeKnob.setBounds(falltimeArea); auto lookaheadArea = areaBottom.withSizeKeepingCentre(80, 100); lookaheadLabel.setBounds(lookaheadArea.removeFromTop(20)); lookaheadKnob.setBounds(lookaheadArea); area.removeFromTop(12); }
6,002
C++
.cpp
106
52.009434
158
0.756489
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,672
PluginProcessor.cpp
belangeo_plugex/Plugex_29_Compressor/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String threshSliderValueToText(float value) { return String(value, 2) + String(" dB"); } static float threshSliderTextToValue(const String& text) { return text.getFloatValue(); } static String ratioSliderValueToText(float value) { return String(value, 2) + String(" x"); } static float ratioSliderTextToValue(const String& text) { return text.getFloatValue(); } static String risetimeSliderValueToText(float value) { return String(value, 2) + String(" ms"); } static float risetimeSliderTextToValue(const String& text) { return text.getFloatValue(); } static String lookaheadSliderValueToText(float value) { return String(value, 2) + String(" ms"); } static float lookaheadSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("thresh"), String("Tresh"), String(), NormalisableRange<float>(-60.0f, 0.0f, 0.01f, 1.0f), -20.0f, threshSliderValueToText, threshSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("ratio"), String("Ratio"), String(), NormalisableRange<float>(1.0f, 20.0f, 0.01f, 0.3f), 2.0f, ratioSliderValueToText, ratioSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("risetime"), String("Risetime"), String(), NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f), 10.0f, risetimeSliderValueToText, risetimeSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("falltime"), String("Falltime"), String(), NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f), 100.0f, risetimeSliderValueToText, risetimeSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lookahead"), String("LookAhead"), String(), NormalisableRange<float>(0.01f, 10.0f, 0.01f, 1.0f), 5.0f, lookaheadSliderValueToText, lookaheadSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_29_compressorAudioProcessor::Plugex_29_compressorAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { threshParameter = parameters.getRawParameterValue("thresh"); ratioParameter = parameters.getRawParameterValue("ratio"); risetimeParameter = parameters.getRawParameterValue("risetime"); falltimeParameter = parameters.getRawParameterValue("falltime"); lookaheadParameter = parameters.getRawParameterValue("lookahead"); } Plugex_29_compressorAudioProcessor::~Plugex_29_compressorAudioProcessor() { } //============================================================================== const String Plugex_29_compressorAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_29_compressorAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_29_compressorAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_29_compressorAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_29_compressorAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_29_compressorAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_29_compressorAudioProcessor::getCurrentProgram() { return 0; } void Plugex_29_compressorAudioProcessor::setCurrentProgram (int index) { } const String Plugex_29_compressorAudioProcessor::getProgramName (int index) { return {}; } void Plugex_29_compressorAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_29_compressorAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; follower[0] = follower[1] = 0.0f; threshSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); threshSmoothed.setCurrentAndTargetValue(*threshParameter); ratioSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); ratioSmoothed.setCurrentAndTargetValue(*ratioParameter); risetimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); risetimeSmoothed.setCurrentAndTargetValue(*risetimeParameter); falltimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); falltimeSmoothed.setCurrentAndTargetValue(*falltimeParameter); lookaheadSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); lookaheadSmoothed.setCurrentAndTargetValue(*lookaheadParameter); for (int channel = 0; channel < 2; channel++) { lookaheadDelay[channel].setup(0.015, currentSampleRate); } } void Plugex_29_compressorAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_29_compressorAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_29_compressorAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); threshSmoothed.setTargetValue(*threshParameter); ratioSmoothed.setTargetValue(*ratioParameter); risetimeSmoothed.setTargetValue(*risetimeParameter); falltimeSmoothed.setTargetValue(*falltimeParameter); lookaheadSmoothed.setTargetValue(*lookaheadParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float thresh = threshSmoothed.getNextValue(); float ratio = ratioSmoothed.getNextValue(); float risetime = risetimeSmoothed.getNextValue() * 0.001f; float falltime = falltimeSmoothed.getNextValue() * 0.001f; float lookahead = lookaheadSmoothed.getNextValue() * 0.001f; ratio = 1.0f / ratio; risetime = expf(-1.0f / (currentSampleRate * risetime)); falltime = expf(-1.0f / (currentSampleRate * falltime)); float knee = 0.5f; /* 0.001 = hard knee, 1 = soft knee */ thresh += 3.0f * knee; if (thresh > 0.0f) thresh = 0.0f; float ampthresh = powf(10.0f, thresh * 0.05f); /* up to 3 dB above threshold */ float kneethresh = powf(10.0f, (thresh - (knee * 8.5f + 0.5f)) * 0.05f); /* up to 6 dB under threshold */ float invKneeRange = 1.0f / (ampthresh - kneethresh); for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); /* Envelope follower */ float rectified = channelData[i] < 0.0f ? -channelData[i] : channelData[i]; if (follower[channel] < rectified) { follower[channel] = rectified + risetime * (follower[channel] - rectified); } else { follower[channel] = rectified + falltime * (follower[channel] - rectified); } /* Look ahead */ float delayedSample = lookaheadDelay[channel].read(lookahead); lookaheadDelay[channel].write(channelData[i]); /* Compress signal */ float outAmplitude = 1.0f; if (follower[channel] > ampthresh) { /* Above threshold */ float indb = 20.0f * log10f(follower[channel] + 1.0e-20); float diff = indb - thresh; float outdb = diff - diff * ratio; outAmplitude = powf(10.0f, -outdb * 0.05f); } else if (follower[channel] > kneethresh) { /* Under the knee */ float kneescl = (follower[channel] - kneethresh) * invKneeRange; float kneeratio = (((knee + 1.0f) * kneescl) / (knee + kneescl)) * (ratio - 1.0f) + 1.0f; float indb = 20.0f * log10f(follower[channel] + 1.0e-20); float diff = indb - thresh; float outdb = diff - diff * kneeratio; outAmplitude = powf(10.0f, -outdb * 0.05f); } outAmplitude = outAmplitude < 1.0e-20 ? 1.0e-20 : outAmplitude > 1.0f ? 1.0f : outAmplitude; channelData[i] = delayedSample * outAmplitude; } } } //============================================================================== bool Plugex_29_compressorAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_29_compressorAudioProcessor::createEditor() { return new Plugex_29_compressorAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_29_compressorAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_29_compressorAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_29_compressorAudioProcessor(); }
12,590
C++
.cpp
267
39.28839
118
0.632271
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,673
PluginEditor.cpp
belangeo_plugex/Plugex_30_Expander/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_30_expanderAudioProcessorEditor::Plugex_30_expanderAudioProcessorEditor (Plugex_30_expanderAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (400, 300); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("grey"); title.setText("Plugex - 30 - Expander", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); downthreshLabel.setText("Down Thresh", NotificationType::dontSendNotification); downthreshLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&downthreshLabel); downthreshKnob.setLookAndFeel(&plugexLookAndFeel); downthreshKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); downthreshKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&downthreshKnob); downthreshAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "downthresh", downthreshKnob)); upthreshLabel.setText("Up Thresh", NotificationType::dontSendNotification); upthreshLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&upthreshLabel); upthreshKnob.setLookAndFeel(&plugexLookAndFeel); upthreshKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); upthreshKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&upthreshKnob); upthreshAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "upthresh", upthreshKnob)); ratioLabel.setText("Ratio", NotificationType::dontSendNotification); ratioLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&ratioLabel); ratioKnob.setLookAndFeel(&plugexLookAndFeel); ratioKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); ratioKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&ratioKnob); ratioAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "ratio", ratioKnob)); risetimeLabel.setText("Rise TIme", NotificationType::dontSendNotification); risetimeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&risetimeLabel); risetimeKnob.setLookAndFeel(&plugexLookAndFeel); risetimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); risetimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&risetimeKnob); risetimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "risetime", risetimeKnob)); falltimeLabel.setText("Fall Time", NotificationType::dontSendNotification); falltimeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&falltimeLabel); falltimeKnob.setLookAndFeel(&plugexLookAndFeel); falltimeKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); falltimeKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&falltimeKnob); falltimeAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "falltime", falltimeKnob)); lookaheadLabel.setText("Look Ahead", NotificationType::dontSendNotification); lookaheadLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&lookaheadLabel); lookaheadKnob.setLookAndFeel(&plugexLookAndFeel); lookaheadKnob.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); lookaheadKnob.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); addAndMakeVisible(&lookaheadKnob); lookaheadAttachment.reset(new AudioProcessorValueTreeState::SliderAttachment(valueTreeState, "lookahead", lookaheadKnob)); } Plugex_30_expanderAudioProcessorEditor::~Plugex_30_expanderAudioProcessorEditor() { downthreshKnob.setLookAndFeel(nullptr); upthreshKnob.setLookAndFeel(nullptr); ratioKnob.setLookAndFeel(nullptr); risetimeKnob.setLookAndFeel(nullptr); falltimeKnob.setLookAndFeel(nullptr); lookaheadKnob.setLookAndFeel(nullptr); setLookAndFeel(nullptr); } //============================================================================== void Plugex_30_expanderAudioProcessorEditor::paint (Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_30_expanderAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto areaTop = area.removeFromTop(120); auto downthreshArea = areaTop.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); downthreshLabel.setBounds(downthreshArea.removeFromTop(20)); downthreshKnob.setBounds(downthreshArea); auto upthreshArea = areaTop.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); upthreshLabel.setBounds(upthreshArea.removeFromTop(20)); upthreshKnob.setBounds(upthreshArea); auto ratioArea = areaTop.withSizeKeepingCentre(80, 100); ratioLabel.setBounds(ratioArea.removeFromTop(20)); ratioKnob.setBounds(ratioArea); auto areaBottom = area.removeFromTop(120); auto risetimeArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); risetimeLabel.setBounds(risetimeArea.removeFromTop(20)); risetimeKnob.setBounds(risetimeArea); auto falltimeArea = areaBottom.removeFromLeft(width/3.0f).withSizeKeepingCentre(80, 100); falltimeLabel.setBounds(falltimeArea.removeFromTop(20)); falltimeKnob.setBounds(falltimeArea); auto lookaheadArea = areaBottom.withSizeKeepingCentre(80, 100); lookaheadLabel.setBounds(lookaheadArea.removeFromTop(20)); lookaheadKnob.setBounds(lookaheadArea); area.removeFromTop(12); }
6,817
C++
.cpp
118
53.084746
152
0.765139
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,674
PluginProcessor.cpp
belangeo_plugex/Plugex_30_Expander/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif static String upthreshSliderValueToText(float value) { return String(value, 2) + String(" dB"); } static float upthreshSliderTextToValue(const String& text) { return text.getFloatValue(); } static String ratioSliderValueToText(float value) { return String(value, 2) + String(" x"); } static float ratioSliderTextToValue(const String& text) { return text.getFloatValue(); } static String risetimeSliderValueToText(float value) { return String(value, 2) + String(" ms"); } static float risetimeSliderTextToValue(const String& text) { return text.getFloatValue(); } static String lookaheadSliderValueToText(float value) { return String(value, 2) + String(" ms"); } static float lookaheadSliderTextToValue(const String& text) { return text.getFloatValue(); } AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("downthresh"), String("DownTresh"), String(), NormalisableRange<float>(-120.0f, -20.0f, 0.01f, 1.0f), -40.0f, upthreshSliderValueToText, upthreshSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("upthresh"), String("UpTresh"), String(), NormalisableRange<float>(-60.0f, 0.0f, 0.01f, 1.0f), -20.0f, upthreshSliderValueToText, upthreshSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("ratio"), String("Ratio"), String(), NormalisableRange<float>(1.0f, 20.0f, 0.01f, 0.3f), 2.0f, ratioSliderValueToText, ratioSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("risetime"), String("Risetime"), String(), NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f), 10.0f, risetimeSliderValueToText, risetimeSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("falltime"), String("Falltime"), String(), NormalisableRange<float>(0.01f, 500.0f, 0.01f, 0.3f), 100.0f, risetimeSliderValueToText, risetimeSliderTextToValue)); parameters.push_back(std::make_unique<Parameter>(String("lookahead"), String("LookAhead"), String(), NormalisableRange<float>(0.01f, 10.0f, 0.01f, 1.0f), 5.0f, lookaheadSliderValueToText, lookaheadSliderTextToValue)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_30_expanderAudioProcessor::Plugex_30_expanderAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { downthreshParameter = parameters.getRawParameterValue("downthresh"); upthreshParameter = parameters.getRawParameterValue("upthresh"); ratioParameter = parameters.getRawParameterValue("ratio"); risetimeParameter = parameters.getRawParameterValue("risetime"); falltimeParameter = parameters.getRawParameterValue("falltime"); lookaheadParameter = parameters.getRawParameterValue("lookahead"); } Plugex_30_expanderAudioProcessor::~Plugex_30_expanderAudioProcessor() { } //============================================================================== const String Plugex_30_expanderAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_30_expanderAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_30_expanderAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_30_expanderAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_30_expanderAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_30_expanderAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_30_expanderAudioProcessor::getCurrentProgram() { return 0; } void Plugex_30_expanderAudioProcessor::setCurrentProgram (int index) { } const String Plugex_30_expanderAudioProcessor::getProgramName (int index) { return {}; } void Plugex_30_expanderAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_30_expanderAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { currentSampleRate = sampleRate; follower[0] = follower[1] = 0.0f; downthreshSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); downthreshSmoothed.setCurrentAndTargetValue(*downthreshParameter); upthreshSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); upthreshSmoothed.setCurrentAndTargetValue(*upthreshParameter); ratioSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); ratioSmoothed.setCurrentAndTargetValue(*ratioParameter); risetimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); risetimeSmoothed.setCurrentAndTargetValue(*risetimeParameter); falltimeSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); falltimeSmoothed.setCurrentAndTargetValue(*falltimeParameter); lookaheadSmoothed.reset(sampleRate, samplesPerBlock/sampleRate); lookaheadSmoothed.setCurrentAndTargetValue(*lookaheadParameter); for (int channel = 0; channel < 2; channel++) { lookaheadDelay[channel].setup(0.015, currentSampleRate); } } void Plugex_30_expanderAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_30_expanderAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_30_expanderAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); downthreshSmoothed.setTargetValue(*upthreshParameter); upthreshSmoothed.setTargetValue(*upthreshParameter); ratioSmoothed.setTargetValue(*ratioParameter); risetimeSmoothed.setTargetValue(*risetimeParameter); falltimeSmoothed.setTargetValue(*falltimeParameter); lookaheadSmoothed.setTargetValue(*lookaheadParameter); for (int i = 0; i < buffer.getNumSamples(); i++) { float downthresh = upthreshSmoothed.getNextValue(); float upthresh = upthreshSmoothed.getNextValue(); float ratio = ratioSmoothed.getNextValue(); float risetime = risetimeSmoothed.getNextValue() * 0.001f; float falltime = falltimeSmoothed.getNextValue() * 0.001f; float lookahead = lookaheadSmoothed.getNextValue() * 0.001f; if (downthresh > upthresh) { downthresh = upthresh; } ratio = 1.0f / ratio; risetime = expf(-1.0f / (currentSampleRate * risetime)); falltime = expf(-1.0f / (currentSampleRate * falltime)); for (int channel = 0; channel < totalNumInputChannels; ++channel) { auto* channelData = buffer.getWritePointer (channel); /* Envelope follower */ float rectified = channelData[i] < 0.0f ? -channelData[i] : channelData[i]; if (follower[channel] < rectified) { follower[channel] = rectified + risetime * (follower[channel] - rectified); } else { follower[channel] = rectified + falltime * (follower[channel] - rectified); } /* Look ahead */ float delayedSample = lookaheadDelay[channel].read(lookahead); lookaheadDelay[channel].write(channelData[i]); /* Expand signal */ float outAmplitude = 1.0f; float indb = follower[channel] < 1.0e-20 ? 1.0e-20 : follower[channel] > 1.0f ? 1.0f : follower[channel]; if (indb > upthresh) { /* Above upper threshold */ float diff = indb - upthresh; outAmplitude = powf(10.0f, (diff * ratio - diff) * 0.05f); } else if (indb < downthresh) { /* Below lower threshold */ float diff = downthresh - indb; outAmplitude = powf(10.0f, (diff - diff * ratio) * 0.05f); } outAmplitude = 1.0 / outAmplitude; channelData[i] = delayedSample * outAmplitude; } } } //============================================================================== bool Plugex_30_expanderAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_30_expanderAudioProcessor::createEditor() { return new Plugex_30_expanderAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_30_expanderAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void Plugex_30_expanderAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_30_expanderAudioProcessor(); }
12,486
C++
.cpp
266
38.958647
117
0.641945
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,675
PluginEditor.cpp
belangeo_plugex/Plugex_32_SpectralDelay/Source/PluginEditor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== Plugex_32_spectralDelayAudioProcessorEditor::Plugex_32_spectralDelayAudioProcessorEditor (Plugex_32_spectralDelayAudioProcessor& p, AudioProcessorValueTreeState& vts) : AudioProcessorEditor (&p), processor (p), valueTreeState (vts) { setSize (400, 450); setLookAndFeel(&plugexLookAndFeel); plugexLookAndFeel.setTheme("steal"); title.setText("Plugex - 32 - Spectral Delay", NotificationType::dontSendNotification); title.setFont(title.getFont().withPointHeight(title.getFont().getHeightInPoints() + 4)); title.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&title); orderLabel.setText("FFT Size", NotificationType::dontSendNotification); orderLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&orderLabel); orderCombo.setLookAndFeel(&plugexLookAndFeel); orderCombo.addItemList({"64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384"}, 6); orderCombo.setSelectedId(10); addAndMakeVisible(&orderCombo); orderAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "order", orderCombo)); overlapsLabel.setText("FFT Overlaps", NotificationType::dontSendNotification); overlapsLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&overlapsLabel); overlapsCombo.setLookAndFeel(&plugexLookAndFeel); overlapsCombo.addItemList({"2", "4", "8"}, 1); overlapsCombo.setSelectedId(2); addAndMakeVisible(&overlapsCombo); overlapsAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "overlaps", overlapsCombo)); wintypeLabel.setText("Window Type", NotificationType::dontSendNotification); wintypeLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&wintypeLabel); wintypeCombo.setLookAndFeel(&plugexLookAndFeel); wintypeCombo.addItemList({"Rectangular", "Triangular", "Hanning", "Hamming", "Blackman", "Blackman-Harris 4 terms", "Blackman-Harris 7 terms", "Flat Top", "Half Sine"}, 1); wintypeCombo.setSelectedId(3); addAndMakeVisible(&wintypeCombo); wintypeAttachment.reset(new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, "wintype", wintypeCombo)); delayLabel.setText("Delay per bin", NotificationType::dontSendNotification); delayLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&delayLabel); delayMultiSlider.setup(multiSliderNumberOfPoints); delayMultiSlider.addListener(this); delayMultiSlider.setLookAndFeel(&plugexLookAndFeel); delayMultiSlider.setPoints(processor.delayPoints); addAndMakeVisible(&delayMultiSlider); feedbackLabel.setText("Feedback per bin", NotificationType::dontSendNotification); feedbackLabel.setJustificationType(Justification::horizontallyCentred); addAndMakeVisible(&feedbackLabel); feedbackMultiSlider.setup(multiSliderNumberOfPoints); feedbackMultiSlider.addListener(this); feedbackMultiSlider.setLookAndFeel(&plugexLookAndFeel); feedbackMultiSlider.setPoints(processor.feedbackPoints); addAndMakeVisible(&feedbackMultiSlider); startTimer(0.05); } Plugex_32_spectralDelayAudioProcessorEditor::~Plugex_32_spectralDelayAudioProcessorEditor() { orderCombo.setLookAndFeel(nullptr); overlapsCombo.setLookAndFeel(nullptr); wintypeCombo.setLookAndFeel(nullptr); delayMultiSlider.setLookAndFeel(nullptr); feedbackMultiSlider.setLookAndFeel(nullptr); } void Plugex_32_spectralDelayAudioProcessorEditor::timerCallback() { if (processor.delayPointsChanged) { delayMultiSlider.setPoints(processor.delayPoints); processor.delayPointsChanged = false; } if (processor.feedbackPointsChanged) { feedbackMultiSlider.setPoints(processor.feedbackPoints); processor.feedbackPointsChanged = false; } } void Plugex_32_spectralDelayAudioProcessorEditor::multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) { if (multiSlider == &delayMultiSlider) { processor.setDelayPoints(value); } else if (multiSlider == &feedbackMultiSlider) { processor.setFeedbackPoints(value); } } //============================================================================== void Plugex_32_spectralDelayAudioProcessorEditor::paint (Graphics& g) { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } void Plugex_32_spectralDelayAudioProcessorEditor::resized() { auto area = getLocalBounds().reduced(12, 12); float width = area.getWidth(); title.setBounds(area.removeFromTop(36)); area.removeFromTop(12); auto area2 = area.removeFromTop(60); auto orderArea = area2.removeFromLeft(width / 3.0f); orderLabel.setBounds(orderArea.removeFromTop(20)); orderCombo.setBounds(orderArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); auto overlapsArea = area2.removeFromLeft(width / 3.0f); overlapsLabel.setBounds(overlapsArea.removeFromTop(20)); overlapsCombo.setBounds(overlapsArea.removeFromTop(60).withSizeKeepingCentre(120, 24)); wintypeLabel.setBounds(area2.removeFromTop(20)); wintypeCombo.setBounds(area2.removeFromTop(60).withSizeKeepingCentre(120, 24)); area.removeFromTop(12); delayLabel.setBounds(area.removeFromTop(20).withSizeKeepingCentre(getWidth() - 20, 20)); delayMultiSlider.setBounds(area.removeFromTop(120).withSizeKeepingCentre(multiSliderNumberOfPoints, 100)); area.removeFromTop(12); feedbackLabel.setBounds(area.removeFromTop(20).withSizeKeepingCentre(getWidth() - 20, 20)); feedbackMultiSlider.setBounds(area.removeFromTop(120).withSizeKeepingCentre(multiSliderNumberOfPoints, 100)); }
6,482
C++
.cpp
119
48.806723
131
0.733196
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,676
PluginProcessor.cpp
belangeo_plugex/Plugex_32_SpectralDelay/Source/PluginProcessor.cpp
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #include "PluginProcessor.h" #include "PluginEditor.h" #ifndef M_PI #define M_PI (3.14159265358979323846264338327950288) #endif AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { using Parameter = AudioProcessorValueTreeState::Parameter; std::vector<std::unique_ptr<Parameter>> parameters; parameters.push_back(std::make_unique<Parameter>(String("order"), String("Order"), String(), NormalisableRange<float>(6.0f, 14.0f, 1.f, 1.0f), 10.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("overlaps"), String("Overlaps"), String(), NormalisableRange<float>(1.0f, 3.0f, 1.f, 1.0f), 2.0f, nullptr, nullptr)); parameters.push_back(std::make_unique<Parameter>(String("wintype"), String("Wintype"), String(), NormalisableRange<float>(1.0f, 9.0f, 1.f, 1.0f), 3.0f, nullptr, nullptr)); return { parameters.begin(), parameters.end() }; } //============================================================================== Plugex_32_spectralDelayAudioProcessor::Plugex_32_spectralDelayAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ), #endif parameters (*this, nullptr, Identifier(JucePlugin_Name), createParameterLayout()) { orderParameter = parameters.getRawParameterValue("order"); overlapsParameter = parameters.getRawParameterValue("overlaps"); wintypeParameter = parameters.getRawParameterValue("wintype"); lastOrder = (int)*orderParameter; lastOverlaps = 1 << (int)*overlapsParameter; lastWintype = (int)*overlapsParameter; ValueTree delayNode(Identifier("delaySavedPoints")); for (int i = 0; i < multiSliderNumberOfPoints; i++) { delayNode.setProperty(Identifier(String(i)), 0.0f, nullptr); } parameters.state.addChild(delayNode, -1, nullptr); ValueTree feedbackNode(Identifier("feedbackSavedPoints")); for (int i = 0; i < multiSliderNumberOfPoints; i++) { feedbackNode.setProperty(Identifier(String(i)), 0.0f, nullptr); } parameters.state.addChild(feedbackNode, -1, nullptr); for (auto channel = 0; channel < 2; channel++) { fftEngine[channel].setup(lastOrder, lastOverlaps, lastWintype); fftEngine[channel].addListener(this); } zeromem (fftDelay, sizeof (fftDelay)); zeromem (fftFeedback, sizeof (fftFeedback)); delayPoints.resize(multiSliderNumberOfPoints); delayPoints.fill(0.0f); feedbackPoints.resize(multiSliderNumberOfPoints); feedbackPoints.fill(0.0f); } Plugex_32_spectralDelayAudioProcessor::~Plugex_32_spectralDelayAudioProcessor() { } //============================================================================== const String Plugex_32_spectralDelayAudioProcessor::getName() const { return JucePlugin_Name; } bool Plugex_32_spectralDelayAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool Plugex_32_spectralDelayAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool Plugex_32_spectralDelayAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double Plugex_32_spectralDelayAudioProcessor::getTailLengthSeconds() const { return 0.0; } int Plugex_32_spectralDelayAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int Plugex_32_spectralDelayAudioProcessor::getCurrentProgram() { return 0; } void Plugex_32_spectralDelayAudioProcessor::setCurrentProgram (int index) { } const String Plugex_32_spectralDelayAudioProcessor::getProgramName (int index) { return {}; } void Plugex_32_spectralDelayAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void Plugex_32_spectralDelayAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { // Use this method as the place to do any pre-playback // initialisation that you need.. currentSampleRate = sampleRate; resizeBuffers(lastOrder, lastOverlaps); } void Plugex_32_spectralDelayAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool Plugex_32_spectralDelayAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void Plugex_32_spectralDelayAudioProcessor::resizeBuffers(int order, int overlaps) { int fftSize = 1 << order; int hopsize = fftSize / overlaps; currentNumberOfFrames = (int)(maxDelayTimeInSeconds * currentSampleRate / hopsize + 0.5f); sampleBuffers[0].resize(currentNumberOfFrames * fftSize); sampleBuffers[0].fill(0.0f); sampleBuffers[1].resize(currentNumberOfFrames * fftSize); sampleBuffers[1].fill(0.0f); frameCount[0] = frameCount[1] = 0; } void Plugex_32_spectralDelayAudioProcessor::computeFFTDelay() { int filterSize = fftEngine[0].getSize() / 2 + 1; for (int i = 0; i < filterSize; i++) { float index = sinf(i / (float)filterSize * M_PI / 2.0f) * multiSliderNumberOfPoints; int ipart = (int)index; float fpart = index - ipart; fftDelay[i] = delayPoints[ipart] + (delayPoints[ipart+1] - delayPoints[ipart]) * fpart; } } void Plugex_32_spectralDelayAudioProcessor::computeFFTFeedback() { int filterSize = fftEngine[0].getSize() / 2 + 1; for (int i = 0; i < filterSize; i++) { float index = sinf(i / (float)filterSize * M_PI / 2.0f) * multiSliderNumberOfPoints; int ipart = (int)index; float fpart = index - ipart; fftFeedback[i] = feedbackPoints[ipart] + (feedbackPoints[ipart+1] - feedbackPoints[ipart]) * fpart; } } void Plugex_32_spectralDelayAudioProcessor::setDelayPoints(const Array<float> &value) { ValueTree delayNode = parameters.state.getChildWithName(Identifier("delaySavedPoints")); for (int i = 0; i < multiSliderNumberOfPoints; i++) { delayPoints.set(i, value[i]); delayNode.setProperty(Identifier(String(i)), delayPoints[i], nullptr); } computeFFTDelay(); } void Plugex_32_spectralDelayAudioProcessor::setFeedbackPoints(const Array<float> &value) { ValueTree feedbackNode = parameters.state.getChildWithName(Identifier("feedbackSavedPoints")); for (int i = 0; i < multiSliderNumberOfPoints; i++) { feedbackPoints.set(i, value[i]); feedbackNode.setProperty(Identifier(String(i)), feedbackPoints[i], nullptr); } computeFFTFeedback(); } void Plugex_32_spectralDelayAudioProcessor::fftEngineFrameReady(FFTEngine *engine, float *fftData, int fftSize) { int channel = (engine == &fftEngine[0]) ? 0 : 1; int count = frameCount[channel]; for (int j = 0; j < fftSize / 2 + 1; j++) { int binDelay = (int)(fftDelay[j] * currentNumberOfFrames); float binFeedback = fftFeedback[j]; binDelay = count - binDelay; if (binDelay < 0) { binDelay += currentNumberOfFrames; } if (binDelay < currentNumberOfFrames) { int realIndex = j * 2; int imagIndex = j * 2 + 1; float realTemp = sampleBuffers[channel][binDelay * fftSize + realIndex]; float imagTemp = sampleBuffers[channel][binDelay * fftSize + imagIndex]; sampleBuffers[channel].set(count * fftSize + realIndex, fftData[realIndex] + realTemp * binFeedback); sampleBuffers[channel].set(count * fftSize + imagIndex, fftData[imagIndex] + imagTemp * binFeedback); fftData[realIndex] = realTemp; fftData[imagIndex] = imagTemp; } } frameCount[channel]++; if (frameCount[channel] >= currentNumberOfFrames) frameCount[channel] = 0; } void Plugex_32_spectralDelayAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); int order = (int) *orderParameter; int overlaps = 1 << (int) *overlapsParameter; int wintype = (int) *wintypeParameter; if (order != lastOrder || overlaps != lastOverlaps) { resizeBuffers(order, overlaps); computeFFTDelay(); computeFFTFeedback(); } for (auto channel = 0; channel < totalNumInputChannels; channel++) { if (order != lastOrder || overlaps != lastOverlaps) { fftEngine[channel].setup(order, overlaps, wintype); } if (wintype != lastWintype) { fftEngine[channel].setWintype(wintype); } auto *channelData = buffer.getWritePointer(channel); for (int i = 0; i < buffer.getNumSamples(); i++) { channelData[i] = fftEngine[channel].process(channelData[i]); } } lastOrder = order; lastOverlaps = overlaps; lastWintype = wintype; } //============================================================================== bool Plugex_32_spectralDelayAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* Plugex_32_spectralDelayAudioProcessor::createEditor() { return new Plugex_32_spectralDelayAudioProcessorEditor (*this, parameters); } //============================================================================== void Plugex_32_spectralDelayAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. auto state = parameters.copyState(); std::unique_ptr<XmlElement> xml (state.createXml()); copyXmlToBinary (*xml, destData); } void Plugex_32_spectralDelayAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. std::unique_ptr<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes)); if (xmlState.get() != nullptr) { if (xmlState->hasTagName (parameters.state.getType())) { ValueTree state = ValueTree::fromXml (*xmlState); parameters.replaceState (state); } } ValueTree delayNode = parameters.state.getChildWithName(Identifier("delaySavedPoints")); if (delayNode.isValid()) { for (int i = 0; i < multiSliderNumberOfPoints; i++) { delayPoints.set(i, (float) delayNode.getProperty(Identifier(String(i)), 0.0f)); } computeFFTDelay(); delayPointsChanged = true; } ValueTree feedbackNode = parameters.state.getChildWithName(Identifier("feedbackSavedPoints")); if (feedbackNode.isValid()) { for (int i = 0; i < multiSliderNumberOfPoints; i++) { feedbackPoints.set(i, (float) feedbackNode.getProperty(Identifier(String(i)), 0.0f)); } computeFFTFeedback(); feedbackPointsChanged = true; } } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Plugex_32_spectralDelayAudioProcessor(); }
13,525
C++
.cpp
312
37.134615
113
0.657065
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,677
PluginEditor.h
belangeo_plugex/Plugex_36_SineWaveMidiSynth/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_36_sineWaveMidiSynthAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_36_sineWaveMidiSynthAudioProcessorEditor (Plugex_36_sineWaveMidiSynthAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_36_sineWaveMidiSynthAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_36_sineWaveMidiSynthAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label gainLabel; Slider gainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gainAttachment; MidiKeyboardComponent keyboardComponent; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_36_sineWaveMidiSynthAudioProcessorEditor) };
1,374
C++
.h
32
39.09375
133
0.709408
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,678
PluginProcessor.h
belangeo_plugex/Plugex_36_SineWaveMidiSynth/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "SinOsc.h" //============================================================================== struct SineWaveSound : public SynthesiserSound { SineWaveSound() {} bool appliesToNote (int) override { return true; } bool appliesToChannel (int) override { return true; } }; //============================================================================== struct SineWaveVoice : public SynthesiserVoice { SineWaveVoice(); void pitchWheelMoved (int) override {} void controllerMoved (int, int) override {} bool canPlaySound (SynthesiserSound *sound) override; void startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) override; void stopNote (float /*velocity*/, bool allowTailOff) override; void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override; private: SinOsc oscillator; double level = 0.0, tailOff = 0.0; }; //============================================================================== class Plugex_36_sineWaveMidiSynthAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_36_sineWaveMidiSynthAudioProcessor(); ~Plugex_36_sineWaveMidiSynthAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; MidiKeyboardState keyboardState; private: //============================================================================== AudioProcessorValueTreeState parameters; Synthesiser synthesiser; std::atomic<float> *gainParameter = nullptr; float lastGain = 0.f; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_36_sineWaveMidiSynthAudioProcessor) };
3,713
C++
.h
76
44.052632
101
0.54553
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,679
PluginEditor.h
belangeo_plugex/Plugex_26_Doppler/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_26_dopplerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_26_dopplerAudioProcessorEditor (Plugex_26_dopplerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_26_dopplerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_26_dopplerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label depthLabel; Slider depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> depthAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_26_dopplerAudioProcessorEditor) };
1,697
C++
.h
40
38.525
113
0.626683
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,681
PluginEditor.h
belangeo_plugex/Plugex_00_VisualDesign/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" #include "MultiSlider.h" class Plugex_00_visualDesignAudioProcessorEditor : public AudioProcessorEditor, public MultiSlider::Listener { public: Plugex_00_visualDesignAudioProcessorEditor (Plugex_00_visualDesignAudioProcessor&); ~Plugex_00_visualDesignAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; void multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) override; private: Plugex_00_visualDesignAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; Label title; Label label; Slider knob; Slider hbar; Slider hslider; Slider vbar; Slider vslider; ComboBox combo; TextButton button1; TextButton button2; ToggleButton toggle; Label multiSliderLabel; MultiSlider multiSlider; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_00_visualDesignAudioProcessorEditor) };
1,555
C++
.h
42
31.571429
94
0.661745
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,685
PluginEditor.h
belangeo_plugex/Plugex_21_Chorus/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_21_chorusAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_21_chorusAudioProcessorEditor (Plugex_21_chorusAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_21_chorusAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_21_chorusAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label depthLabel; Slider depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> depthAttachment; Label feedbackLabel; Slider feedbackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> feedbackAttachment; Label balanceLabel; Slider balanceKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balanceAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_21_chorusAudioProcessorEditor) };
1,840
C++
.h
43
38.790698
111
0.641286
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,687
PluginEditor.h
belangeo_plugex/Plugex_20_Flanger/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_20_flangerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_20_flangerAudioProcessorEditor (Plugex_20_flangerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_20_flangerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_20_flangerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label delayLabel; Slider delayKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> delayAttachment; Label depthLabel; Slider depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> depthAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_20_flangerAudioProcessorEditor) };
1,828
C++
.h
43
38.511628
113
0.638842
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,689
PluginEditor.h
belangeo_plugex/Plugex_04_FirstOrderLP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_04_firstOrderLpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_04_firstOrderLpAudioProcessorEditor (Plugex_04_firstOrderLpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_04_firstOrderLpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: Plugex_04_firstOrderLpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_04_firstOrderLpAudioProcessorEditor) };
1,383
C++
.h
32
39.40625
123
0.65237
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,692
PluginProcessor.h
belangeo_plugex/Plugex_37_SineAdsrMidiSynth/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "SinOsc.h" //============================================================================== struct MySynthesiserSound : public SynthesiserSound { MySynthesiserSound() {} bool appliesToNote (int) override { return true; } bool appliesToChannel (int) override { return true; } }; //============================================================================== struct MySynthesiserVoice : public SynthesiserVoice { MySynthesiserVoice(); void pitchWheelMoved (int) override {} void controllerMoved (int, int) override {} bool canPlaySound (SynthesiserSound *sound) override; void startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) override; void stopNote (float /*velocity*/, bool allowTailOff) override; void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override; void setEnvelopeParameters(ADSR::Parameters params); private: SinOsc oscillator; ADSR envelope; double level = 0.0; }; //============================================================================== class MySynthesiser : public Synthesiser { public: void setEnvelopeParameters(ADSR::Parameters params); }; //============================================================================== class Plugex_37_sineAdsrMidiSynthAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_37_sineAdsrMidiSynthAudioProcessor(); ~Plugex_37_sineAdsrMidiSynthAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; MidiKeyboardState keyboardState; private: //============================================================================== AudioProcessorValueTreeState parameters; MySynthesiser synthesiser; std::atomic<float> *attackParameter = nullptr; std::atomic<float> *decayParameter = nullptr; std::atomic<float> *sustainParameter = nullptr; std::atomic<float> *releaseParameter = nullptr; std::atomic<float> *gainParameter = nullptr; float lastGain = 0.f; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_37_sineAdsrMidiSynthAudioProcessor) };
4,196
C++
.h
88
43.045455
101
0.556787
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,693
PluginEditor.h
belangeo_plugex/Plugex_39_WaveModMidiSynth/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_39_waveModMidiSynthAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_39_waveModMidiSynthAudioProcessorEditor (Plugex_39_waveModMidiSynthAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_39_waveModMidiSynthAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_39_waveModMidiSynthAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label attackLabel; Slider attackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> attackAttachment; Label decayLabel; Slider decayKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> decayAttachment; Label sustainLabel; Slider sustainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sustainAttachment; Label releaseLabel; Slider releaseKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> releaseAttachment; //--------------------------------------------------------------------------------- Label lfotypeLabel; ComboBox lfotypeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> lfotypeAttachment; Label lfofreqLabel; Slider lfofreqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfofreqAttachment; Label lfodepthLabel; Slider lfodepthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfodepthAttachment; ToggleButton lfoRouteFreq; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteFreqAttachment; ToggleButton lfoRouteFreqInv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteFreqInvAttachment; ToggleButton lfoRouteSharp; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteSharpAttachment; ToggleButton lfoRouteSharpInv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteSharpInvAttachment; ToggleButton lfoRouteGain; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteGainAttachment; ToggleButton lfoRouteGainInv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfoRouteGainInvAttachment; //--------------------------------------------------------------------------------- Label typeLabel; ComboBox typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> typeAttachment; Label sharpLabel; Slider sharpKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sharpAttachment; Label gainLabel; Slider gainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gainAttachment; ToggleButton stereoToggle; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> stereoToggleAttachment; MidiKeyboardComponent keyboardComponent; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_39_waveModMidiSynthAudioProcessorEditor) };
3,648
C++
.h
75
44
131
0.739474
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,694
PluginProcessor.h
belangeo_plugex/Plugex_39_WaveModMidiSynth/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "BandLimitedOsc.h" //============================================================================== struct MySynthesiserSound : public SynthesiserSound { MySynthesiserSound() {} bool appliesToNote (int) override { return true; } bool appliesToChannel (int) override { return true; } }; //============================================================================== struct MySynthesiserVoice : public SynthesiserVoice { MySynthesiserVoice(); void pitchWheelMoved (int) override {} void controllerMoved (int, int) override {} bool canPlaySound (SynthesiserSound *sound) override; void startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) override; void stopNote (float /*velocity*/, bool allowTailOff) override; void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override; void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type); void setSharpParameter(float sharp); void setStereoToggleParameter(int state); void setLFOWavetypeParameter(int type); void setLFOFreqParameter(float freq); void setLFODepthParameter(float depth); void setLFORoutingParameters(int freq, int freqInv, int sharp, int sharpInv, int gain, int gainInv); private: BandLimitedOsc lfo; BandLimitedOsc oscillatorLeft; BandLimitedOsc oscillatorRight; ADSR envelope; int stereoSwitch = 0; int freqSwitch = 0, freqSwitchInv = 0, sharpSwitch = 0, sharpSwitchInv = 0, gainSwitch = 0, gainSwitchInv = 0; double noteFreq = 0.0, noteSharp = 0.0, lfoDepth = 0.0, level = 0.0; }; //============================================================================== class MySynthesiser : public Synthesiser { public: void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type); void setSharpParameter(float sharp); void setStereoToggleParameter(int state); void setLFOWavetypeParameter(int type); void setLFOFreqParameter(float freq); void setLFODepthParameter(float depth); void setLFORoutingParameters(int freq, int freqInv, int sharp, int sharpInv, int gain, int gainInv); }; //============================================================================== class Plugex_39_waveModMidiSynthAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_39_waveModMidiSynthAudioProcessor(); ~Plugex_39_waveModMidiSynthAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; MidiKeyboardState keyboardState; private: //============================================================================== AudioProcessorValueTreeState parameters; MySynthesiser synthesiser; std::atomic<float> *attackParameter = nullptr; std::atomic<float> *decayParameter = nullptr; std::atomic<float> *sustainParameter = nullptr; std::atomic<float> *releaseParameter = nullptr; std::atomic<float> *lfotypeParameter = nullptr; std::atomic<float> *lfofreqParameter = nullptr; std::atomic<float> *lfodepthParameter = nullptr; std::atomic<float> *lfoRouteFreqParameter = nullptr; std::atomic<float> *lfoRouteFreqInvParameter = nullptr; std::atomic<float> *lfoRouteSharpParameter = nullptr; std::atomic<float> *lfoRouteSharpInvParameter = nullptr; std::atomic<float> *lfoRouteGainParameter = nullptr; std::atomic<float> *lfoRouteGainInvParameter = nullptr; std::atomic<float> *typeParameter = nullptr; std::atomic<float> *sharpParameter = nullptr; std::atomic<float> *gainParameter = nullptr; std::atomic<float> *stereoParameter = nullptr; float lastGain = 0.f; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_39_waveModMidiSynthAudioProcessor) };
5,846
C++
.h
118
44.830508
114
0.613448
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,695
PluginEditor.h
belangeo_plugex/Plugex_05_FirstOrderHP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_05_firstOrderHpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_05_firstOrderHpAudioProcessorEditor (Plugex_05_firstOrderHpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_05_firstOrderHpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: Plugex_05_firstOrderHpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_05_firstOrderHpAudioProcessorEditor) };
1,383
C++
.h
32
39.40625
123
0.65237
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,697
PluginEditor.h
belangeo_plugex/Plugex_19_SmoothDelay/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_19_smoothDelayAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_19_smoothDelayAudioProcessorEditor (Plugex_19_smoothDelayAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_19_smoothDelayAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_19_smoothDelayAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label timeLabel; Slider timeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> timeAttachment; Label feedbackLabel; Slider feedbackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> feedbackAttachment; Label balanceLabel; Slider balanceKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balanceAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_19_smoothDelayAudioProcessorEditor) };
1,867
C++
.h
43
39.418605
121
0.646667
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,698
PluginProcessor.h
belangeo_plugex/Plugex_19_SmoothDelay/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "DelayLine.h" //============================================================================== /** */ class Plugex_19_smoothDelayAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_19_smoothDelayAudioProcessor(); ~Plugex_19_smoothDelayAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; private: //============================================================================== AudioProcessorValueTreeState parameters; double currentSampleRate; int writePosition; int crossFadeTime; int waitingTime; int waitingClock; int currentDelay; float delay1Time; float delay2Time; float delay1Gain; float delay2Gain; float gain1Increment; float gain2Increment; std::atomic<float> *timeParameter = nullptr; SmoothedValue<float> timeSmoothed; std::atomic<float> *feedbackParameter = nullptr; SmoothedValue<float> feedbackSmoothed; std::atomic<float> *balanceParameter = nullptr; SmoothedValue<float> balanceSmoothed; DelayLine delayLine[2]; void computeDelayTime(float delayTime); void updateAmplitude(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_19_smoothDelayAudioProcessor) };
3,232
C++
.h
73
39.383562
87
0.559116
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,699
PluginEditor.h
belangeo_plugex/Plugex_00_TemplateFFT/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_00_templateFftAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_00_templateFftAudioProcessorEditor (Plugex_00_templateFftAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_00_templateFftAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_00_templateFftAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label description; Label orderLabel; ComboBox orderCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> orderAttachment; Label overlapsLabel; ComboBox overlapsCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> overlapsAttachment; Label wintypeLabel; ComboBox wintypeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> wintypeAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_00_templateFftAudioProcessorEditor) };
1,607
C++
.h
38
38.263158
121
0.719741
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,701
PluginEditor.h
belangeo_plugex/Plugex_23_Phaser/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_23_phaserAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_23_phaserAudioProcessorEditor (Plugex_23_phaserAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_23_phaserAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_23_phaserAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label spreadLabel; Slider spreadKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> spreadAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; Label feedbackLabel; Slider feedbackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> feedbackAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_23_phaserAudioProcessorEditor) };
1,927
C++
.h
46
38.369565
110
0.655209
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,703
PluginEditor.h
belangeo_plugex/Plugex_24_Panner/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_24_pannerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_24_pannerAudioProcessorEditor (Plugex_24_pannerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_24_pannerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_24_pannerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label panLabel; Slider panKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> panAttachment; Label typeLabel; ComboBox typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> typeAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_24_pannerAudioProcessorEditor) };
1,689
C++
.h
40
38.325
111
0.625461
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,705
PluginEditor.h
belangeo_plugex/Plugex_28_Gate/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_28_gateAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_28_gateAudioProcessorEditor (Plugex_28_gateAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_28_gateAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_28_gateAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label threshLabel; Slider threshKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> threshAttachment; Label risetimeLabel; Slider risetimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> risetimeAttachment; Label falltimeLabel; Slider falltimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> falltimeAttachment; Label lookaheadLabel; Slider lookaheadKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lookaheadAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_28_gateAudioProcessorEditor) };
1,951
C++
.h
46
38.891304
106
0.659597
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,711
PluginEditor.h
belangeo_plugex/Plugex_07_ButterworthLP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_07_butterworthLpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_07_butterworthLpAudioProcessorEditor (Plugex_07_butterworthLpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_07_butterworthLpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_07_butterworthLpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_07_butterworthLpAudioProcessorEditor) };
1,602
C++
.h
37
39.513514
125
0.621517
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,715
PluginEditor.h
belangeo_plugex/Plugex_09_ButterworthBP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_09_butterworthBpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_09_butterworthBpAudioProcessorEditor (Plugex_09_butterworthBpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_09_butterworthBpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_09_butterworthBpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_09_butterworthBpAudioProcessorEditor) };
1,721
C++
.h
40
39.125
125
0.632087
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,717
PluginEditor.h
belangeo_plugex/Plugex_18_Delay/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_18_delayAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_18_delayAudioProcessorEditor (Plugex_18_delayAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_18_delayAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_18_delayAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label timeLabel; Slider timeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> timeAttachment; Label feedbackLabel; Slider feedbackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> feedbackAttachment; Label balanceLabel; Slider balanceKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balanceAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_18_delayAudioProcessorEditor) };
1,831
C++
.h
43
38.581395
109
0.639456
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,719
PluginEditor.h
belangeo_plugex/Plugex_14_Rectifier/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_14_rectifierAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_14_rectifierAudioProcessorEditor (Plugex_14_rectifierAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_14_rectifierAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_14_rectifierAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label percentLabel; Slider percentKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> percentAttachment; Label cutoffLabel; Slider cutoffKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> cutoffAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_14_rectifierAudioProcessorEditor) };
1,721
C++
.h
40
39.125
117
0.632087
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,721
PluginEditor.h
belangeo_plugex/Plugex_03_AmplitudeLFO/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_03_amplitudeLfoAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_03_amplitudeLfoAudioProcessorEditor (Plugex_03_amplitudeLfoAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_03_amplitudeLfoAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: Plugex_03_amplitudeLfoAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label depthLabel; Slider depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> depthAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_03_amplitudeLfoAudioProcessorEditor) };
1,514
C++
.h
35
39.314286
123
0.664835
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,723
PluginEditor.h
belangeo_plugex/Plugex_41_Resampler/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_41_resamplerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_41_resamplerAudioProcessorEditor (Plugex_41_resamplerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_41_resamplerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_41_resamplerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label srscaleLabel; Slider srscaleKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> srscaleAttachment; Label bitdepthLabel; Slider bitdepthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> bitdepthAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_41_resamplerAudioProcessorEditor) };
1,727
C++
.h
40
39.275
117
0.633413
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,725
PluginEditor.h
belangeo_plugex/Plugex_22_Harmonizer/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_22_harmonizerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_22_harmonizerAudioProcessorEditor (Plugex_22_harmonizerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_22_harmonizerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_22_harmonizerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label transpoLabel; Slider transpoKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> transpoAttachment; Label feedbackLabel; Slider feedbackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> feedbackAttachment; Label winsizeLabel; Slider winsizeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> winsizeAttachment; Label balanceLabel; Slider balanceKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balanceAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_22_harmonizerAudioProcessorEditor) };
2,007
C++
.h
46
39.543478
119
0.658058
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,727
PlugexLookAndFeel.h
belangeo_plugex/common/PlugexLookAndFeel.h
/******************************************************************************* * * Plugex - PLUGin EXamples * Author: Olivier Bélanger * * Ce fichier d'en-tête est destiné à être utilisé par tous les plugiciels de * l'ensemble Plugex. Il définit le style visuel commun à tous les plugiciels. * * La méthode setTheme(String newTheme) peut être appelée pour définir la couleur * dominante du thème. Les valeurs possibles sont: blue, grey, red, green, orange * ou purple. * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" // Notre LookAndFeel hérite de la version 4 du LookAndFeel par défaut de Juce. // Cette classe n'a donc besoin de définir que les méthodes nécessaires pour // modifier l'apparence des objets graphiques utilisés par l'ensemble de plugiciels. class PlugexLookAndFeel : public LookAndFeel_V4 { public: // Le thème par defaut, définit dans le constructeur est le thème bleu. PlugexLookAndFeel() { setTheme("blue"); } // Méthode permettant de changer le thème visuel du plugiciel. Les différents thèmes // se différencient par leur couleur dominante. bool setTheme(String newTheme) { const StringArray themes = StringArray("blue", "green", "red", "orange", "purple", "grey", "steal", "lightblue", "lightgreen", "pink"); if (! themes.contains(newTheme)) { return false; } //Colour darktheme, lighttheme; Colour light = Colour(212, 211, 224); if (newTheme == "blue") { darktheme = Colour(6, 28, 64); lighttheme = Colour(113, 137, 209); } else if (newTheme == "grey") { darktheme = Colour(87, 87, 87); lighttheme = Colour(209, 209, 209); } else if (newTheme == "red") { darktheme = Colour(61, 7, 7); lighttheme = Colour(232, 70, 70); } else if (newTheme == "green") { darktheme = Colour(6, 54, 20); lighttheme = Colour(24, 191, 26); } else if (newTheme == "orange") { darktheme = Colour(56, 37, 7); lighttheme = Colour(191, 127, 23); } else if (newTheme == "purple") { darktheme = Colour(48, 6, 54); lighttheme = Colour(190, 25, 212); } else if (newTheme == "steal") { darktheme = Colour(35, 46, 54); lighttheme = Colour(118, 154, 181); } else if (newTheme == "lightblue") { darktheme = Colour(13, 69, 65); lighttheme = Colour(33, 184, 174); } else if (newTheme == "lightgreen") { darktheme = Colour(39, 56, 5); lighttheme = Colour(120, 171, 17); } else if (newTheme == "pink") { darktheme = Colour(56, 6, 40); lighttheme = Colour(184, 18, 131); } // Fenêtre principale. setColour(ResizableWindow::backgroundColourId, darktheme); // Étiquette. setColour(Label::textColourId, light); setColour(Label::textWhenEditingColourId, light); setColour(Label::outlineWhenEditingColourId, Colours::transparentBlack); setColour(Label::backgroundWhenEditingColourId, Colours::transparentBlack); // Potentiomètre. setColour(Slider::textBoxTextColourId, light); setColour(Slider::textBoxOutlineColourId, Colours::transparentBlack); setColour(Slider::textBoxHighlightColourId, lighttheme.withAlpha(0.5f)); setColour(Slider::backgroundColourId, Colours::transparentBlack); setColour(Slider::rotarySliderOutlineColourId, lighttheme); setColour(Slider::rotarySliderFillColourId, lighttheme.withAlpha(0.25f)); setColour(Slider::trackColourId, lighttheme.withAlpha(0.25f)); setColour(Slider::thumbColourId, lighttheme); // Menu déroulant. setColour(ComboBox::backgroundColourId, Colours::transparentBlack); setColour(ComboBox::textColourId, light); setColour(ComboBox::outlineColourId, lighttheme); setColour(ComboBox::buttonColourId, lighttheme); setColour(ComboBox::arrowColourId, lighttheme); setColour(ComboBox::focusedOutlineColourId, lighttheme); setColour(PopupMenu::backgroundColourId, darktheme); setColour(PopupMenu::textColourId, light); setColour(PopupMenu::highlightedBackgroundColourId, lighttheme.withAlpha(0.25f)); setColour(PopupMenu::highlightedTextColourId, light); // Boutons. setColour(TextButton::buttonColourId, darktheme); setColour(TextButton::buttonOnColourId, lighttheme.withAlpha(0.25f)); setColour(TextButton::textColourOnId, light); setColour(TextButton::textColourOffId, light); setColour(ToggleButton::textColourId, light); setColour(ToggleButton::tickColourId, lighttheme); setColour(ToggleButton::tickDisabledColourId, lighttheme.withAlpha(0.25f)); return true; } Colour getDarkTheme() { return darktheme; } Colour getLightTheme() { return lighttheme; } Colour getLightFadeTheme() { return lighttheme.withAlpha(0.25f); } // Redéfinition de la méthode pour dessiner un potentiomètre en forme de bouton rond (knob). void drawRotarySlider(Graphics& g, int x, int y, int width, int height, float sliderPos, const float rotaryStartAngle, const float rotaryEndAngle, Slider& slider) { auto bounds = Rectangle<int> ((width - height) / 2.0f, y, height, height).toFloat().reduced (10); auto radius = jmin (bounds.getWidth(), bounds.getHeight()) / 2.0f; auto toAngle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle); auto lineW = jmin (1.5f, radius * 0.5f); auto arcRadius = radius - lineW * 0.5f; Path background; background.addEllipse (bounds); g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId)); g.strokePath (background, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded)); if (slider.isEnabled()) { Path value; value.addPieSegment (bounds, rotaryStartAngle, toAngle, 0.0f); g.setColour (slider.findColour (Slider::rotarySliderFillColourId)); g.fillPath (value); } Path thumb; Point<float> thumbPoint (bounds.getCentreX() + arcRadius * std::cos (toAngle - MathConstants<float>::halfPi), bounds.getCentreY() + arcRadius * std::sin (toAngle - MathConstants<float>::halfPi)); g.setColour (slider.findColour (Slider::thumbColourId)); thumb.addLineSegment (Line<float> (bounds.getCentre(), thumbPoint), 1.5f); g.strokePath(thumb, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded)); } // Redéfinition de la méthode pour dessiner un potentiomètre linéaire (traditionnel vertical ou horizontal et // rectangulaire plein avec la valeur écrite dans le potentiomètre, vertical ou horizontal). void drawLinearSlider (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { if (slider.isBar()) { g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId)); g.drawRect(Rectangle<float>(0.f, 0.f, width, height)); if (slider.isHorizontal()) { float linePos = sliderPos < 0.0f ? 0.0f : sliderPos > width ? width : sliderPos; g.drawLine(Line<float>(linePos, y + 1.0f, linePos, height - 2.0f)); g.setColour (slider.findColour (Slider::trackColourId)); g.fillRect(Rectangle<float> (static_cast<float> (x), y + 1.0f, sliderPos - x - 1.0f, height - 2.0f)); } else { float linePos = sliderPos < 0.0f ? 0.0f : sliderPos > height ? height : sliderPos; g.drawLine(Line<float>(x = 1.0f, linePos, width - 2.0f, linePos)); g.setColour (slider.findColour (Slider::trackColourId)); g.fillRect(Rectangle<float>(x + 1.0f, sliderPos, width - 2.0f, y + (height - sliderPos - 2.0f))); } } else { auto isTwoVal = (style == Slider::SliderStyle::TwoValueVertical || style == Slider::SliderStyle::TwoValueHorizontal); auto isThreeVal = (style == Slider::SliderStyle::ThreeValueVertical || style == Slider::SliderStyle::ThreeValueHorizontal); auto trackWidth = jmin (6.0f, slider.isHorizontal() ? height * 0.25f : width * 0.25f); Point<float> startPoint (slider.isHorizontal() ? x : x + width * 0.5f, slider.isHorizontal() ? y + height * 0.5f : height + y); Point<float> endPoint (slider.isHorizontal() ? width + x : startPoint.x, slider.isHorizontal() ? startPoint.y : y); Rectangle<float> track = slider.isHorizontal() ? Rectangle<float>(x, y, width, height).withSizeKeepingCentre(width, height * 0.25f) : Rectangle<float>(x, y, width, height).withSizeKeepingCentre(jmin(6.0f, width * 0.1f), height); g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId)); g.drawRect(track); Point<float> minPoint, maxPoint, thumbPoint; if (isTwoVal || isThreeVal) { minPoint = { slider.isHorizontal() ? minSliderPos : width * 0.5f, slider.isHorizontal() ? height * 0.5f : minSliderPos }; if (isThreeVal) thumbPoint = { slider.isHorizontal() ? sliderPos : width * 0.5f, slider.isHorizontal() ? height * 0.5f : sliderPos }; maxPoint = { slider.isHorizontal() ? maxSliderPos : width * 0.5f, slider.isHorizontal() ? height * 0.5f : maxSliderPos }; } else { auto kx = slider.isHorizontal() ? sliderPos : (x + width * 0.5f); auto ky = slider.isHorizontal() ? (y + height * 0.5f) : sliderPos; minPoint = startPoint; maxPoint = { kx, ky }; } auto thumbWidth = slider.isHorizontal() ? 6.0f : width * 0.33f; auto thumbHeight = slider.isHorizontal() ? height * 0.8f : 6.0f; if (! isTwoVal) { g.setColour (slider.findColour (Slider::thumbColourId)); g.fillRect (Rectangle<float> (thumbWidth, thumbHeight).withCentre (isThreeVal ? thumbPoint : maxPoint)); } if (isTwoVal || isThreeVal) { auto sr = jmin (trackWidth, (slider.isHorizontal() ? height : width) * 0.4f); auto pointerColour = slider.findColour (Slider::thumbColourId); if (slider.isHorizontal()) { drawPointer (g, minSliderPos - sr, jmax (0.0f, y + height * 0.5f - trackWidth * 2.0f), trackWidth * 2.0f, pointerColour, 2); drawPointer (g, maxSliderPos - trackWidth, jmin (y + height - trackWidth * 2.0f, y + height * 0.5f), trackWidth * 2.0f, pointerColour, 4); } else { drawPointer (g, jmax (0.0f, x + width * 0.5f - trackWidth * 2.0f), minSliderPos - trackWidth, trackWidth * 2.0f, pointerColour, 1); drawPointer (g, jmin (x + width - trackWidth * 2.0f, x + width * 0.5f), maxSliderPos - sr, trackWidth * 2.0f, pointerColour, 3); } } } } // Redéfinition de la méthode pour dessiner un menu déroulant. void drawComboBox (Graphics& g, int width, int height, bool, int, int, int, int, ComboBox& box) { Rectangle<int> boxBounds (0, 0, width, height); g.setColour (box.findColour (ComboBox::backgroundColourId)); g.fillRect (boxBounds.toFloat()); g.setColour (box.findColour (ComboBox::outlineColourId)); g.drawRect (boxBounds.toFloat()); Rectangle<int> arrowZone (width - 30, 0, 20, height); Path path; path.startNewSubPath (arrowZone.getX() + 3.0f, arrowZone.getCentreY() - 3.0f); path.lineTo (static_cast<float> (arrowZone.getCentreX()), arrowZone.getCentreY() + 3.0f); path.lineTo (arrowZone.getRight() - 3.0f, arrowZone.getCentreY() - 3.0f); g.setColour (box.findColour (ComboBox::arrowColourId).withAlpha ((box.isEnabled() ? 0.9f : 0.2f))); g.fillPath (path); } // Redéfinition de la méthode pour dessiner les boutons. void drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) { auto bounds = button.getLocalBounds().toFloat(); auto baseColour = backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f); if (shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) baseColour = baseColour.contrasting (shouldDrawButtonAsDown ? 0.2f : 0.05f); g.setColour (baseColour); if (button.isConnectedOnLeft() || button.isConnectedOnRight()) { Path path; path.addRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); g.fillPath (path); g.setColour (button.findColour (ComboBox::outlineColourId)); g.strokePath (path, PathStrokeType (1.0f)); } else { g.fillRect (bounds); g.setColour (button.findColour (ComboBox::outlineColourId)); g.drawRect (bounds, 1.0f); } } // Redéfinition de la méthode pour dessiner le bouton à deux états. void drawToggleButton (Graphics& g, ToggleButton& button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) { auto fontSize = jmin (15.0f, button.getHeight() * 0.75f); auto tickWidth = fontSize * 1.1f; drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); g.setColour (button.findColour (ToggleButton::textColourId)); g.setFont (fontSize); if (! button.isEnabled()) g.setOpacity (0.5f); g.drawFittedText (button.getButtonText(), button.getLocalBounds().withTrimmedLeft (roundToInt (tickWidth) + 10) .withTrimmedRight (2), Justification::centredLeft, 10); } // Redéfinition de la méthode pour dessiner la case à cocher du bouton à deux états. void drawTickBox (Graphics& g, Component& component, float x, float y, float w, float h, const bool ticked, const bool isEnabled, const bool shouldDrawButtonAsHighlighted, const bool shouldDrawButtonAsDown) { ignoreUnused (shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); Rectangle<float> tickBounds (x, y, w, h); g.setColour (component.findColour (isEnabled ? ToggleButton::tickColourId : ToggleButton::tickDisabledColourId)); g.drawRect (tickBounds, 1.0f); if (ticked) { g.setColour (component.findColour (ToggleButton::tickColourId)); g.fillRect(tickBounds.reduced(4.0f, 4.0f)); } } private: Colour darktheme; Colour lighttheme; };
16,488
C++
.h
295
43.030508
155
0.595841
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,728
Biquad.h
belangeo_plugex/common/Biquad.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once class Biquad { public: Biquad(); ~Biquad(); void setup(double sampleRate); void setFreq(float freq); void setQ(float q); void setType(int type); void setParameters(float freq, float q, int type); void computeVariables(); void computeCoefficients(); float process(float input); private: double m_sampleRate; // Parameters float m_freq; float m_q; int m_type; // Variables float w0; float c; float alpha; // Coefficients float a0; float a1; float a2; float b0; float b1; float b2; // Last samples float x1; float x2; float y1; float y2; };
1,237
C++
.h
46
20.108696
80
0.509306
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,729
Granulator.h
belangeo_plugex/common/Granulator.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include <vector> #include <memory> #include <stdlib.h> #include <time.h> class Granulator { public: Granulator(); ~Granulator(); void setup(double sampleRate, double memorySize); float process(float input); void setRecordingSize(double newRecordingSize); void setRecording(bool shouldBeRecording); bool getIsRecording(); void setDensity(float newDensity); void setPitch(float newPitch); void setPosition(float newPosition); void setDuration(float newDuration); void setDeviation(float newDeviation); private: double m_sampleRate; long maxSize; long recordingSize; long recordedSize; bool initialized; const int maxNumberOfGrains = 4096; bool isRecording; long recordingIndex; // Parameters float density; float pitch; float position; float duration; float deviation; float gainFactor; double timer; double deviationFactor; double oneOverSr; float numberOfActiveGrains; std::vector<float> gpos; std::vector<float> glen; std::vector<float> ginc; std::vector<float> gphs; std::vector<int> flags; std::unique_ptr<float[]> data; };
1,788
C++
.h
56
25.089286
80
0.59883
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,730
BandLimitedOsc.h
belangeo_plugex/common/BandLimitedOsc.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once class BandLimitedOsc { public: BandLimitedOsc(); ~BandLimitedOsc(); void setup(float sampleRate); void setWavetype(int type); void setFreq(float freq); void setSharp(float sharp); void setPhase(float phase); void reset(); float process(); private: // globals float m_sampleRate; float m_oneOverSr; float m_twopi; float m_oneOverPiOverTwo; float m_srOverFour; float m_srOverEight; // parameters // 0 = Sine, 1 = Triangle, 2 = Square, 3 = Saw, // 4 = Ramp, 5 = pulse, 6 = bi-pulse, 7 = SAH int m_wavetype; float m_freq; float m_sharp; float m_pointer_pos; float m_sah_pointer_pos; float m_sah_last_value; float m_sah_current_value; // private methods float _clip(float x); };
1,350
C++
.h
43
24.744186
80
0.537394
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,731
Windowing.h
belangeo_plugex/common/Windowing.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" class Windowing { public: enum WindowType { rectangular = 1, triangular, hanning, hamming, blackman, blackmanHarris4, blackmanHarris7, flatTop, halfSine, numWindowingMethods }; Windowing(); ~Windowing(); void setup(int size, WindowType type); /** Multiplies the content of a buffer with the given window. */ void multiplyWithWindowingTable (float *samples, int size) noexcept; /** Returns the name of a given windowing method. */ static const char* getWindowingMethodName (WindowType type) noexcept; private: Array<float> windowTable; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Windowing) };
1,216
C++
.h
39
26.461538
80
0.607573
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,732
SinOsc.h
belangeo_plugex/common/SinOsc.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once class SinOsc { public: SinOsc(); ~SinOsc(); void setup(double sampleRate); void setFreq(float freq); void setPhase(float phase); float process(); private: double m_sampleRate; long m_freq; float m_phase; float m_increment; float m_runningPhase; };
787
C++
.h
26
25.192308
80
0.522606
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,733
OnePoleLowpass.h
belangeo_plugex/common/OnePoleLowpass.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once class OnePoleLowpass { public: OnePoleLowpass(); ~OnePoleLowpass(); void setup(double sampleRate); void setFreq(float freq); float process(float input); private: double m_sampleRate; float m_freq; float m_coeff; float m_y1; };
750
C++
.h
24
26.5
80
0.531381
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,734
FFTEngine.h
belangeo_plugex/common/FFTEngine.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "Windowing.h" class FFTEngine { public: FFTEngine(); ~FFTEngine(); void reset(); void setup(int order, int overlaps, int wintype); void computeFrame(int overlap); float process(float input); void setOrder(int order); void setOverlaps(int overlaps); void setWintype(int type); int getSize(); struct Listener { virtual ~Listener() {} virtual void fftEngineFrameReady(FFTEngine *engine, float *fftData, int fftSize) = 0; }; void addListener(Listener* l) { listeners.add (l); } void removeListener(Listener* l) { listeners.remove (l); } private: ListenerList<Listener> listeners; enum { fftMaxOrder = 14, fftMaxSize = 1 << fftMaxOrder, fftMaxOverlaps = 8 }; Windowing window; std::unique_ptr<dsp::FFT> forwardFFT; float fifo[fftMaxOverlaps][fftMaxSize]; float fftData[fftMaxOverlaps][2 * fftMaxSize]; int fifoIndex; int fftOrder; int fftSize; int fftOverlaps; int fftHopSize; int fftWintype; };
1,552
C++
.h
52
25.461538
93
0.621457
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,735
MultiSlider.h
belangeo_plugex/common/MultiSlider.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PlugexLookAndFeel.h" class MultiSlider : public Component { public: MultiSlider(); ~MultiSlider(); void setup(int numberOfPoints); void paint(Graphics&) override; void resized() override; void mouseDown (const MouseEvent &event) override; void mouseDrag (const MouseEvent &event) override; void setPoints(const Array<float> &points); struct Listener { virtual ~Listener() {} virtual void multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) = 0; }; void addListener(Listener* l) { listeners.add (l); } void removeListener(Listener* l) { listeners.remove (l); } private: ListenerList<Listener> listeners; Point<int> lastPosition; Array<float> bars; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiSlider) };
1,315
C++
.h
37
31.864865
98
0.644162
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,736
DelayLine.h
belangeo_plugex/common/DelayLine.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include <memory> class DelayLine { public: DelayLine(); ~DelayLine(); void setup(float maxDelayTime, double sampleRate); float read(float delayTime); void write(float input); private: double m_sampleRate; long m_maxSize; float m_writePosition; std::unique_ptr<float[]> data; };
804
C++
.h
25
27.48
80
0.545573
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,737
PluginEditor.h
belangeo_plugex/Plugex_10_ButterworthBR/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_10_butterworthBrAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_10_butterworthBrAudioProcessorEditor (Plugex_10_butterworthBrAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_10_butterworthBrAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_10_butterworthBrAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_10_butterworthBrAudioProcessorEditor) };
1,721
C++
.h
40
39.125
125
0.632087
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,739
PluginEditor.h
belangeo_plugex/Plugex_31_FFTFilter/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" #include "MultiSlider.h" class Plugex_31_fftFilterAudioProcessorEditor : public AudioProcessorEditor, public MultiSlider::Listener, public Timer { public: Plugex_31_fftFilterAudioProcessorEditor (Plugex_31_fftFilterAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_31_fftFilterAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; void timerCallback() override; void multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) override; private: Plugex_31_fftFilterAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label orderLabel; ComboBox orderCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> orderAttachment; Label overlapsLabel; ComboBox overlapsCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> overlapsAttachment; Label wintypeLabel; ComboBox wintypeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> wintypeAttachment; Label filterLabel; MultiSlider filterMultiSlider; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_31_fftFilterAudioProcessorEditor) };
1,924
C++
.h
44
37.590909
117
0.690399
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,741
PluginEditor.h
belangeo_plugex/Plugex_34_GranularStretcher/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_34_granularStretcherAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_34_granularStretcherAudioProcessorEditor (Plugex_34_granularStretcherAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_34_granularStretcherAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_34_granularStretcherAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; TextButton activeButton; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> activeAttachment; Label durationLabel; Slider durationKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> durationAttachment; Label pitchLabel; Slider pitchKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> pitchAttachment; Label speedLabel; Slider speedKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> speedAttachment; Label jitterLabel; Slider jitterKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> jitterAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_34_granularStretcherAudioProcessorEditor) };
2,150
C++
.h
48
40.645833
133
0.671965
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,743
PluginEditor.h
belangeo_plugex/Plugex_33_GranularFreeze/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_33_granularFreezeAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_33_granularFreezeAudioProcessorEditor (Plugex_33_granularFreezeAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_33_granularFreezeAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_33_granularFreezeAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; TextButton activeButton; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> activeAttachment; Label densityLabel; Slider densityKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> densityAttachment; Label pitchLabel; Slider pitchKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> pitchAttachment; Label durationLabel; Slider durationKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> durationAttachment; Label jitterLabel; Slider jitterKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> jitterAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_33_granularFreezeAudioProcessorEditor) };
2,138
C++
.h
48
40.395833
127
0.670058
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,744
PluginProcessor.h
belangeo_plugex/Plugex_33_GranularFreeze/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "Granulator.h" //============================================================================== /** */ class Plugex_33_granularFreezeAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_33_granularFreezeAudioProcessor(); ~Plugex_33_granularFreezeAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; private: //============================================================================== AudioProcessorValueTreeState parameters; Random jitterRandom; Granulator granulator[2]; float portLastSample = 0.f; bool isActive = false; std::atomic<float> *activeParameter = nullptr; std::atomic<float> *densityParameter = nullptr; SmoothedValue<float> densitySmoothed; std::atomic<float> *pitchParameter = nullptr; SmoothedValue<float> pitchSmoothed; std::atomic<float> *durationParameter = nullptr; SmoothedValue<float> durationSmoothed; std::atomic<float> *jitterParameter = nullptr; SmoothedValue<float> jitterSmoothed; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_33_granularFreezeAudioProcessor) };
3,126
C++
.h
65
43.169231
90
0.553459
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,745
PluginEditor.h
belangeo_plugex/Plugex_12_Equalizer/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_12_equalizerAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_12_equalizerAudioProcessorEditor (Plugex_12_equalizerAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_12_equalizerAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_12_equalizerAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; Label boostLabel; Slider boostKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> boostAttachment; Label typeLabel; ComboBox typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> typeAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_12_equalizerAudioProcessorEditor) };
1,960
C++
.h
46
38.521739
117
0.650079
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,747
PluginEditor.h
belangeo_plugex/Plugex_11_Biquad/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_11_biquadAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_11_biquadAudioProcessorEditor (Plugex_11_biquadAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_11_biquadAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_11_biquadAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; Label typeLabel; ComboBox typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> typeAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_11_biquadAudioProcessorEditor) };
1,811
C++
.h
43
38.116279
111
0.635894
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,749
PluginEditor.h
belangeo_plugex/Plugex_06_SecondOrderBP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_06_secondOrderBpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_06_secondOrderBpAudioProcessorEditor (Plugex_06_secondOrderBpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_06_secondOrderBpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: Plugex_06_secondOrderBpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; Label qLabel; Slider qKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> qAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_06_secondOrderBpAudioProcessorEditor) };
1,508
C++
.h
35
39.142857
125
0.663448
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,751
PluginEditor.h
belangeo_plugex/Plugex_02_AmplitudeDB/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_02_amplitudeDbAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_02_amplitudeDbAudioProcessorEditor (Plugex_02_amplitudeDbAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_02_amplitudeDbAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_02_amplitudeDbAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label gainLabel; Slider gainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gainAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_02_amplitudeDbAudioProcessorEditor) };
1,292
C++
.h
31
37.903226
121
0.695477
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,753
PluginEditor.h
belangeo_plugex/Plugex_08_ButterworthHP/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_08_butterworthHpAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_08_butterworthHpAudioProcessorEditor (Plugex_08_butterworthHpAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_08_butterworthHpAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_08_butterworthHpAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label freqLabel; Slider freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> freqAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_08_butterworthHpAudioProcessorEditor) };
1,602
C++
.h
37
39.513514
125
0.621517
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,755
PluginEditor.h
belangeo_plugex/Plugex_17_FullDistortion/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_17_fullDistortionAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_17_fullDistortionAudioProcessorEditor (Plugex_17_fullDistortionAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_17_fullDistortionAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_17_fullDistortionAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label highpassFreqLabel; Slider highpassFreqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> highpassFreqAttachment; Label highpassQLabel; Slider highpassQKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> highpassQAttachment; Label driveLabel; Slider driveKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> driveAttachment; Label lowpassFreqLabel; Slider lowpassFreqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lowpassFreqAttachment; Label lowpassQLabel; Slider lowpassQKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lowpassQAttachment; Label balanceLabel; Slider balanceKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balanceAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_17_fullDistortionAudioProcessorEditor) };
2,332
C++
.h
52
40.615385
127
0.683089
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,757
PluginEditor.h
belangeo_plugex/Plugex_16_Waveshapping/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_16_waveshappingAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_16_waveshappingAudioProcessorEditor (Plugex_16_waveshappingAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_16_waveshappingAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_16_waveshappingAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label driveLabel; Slider driveKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> driveAttachment; Label cutoffLabel; Slider cutoffKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> cutoffAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_16_waveshappingAudioProcessorEditor) };
1,733
C++
.h
40
39.425
123
0.634731
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,759
PluginEditor.h
belangeo_plugex/Plugex_35_GranularSoundcloud/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_35_granularSoundcloudAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_35_granularSoundcloudAudioProcessorEditor (Plugex_35_granularSoundcloudAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_35_granularSoundcloudAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_35_granularSoundcloudAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; TextButton activeButton; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> activeAttachment; Label densityLabel; Slider densityKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> densityAttachment; Label rndpitLabel; Slider rndpitKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> rndpitAttachment; Label rndposLabel; Slider rndposKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> rndposAttachment; Label rnddurLabel; Slider rnddurKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> rnddurAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_35_granularSoundcloudAudioProcessorEditor) };
2,159
C++
.h
48
40.833333
135
0.673381
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,761
PluginEditor.h
belangeo_plugex/Plugex_38_WaveformMidiSynth/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_38_waveformMidiSynthAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_38_waveformMidiSynthAudioProcessorEditor (Plugex_38_waveformMidiSynthAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_38_waveformMidiSynthAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_38_waveformMidiSynthAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label attackLabel; Slider attackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> attackAttachment; Label decayLabel; Slider decayKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> decayAttachment; Label sustainLabel; Slider sustainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sustainAttachment; Label releaseLabel; Slider releaseKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> releaseAttachment; Label typeLabel; ComboBox typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> typeAttachment; Label sharpLabel; Slider sharpKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sharpAttachment; Label gainLabel; Slider gainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gainAttachment; MidiKeyboardComponent keyboardComponent; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_38_waveformMidiSynthAudioProcessorEditor) };
2,175
C++
.h
50
39.14
133
0.743321
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,762
PluginProcessor.h
belangeo_plugex/Plugex_38_WaveformMidiSynth/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "BandLimitedOsc.h" //============================================================================== struct MySynthesiserSound : public SynthesiserSound { MySynthesiserSound() {} bool appliesToNote (int) override { return true; } bool appliesToChannel (int) override { return true; } }; //============================================================================== struct MySynthesiserVoice : public SynthesiserVoice { MySynthesiserVoice(); void pitchWheelMoved (int) override {} void controllerMoved (int, int) override {} bool canPlaySound (SynthesiserSound *sound) override; void startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) override; void stopNote (float /*velocity*/, bool allowTailOff) override; void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override; void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type); void setSharpParameter(float sharp); private: BandLimitedOsc oscillator; ADSR envelope; double level = 0.0; }; //============================================================================== class MySynthesiser : public Synthesiser { public: void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type); void setSharpParameter(float sharp); }; //============================================================================== class Plugex_38_waveformMidiSynthAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_38_waveformMidiSynthAudioProcessor(); ~Plugex_38_waveformMidiSynthAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; MidiKeyboardState keyboardState; private: //============================================================================== AudioProcessorValueTreeState parameters; MySynthesiser synthesiser; std::atomic<float> *attackParameter = nullptr; std::atomic<float> *decayParameter = nullptr; std::atomic<float> *sustainParameter = nullptr; std::atomic<float> *releaseParameter = nullptr; std::atomic<float> *typeParameter = nullptr; std::atomic<float> *sharpParameter = nullptr; std::atomic<float> *gainParameter = nullptr; float lastGain = 0.f; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_38_waveformMidiSynthAudioProcessor) };
4,472
C++
.h
94
42.946809
101
0.569945
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,763
PluginEditor.h
belangeo_plugex/Plugex_25_Balance/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_25_balanceAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_25_balanceAudioProcessorEditor (Plugex_25_balanceAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_25_balanceAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_25_balanceAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label balLabel; Slider balKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> balAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_25_balanceAudioProcessorEditor) };
1,265
C++
.h
31
37.032258
113
0.688119
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,765
PluginEditor.h
belangeo_plugex/Plugex_40_TwoOscMidiSynth/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" class Plugex_40_twoOscMidiSynthAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_40_twoOscMidiSynthAudioProcessorEditor (Plugex_40_twoOscMidiSynthAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_40_twoOscMidiSynthAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; private: Plugex_40_twoOscMidiSynthAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label attackLabel; Slider attackKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> attackAttachment; Label decayLabel; Slider decayKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> decayAttachment; Label sustainLabel; Slider sustainKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sustainAttachment; Label releaseLabel; Slider releaseKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> releaseAttachment; //--------------------------------------------------------------------------------- Label lfo1typeLabel; ComboBox lfo1typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> lfo1typeAttachment; Label lfo1freqLabel; Slider lfo1freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfo1freqAttachment; Label lfo1depthLabel; Slider lfo1depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfo1depthAttachment; ToggleButton lfo1RouteLfo2Freq; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteLfo2FreqAttachment; ToggleButton lfo1RouteLfo2FreqInv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteLfo2FreqInvAttachment; ToggleButton lfo1RouteLfo2Depth; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteLfo2DepthAttachment; ToggleButton lfo1RouteLfo2DepthInv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteLfo2DepthInvAttachment; ToggleButton lfo1RouteFreq1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteFreq1Attachment; ToggleButton lfo1RouteFreq1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteFreq1InvAttachment; ToggleButton lfo1RouteSharp1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteSharp1Attachment; ToggleButton lfo1RouteSharp1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteSharp1InvAttachment; ToggleButton lfo1RouteGain1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteGain1Attachment; ToggleButton lfo1RouteGain1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteGain1InvAttachment; ToggleButton lfo1RouteFreq2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteFreq2Attachment; ToggleButton lfo1RouteFreq2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteFreq2InvAttachment; ToggleButton lfo1RouteSharp2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteSharp2Attachment; ToggleButton lfo1RouteSharp2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteSharp2InvAttachment; ToggleButton lfo1RouteGain2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteGain2Attachment; ToggleButton lfo1RouteGain2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo1RouteGain2InvAttachment; //--------------------------------------------------------------------------------- Label lfo2typeLabel; ComboBox lfo2typeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> lfo2typeAttachment; Label lfo2freqLabel; Slider lfo2freqKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfo2freqAttachment; Label lfo2depthLabel; Slider lfo2depthKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lfo2depthAttachment; ToggleButton lfo2RouteFreq1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteFreq1Attachment; ToggleButton lfo2RouteFreq1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteFreq1InvAttachment; ToggleButton lfo2RouteSharp1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteSharp1Attachment; ToggleButton lfo2RouteSharp1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteSharp1InvAttachment; ToggleButton lfo2RouteGain1; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteGain1Attachment; ToggleButton lfo2RouteGain1Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteGain1InvAttachment; ToggleButton lfo2RouteFreq2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteFreq2Attachment; ToggleButton lfo2RouteFreq2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteFreq2InvAttachment; ToggleButton lfo2RouteSharp2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteSharp2Attachment; ToggleButton lfo2RouteSharp2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteSharp2InvAttachment; ToggleButton lfo2RouteGain2; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteGain2Attachment; ToggleButton lfo2RouteGain2Inv; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> lfo2RouteGain2InvAttachment; //--------------------------------------------------------------------------------- Label type1Label; ComboBox type1Combo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> type1Attachment; Label sharp1Label; Slider sharp1Knob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sharp1Attachment; Label gain1Label; Slider gain1Knob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gain1Attachment; ToggleButton stereo1Toggle; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> stereo1ToggleAttachment; //--------------------------------------------------------------------------------- Label type2Label; ComboBox type2Combo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> type2Attachment; Label sharp2Label; Slider sharp2Knob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> sharp2Attachment; Label gain2Label; Slider gain2Knob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> gain2Attachment; ToggleButton stereo2Toggle; std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> stereo2ToggleAttachment; MidiKeyboardComponent keyboardComponent; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_40_twoOscMidiSynthAudioProcessorEditor) };
7,719
C++
.h
141
49.858156
129
0.776052
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,766
PluginProcessor.h
belangeo_plugex/Plugex_40_TwoOscMidiSynth/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2020 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "BandLimitedOsc.h" //============================================================================== struct MySynthesiserSound : public SynthesiserSound { MySynthesiserSound() {} bool appliesToNote (int) override { return true; } bool appliesToChannel (int) override { return true; } }; //============================================================================== struct MySynthesiserVoice : public SynthesiserVoice { MySynthesiserVoice(); void pitchWheelMoved (int) override {} void controllerMoved (int, int) override {} bool canPlaySound (SynthesiserSound *sound) override; void startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int /*currentPitchWheelPosition*/) override; void stopNote (float /*velocity*/, bool allowTailOff) override; void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override; void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type1, int type2); void setSharpParameter(float sharp1, float sharp2); void setGainParameter(float gain1, float gain2); void setStereoToggleParameter(int state1, int state2); void setLFOWavetypeParameter(int type1, int type2); void setLFOFreqParameter(float freq1, float freq2); void setLFODepthParameter(float depth1, float depth2); void setLFO1RoutingParameters(int lfo2freq, int lfo2freqInv, int lfo2depth, int lfo2depthInv, int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv); void setLFO2RoutingParameters(int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv); private: ADSR envelope; BandLimitedOsc lfo1; BandLimitedOsc lfo2; BandLimitedOsc oscillator1Left; BandLimitedOsc oscillator1Right; BandLimitedOsc oscillator2Left; BandLimitedOsc oscillator2Right; int stereoSwitch1 = 0, stereoSwitch2 = 0; int lfo1lfo2freqSwith = 0, lfo1lfo2freqSwithInv = 0, lfo1lfo2depthSwith = 0, lfo1lfo2depthSwithInv = 0; int lfo1freqSwitch1 = 0, lfo1freqSwitch1Inv = 0, lfo1sharpSwitch1 = 0, lfo1sharpSwitch1Inv = 0, lfo1gainSwitch1 = 0, lfo1gainSwitch1Inv = 0; int lfo1freqSwitch2 = 0, lfo1freqSwitch2Inv = 0, lfo1sharpSwitch2 = 0, lfo1sharpSwitch2Inv = 0, lfo1gainSwitch2 = 0, lfo1gainSwitch2Inv = 0; int lfo2freqSwitch1 = 0, lfo2freqSwitch1Inv = 0, lfo2sharpSwitch1 = 0, lfo2sharpSwitch1Inv = 0, lfo2gainSwitch1 = 0, lfo2gainSwitch1Inv = 0; int lfo2freqSwitch2 = 0, lfo2freqSwitch2Inv = 0, lfo2sharpSwitch2 = 0, lfo2sharpSwitch2Inv = 0, lfo2gainSwitch2 = 0, lfo2gainSwitch2Inv = 0; double noteSharp1 = 0.0, noteSharp2 = 0.0, lfoDepth1 = 0.0, lfoDepth2 = 0.0, lfoFreq1 = 0.0, lfoFreq2 = 0.0; double noteFreq = 0.0, level = 0.0; SmoothedValue<float> smoothedGain1, smoothedGain2; }; //============================================================================== class MySynthesiser : public Synthesiser { public: void setEnvelopeParameters(ADSR::Parameters params); void setWavetypeParameter(int type1, int type2); void setSharpParameter(float sharp1, float sharp2); void setGainParameter(float gain1, float gain2); void setStereoToggleParameter(int state1, int state2); void setLFOWavetypeParameter(int type1, int type2); void setLFOFreqParameter(float freq1, float freq2); void setLFODepthParameter(float depth1, float depth2); void setLFO1RoutingParameters(int lfo2freq, int lfo2freqInv, int lfo2depth, int lfo2depthInv, int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv); void setLFO2RoutingParameters(int freq1, int freq1Inv, int sharp1, int sharp1Inv, int gain1, int gain1Inv, int freq2, int freq2Inv, int sharp2, int sharp2Inv, int gain2, int gain2Inv); }; //============================================================================== class Plugex_40_twoOscMidiSynthAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_40_twoOscMidiSynthAudioProcessor(); ~Plugex_40_twoOscMidiSynthAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; MidiKeyboardState keyboardState; private: //============================================================================== AudioProcessorValueTreeState parameters; MySynthesiser synthesiser; std::atomic<float> *attackParameter = nullptr; std::atomic<float> *decayParameter = nullptr; std::atomic<float> *sustainParameter = nullptr; std::atomic<float> *releaseParameter = nullptr; std::atomic<float> *lfo1typeParameter = nullptr; std::atomic<float> *lfo1freqParameter = nullptr; std::atomic<float> *lfo1depthParameter = nullptr; std::atomic<float> *lfo1RouteLfo2FreqParameter = nullptr; std::atomic<float> *lfo1RouteLfo2FreqInvParameter = nullptr; std::atomic<float> *lfo1RouteLfo2DepthParameter = nullptr; std::atomic<float> *lfo1RouteLfo2DepthInvParameter = nullptr; std::atomic<float> *lfo1RouteFreq1Parameter = nullptr; std::atomic<float> *lfo1RouteFreq1InvParameter = nullptr; std::atomic<float> *lfo1RouteSharp1Parameter = nullptr; std::atomic<float> *lfo1RouteSharp1InvParameter = nullptr; std::atomic<float> *lfo1RouteGain1Parameter = nullptr; std::atomic<float> *lfo1RouteGain1InvParameter = nullptr; std::atomic<float> *lfo1RouteFreq2Parameter = nullptr; std::atomic<float> *lfo1RouteFreq2InvParameter = nullptr; std::atomic<float> *lfo1RouteSharp2Parameter = nullptr; std::atomic<float> *lfo1RouteSharp2InvParameter = nullptr; std::atomic<float> *lfo1RouteGain2Parameter = nullptr; std::atomic<float> *lfo1RouteGain2InvParameter = nullptr; std::atomic<float> *lfo2typeParameter = nullptr; std::atomic<float> *lfo2freqParameter = nullptr; std::atomic<float> *lfo2depthParameter = nullptr; std::atomic<float> *lfo2RouteFreq1Parameter = nullptr; std::atomic<float> *lfo2RouteFreq1InvParameter = nullptr; std::atomic<float> *lfo2RouteSharp1Parameter = nullptr; std::atomic<float> *lfo2RouteSharp1InvParameter = nullptr; std::atomic<float> *lfo2RouteGain1Parameter = nullptr; std::atomic<float> *lfo2RouteGain1InvParameter = nullptr; std::atomic<float> *lfo2RouteFreq2Parameter = nullptr; std::atomic<float> *lfo2RouteFreq2InvParameter = nullptr; std::atomic<float> *lfo2RouteSharp2Parameter = nullptr; std::atomic<float> *lfo2RouteSharp2InvParameter = nullptr; std::atomic<float> *lfo2RouteGain2Parameter = nullptr; std::atomic<float> *lfo2RouteGain2InvParameter = nullptr; std::atomic<float> *type1Parameter = nullptr; std::atomic<float> *sharp1Parameter = nullptr; std::atomic<float> *gain1Parameter = nullptr; std::atomic<float> *stereo1Parameter = nullptr; std::atomic<float> *type2Parameter = nullptr; std::atomic<float> *sharp2Parameter = nullptr; std::atomic<float> *gain2Parameter = nullptr; std::atomic<float> *stereo2Parameter = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_40_twoOscMidiSynthAudioProcessor) };
9,527
C++
.h
165
51.836364
144
0.658398
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,767
PluginEditor.h
belangeo_plugex/Plugex_29_Compressor/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_29_compressorAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_29_compressorAudioProcessorEditor (Plugex_29_compressorAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_29_compressorAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_29_compressorAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label threshLabel; Slider threshKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> threshAttachment; Label ratioLabel; Slider ratioKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> ratioAttachment; Label risetimeLabel; Slider risetimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> risetimeAttachment; Label falltimeLabel; Slider falltimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> falltimeAttachment; Label lookaheadLabel; Slider lookaheadKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lookaheadAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_29_compressorAudioProcessorEditor) };
2,118
C++
.h
49
39.591837
118
0.673987
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,768
PluginProcessor.h
belangeo_plugex/Plugex_29_Compressor/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "DelayLine.h" //============================================================================== /** */ class Plugex_29_compressorAudioProcessor : public AudioProcessor { public: //============================================================================== Plugex_29_compressorAudioProcessor(); ~Plugex_29_compressorAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; private: //============================================================================== AudioProcessorValueTreeState parameters; double currentSampleRate; float follower[2]; std::atomic<float> *threshParameter = nullptr; SmoothedValue<float> threshSmoothed; std::atomic<float> *ratioParameter = nullptr; SmoothedValue<float> ratioSmoothed; std::atomic<float> *risetimeParameter = nullptr; SmoothedValue<float> risetimeSmoothed; std::atomic<float> *falltimeParameter = nullptr; SmoothedValue<float> falltimeSmoothed; std::atomic<float> *lookaheadParameter = nullptr; SmoothedValue<float> lookaheadSmoothed; DelayLine lookaheadDelay[2]; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_29_compressorAudioProcessor) };
3,128
C++
.h
65
43.230769
86
0.555041
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,769
PluginEditor.h
belangeo_plugex/Plugex_30_Expander/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" //============================================================================== /** */ class Plugex_30_expanderAudioProcessorEditor : public AudioProcessorEditor { public: Plugex_30_expanderAudioProcessorEditor (Plugex_30_expanderAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_30_expanderAudioProcessorEditor(); //============================================================================== void paint (Graphics&) override; void resized() override; private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Plugex_30_expanderAudioProcessor& processor; AudioProcessorValueTreeState& valueTreeState; PlugexLookAndFeel plugexLookAndFeel; Label title; Label downthreshLabel; Slider downthreshKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> downthreshAttachment; Label upthreshLabel; Slider upthreshKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> upthreshAttachment; Label ratioLabel; Slider ratioKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> ratioAttachment; Label risetimeLabel; Slider risetimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> risetimeAttachment; Label falltimeLabel; Slider falltimeKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> falltimeAttachment; Label lookaheadLabel; Slider lookaheadKnob; std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> lookaheadAttachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_30_expanderAudioProcessorEditor) };
2,258
C++
.h
52
39.692308
114
0.68238
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,771
PluginEditor.h
belangeo_plugex/Plugex_32_SpectralDelay/Source/PluginEditor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" #include "PlugexLookAndFeel.h" #include "MultiSlider.h" class Plugex_32_spectralDelayAudioProcessorEditor : public AudioProcessorEditor, public MultiSlider::Listener, public Timer { public: Plugex_32_spectralDelayAudioProcessorEditor (Plugex_32_spectralDelayAudioProcessor&, AudioProcessorValueTreeState& vts); ~Plugex_32_spectralDelayAudioProcessorEditor(); void paint (Graphics&) override; void resized() override; void timerCallback() override; void multiSliderChanged(MultiSlider *multiSlider, const Array<float> &value) override; private: Plugex_32_spectralDelayAudioProcessor& processor; PlugexLookAndFeel plugexLookAndFeel; AudioProcessorValueTreeState& valueTreeState; Label title; Label orderLabel; ComboBox orderCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> orderAttachment; Label overlapsLabel; ComboBox overlapsCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> overlapsAttachment; Label wintypeLabel; ComboBox wintypeCombo; std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> wintypeAttachment; Label delayLabel; MultiSlider delayMultiSlider; Label feedbackLabel; MultiSlider feedbackMultiSlider; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_32_spectralDelayAudioProcessorEditor) };
2,010
C++
.h
46
37.586957
125
0.696954
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,772
PluginProcessor.h
belangeo_plugex/Plugex_32_SpectralDelay/Source/PluginProcessor.h
/******************************************************************************* * Plugex - PLUGin EXamples * * Plugex est une série de plugiciels auto-documentés permettant une étude * autonome du développement de plugiciels avec JUCE ainsi que des bases du * traitement de signal audio avec le langage C++. * * © Olivier Bélanger 2019 * *******************************************************************************/ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "FFTEngine.h" const int multiSliderNumberOfPoints = 350; const float maxDelayTimeInSeconds = 1.0f; class Plugex_32_spectralDelayAudioProcessor : public AudioProcessor, public FFTEngine::Listener { public: //============================================================================== Plugex_32_spectralDelayAudioProcessor(); ~Plugex_32_spectralDelayAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; void fftEngineFrameReady(FFTEngine *engine, float *fftData, int fftSize) override; void computeFFTDelay(); void computeFFTFeedback(); void setDelayPoints(const Array<float> &value); void setFeedbackPoints(const Array<float> &value); bool delayPointsChanged = false; bool feedbackPointsChanged = false; Array<float> delayPoints; Array<float> feedbackPoints; private: //============================================================================== AudioProcessorValueTreeState parameters; double currentSampleRate; FFTEngine fftEngine[2]; float fftDelay[8193]; float fftFeedback[8193]; void resizeBuffers(int order, int overlaps); int frameCount[2]; int currentNumberOfFrames; Array<float> sampleBuffers[2]; int lastOrder; int lastOverlaps; int lastWintype; std::atomic<float> *orderParameter = nullptr; std::atomic<float> *overlapsParameter = nullptr; std::atomic<float> *wintypeParameter = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Plugex_32_spectralDelayAudioProcessor) };
3,517
C++
.h
75
41.333333
89
0.585689
belangeo/plugex
35
3
1
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,773
eiquadprog-basic.cpp
stack-of-tasks_eiquadprog/tests/eiquadprog-basic.cpp
// // Copyright (c) 2019 CNRS // // This file is part of eiquadprog. // // eiquadprog is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // eiquadprog is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public License // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. #include <Eigen/Core> #include <boost/test/unit_test.hpp> #include <iostream> #include "eiquadprog/eiquadprog.hpp" // The problem is in the form: // min 0.5 * x G x + g0 x // s.t. // CE^T x + ce0 = 0 // CI^T x + ci0 >= 0 // The matrix and vectors dimensions are as follows: // G: n * n // g0: n // CE: n * p // ce0: p // CI: n * m // ci0: m // x: n BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) // min ||x||^2 BOOST_AUTO_TEST_CASE(test_unbiased) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 0); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(0); size_t activeSetSize; Eigen::VectorXd solution(2); solution.setZero(); double val = 0.0; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK_CLOSE(out, val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T BOOST_AUTO_TEST_CASE(test_biased) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 0); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(0); size_t activeSetSize; Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = -1.; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK_CLOSE(out, val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[1] = 1 - x[0] BOOST_AUTO_TEST_CASE(test_equality_constraints) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 1); Aeq(0, 0) = 1.; Aeq(1, 0) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -1.; Eigen::MatrixXd Aineq(2, 0); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(1); size_t activeSetSize; Eigen::VectorXd solution(2); solution(0) = 0.5; solution(1) = 0.5; double val = 0.25; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK_CLOSE(out, val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[i] >= 1 BOOST_AUTO_TEST_CASE(test_inequality_constraints) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 1) = 1.; Eigen::VectorXd Bineq(2); Bineq(0) = -1.; Bineq(1) = -1.; Eigen::VectorXd x(2); Eigen::VectorXi activeSet(2); size_t activeSetSize; Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = 1.; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK_CLOSE(out, val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 5 - x[0] // x[1] >= 3 BOOST_AUTO_TEST_CASE(test_full) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(2, 1); Aeq(0, 0) = 1.; Aeq(1, 0) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -5.; Eigen::MatrixXd Aineq(2, 1); Aineq.setZero(); Aineq(1, 0) = 1.; Eigen::VectorXd Bineq(1); Bineq(0) = -3.; Eigen::VectorXd x(2); Eigen::VectorXi activeSet(2); size_t activeSetSize; Eigen::VectorXd solution(2); solution(0) = 2.; solution(1) = 3.; double val = 1.5; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK_CLOSE(out, val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[0] = 1 // x[0] = -1 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_unfeasible_equalities) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 2); Aeq.setZero(); Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; Eigen::VectorXd Beq(2); Beq(0) = -1.; Beq(1) = 1.; Eigen::MatrixXd Aineq(2, 0); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(2); size_t activeSetSize; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); // DOES NOT WORK!? BOOST_WARN(std::isinf(out)); } // min ||x||^2 // s.t. // x[0] >= 1 // x[0] <= -1 BOOST_AUTO_TEST_CASE(test_unfeasible_inequalities) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(0, 1) = -1.; Eigen::VectorXd Bineq(2); Bineq(0) = -1; Bineq(1) = -1; Eigen::VectorXd x(2); Eigen::VectorXi activeSet(2); size_t activeSetSize; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK(std::isinf(out)); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 1 - x[0] // x[0] <= 0 // x[1] <= 0 BOOST_AUTO_TEST_CASE(test_unfeasible_constraints) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(2, 1); Aeq(0, 0) = 1.; Aeq(1, 0) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -1.; Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = -1.; Aineq(1, 1) = -1.; Eigen::VectorXd Bineq(2); Bineq.setZero(); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(3); size_t activeSetSize; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); BOOST_CHECK(std::isinf(out)); } // min -||x||^2 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_unbounded) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 0); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXi activeSet(0); size_t activeSetSize; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); // DOES NOT WORK!? BOOST_WARN(std::isinf(out)); } // min -||x||^2 // s.t. // 0<= x[0] <= 1 // 0<= x[1] <= 1 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_nonconvex) { Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 0); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 4); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(0, 1) = -1.; Aineq(1, 2) = 1.; Aineq(1, 3) = -1.; Eigen::VectorXd Bineq(4); Bineq(0) = 0.; Bineq(1) = 1.; Bineq(2) = 0.; Bineq(3) = 1.; Eigen::VectorXd x(2); Eigen::VectorXi activeSet(4); size_t activeSetSize; Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = -1.; double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x, activeSet, activeSetSize); // DOES NOT WORK!? BOOST_WARN_CLOSE(out, val, 1e-6); BOOST_WARN(x.isApprox(solution)); } BOOST_AUTO_TEST_SUITE_END()
8,920
C++
.cpp
322
23.332298
80
0.592352
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,774
eiquadprog-rt.cpp
stack-of-tasks_eiquadprog/tests/eiquadprog-rt.cpp
// // Copyright (c) 2019 CNRS // // This file is part of eiquadprog. // // eiquadprog is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // eiquadprog is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public License // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. #include "eiquadprog/eiquadprog-rt.hpp" #include <Eigen/Core> #include <boost/test/unit_test.hpp> #include <iostream> using namespace eiquadprog::solvers; /** * solves the problem * min. 0.5 * x' Hess x + g0' x * s.t. CE x + ce0 = 0 * CI x + ci0 >= 0 */ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) // min ||x||^2 BOOST_AUTO_TEST_CASE(test_unbiased) { RtEiquadprog<2, 0, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution.setZero(); double val = 0.0; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T BOOST_AUTO_TEST_CASE(test_biased) { RtEiquadprog<2, 0, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C(0) = -1.; C(1) = -1.; RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 1.; solution(1) = 1.; double val = -1.; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[1] = 1 - x[0] BOOST_AUTO_TEST_CASE(test_equality_constraints) { RtEiquadprog<2, 1, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<1, 2>::d Aeq; Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; RtVectorX<1>::d Beq; Beq(0) = -1.; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 0.5; solution(1) = 0.5; double val = 0.25; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[i] >= 1 BOOST_AUTO_TEST_CASE(test_inequality_constraints) { RtEiquadprog<2, 0, 2> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq(0); RtMatrixX<2, 2>::d Aineq; Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 1) = 1.; RtVectorX<2>::d Bineq; Bineq(0) = -1.; Bineq(1) = -1.; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 1.; solution(1) = 1.; double val = 1.; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 5 - x[0] // x[1] >= 3 BOOST_AUTO_TEST_CASE(test_full) { RtEiquadprog<2, 1, 1> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C(0) = -1.; C(1) = -1.; RtMatrixX<1, 2>::d Aeq; Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; RtVectorX<1>::d Beq; Beq(0) = -5.; RtMatrixX<1, 2>::d Aineq; Aineq.setZero(); Aineq(0, 1) = 1.; RtVectorX<1>::d Bineq; Bineq(0) = -3.; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 2.; solution(1) = 3.; double val = 1.5; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[0] = 1 // x[0] = -1 BOOST_AUTO_TEST_CASE(test_unfeasible_equalities) { RtEiquadprog<2, 2, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<2, 2>::d Aeq; Aeq.setZero(); Aeq(0, 0) = 1.; Aeq(1, 0) = 1.; RtVectorX<2>::d Beq; Beq(0) = -1.; Beq(1) = 1.; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtEiquadprog_status expected = RT_EIQUADPROG_REDUNDANT_EQUALITIES; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); } // min ||x||^2 // s.t. // x[0] >= 1 // x[0] <= -1 // // correctly fails, but returns wrong error code BOOST_AUTO_TEST_CASE(test_unfeasible_inequalities) { RtEiquadprog<2, 0, 2> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<2, 2>::d Aineq; Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 0) = -1.; RtVectorX<2>::d Bineq; Bineq(0) = -1; Bineq(1) = -1; RtVectorX<2>::d x; RtEiquadprog_status expected = RT_EIQUADPROG_INFEASIBLE; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 1 - x[0] // x[0] <= 0 // x[1] <= 0 // // correctly fails, but returns wrong error code BOOST_AUTO_TEST_CASE(test_unfeasible_constraints) { RtEiquadprog<2, 1, 2> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C(0) = -1.; C(1) = -1.; RtMatrixX<1, 2>::d Aeq; Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; RtVectorX<1>::d Beq; Beq(0) = -1.; RtMatrixX<2, 2>::d Aineq; Aineq.setZero(); Aineq(0, 0) = -1.; Aineq(1, 1) = -1.; RtVectorX<2>::d Bineq; Bineq.setZero(); RtVectorX<2>::d x; RtEiquadprog_status expected = RT_EIQUADPROG_INFEASIBLE; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL); } // min -||x||^2 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_unbounded) { RtEiquadprog<2, 0, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtEiquadprog_status expected = RT_EIQUADPROG_UNBOUNDED; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_WARN(status != RT_EIQUADPROG_OPTIMAL); // SHOULD pass! } // min -||x||^2 // s.t. // 0<= x[0] <= 1 // 0<= x[1] <= 1 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_nonconvex) { RtEiquadprog<2, 0, 4> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<4, 2>::d Aineq(4, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 0) = -1.; Aineq(2, 1) = 1.; Aineq(3, 1) = -1.; RtVectorX<4>::d Bineq; Bineq(0) = 0.; Bineq(1) = 1.; Bineq(2) = 0.; Bineq(3) = 1.; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 1.; solution(1) = 1.; double val = -1.; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_WARN_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_WARN(x.isApprox(solution)); } BOOST_AUTO_TEST_SUITE_END()
8,736
C++
.cpp
325
23.790769
78
0.627073
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,775
TestA.cpp
stack-of-tasks_eiquadprog/tests/TestA.cpp
#include "TestA.hpp" #include <Eigen/Core> #include <iostream> using namespace eiquadprog::solvers; using namespace eiquadprog::tests; A::A() : Q_(2, 2), C_(2), Aeq_(0, 2), Beq_(0), Aineq_(0, 2), Bineq_(0), QP_() { QP_.reset(2, 0, 0); Q_.setZero(); Q_(0, 0) = 1.0; Q_(1, 1) = 1.0; C_.setZero(); expected_ = EIQUADPROG_FAST_OPTIMAL; } EiquadprogFast_status A::solve(Eigen::VectorXd &x) { return QP_.solve_quadprog(Q_, C_, Aeq_, Beq_, Aineq_, Bineq_, x); }
476
C++
.cpp
16
27.4375
79
0.622517
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,776
eiquadprog-fast.cpp
stack-of-tasks_eiquadprog/tests/eiquadprog-fast.cpp
// // Copyright (c) 2019 CNRS // // This file is part of eiquadprog. // // eiquadprog is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // eiquadprog is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public License // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. #include "eiquadprog/eiquadprog-fast.hpp" #include <Eigen/Core> #include <boost/test/unit_test.hpp> #include <iostream> using namespace eiquadprog::solvers; /** * solves the problem * min. 0.5 * x' Hess x + g0' x * s.t. CE x + ce0 = 0 * CI x + ci0 >= 0 */ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) // min ||x||^2 BOOST_AUTO_TEST_CASE(test_unbiased) { EiquadprogFast qp; qp.reset(2, 0, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution.setZero(); double val = 0.0; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T BOOST_AUTO_TEST_CASE(test_biased) { EiquadprogFast qp; qp.reset(2, 0, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = -1.; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[1] = 1 - x[0] BOOST_AUTO_TEST_CASE(test_equality_constraints) { EiquadprogFast qp; qp.reset(2, 1, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(1, 2); Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -1.; Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution(0) = 0.5; solution(1) = 0.5; double val = 0.25; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[i] >= 1 BOOST_AUTO_TEST_CASE(test_inequality_constraints) { EiquadprogFast qp; qp.reset(2, 0, 2); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 1) = 1.; Eigen::VectorXd Bineq(2); Bineq(0) = -1.; Bineq(1) = -1.; Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = 1.; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 5 - x[0] // x[1] >= 3 BOOST_AUTO_TEST_CASE(test_full) { EiquadprogFast qp; qp.reset(2, 1, 1); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(1, 2); Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -5.; Eigen::MatrixXd Aineq(1, 2); Aineq.setZero(); Aineq(0, 1) = 1.; Eigen::VectorXd Bineq(1); Bineq(0) = -3.; Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution(0) = 2.; solution(1) = 3.; double val = 1.5; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[0] = 1 // x[0] = -1 BOOST_AUTO_TEST_CASE(test_unfeasible_equalities) { EiquadprogFast qp; qp.reset(2, 2, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(2, 2); Aeq.setZero(); Aeq(0, 0) = 1.; Aeq(1, 0) = 1.; Eigen::VectorXd Beq(2); Beq(0) = -1.; Beq(1) = 1.; Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); EiquadprogFast_status expected = EIQUADPROG_FAST_REDUNDANT_EQUALITIES; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); } // min ||x||^2 // s.t. // x[0] >= 1 // x[0] <= -1 // // correctly fails, but returns wrong error code BOOST_AUTO_TEST_CASE(test_unfeasible_inequalities) { EiquadprogFast qp; qp.reset(2, 0, 2); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 0) = -1.; Eigen::VectorXd Bineq(2); Bineq(0) = -1; Bineq(1) = -1; Eigen::VectorXd x(2); EiquadprogFast_status expected = EIQUADPROG_FAST_INFEASIBLE; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_CHECK(status != EIQUADPROG_FAST_OPTIMAL); } // min ||x-x_0||^2, x_0 = (1 1)^T // s.t. // x[1] = 1 - x[0] // x[0] <= 0 // x[1] <= 0 // // correctly fails, but returns wrong error code BOOST_AUTO_TEST_CASE(test_unfeasible_constraints) { EiquadprogFast qp; qp.reset(2, 1, 2); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C(0) = -1.; C(1) = -1.; Eigen::MatrixXd Aeq(1, 2); Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; Eigen::VectorXd Beq(1); Beq(0) = -1.; Eigen::MatrixXd Aineq(2, 2); Aineq.setZero(); Aineq(0, 0) = -1.; Aineq(1, 1) = -1.; Eigen::VectorXd Bineq(2); Bineq.setZero(); Eigen::VectorXd x(2); EiquadprogFast_status expected = EIQUADPROG_FAST_INFEASIBLE; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_CHECK(status != EIQUADPROG_FAST_OPTIMAL); } // min -||x||^2 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_unbounded) { EiquadprogFast qp; qp.reset(2, 0, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); EiquadprogFast_status expected = EIQUADPROG_FAST_UNBOUNDED; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_WARN_EQUAL(status, expected); BOOST_WARN(status != EIQUADPROG_FAST_OPTIMAL); // SHOULD pass! } // min -||x||^2 // s.t. // 0<= x[0] <= 1 // 0<= x[1] <= 1 // DOES NOT WORK! BOOST_AUTO_TEST_CASE(test_nonconvex) { EiquadprogFast qp; qp.reset(2, 0, 4); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = -1.0; Q(1, 1) = -1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(4, 2); Aineq.setZero(); Aineq(0, 0) = 1.; Aineq(1, 0) = -1.; Aineq(2, 1) = 1.; Aineq(3, 1) = -1.; Eigen::VectorXd Bineq(4); Bineq(0) = 0.; Bineq(1) = 1.; Bineq(2) = 0.; Bineq(3) = 1.; Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution(0) = 1.; solution(1) = 1.; double val = -1.; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_WARN_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_WARN(x.isApprox(solution)); } BOOST_AUTO_TEST_SUITE_END()
9,163
C++
.cpp
335
24.265672
78
0.641079
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,777
eiquadprog-both.cpp
stack-of-tasks_eiquadprog/tests/eiquadprog-both.cpp
// // Copyright (c) 2020 CNRS // // This file is part of eiquadprog. // // eiquadprog is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // eiquadprog is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public License // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. #include <Eigen/Core> #include <boost/test/unit_test.hpp> #include <iostream> #include "eiquadprog/eiquadprog-fast.hpp" #include "eiquadprog/eiquadprog-rt.hpp" using namespace eiquadprog::solvers; /** * solves the problem * min. 0.5 * x' Hess x + g0' x * s.t. CE x + ce0 = 0 * CI x + ci0 >= 0 */ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) // min ||x||^2 BOOST_AUTO_TEST_CASE(test_unbiased) { EiquadprogFast qp; qp.reset(2, 0, 0); Eigen::MatrixXd Q(2, 2); Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; Eigen::VectorXd C(2); C.setZero(); Eigen::MatrixXd Aeq(0, 2); Eigen::VectorXd Beq(0); Eigen::MatrixXd Aineq(0, 2); Eigen::VectorXd Bineq(0); Eigen::VectorXd x(2); Eigen::VectorXd solution(2); solution.setZero(); double val = 0.0; EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x-x_0||^2, x_0 = (1 1)^T BOOST_AUTO_TEST_CASE(test_biased) { RtEiquadprog<2, 0, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C(0) = -1.; C(1) = -1.; RtMatrixX<0, 2>::d Aeq; RtVectorX<0>::d Beq; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 1.; solution(1) = 1.; double val = -1.; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } // min ||x||^2 // s.t. // x[1] = 1 - x[0] BOOST_AUTO_TEST_CASE(test_equality_constraints) { RtEiquadprog<2, 1, 0> qp; RtMatrixX<2, 2>::d Q; Q.setZero(); Q(0, 0) = 1.0; Q(1, 1) = 1.0; RtVectorX<2>::d C; C.setZero(); RtMatrixX<1, 2>::d Aeq; Aeq(0, 0) = 1.; Aeq(0, 1) = 1.; RtVectorX<1>::d Beq; Beq(0) = -1.; RtMatrixX<0, 2>::d Aineq; RtVectorX<0>::d Bineq; RtVectorX<2>::d x; RtVectorX<2>::d solution; solution(0) = 0.5; solution(1) = 0.5; double val = 0.25; RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL; RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x); BOOST_CHECK_EQUAL(status, expected); BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6); BOOST_CHECK(x.isApprox(solution)); } BOOST_AUTO_TEST_SUITE_END()
3,333
C++
.cpp
110
27.363636
78
0.673192
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,779
TestB.cpp
stack-of-tasks_eiquadprog/tests/TestB.cpp
#include "TestB.hpp" #include <Eigen/Core> #include <iostream> using namespace eiquadprog::solvers; namespace eiquadprog { namespace tests { B::B() : solution_(2) { solution_.setZero(); } bool B::do_something() { eiquadprog::solvers::EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL; Eigen::VectorXd x(2); eiquadprog::solvers::EiquadprogFast_status status = A_.solve(x); bool rstatus = true; if (status != expected) { std::cerr << "Status not to true for A_" << expected << " " << status << std::endl; rstatus = false; } if (!x.isApprox(solution_)) { std::cerr << "x!=solution : " << x << "!=" << solution_ << std::endl; rstatus = false; } return rstatus; } } // namespace tests } // namespace eiquadprog
773
C++
.cpp
25
27.6
80
0.653117
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,781
eiquadprog.cpp
stack-of-tasks_eiquadprog/src/eiquadprog.cpp
#include <eiquadprog/eiquadprog.hpp> namespace eiquadprog { namespace solvers { using namespace Eigen; /* solve_quadprog is used for on-demand QP solving */ double solve_quadprog(MatrixXd &G, VectorXd &g0, const MatrixXd &CE, const VectorXd &ce0, const MatrixXd &CI, const VectorXd &ci0, VectorXd &x, VectorXi &activeSet, size_t &activeSetSize) { Eigen::DenseIndex p = CE.cols(); Eigen::DenseIndex m = CI.cols(); VectorXd y(p + m); return solve_quadprog(G, g0, CE, ce0, CI, ci0, x, y, activeSet, activeSetSize); } double solve_quadprog(MatrixXd &G, VectorXd &g0, const MatrixXd &CE, const VectorXd &ce0, const MatrixXd &CI, const VectorXd &ci0, VectorXd &x, VectorXd &y, VectorXi &activeSet, size_t &activeSetSize) { LLT<MatrixXd, Lower> chol(G.cols()); double c1; /* compute the trace of the original matrix G */ c1 = G.trace(); /* decompose the matrix G in the form LL^T */ chol.compute(G); return solve_quadprog(chol, c1, g0, CE, ce0, CI, ci0, x, y, activeSet, activeSetSize); } double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0, const MatrixXd &CE, const VectorXd &ce0, const MatrixXd &CI, const VectorXd &ci0, VectorXd &x, VectorXi &activeSet, size_t &activeSetSize) { Eigen::DenseIndex p = CE.cols(); Eigen::DenseIndex m = CI.cols(); VectorXd y(p + m); return solve_quadprog(chol, c1, g0, CE, ce0, CI, ci0, x, y, activeSet, activeSetSize); } /* solve_quadprog2 is used for when the Cholesky decomposition of G is * pre-computed * @param A Output vector containing the indexes of the active constraints. * @param q Output value representing the size of the active set. */ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0, const MatrixXd &CE, const VectorXd &ce0, const MatrixXd &CI, const VectorXd &ci0, VectorXd &x, VectorXd &u, VectorXi &A, size_t &q) { size_t i, k, l; /* indices */ size_t ip, me, mi; size_t n = g0.size(); size_t p = CE.cols(); size_t m = CI.cols(); MatrixXd R(g0.size(), g0.size()), J(g0.size(), g0.size()); VectorXd s(m + p), z(n), r(m + p), d(n), np(n); VectorXd x_old(n), u_old(m + p); double f_value, psi, c2, sum, ss, R_norm; const double inf = std::numeric_limits<double>::infinity(); double t, t1, t2; /* t is the step length, which is the minimum of the partial * step length t1 and the full step length t2 */ // VectorXi A(m + p); // Del Prete: active set is now an output // parameter if (static_cast<size_t>(A.size()) != m + p) A.resize(m + p); VectorXi A_old(m + p), iai(m + p), iaexcl(m + p); // int q; size_t iq, iter = 0; me = p; /* number of equality constraints */ mi = m; /* number of inequality constraints */ q = 0; /* size of the active set A (containing the indices of the active constraints) */ /* * Preprocessing phase */ /* initialize the matrix R */ d.setZero(); R.setZero(); R_norm = 1.0; /* this variable will hold the norm of the matrix R */ /* compute the inverse of the factorized matrix G^-1, this is the initial * value for H */ // J = L^-T J.setIdentity(); chol.matrixU().solveInPlace(J); c2 = J.trace(); #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_matrix("J", J); #endif /* c1 * c2 is an estimate for cond(G) */ /* * Find the unconstrained minimizer of the quadratic form 0.5 * x G x + g0 x * this is a feasible point in the dual space * x = G^-1 * g0 */ x = -g0; chol.solveInPlace(x); /* and compute the current solution value */ f_value = 0.5 * g0.dot(x); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Unconstrained solution: " << f_value << std::endl; utils::print_vector("x", x); #endif /* Add equality constraints to the working set A */ iq = 0; for (i = 0; i < me; i++) { np = CE.col(i); compute_d(d, J, np); update_z(z, J, d, iq); update_r(R, r, d, iq); #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_matrix("R", R); utils::print_vector("z", z); utils::print_vector("r", r); utils::print_vector("d", d); #endif /* compute full step length t2: i.e., the minimum step in primal space s.t. the contraint becomes feasible */ t2 = 0.0; if (std::abs(z.dot(z)) > std::numeric_limits<double>::epsilon()) // i.e. z != 0 t2 = (-np.dot(x) - ce0(i)) / z.dot(np); x += t2 * z; /* set u = u+ */ u(iq) = t2; u.head(iq) -= t2 * r.head(iq); /* compute the new solution value */ f_value += 0.5 * (t2 * t2) * z.dot(np); A(i) = static_cast<VectorXi::Scalar>(-i - 1); if (!add_constraint(R, J, d, iq, R_norm)) { // FIXME: it should raise an error // Equality constraints are linearly dependent return f_value; } } /* set iai = K \ A */ for (i = 0; i < mi; i++) iai(i) = static_cast<VectorXi::Scalar>(i); l1: iter++; #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_vector("x", x); #endif /* step 1: choose a violated constraint */ for (i = me; i < iq; i++) { ip = A(i); iai(ip) = -1; } /* compute s(x) = ci^T * x + ci0 for all elements of K \ A */ ss = 0.0; psi = 0.0; /* this value will contain the sum of all infeasibilities */ ip = 0; /* ip will be the index of the chosen violated constraint */ for (i = 0; i < mi; i++) { iaexcl(i) = 1; sum = CI.col(i).dot(x) + ci0(i); s(i) = sum; psi += std::min(0.0, sum); } #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_vector("s", s); #endif if (std::abs(psi) <= static_cast<double>(mi) * std::numeric_limits<double>::epsilon() * c1 * c2 * 100.0) { /* numerically there are not infeasibilities anymore */ q = iq; return f_value; } /* save old values for u, x and A */ u_old.head(iq) = u.head(iq); A_old.head(iq) = A.head(iq); x_old = x; l2: /* Step 2: check for feasibility and determine a new S-pair */ for (i = 0; i < mi; i++) { if (s(i) < ss && iai(i) != -1 && iaexcl(i)) { ss = s(i); ip = i; } } if (ss >= 0.0) { q = iq; return f_value; } /* set np = n(ip) */ np = CI.col(ip); /* set u = (u 0)^T */ u(iq) = 0.0; /* add ip to the active set A */ A(iq) = static_cast<VectorXi::Scalar>(ip); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Trying with constraint " << ip << std::endl; utils::print_vector("np", np); #endif l2a: /* Step 2a: determine step direction */ /* compute z = H np: the step direction in the primal space (through J, see * the paper) */ compute_d(d, J, np); update_z(z, J, d, iq); /* compute N* np (if q > 0): the negative of the step direction in the dual * space */ update_r(R, r, d, iq); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Step direction z" << std::endl; utils::print_vector("z", z); utils::print_vector("r", r); utils::print_vector("u", u); utils::print_vector("d", d); utils::print_vector("A", A); #endif /* Step 2b: compute step length */ l = 0; /* Compute t1: partial step length (maximum step in dual space without * violating dual feasibility */ t1 = inf; /* +inf */ /* find the index l s.t. it reaches the minimum of u+(x) / r */ for (k = me; k < iq; k++) { double tmp; if (r(k) > 0.0 && ((tmp = u(k) / r(k)) < t1)) { t1 = tmp; l = A(k); } } /* Compute t2: full step length (minimum step in primal space such that the * constraint ip becomes feasible */ if (std::abs(z.dot(z)) > std::numeric_limits<double>::epsilon()) // i.e. z != 0 t2 = -s(ip) / z.dot(np); else t2 = inf; /* +inf */ /* the step is chosen as the minimum of t1 and t2 */ t = std::min(t1, t2); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Step sizes: " << t << " (t1 = " << t1 << ", t2 = " << t2 << ") "; #endif /* Step 2c: determine new S-pair and take step: */ /* case (i): no step in primal or dual space */ if (t >= inf) { /* QPP is infeasible */ // FIXME: unbounded to raise q = iq; return inf; } /* case (ii): step in dual space */ if (t2 >= inf) { /* set u = u + t * [-r 1) and drop constraint l from the active set A */ u.head(iq) -= t * r.head(iq); u(iq) += t; iai(l) = static_cast<VectorXi::Scalar>(l); delete_constraint(R, J, A, u, p, iq, l); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << " in dual space: " << f_value << std::endl; utils::print_vector("x", x); utils::print_vector("z", z); utils::print_vector("A", A); #endif goto l2a; } /* case (iii): step in primal and dual space */ x += t * z; /* update the solution value */ f_value += t * z.dot(np) * (0.5 * t + u(iq)); u.head(iq) -= t * r.head(iq); u(iq) += t; #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << " in both spaces: " << f_value << std::endl; utils::print_vector("x", x); utils::print_vector("u", u); utils::print_vector("r", r); utils::print_vector("A", A); #endif if (t == t2) { #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Full step has taken " << t << std::endl; utils::print_vector("x", x); #endif /* full step has taken */ /* add constraint ip to the active set*/ if (!add_constraint(R, J, d, iq, R_norm)) { iaexcl(ip) = 0; delete_constraint(R, J, A, u, p, iq, ip); #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_matrix("R", R); utils::print_vector("A", A); #endif for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i); for (i = 0; i < iq; i++) { A(i) = A_old(i); iai(A(i)) = -1; u(i) = u_old(i); } x = x_old; goto l2; /* go to step 2 */ } else iai(ip) = -1; #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_matrix("R", R); utils::print_vector("A", A); #endif goto l1; } /* a patial step has taken */ #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Partial step has taken " << t << std::endl; utils::print_vector("x", x); #endif /* drop constraint l */ iai(l) = static_cast<VectorXi::Scalar>(l); delete_constraint(R, J, A, u, p, iq, l); #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_matrix("R", R); utils::print_vector("A", A); #endif s(ip) = CI.col(ip).dot(x) + ci0(ip); #ifdef EIQGUADPROG_TRACE_SOLVER utils::print_vector("s", s); #endif goto l2a; } bool add_constraint(MatrixXd &R, MatrixXd &J, VectorXd &d, size_t &iq, double &R_norm) { size_t n = J.rows(); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Add constraint " << iq << '/'; #endif size_t j, k; double cc, ss, h, t1, t2, xny; /* we have to find the Givens rotation which will reduce the element d(j) to zero. if it is already zero we don't have to do anything, except of decreasing j */ for (j = n - 1; j >= iq + 1; j--) { /* The Givens rotation is done with the matrix (cc cs, cs -cc). If cc is one, then element (j) of d is zero compared with element (j - 1). Hence we don't have to do anything. If cc is zero, then we just have to switch column (j) and column (j - 1) of J. Since we only switch columns in J, we have to be careful how we update d depending on the sign of gs. Otherwise we have to apply the Givens rotation to these columns. The i - 1 element of d has to be updated to h. */ cc = d(j - 1); ss = d(j); h = utils::distance(cc, ss); if (h == 0.0) continue; d(j) = 0.0; ss = ss / h; cc = cc / h; if (cc < 0.0) { cc = -cc; ss = -ss; d(j - 1) = -h; } else d(j - 1) = h; xny = ss / (1.0 + cc); for (k = 0; k < n; k++) { t1 = J(k, j - 1); t2 = J(k, j); J(k, j - 1) = t1 * cc + t2 * ss; J(k, j) = xny * (t1 + J(k, j - 1)) - t2; } } /* update the number of constraints added*/ iq++; /* To update R we have to put the iq components of the d vector into column iq - 1 of R */ R.col(iq - 1).head(iq) = d.head(iq); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << iq << std::endl; #endif if (std::abs(d(iq - 1)) <= std::numeric_limits<double>::epsilon() * R_norm) // problem degenerate return false; R_norm = std::max<double>(R_norm, std::abs(d(iq - 1))); return true; } void delete_constraint(MatrixXd &R, MatrixXd &J, VectorXi &A, VectorXd &u, size_t p, size_t &iq, size_t l) { size_t n = R.rows(); #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << "Delete constraint " << l << ' ' << iq; #endif size_t i, j, k, qq = 0; double cc, ss, h, xny, t1, t2; /* Find the index qq for active constraint l to be removed */ for (i = p; i < iq; i++) if (static_cast<size_t>(A(i)) == l) { qq = i; break; } /* remove the constraint from the active set and the duals */ for (i = qq; i < iq - 1; i++) { A(i) = A(i + 1); u(i) = u(i + 1); R.col(i) = R.col(i + 1); } A(iq - 1) = A(iq); u(iq - 1) = u(iq); A(iq) = 0; u(iq) = 0.0; for (j = 0; j < iq; j++) R(j, iq - 1) = 0.0; /* constraint has been fully removed */ iq--; #ifdef EIQGUADPROG_TRACE_SOLVER std::cerr << '/' << iq << std::endl; #endif if (iq == 0) return; for (j = qq; j < iq; j++) { cc = R(j, j); ss = R(j + 1, j); h = utils::distance(cc, ss); if (h == 0.0) continue; cc = cc / h; ss = ss / h; R(j + 1, j) = 0.0; if (cc < 0.0) { R(j, j) = -h; cc = -cc; ss = -ss; } else R(j, j) = h; xny = ss / (1.0 + cc); for (k = j + 1; k < iq; k++) { t1 = R(j, k); t2 = R(j + 1, k); R(j, k) = t1 * cc + t2 * ss; R(j + 1, k) = xny * (t1 + R(j, k)) - t2; } for (k = 0; k < n; k++) { t1 = J(k, j); t2 = J(k, j + 1); J(k, j) = t1 * cc + t2 * ss; J(k, j + 1) = xny * (J(k, j) + t1) - t2; } } } } // namespace solvers } // namespace eiquadprog
14,155
C++
.cpp
433
27.838337
80
0.561466
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,784
eiquadprog-utils.hxx
stack-of-tasks_eiquadprog/include/eiquadprog/eiquadprog-utils.hxx
#ifndef EIQUADPROG_UTILS_HPP_ #define EIQUADPROG_UTILS_HPP_ #include <Eigen/Core> #include <iostream> namespace eiquadprog { namespace utils { /// Compute sqrt(a^2 + b^2) template <typename Scalar> inline Scalar distance(Scalar a, Scalar b) { Scalar a1, b1, t; a1 = std::abs(a); b1 = std::abs(b); if (a1 > b1) { t = (b1 / a1); return a1 * std::sqrt(1.0 + t * t); } else if (b1 > a1) { t = (a1 / b1); return b1 * std::sqrt(1.0 + t * t); } return a1 * std::sqrt(2.0); } template <class Derived> void print_vector(const char *name, Eigen::MatrixBase<Derived> &x) { std::cerr << name << x.transpose() << std::endl; } template <class Derived> void print_matrix(const char *name, Eigen::MatrixBase<Derived> &x) { std::cerr << name << std::endl << x << std::endl; } template <class Derived> void print_vector(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) { print_vector(name, x); } template <class Derived> void print_matrix(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) { print_matrix(name, x); } } // namespace utils } // namespace eiquadprog #endif
1,120
C++
.h
40
25.875
79
0.660764
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,786
eiquadprog.hpp
stack-of-tasks_eiquadprog/include/eiquadprog/eiquadprog.hpp
// // Copyright (c) 2019,2022 CNRS INRIA // // This file is part of eiquadprog. // // eiquadprog is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // eiquadprog is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public License // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. #ifndef _EIGEN_QUADSOLVE_HPP_ #define _EIGEN_QUADSOLVE_HPP_ /* FILE eiquadprog.hpp NOTE: this is a modified of uQuadProg++ package, working with Eigen data structures. uQuadProg++ is itself a port made by Angelo Furfaro of QuadProg++ originally developed by Luca Di Gaspero, working with ublas data structures. The quadprog_solve() function implements the algorithm of Goldfarb and Idnani for the solution of a (convex) Quadratic Programming problem by means of a dual method. The problem is in the form: min 0.5 * x G x + g0 x s.t. CE^T x + ce0 = 0 CI^T x + ci0 >= 0 The matrix and vectors dimensions are as follows: G: n * n g0: n CE: n * p ce0: p CI: n * m ci0: m x: n The function will return the cost of the solution written in the x vector or std::numeric_limits::infinity() if the problem is infeasible. In the latter case the value of the x vector is not correct. References: D. Goldfarb, A. Idnani. A numerically stable dual method for solving strictly convex quadratic programs. Mathematical Programming 27 (1983) pp. 1-33. Notes: 1. pay attention in setting up the vectors ce0 and ci0. If the constraints of your problem are specified in the form A^T x = b and C^T x >= d, then you should set ce0 = -b and ci0 = -d. 2. The matrix G is modified within the function since it is used to compute the G = L^T L cholesky factorization for further computations inside the function. If you need the original matrix G you should make a copy of it and pass the copy to the function. The author will be grateful if the researchers using this software will acknowledge the contribution of this modified function and of Di Gaspero's original version in their research papers. LICENSE Copyright (2011) Benjamin Stephens Copyright (2010) Gael Guennebaud Copyright (2008) Angelo Furfaro Copyright (2006) Luca Di Gaspero This file is a porting of QuadProg++ routine, originally developed by Luca Di Gaspero, exploiting uBlas data structures for vectors and matrices instead of native C++ array. uquadprog is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. uquadprog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with uquadprog; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <Eigen/Cholesky> #include <Eigen/Core> #include "eiquadprog/deprecated.hpp" #include "eiquadprog/eiquadprog-utils.hxx" // namespace internal { namespace eiquadprog { namespace solvers { inline void compute_d(Eigen::VectorXd &d, const Eigen::MatrixXd &J, const Eigen::VectorXd &np) { d.noalias() = J.adjoint() * np; } inline void update_z(Eigen::VectorXd &z, const Eigen::MatrixXd &J, const Eigen::VectorXd &d, size_t iq) { z.noalias() = J.rightCols(z.size() - iq) * d.tail(d.size() - iq); } inline void update_r(const Eigen::MatrixXd &R, Eigen::VectorXd &r, const Eigen::VectorXd &d, size_t iq) { r.head(iq) = d.head(iq); R.topLeftCorner(iq, iq).triangularView<Eigen::Upper>().solveInPlace( r.head(iq)); } bool add_constraint(Eigen::MatrixXd &R, Eigen::MatrixXd &J, Eigen::VectorXd &d, size_t &iq, double &R_norm); void delete_constraint(Eigen::MatrixXd &R, Eigen::MatrixXd &J, Eigen::VectorXi &A, Eigen::VectorXd &u, size_t p, size_t &iq, size_t l); double solve_quadprog(Eigen::LLT<Eigen::MatrixXd, Eigen::Lower> &chol, double c1, Eigen::VectorXd &g0, const Eigen::MatrixXd &CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x, Eigen::VectorXi &A, size_t &q); double solve_quadprog(Eigen::LLT<Eigen::MatrixXd, Eigen::Lower> &chol, double c1, Eigen::VectorXd &g0, const Eigen::MatrixXd &CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x, Eigen::VectorXd &y, Eigen::VectorXi &A, size_t &q); EIQUADPROG_DEPRECATED inline double solve_quadprog2(Eigen::LLT<Eigen::MatrixXd, Eigen::Lower> &chol, double c1, Eigen::VectorXd &g0, const Eigen::MatrixXd &CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x, Eigen::VectorXi &A, size_t &q) { return solve_quadprog(chol, c1, g0, CE, ce0, CI, ci0, x, A, q); } /* solve_quadprog is used for on-demand QP solving */ double solve_quadprog(Eigen::MatrixXd &G, Eigen::VectorXd &g0, const Eigen::MatrixXd &CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x, Eigen::VectorXi &activeSet, size_t &activeSetSize); double solve_quadprog(Eigen::MatrixXd &G, Eigen::VectorXd &g0, const Eigen::MatrixXd &CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x, Eigen::VectorXd &y, Eigen::VectorXi &activeSet, size_t &activeSetSize); // } } // namespace solvers } // namespace eiquadprog #endif
6,644
C++
.h
132
43.659091
80
0.680782
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,787
TestA.hpp
stack-of-tasks_eiquadprog/tests/TestA.hpp
#ifndef TEST_EIQUADPROG_CLASS_A_ #define TEST_EIQUADPROG_CLASS_A_ #include <Eigen/Core> #include <eiquadprog/eiquadprog-fast.hpp> namespace eiquadprog { namespace tests { class A { protected: eiquadprog::solvers::EiquadprogFast_status expected_; Eigen::MatrixXd Q_; Eigen::VectorXd C_; Eigen::MatrixXd Aeq_; Eigen::VectorXd Beq_; Eigen::MatrixXd Aineq_; Eigen::VectorXd Bineq_; public: eiquadprog::solvers::EiquadprogFast QP_; A(); eiquadprog::solvers::EiquadprogFast_status solve(Eigen::VectorXd &x); }; } // namespace tests } /* namespace eiquadprog */ #endif /* TEST_EIQUADPROG_CLASS_A_ */
623
C++
.h
23
24.826087
71
0.750422
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,788
TestB.hpp
stack-of-tasks_eiquadprog/tests/TestB.hpp
#ifndef TEST_EIQUADPROG_CLASS_B_ #define TEST_EIQUADPROG_CLASS_B_ #include "TestA.hpp" namespace eiquadprog { namespace tests { class B { protected: Eigen::VectorXd solution_; public: A A_; B(); bool do_something(); }; } // namespace tests } // namespace eiquadprog #endif /* TEST_EIQUADPROG_CLASS_B_ */
321
C++
.h
16
18.125
37
0.726667
stack-of-tasks/eiquadprog
34
25
4
LGPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,789
sim.cpp
ustb-owl_TinyMIPS/test/cpu/verilator/sim.cpp
#include <iostream> #include <cstring> using namespace std; // some magic #define XSTR(x) #x #define STR(x) XSTR(x) #define IDENT(x) x #define INC(x) STR(IDENT(MODULE_NAME).h) #include "verilated.h" #include INC(MODULE_NAME) namespace { bool is_interactive = false; void ParseCmdArgs(int argc, const char *argv[]) { for (int i = 0; i < argc; ++i) { if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--interactive")) { is_interactive = true; } } } } // namesapce int main(int argc, const char *argv[]) { // parse command line arguments ParseCmdArgs(argc, argv); // parse verilator command line arguments Verilated::commandArgs(argc, argv); // create new instance of module MODULE_NAME* top = new MODULE_NAME; int reset = 0; // start evaluate while (!Verilated::gotFinish()) { // check if is interactive mode if (is_interactive) cin.get(); // set reset signal top->rst_n = reset; if (!reset) reset = 1; // evaluate top->clk = 0; top->eval(); top->clk = 1; top->eval(); top->clk = 0; top->eval(); } // delete module instance delete top; return 0; }
1,177
C++
.cpp
47
21.93617
70
0.626892
ustb-owl/TinyMIPS
34
6
0
GPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,534,790
main.cpp
ustb-owl_TinyMIPS/src/compiler/main.cpp
#include <fstream> #include <iostream> #include <string> #include <cstdlib> #include "version.h" #include "front/lexer.h" #include "front/parser.h" #include "back/tac/builder.h" #include "back/tac/optimizer.h" #include "back/tac/codegen.h" #include "util/argparse.h" using namespace std; using namespace tinylang::front; using namespace tinylang::back::tac; using namespace tinylang::util; namespace { // show version info void PrintVersion() { cout << APP_NAME << " version " << APP_VERSION << endl; cout << "Compiler of the TinyLang programming language." << endl; cout << endl; cout << "Copyright (C) 2019 USTB NSCSCC team. License GPLv3."; cout << endl; } } // namespace int main(int argc, const char *argv[]) { // set up argument parser ArgParser argp; argp.AddArgument<string>("input", "input TinyLang source file"); argp.AddOption<bool>("help", "h", "show this message", false); argp.AddOption<bool>("version", "v", "show version info", false); argp.AddOption<bool>("verbose", "V", "use verbose output", false); argp.AddOption<int>("opt-level", "O", "set optimization level (0-2)", 0); argp.AddOption<bool>("dump-ast", "da", "dump AST info to output", false); argp.AddOption<bool>("dump-ir", "di", "dump IR info to output", false); argp.AddOption<string>("output", "o", "set output (default to stdout)", ""); // parse argument auto ret = argp.Parse(argc, argv); // check if need to exit program if (argp.GetValue<bool>("help")) { argp.PrintHelp(); return 0; } else if (argp.GetValue<bool>("version")) { PrintVersion(); return 0; } else if (!ret) { cerr << "invalid input, run '"; cerr << argp.program_name() << " -h' for help" << endl; return 1; } // get input & output auto input = argp.GetValue<string>("input"); auto output = argp.GetValue<string>("output"); // initialize input & output std::ifstream is(input); std::ofstream ofs(output); std::ostream *os = output.empty() ? &cout : &ofs; // initialize objects Lexer lexer(is); Parser parser(lexer); Analyzer ana; TACBuilder irb; // generate IR while (auto ast = parser.ParseNext()) { if (!ast->SemaAnalyze(ana)) break; ast->GenerateIR(irb); // dump AST if (argp.GetValue<bool>("dump-ast")) ast->Dump(*os); } // check if has error auto error_num = lexer.error_num() + parser.error_num() + ana.error_num(); if (error_num) return error_num; // check if need to exit now if (argp.GetValue<bool>("dump-ast")) return 0; // run optimization Optimizer opt; opt.set_opt_level(argp.GetValue<int>("opt-level")); if (argp.GetValue<bool>("verbose")) opt.ShowInfo(cerr); irb.RunOptimization(opt); // dump IR if (argp.GetValue<bool>("dump-ir")) { irb.Dump(*os); return 0; } // run code generation CodeGenerator gen; irb.RunCodeGeneration(gen); gen.Dump(*os); return 0; }
2,923
C++
.cpp
93
28.236559
76
0.667022
ustb-owl/TinyMIPS
34
6
0
GPL-3.0
9/20/2024, 10:44:10 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false