Remove secondary brightness bus and replace with third optional input

pull/263/head
James H Ball 2024-10-05 20:45:18 +01:00
rodzic 35aa8ded56
commit 558bd0011d
5 zmienionych plików z 41 dodań i 20 usunięć

Wyświetl plik

@ -32,7 +32,7 @@ public:
VisualiserComponent visualiser{audioProcessor, audioProcessor, visualiserSettings, nullptr, false, true};
std::unique_ptr<juce::FileChooser> chooser;
SosciMainMenuBarModel menuBarModel{*this};
SosciMainMenuBarModel menuBarModel{*this, audioProcessor};
juce::MenuBarComponent menuBar;
juce::TooltipWindow tooltipWindow{nullptr, 0};

Wyświetl plik

@ -13,8 +13,7 @@
//==============================================================================
SosciAudioProcessor::SosciAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties().withInput("Input", juce::AudioChannelSet::stereo(), true)
.withInput("Brightness", juce::AudioChannelSet::mono(), true)
: AudioProcessor (BusesProperties().withInput("Input", juce::AudioChannelSet::namedChannelSet(3), true)
.withOutput("Output", juce::AudioChannelSet::stereo(), true))
#endif
{
@ -121,10 +120,7 @@ void SosciAudioProcessor::releaseResources() {
}
bool SosciAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const {
auto numIns = layouts.getMainInputChannels();
auto numOuts = layouts.getMainOutputChannels();
return numIns >= 2 && numOuts >= 2;
return true;
}
// effectsLock should be held when calling this
@ -171,21 +167,30 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::M
juce::ScopedNoDenormals noDenormals;
auto input = getBusBuffer(buffer, true, 0);
auto brightness = getBusBuffer(buffer, true, 1);
float EPSILON = 0.0001f;
midiMessages.clear();
auto inputArray = input.getArrayOfWritePointers();
auto brightnessArray = brightness.getArrayOfWritePointers();
for (int sample = 0; sample < input.getNumSamples(); ++sample) {
juce::SpinLock::ScopedLockType scope(consumerLock);
float x = input.getNumChannels() > 0 ? inputArray[0][sample] : 0.0f;
float y = input.getNumChannels() > 1 ? inputArray[1][sample] : 0.0f;
float z = brightness.getNumChannels() > 0 ? brightnessArray[0][sample] : 1.0f;
float brightness = 1.0f;
if (input.getNumChannels() > 2 && !forceDisableBrightnessInput) {
float brightnessChannel = inputArray[2][sample];
// Only enable brightness if we actually receive a signal on the brightness channel
if (!brightnessEnabled && brightnessChannel > EPSILON) {
brightnessEnabled = true;
}
if (brightnessEnabled) {
brightness = brightnessChannel;
}
}
Point point = { x, y, z };
Point point = { x, y, brightness };
for (auto& effect : allEffects) {
point = effect->apply(sample, point);

Wyświetl plik

@ -58,6 +58,8 @@ public:
std::atomic<double> currentSampleRate = 0.0;
juce::SpinLock effectsLock;
VisualiserParameters parameters;
std::atomic<bool> forceDisableBrightnessInput = false;
// shouldn't be accessed by audio thread, but needs to persist when GUI is closed
// so should only be accessed by message thread
@ -66,6 +68,8 @@ public:
private:
bool brightnessEnabled = false;
std::vector<BooleanParameter*> booleanParameters;
std::vector<FloatParameter*> floatParameters;
std::vector<IntParameter*> intParameters;

Wyświetl plik

@ -1,16 +1,13 @@
#include "SosciMainMenuBarModel.h"
#include "../SosciPluginEditor.h"
#include "../SosciPluginProcessor.h"
SosciMainMenuBarModel::SosciMainMenuBarModel(SosciPluginEditor& editor) : editor(editor) {}
SosciMainMenuBarModel::SosciMainMenuBarModel(SosciPluginEditor& editor, SosciAudioProcessor& processor) : editor(editor), processor(processor) {}
SosciMainMenuBarModel::~SosciMainMenuBarModel() {}
juce::StringArray SosciMainMenuBarModel::getMenuBarNames() {
if (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
return juce::StringArray("File", "About", "Audio");
} else {
return juce::StringArray("File", "About");
}
return juce::StringArray("File", "About", "Audio");
}
juce::PopupMenu SosciMainMenuBarModel::getMenuForIndex(int topLevelMenuIndex, const juce::String& menuName) {
@ -26,7 +23,10 @@ juce::PopupMenu SosciMainMenuBarModel::getMenuForIndex(int topLevelMenuIndex, co
} else if (topLevelMenuIndex == 1) {
menu.addItem(1, "About sosci");
} else if (topLevelMenuIndex == 2) {
menu.addItem(1, "Settings");
menu.addItem(1, "Force Disable Brightness Input", true, processor.forceDisableBrightnessInput);
if (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
menu.addItem(2, "Settings...");
}
}
return menu;
@ -71,7 +71,17 @@ void SosciMainMenuBarModel::menuItemSelected(int menuItemID, int topLevelMenuInd
juce::DialogWindow* dw = options.launchAsync();
} break;
case 2:
editor.openAudioSettings();
switch (menuItemID) {
case 1:
processor.forceDisableBrightnessInput = !processor.forceDisableBrightnessInput;
menuItemsChanged();
break;
case 2:
editor.openAudioSettings();
break;
default:
break;
}
break;
default:
break;

Wyświetl plik

@ -4,9 +4,10 @@
class SosciPluginEditor;
class SosciAudioProcessor;
class SosciMainMenuBarModel : public juce::MenuBarModel {
public:
SosciMainMenuBarModel(SosciPluginEditor& editor);
SosciMainMenuBarModel(SosciPluginEditor& editor, SosciAudioProcessor& processor);
~SosciMainMenuBarModel();
juce::StringArray getMenuBarNames() override;
@ -16,4 +17,5 @@ public:
private:
SosciPluginEditor& editor;
SosciAudioProcessor& processor;
};