kopia lustrzana https://github.com/jameshball/osci-render
Add combobox on all effects for changing LFO and move lua/obj panel underneath other effects
rodzic
26535b7a69
commit
e4bc512a66
|
@ -74,10 +74,15 @@ void OscirenderAudioProcessorEditor::resized() {
|
|||
} else {
|
||||
collapseButton.setBounds(0, 0, 0, 0);
|
||||
}
|
||||
effects.setBounds(area.removeFromRight(getWidth() / sections));
|
||||
main.setBounds(area.removeFromTop(getHeight() / 2));
|
||||
lua.setBounds(area);
|
||||
obj.setBounds(area);
|
||||
auto effectsSection = area.removeFromRight(1.2 * getWidth() / sections);
|
||||
main.setBounds(area);
|
||||
if (lua.isVisible() || obj.isVisible()) {
|
||||
auto altEffectsSection = effectsSection.removeFromBottom(juce::jmin(effectsSection.getHeight() / 2, 300));
|
||||
lua.setBounds(altEffectsSection);
|
||||
obj.setBounds(altEffectsSection);
|
||||
}
|
||||
effects.setBounds(effectsSection);
|
||||
|
||||
}
|
||||
|
||||
void OscirenderAudioProcessorEditor::addCodeEditor(int index) {
|
||||
|
|
|
@ -46,26 +46,26 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
|||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<RotateEffect>(),
|
||||
new EffectParameter("2D Rotate Speed", "rotateSpeed", 0.0, 0.0, 1.0)
|
||||
new EffectParameter("2D Rotate", "rotateSpeed", 0.0, 0.0, 1.0)
|
||||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<VectorCancellingEffect>(),
|
||||
new EffectParameter("Vector Cancelling", "vectorCancelling", 0.0, 0.0, 1.0)
|
||||
new EffectParameter("Vector Cancel", "vectorCancelling", 0.0, 0.0, 1.0)
|
||||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<DistortEffect>(false),
|
||||
new EffectParameter("Horizontal Distort", "horizontalDistort", 0.0, 0.0, 1.0)
|
||||
new EffectParameter("X Distort", "horizontalDistort", 0.0, 0.0, 1.0)
|
||||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<DistortEffect>(true),
|
||||
new EffectParameter("Vertical Distort", "verticalDistort", 0.0, 0.0, 1.0)
|
||||
new EffectParameter("Y Distort", "verticalDistort", 0.0, 0.0, 1.0)
|
||||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||
input.x += values[0];
|
||||
input.y += values[1];
|
||||
return input;
|
||||
}, std::vector<EffectParameter*>{new EffectParameter("Translate x", "translateX", 0.0, -1.0, 1.0), new EffectParameter("Translate y", "translateY", 0.0, -1.0, 1.0)}
|
||||
}, std::vector<EffectParameter*>{new EffectParameter("Translate X", "translateX", 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "translateY", 0.0, -1.0, 1.0)}
|
||||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<SmoothEffect>(),
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
}
|
||||
}
|
||||
return input;
|
||||
}, new EffectParameter("Rotate x", "rotateX", 1.0, -1.0, 1.0)
|
||||
}, new EffectParameter("Rotate X", "rotateX", 1.0, -1.0, 1.0)
|
||||
);
|
||||
std::shared_ptr<Effect> rotateY = std::make_shared<Effect>(
|
||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
}
|
||||
}
|
||||
return input;
|
||||
}, new EffectParameter("Rotate y", "rotateY", 1.0, -1.0, 1.0)
|
||||
}, new EffectParameter("Rotate Y", "rotateY", 1.0, -1.0, 1.0)
|
||||
);
|
||||
std::shared_ptr<Effect> rotateZ = std::make_shared<Effect>(
|
||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
}
|
||||
}
|
||||
return input;
|
||||
}, new EffectParameter("Rotate z", "rotateZ", 0.0, -1.0, 1.0)
|
||||
}, new EffectParameter("Rotate Z", "rotateZ", 0.0, -1.0, 1.0)
|
||||
);
|
||||
std::shared_ptr<Effect> rotateSpeed = std::make_shared<Effect>(
|
||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
obj->setRotationSpeed(values[0]);
|
||||
}
|
||||
return input;
|
||||
}, new EffectParameter("Rotate speed", "rotateSpeed", 0.0, -1.0, 1.0)
|
||||
}, new EffectParameter("Rotate Speed", "rotateSpeed", 0.0, -1.0, 1.0)
|
||||
);
|
||||
|
||||
std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
#include "../shape/Vector2.h"
|
||||
#include <JuceHeader.h>
|
||||
|
||||
enum class LfoType : int {
|
||||
Static = 1,
|
||||
Sine = 2,
|
||||
Square = 3,
|
||||
Seesaw = 4,
|
||||
Triangle = 5,
|
||||
Sawtooth = 6,
|
||||
ReverseSawtooth = 7,
|
||||
Noise = 8
|
||||
};
|
||||
|
||||
class EffectParameter : public juce::AudioProcessorParameter {
|
||||
public:
|
||||
juce::String name;
|
||||
|
@ -11,6 +22,7 @@ public:
|
|||
std::atomic<float> max = 1.0;
|
||||
std::atomic<float> step = 0.001;
|
||||
std::atomic<bool> smoothValueChange = true;
|
||||
std::atomic<LfoType> lfoType = LfoType::Static;
|
||||
|
||||
EffectParameter(juce::String name, juce::String id, float value, float min, float max, float step = 0.001, bool smoothValueChange = true) : name(name), id(id), value(value), min(min), max(max), step(step), smoothValueChange(smoothValueChange) {}
|
||||
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
EffectComponent::EffectComponent(Effect& effect, int index) : effect(effect), index(index) {
|
||||
addAndMakeVisible(slider);
|
||||
addAndMakeVisible(selected);
|
||||
addAndMakeVisible(lfo);
|
||||
|
||||
lfo.addItem("Static", static_cast<int>(LfoType::Static));
|
||||
lfo.addItem("Sine", static_cast<int>(LfoType::Sine));
|
||||
lfo.addItem("Square", static_cast<int>(LfoType::Square));
|
||||
lfo.addItem("Seesaw", static_cast<int>(LfoType::Seesaw));
|
||||
lfo.addItem("Triangle", static_cast<int>(LfoType::Triangle));
|
||||
lfo.addItem("Sawtooth", static_cast<int>(LfoType::Sawtooth));
|
||||
lfo.addItem("Reverse Sawtooth", static_cast<int>(LfoType::ReverseSawtooth));
|
||||
lfo.addItem("Noise", static_cast<int>(LfoType::Noise));
|
||||
|
||||
lfo.setLookAndFeel(&lfoLookAndFeel);
|
||||
|
||||
effect.addListener(index, this);
|
||||
setupComponent();
|
||||
}
|
||||
|
@ -24,11 +37,19 @@ void EffectComponent::setupComponent() {
|
|||
slider.setValue(parameter->getValueUnnormalised(), juce::dontSendNotification);
|
||||
|
||||
slider.setSliderStyle(juce::Slider::LinearHorizontal);
|
||||
slider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 90, slider.getTextBoxHeight());
|
||||
slider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 70, slider.getTextBoxHeight());
|
||||
|
||||
bool enabled = effect.enabled == nullptr || effect.enabled->getValue();
|
||||
selected.setToggleState(enabled, juce::dontSendNotification);
|
||||
|
||||
lfo.setSelectedId(static_cast<int>(parameter->lfoType.load()), juce::dontSendNotification);
|
||||
|
||||
lfo.onChange = [this]() {
|
||||
if (lfo.getSelectedId() != 0) {
|
||||
effect.parameters[index]->lfoType = static_cast<LfoType>(lfo.getSelectedId());
|
||||
}
|
||||
};
|
||||
|
||||
min.textBox.setValue(parameter->min, juce::dontSendNotification);
|
||||
max.textBox.setValue(parameter->max, juce::dontSendNotification);
|
||||
|
||||
|
@ -64,22 +85,25 @@ EffectComponent::~EffectComponent() {
|
|||
effect.removeListener(index, this);
|
||||
}
|
||||
|
||||
void EffectComponent::resized() {
|
||||
auto sliderRight = getWidth() - 160;
|
||||
void EffectComponent::resized() {
|
||||
auto bounds = getLocalBounds();
|
||||
auto componentBounds = bounds.removeFromRight(25);
|
||||
if (component != nullptr) {
|
||||
component->setBounds(componentBounds);
|
||||
}
|
||||
|
||||
slider.setBounds(bounds.removeFromRight(sliderRight));
|
||||
lfo.setBounds(bounds.removeFromRight(100).reduced(5));
|
||||
|
||||
auto checkboxLabel = bounds.removeFromLeft(110);
|
||||
|
||||
if (checkboxVisible) {
|
||||
bounds.removeFromLeft(2);
|
||||
selected.setBounds(bounds.removeFromLeft(25));
|
||||
checkboxLabel.removeFromLeft(2);
|
||||
selected.setBounds(checkboxLabel.removeFromLeft(25));
|
||||
} else {
|
||||
bounds.removeFromLeft(5);
|
||||
checkboxLabel.removeFromLeft(5);
|
||||
}
|
||||
textBounds = bounds;
|
||||
textBounds = checkboxLabel;
|
||||
slider.setBounds(bounds);
|
||||
}
|
||||
|
||||
void EffectComponent::paint(juce::Graphics& g) {
|
||||
|
|
|
@ -4,6 +4,33 @@
|
|||
#include "../audio/Effect.h"
|
||||
#include "LabelledTextBox.h"
|
||||
|
||||
class SmallComboBoxArrow : public juce::LookAndFeel_V4 {
|
||||
void drawComboBox(juce::Graphics& g, int width, int height, bool, int, int, int, int, juce::ComboBox& box) override {
|
||||
auto cornerSize = box.findParentComponentOfClass<juce::ChoicePropertyComponent>() != nullptr ? 0.0f : 3.0f;
|
||||
juce::Rectangle<int> boxBounds{0, 0, width, height};
|
||||
|
||||
g.setColour(box.findColour(juce::ComboBox::backgroundColourId));
|
||||
g.fillRoundedRectangle(boxBounds.toFloat(), cornerSize);
|
||||
|
||||
g.setColour(box.findColour(juce::ComboBox::outlineColourId));
|
||||
g.drawRoundedRectangle(boxBounds.toFloat().reduced(0.5f, 0.5f), cornerSize, 1.0f);
|
||||
|
||||
juce::Rectangle<int> arrowZone{width - 15, 0, 10, height};
|
||||
juce::Path path;
|
||||
path.startNewSubPath((float) arrowZone.getX(), (float) arrowZone.getCentreY() - 3.0f);
|
||||
path.lineTo((float) arrowZone.getCentreX(), (float) arrowZone.getCentreY() + 4.0f);
|
||||
path.lineTo((float) arrowZone.getRight(), (float) arrowZone.getCentreY() - 3.0f);
|
||||
path.closeSubPath();
|
||||
|
||||
g.setColour(box.findColour(juce::ComboBox::arrowColourId).withAlpha((box.isEnabled() ? 0.9f : 0.2f)));
|
||||
g.fillPath(path);
|
||||
}
|
||||
|
||||
void positionComboBoxText(juce::ComboBox& box, juce::Label& label) {
|
||||
label.setBounds(1, 1, box.getWidth() - 15, box.getHeight() - 2);
|
||||
label.setFont(getComboBoxFont(box));
|
||||
}
|
||||
};
|
||||
|
||||
class EffectComponent : public juce::Component, public juce::AudioProcessorParameter::Listener, juce::AsyncUpdater {
|
||||
public:
|
||||
|
@ -27,6 +54,8 @@ public:
|
|||
Effect& effect;
|
||||
int index;
|
||||
juce::ToggleButton selected;
|
||||
SmallComboBoxArrow lfoLookAndFeel;
|
||||
juce::ComboBox lfo;
|
||||
|
||||
private:
|
||||
void setupComponent();
|
||||
|
|
|
@ -86,6 +86,6 @@ void VisualiserComponent::paintXY(juce::Graphics& g, juce::Rectangle<float> area
|
|||
double strength = 10;
|
||||
lengthScale = std::log(strength * lengthScale + 1) / std::log(strength + 1);
|
||||
g.setColour(waveformColour.withAlpha(lengthScale));
|
||||
g.drawLine(line, 1.0f);
|
||||
g.drawLine(line, 2.0f);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue