kopia lustrzana https://github.com/jameshball/osci-render
Remove secondary brightness bus and replace with third optional input
rodzic
35aa8ded56
commit
558bd0011d
|
@ -32,7 +32,7 @@ public:
|
||||||
VisualiserComponent visualiser{audioProcessor, audioProcessor, visualiserSettings, nullptr, false, true};
|
VisualiserComponent visualiser{audioProcessor, audioProcessor, visualiserSettings, nullptr, false, true};
|
||||||
|
|
||||||
std::unique_ptr<juce::FileChooser> chooser;
|
std::unique_ptr<juce::FileChooser> chooser;
|
||||||
SosciMainMenuBarModel menuBarModel{*this};
|
SosciMainMenuBarModel menuBarModel{*this, audioProcessor};
|
||||||
juce::MenuBarComponent menuBar;
|
juce::MenuBarComponent menuBar;
|
||||||
|
|
||||||
juce::TooltipWindow tooltipWindow{nullptr, 0};
|
juce::TooltipWindow tooltipWindow{nullptr, 0};
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
SosciAudioProcessor::SosciAudioProcessor()
|
SosciAudioProcessor::SosciAudioProcessor()
|
||||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||||
: AudioProcessor (BusesProperties().withInput("Input", juce::AudioChannelSet::stereo(), true)
|
: AudioProcessor (BusesProperties().withInput("Input", juce::AudioChannelSet::namedChannelSet(3), true)
|
||||||
.withInput("Brightness", juce::AudioChannelSet::mono(), true)
|
|
||||||
.withOutput("Output", juce::AudioChannelSet::stereo(), true))
|
.withOutput("Output", juce::AudioChannelSet::stereo(), true))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -121,10 +120,7 @@ void SosciAudioProcessor::releaseResources() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SosciAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const {
|
bool SosciAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const {
|
||||||
auto numIns = layouts.getMainInputChannels();
|
return true;
|
||||||
auto numOuts = layouts.getMainOutputChannels();
|
|
||||||
|
|
||||||
return numIns >= 2 && numOuts >= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// effectsLock should be held when calling this
|
// effectsLock should be held when calling this
|
||||||
|
@ -171,21 +167,30 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::M
|
||||||
juce::ScopedNoDenormals noDenormals;
|
juce::ScopedNoDenormals noDenormals;
|
||||||
|
|
||||||
auto input = getBusBuffer(buffer, true, 0);
|
auto input = getBusBuffer(buffer, true, 0);
|
||||||
auto brightness = getBusBuffer(buffer, true, 1);
|
float EPSILON = 0.0001f;
|
||||||
|
|
||||||
midiMessages.clear();
|
midiMessages.clear();
|
||||||
|
|
||||||
auto inputArray = input.getArrayOfWritePointers();
|
auto inputArray = input.getArrayOfWritePointers();
|
||||||
auto brightnessArray = brightness.getArrayOfWritePointers();
|
|
||||||
|
|
||||||
for (int sample = 0; sample < input.getNumSamples(); ++sample) {
|
for (int sample = 0; sample < input.getNumSamples(); ++sample) {
|
||||||
juce::SpinLock::ScopedLockType scope(consumerLock);
|
juce::SpinLock::ScopedLockType scope(consumerLock);
|
||||||
|
|
||||||
float x = input.getNumChannels() > 0 ? inputArray[0][sample] : 0.0f;
|
float x = input.getNumChannels() > 0 ? inputArray[0][sample] : 0.0f;
|
||||||
float y = input.getNumChannels() > 1 ? inputArray[1][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) {
|
for (auto& effect : allEffects) {
|
||||||
point = effect->apply(sample, point);
|
point = effect->apply(sample, point);
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
juce::SpinLock effectsLock;
|
juce::SpinLock effectsLock;
|
||||||
VisualiserParameters parameters;
|
VisualiserParameters parameters;
|
||||||
|
|
||||||
|
std::atomic<bool> forceDisableBrightnessInput = false;
|
||||||
|
|
||||||
// shouldn't be accessed by audio thread, but needs to persist when GUI is closed
|
// shouldn't be accessed by audio thread, but needs to persist when GUI is closed
|
||||||
// so should only be accessed by message thread
|
// so should only be accessed by message thread
|
||||||
juce::String currentProjectFile;
|
juce::String currentProjectFile;
|
||||||
|
@ -66,6 +68,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool brightnessEnabled = false;
|
||||||
|
|
||||||
std::vector<BooleanParameter*> booleanParameters;
|
std::vector<BooleanParameter*> booleanParameters;
|
||||||
std::vector<FloatParameter*> floatParameters;
|
std::vector<FloatParameter*> floatParameters;
|
||||||
std::vector<IntParameter*> intParameters;
|
std::vector<IntParameter*> intParameters;
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
#include "SosciMainMenuBarModel.h"
|
#include "SosciMainMenuBarModel.h"
|
||||||
#include "../SosciPluginEditor.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() {}
|
SosciMainMenuBarModel::~SosciMainMenuBarModel() {}
|
||||||
|
|
||||||
juce::StringArray SosciMainMenuBarModel::getMenuBarNames() {
|
juce::StringArray SosciMainMenuBarModel::getMenuBarNames() {
|
||||||
if (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
|
|
||||||
return juce::StringArray("File", "About", "Audio");
|
return juce::StringArray("File", "About", "Audio");
|
||||||
} else {
|
|
||||||
return juce::StringArray("File", "About");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
juce::PopupMenu SosciMainMenuBarModel::getMenuForIndex(int topLevelMenuIndex, const juce::String& menuName) {
|
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) {
|
} else if (topLevelMenuIndex == 1) {
|
||||||
menu.addItem(1, "About sosci");
|
menu.addItem(1, "About sosci");
|
||||||
} else if (topLevelMenuIndex == 2) {
|
} 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;
|
return menu;
|
||||||
|
@ -70,12 +70,22 @@ void SosciMainMenuBarModel::menuItemSelected(int menuItemID, int topLevelMenuInd
|
||||||
|
|
||||||
juce::DialogWindow* dw = options.launchAsync();
|
juce::DialogWindow* dw = options.launchAsync();
|
||||||
} break;
|
} break;
|
||||||
|
case 2:
|
||||||
|
switch (menuItemID) {
|
||||||
|
case 1:
|
||||||
|
processor.forceDisableBrightnessInput = !processor.forceDisableBrightnessInput;
|
||||||
|
menuItemsChanged();
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
editor.openAudioSettings();
|
editor.openAudioSettings();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
|
|
||||||
class SosciPluginEditor;
|
class SosciPluginEditor;
|
||||||
|
class SosciAudioProcessor;
|
||||||
class SosciMainMenuBarModel : public juce::MenuBarModel {
|
class SosciMainMenuBarModel : public juce::MenuBarModel {
|
||||||
public:
|
public:
|
||||||
SosciMainMenuBarModel(SosciPluginEditor& editor);
|
SosciMainMenuBarModel(SosciPluginEditor& editor, SosciAudioProcessor& processor);
|
||||||
~SosciMainMenuBarModel();
|
~SosciMainMenuBarModel();
|
||||||
|
|
||||||
juce::StringArray getMenuBarNames() override;
|
juce::StringArray getMenuBarNames() override;
|
||||||
|
@ -16,4 +17,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SosciPluginEditor& editor;
|
SosciPluginEditor& editor;
|
||||||
|
SosciAudioProcessor& processor;
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue