Move Lua component under the code editor, remove z pos and rotate speed parameters

pull/218/head
James Ball 2024-02-12 22:33:06 +00:00
rodzic 7a74976341
commit 690ea8bd43
15 zmienionych plików z 104 dodań i 198 usunięć

Wyświetl plik

@ -7,11 +7,9 @@ PerspectiveComponent::PerspectiveComponent(OscirenderAudioProcessor& p, Oscirend
addAndMakeVisible(perspective);
addAndMakeVisible(focalLength);
addAndMakeVisible(distance);
perspective.setSliderOnValueChange();
focalLength.setSliderOnValueChange();
distance.setSliderOnValueChange();
}
PerspectiveComponent::~PerspectiveComponent() {}
@ -21,5 +19,4 @@ void PerspectiveComponent::resized() {
double rowHeight = 30;
perspective.setBounds(area.removeFromTop(rowHeight));
focalLength.setBounds(area.removeFromTop(rowHeight));
distance.setBounds(area.removeFromTop(rowHeight));
}

Wyświetl plik

@ -18,7 +18,6 @@ private:
EffectComponent perspective{audioProcessor, *audioProcessor.perspective, 0};
EffectComponent focalLength{audioProcessor, *audioProcessor.perspective, 1};
EffectComponent distance{audioProcessor, *audioProcessor.perspective, 2};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PerspectiveComponent)
};

Wyświetl plik

@ -80,12 +80,19 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
setResizeLimits(500, 400, 999999, 999999);
layout.setItemLayout(0, -0.3, -1.0, -0.7);
layout.setItemLayout(1, 7, 7, 7);
layout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
layout.setItemLayout(2, -0.1, -1.0, -0.3);
addAndMakeVisible(settings);
addAndMakeVisible(resizerBar);
luaLayout.setItemLayout(0, -0.3, -1.0, -0.7);
luaLayout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
luaLayout.setItemLayout(2, -0.1, -1.0, -0.3);
addAndMakeVisible(lua);
addAndMakeVisible(luaResizerBar);
if (visualiserFullScreen) {
addAndMakeVisible(visualiser);
}
@ -134,6 +141,10 @@ void OscirenderAudioProcessorEditor::paint(juce::Graphics& g) {
if ((originalIndex != -1 || editingCustomFunction) && index < codeEditors.size() && codeEditors[index]->isVisible()) {
auto ds = juce::DropShadow(juce::Colours::black, 5, juce::Point<int>(0, 0));
ds.drawForRectangle(g, codeEditors[index]->getBounds());
if (editingCustomFunction || audioProcessor.getFileName(originalIndex).fromLastOccurrenceOf(".", true, false) == ".lua") {
ds.drawForRectangle(g, lua.getBounds());
}
}
}
@ -156,8 +167,6 @@ void OscirenderAudioProcessorEditor::resized() {
area.removeFromLeft(3);
bool editorVisible = false;
juce::Component dummy;
{
juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock);
@ -167,23 +176,47 @@ void OscirenderAudioProcessorEditor::resized() {
if (codeEditors[index]->isVisible()) {
editorVisible = true;
juce::Component* columns[] = { &dummy, &resizerBar, codeEditors[index].get() };
juce::Component dummy;
juce::Component dummy2;
juce::Component* columns[] = { &dummy, &resizerBar, &dummy2 };
// offsetting the y position by -1 and the height by +1 is a hack to fix a bug where the code editor
// doesn't draw up to the edges of the menu bar above.
layout.layOutComponents(columns, 3, area.getX(), area.getY() - 1, area.getWidth(), area.getHeight() + 1, false, true);
auto dummyBounds = dummy.getBounds();
collapseButton.setBounds(dummyBounds.removeFromRight(20));
area = dummyBounds;
auto dummy2Bounds = dummy2.getBounds();
dummy2Bounds.removeFromBottom(5);
dummy2Bounds.removeFromTop(5);
dummy2Bounds.removeFromRight(5);
juce::String extension;
if (originalIndex >= 0) {
extension = audioProcessor.getFileName(originalIndex).fromLastOccurrenceOf(".", true, false);
}
if (editingCustomFunction || extension == ".lua") {
juce::Component* rows[] = { codeEditors[index].get(), &luaResizerBar, &lua };
luaLayout.layOutComponents(rows, 3, dummy2Bounds.getX(), dummy2Bounds.getY(), dummy2Bounds.getWidth(), dummy2Bounds.getHeight(), true, true);
} else {
codeEditors[index]->setBounds(dummy2Bounds);
luaResizerBar.setBounds(0, 0, 0, 0);
lua.setBounds(0, 0, 0, 0);
}
} else {
codeEditors[index]->setBounds(0, 0, 0, 0);
resizerBar.setBounds(0, 0, 0, 0);
luaResizerBar.setBounds(0, 0, 0, 0);
lua.setBounds(0, 0, 0, 0);
collapseButton.setBounds(area.removeFromRight(20));
}
} else {
collapseButton.setBounds(0, 0, 0, 0);
luaResizerBar.setBounds(0, 0, 0, 0);
lua.setBounds(0, 0, 0, 0);
}
}
@ -298,6 +331,25 @@ void OscirenderAudioProcessorEditor::changeListenerCallback(juce::ChangeBroadcas
}
}
void OscirenderAudioProcessorEditor::toggleLayout(juce::StretchableLayoutManager& layout, double prefSize) {
double minSize, maxSize, preferredSize;
double otherMinSize, otherMaxSize, otherPreferredSize;
layout.getItemLayout(2, minSize, maxSize, preferredSize);
layout.getItemLayout(0, otherMinSize, otherMaxSize, otherPreferredSize);
if (preferredSize == CLOSED_PREF_SIZE) {
double otherPrefSize = -(1 + prefSize);
if (prefSize > 0) {
otherPrefSize = -1.0;
}
layout.setItemLayout(2, CLOSED_PREF_SIZE, maxSize, prefSize);
layout.setItemLayout(0, CLOSED_PREF_SIZE, otherMaxSize, otherPrefSize);
} else {
layout.setItemLayout(2, CLOSED_PREF_SIZE, maxSize, CLOSED_PREF_SIZE);
layout.setItemLayout(0, CLOSED_PREF_SIZE, otherMaxSize, -1.0);
}
}
void OscirenderAudioProcessorEditor::editCustomFunction(bool enable) {
editingCustomFunction = enable;
juce::SpinLock::ScopedLockType lock1(audioProcessor.parsersLock);

Wyświetl plik

@ -24,6 +24,7 @@ public:
void fileUpdated(juce::String fileName);
void handleAsyncUpdate() override;
void changeListenerCallback(juce::ChangeBroadcaster* source) override;
void toggleLayout(juce::StretchableLayoutManager& layout, double prefSize);
void editCustomFunction(bool enabled);
@ -39,6 +40,9 @@ private:
OscirenderAudioProcessor& audioProcessor;
public:
const double CLOSED_PREF_SIZE = 30.0;
const double RESIZER_BAR_SIZE = 7.0;
OscirenderLookAndFeel lookAndFeel;
std::atomic<bool> editingCustomFunction = false;
@ -46,6 +50,7 @@ public:
VisualiserComponent visualiser{2, audioProcessor};
std::atomic<bool> visualiserFullScreen = false;
SettingsComponent settings{audioProcessor, *this};
LuaComponent lua{audioProcessor, *this};
VolumeComponent volume{audioProcessor};
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
@ -64,6 +69,9 @@ public:
juce::StretchableLayoutManager layout;
juce::StretchableLayoutResizerBar resizerBar{&layout, 1, true};
juce::StretchableLayoutManager luaLayout;
juce::StretchableLayoutResizerBar luaResizerBar{&luaLayout, 1, false};
juce::TooltipWindow tooltipWindow{this, 0};
std::atomic<bool> updatingDocumentsWithParserLock = false;

Wyświetl plik

@ -53,7 +53,16 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
std::make_shared<DistortEffect>(true),
new EffectParameter("Distort Y", "Distorts the image in the vertical direction by jittering the audio sample being drawn.", "distortY", VERSION_HINT, 0.0, 0.0, 1.0)
));
toggleableEffects.push_back(rotate);
toggleableEffects.push_back(std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
input.rotate(values[0] * std::numbers::pi, values[1] * std::numbers::pi, values[2] * std::numbers::pi);
return input;
}, std::vector<EffectParameter*>{
new EffectParameter("Rotate X", "Controls the rotation of the object in the X axis.", "rotateX", VERSION_HINT, 0.0, -1.0, 1.0),
new EffectParameter("Rotate Y", "Controls the rotation of the object in the Y axis.", "rotateY", VERSION_HINT, 0.0, -1.0, 1.0),
new EffectParameter("Rotate Z", "Controls the rotation of the object in the Z axis.", "rotateZ", VERSION_HINT, 0.0, -1.0, 1.0),
}
));
toggleableEffects.push_back(std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
input.x += values[0];
@ -122,9 +131,6 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
}
}
booleanParameters.push_back(rotateEffect->fixedRotateX);
booleanParameters.push_back(rotateEffect->fixedRotateY);
booleanParameters.push_back(rotateEffect->fixedRotateZ);
booleanParameters.push_back(midiEnabled);
booleanParameters.push_back(inputEnabled);

Wyświetl plik

@ -25,7 +25,6 @@
#include "UGen/Env.h"
#include "UGen/ugen_JuceEnvelopeComponent.h"
#include "audio/CustomEffect.h"
#include "audio/RotateEffect.h"
//==============================================================================
/**
@ -149,20 +148,8 @@ public:
std::vector<EffectParameter*>{
new EffectParameter("3D Perspective", "Controls the strength of the 3D perspective projection.", "perspectiveStrength", VERSION_HINT, 1.0, 0.0, 1.0),
new EffectParameter("Focal Length", "Controls the focal length of the 3D perspective effect. A higher focal length makes the image look more flat, and a lower focal length makes the image look more 3D.", "perspectiveFocalLength", VERSION_HINT, 2.0, 0.0, 10.0),
new EffectParameter("Distance (z)", "Controls how far away the 3D object is drawn away from the camera (the Z position).", "perspectiveZPos", VERSION_HINT, 0.0, -10.0, 10.0),
}
);
std::shared_ptr<RotateEffect> rotateEffect = std::make_shared<RotateEffect>(VERSION_HINT);
std::shared_ptr<Effect> rotate = std::make_shared<Effect>(
rotateEffect,
std::vector<EffectParameter*>{
new EffectParameter("Rotate Speed", "Controls how fast the 3D object rotates in the direction determined by the rotation sliders below.", "rotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0),
new EffectParameter("Rotate X", "Controls the rotation of the object in the X axis.", "rotateX", VERSION_HINT, 1.0, -1.0, 1.0),
new EffectParameter("Rotate Y", "Controls the rotation of the object in the Y axis.", "rotateY", VERSION_HINT, 1.0, -1.0, 1.0),
new EffectParameter("Rotate Z", "Controls the rotation of the object in the Z axis.", "rotateZ", VERSION_HINT, 1.0, -1.0, 1.0),
}
);
BooleanParameter* midiEnabled = new BooleanParameter("MIDI Enabled", "midiEnabled", VERSION_HINT, false);
BooleanParameter* inputEnabled = new BooleanParameter("Audio Input Enabled", "inputEnabled", VERSION_HINT, false);

Wyświetl plik

@ -7,27 +7,16 @@ SettingsComponent::SettingsComponent(OscirenderAudioProcessor& p, OscirenderAudi
addAndMakeVisible(perspective);
addAndMakeVisible(midiResizerBar);
addAndMakeVisible(mainResizerBar);
addAndMakeVisible(mainPerspectiveResizerBar);
addAndMakeVisible(effectResizerBar);
addAndMakeVisible(midi);
addChildComponent(lua);
addChildComponent(txt);
midiLayout.setItemLayout(0, -0.1, -1.0, -1.0);
midiLayout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
midiLayout.setItemLayout(2, CLOSED_PREF_SIZE, -0.9, CLOSED_PREF_SIZE);
midiLayout.setItemLayout(1, pluginEditor.RESIZER_BAR_SIZE, pluginEditor.RESIZER_BAR_SIZE, pluginEditor.RESIZER_BAR_SIZE);
midiLayout.setItemLayout(2, pluginEditor.CLOSED_PREF_SIZE, -0.9, pluginEditor.CLOSED_PREF_SIZE);
mainLayout.setItemLayout(0, -0.1, -0.9, -0.4);
mainLayout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
mainLayout.setItemLayout(1, pluginEditor.RESIZER_BAR_SIZE, pluginEditor.RESIZER_BAR_SIZE, pluginEditor.RESIZER_BAR_SIZE);
mainLayout.setItemLayout(2, -0.1, -0.9, -0.6);
mainPerspectiveLayout.setItemLayout(0, RESIZER_BAR_SIZE, -1.0, -1.0);
mainPerspectiveLayout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
mainPerspectiveLayout.setItemLayout(2, CLOSED_PREF_SIZE, -1.0, CLOSED_PREF_SIZE);
effectLayout.setItemLayout(0, CLOSED_PREF_SIZE, -1.0, -0.6);
effectLayout.setItemLayout(1, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE, RESIZER_BAR_SIZE);
effectLayout.setItemLayout(2, CLOSED_PREF_SIZE, -1.0, -0.4);
}
@ -47,38 +36,35 @@ void SettingsComponent::resized() {
juce::Component* columns[] = { &dummy2, &mainResizerBar, &dummy };
mainLayout.layOutComponents(columns, 3, dummy.getX(), dummy.getY(), dummy.getWidth(), dummy.getHeight(), false, true);
juce::Component* rows1[] = { &main, &mainPerspectiveResizerBar, &perspective };
mainPerspectiveLayout.layOutComponents(rows1, 3, dummy2.getX(), dummy2.getY(), dummy2.getWidth(), dummy2.getHeight(), true, true);
auto bounds = dummy2.getBounds();
perspective.setBounds(bounds.removeFromBottom(120));
bounds.removeFromBottom(pluginEditor.RESIZER_BAR_SIZE);
main.setBounds(bounds);
juce::Component* effectSettings = nullptr;
if (lua.isVisible()) {
effectSettings = &lua;
} else if (txt.isVisible()) {
if (txt.isVisible()) {
effectSettings = &txt;
}
juce::Component* rows2[] = {&effects, &effectResizerBar, effectSettings};
auto dummyBounds = dummy.getBounds();
// use the dummy component to work out the bounds of the rows
if (effectSettings != nullptr) {
effectLayout.layOutComponents(rows2, 3, dummy.getX(), dummy.getY(), dummy.getWidth(), dummy.getHeight(), true, true);
} else {
effects.setBounds(dummy.getBounds());
effectSettings->setBounds(dummyBounds.removeFromBottom(150));
dummyBounds.removeFromBottom(pluginEditor.RESIZER_BAR_SIZE);
}
effects.setBounds(dummyBounds);
repaint();
}
void SettingsComponent::fileUpdated(juce::String fileName) {
juce::String extension = fileName.fromLastOccurrenceOf(".", true, false);
lua.setVisible(false);
txt.setVisible(false);
if (fileName.isEmpty() || audioProcessor.objectServerRendering) {
// do nothing
} else if (extension == ".lua") {
lua.setVisible(true);
} else if (extension == ".txt") {
} if (extension == ".txt") {
txt.setVisible(true);
}
main.updateFileLabel();
@ -89,25 +75,9 @@ void SettingsComponent::update() {
txt.update();
}
void SettingsComponent::toggleLayout(juce::StretchableLayoutManager& layout, double prefSize) {
double minSize, maxSize, preferredSize;
layout.getItemLayout(2, minSize, maxSize, preferredSize);
if (preferredSize == CLOSED_PREF_SIZE) {
double otherPrefSize = -(1 + prefSize);
layout.setItemLayout(2, CLOSED_PREF_SIZE, -1.0, prefSize);
layout.setItemLayout(0, CLOSED_PREF_SIZE, -1.0, otherPrefSize);
} else {
layout.setItemLayout(2, CLOSED_PREF_SIZE, -1.0, CLOSED_PREF_SIZE);
layout.setItemLayout(0, CLOSED_PREF_SIZE, -1.0, -1.0);
}
resized();
}
void SettingsComponent::mouseMove(const juce::MouseEvent& event) {
for (int i = 0; i < 4; i++) {
if (toggleComponents[i]->getBounds().removeFromTop(CLOSED_PREF_SIZE).contains(event.getPosition())) {
for (int i = 0; i < 2; i++) {
if (toggleComponents[i]->getBounds().removeFromTop(pluginEditor.CLOSED_PREF_SIZE).contains(event.getPosition())) {
setMouseCursor(juce::MouseCursor::PointingHandCursor);
return;
}
@ -117,8 +87,10 @@ void SettingsComponent::mouseMove(const juce::MouseEvent& event) {
void SettingsComponent::mouseDown(const juce::MouseEvent& event) {
for (int i = 0; i < 4; i++) {
if (toggleComponents[i]->getBounds().removeFromTop(CLOSED_PREF_SIZE).contains(event.getPosition())) {
toggleLayout(*toggleLayouts[i], prefSizes[i]);
if (toggleComponents[i]->getBounds().removeFromTop(pluginEditor.CLOSED_PREF_SIZE).contains(event.getPosition())) {
pluginEditor.toggleLayout(*toggleLayouts[i], prefSizes[i]);
resized();
return;
}
}
}
@ -131,9 +103,7 @@ void SettingsComponent::paint(juce::Graphics& g) {
dc.drawForRectangle(g, midi.getBounds());
dc.drawForRectangle(g, perspective.getBounds());
if (lua.isVisible()) {
dc.drawForRectangle(g, lua.getBounds());
} else if (txt.isVisible()) {
if (txt.isVisible()) {
dc.drawForRectangle(g, txt.getBounds());
}
}

Wyświetl plik

@ -17,7 +17,6 @@ public:
void resized() override;
void fileUpdated(juce::String fileName);
void update();
void toggleLayout(juce::StretchableLayoutManager& layout, double prefSize);
void mouseMove(const juce::MouseEvent& event) override;
void mouseDown(const juce::MouseEvent& event) override;
void paint(juce::Graphics& g) override;
@ -27,27 +26,19 @@ private:
OscirenderAudioProcessorEditor& pluginEditor;
MainComponent main{audioProcessor, pluginEditor};
LuaComponent lua{audioProcessor, pluginEditor};
PerspectiveComponent perspective{audioProcessor, pluginEditor};
TxtComponent txt{audioProcessor, pluginEditor};
EffectsComponent effects{audioProcessor, pluginEditor};
MidiComponent midi{audioProcessor, pluginEditor};
const double CLOSED_PREF_SIZE = 30.0;
const double RESIZER_BAR_SIZE = 7.0;
juce::StretchableLayoutManager midiLayout;
juce::StretchableLayoutResizerBar midiResizerBar{&midiLayout, 1, false};
juce::StretchableLayoutManager mainLayout;
juce::StretchableLayoutResizerBar mainResizerBar{&mainLayout, 1, true};
juce::StretchableLayoutManager mainPerspectiveLayout;
juce::StretchableLayoutResizerBar mainPerspectiveResizerBar{&mainPerspectiveLayout, 1, false};
juce::StretchableLayoutManager effectLayout;
juce::StretchableLayoutResizerBar effectResizerBar{&effectLayout, 1, false};
juce::Component* toggleComponents[4] = { &midi, &perspective, &lua, &txt };
juce::StretchableLayoutManager* toggleLayouts[4] = { &midiLayout, &mainPerspectiveLayout, &effectLayout, &effectLayout };
double prefSizes[4] = { -0.3, -0.5, -0.4, -0.4 };
juce::Component* toggleComponents[1] = { &midi };
juce::StretchableLayoutManager* toggleLayouts[1] = { &midiLayout };
double prefSizes[1] = { 300 };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SettingsComponent)
};

Wyświetl plik

@ -328,7 +328,7 @@ class EffectParameter : public FloatParameter {
public:
std::atomic<bool> smoothValueChange = true;
LfoTypeParameter* lfo = new LfoTypeParameter(name + " LFO", paramID + "Lfo", getVersionHint(), 1);
FloatParameter* lfoRate = new FloatParameter(name + " LFO Rate", paramID + "LfoRate", getVersionHint(), 1.0f, 0.0f, 100.0f, 0.1f, "Hz");
FloatParameter* lfoRate = new FloatParameter(name + " LFO Rate", paramID + "LfoRate", getVersionHint(), 1.0f, 0.0f, 1000.0f, 0.1f, "Hz");
BooleanParameter* sidechain = new BooleanParameter(name + " Sidechain Enabled", paramID + "Sidechain", getVersionHint(), false);
std::atomic<float> phase = 0.0f;
juce::String description;

Wyświetl plik

@ -10,9 +10,8 @@ PerspectiveEffect::~PerspectiveEffect() {}
Point PerspectiveEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate) {
auto effectScale = values[0];
auto focalLength = juce::jmax(values[1], 0.001);
auto depth = values[2];
Vec3 origin = Vec3(0, 0, -focalLength - depth);
Vec3 origin = Vec3(0, 0, -focalLength);
camera.setPosition(origin);
camera.setFocalLength(focalLength);
Vec3 vec = Vec3(input.x, input.y, input.z);

Wyświetl plik

@ -1,51 +0,0 @@
#include "RotateEffect.h"
#include <numbers>
#include "../MathUtil.h"
RotateEffect::RotateEffect(int versionHint) {
fixedRotateX = new BooleanParameter("Fixed Rotate X", "fixedRotateX", versionHint, false);
fixedRotateY = new BooleanParameter("Fixed Rotate Y", "fixedRotateY", versionHint, false);
fixedRotateZ = new BooleanParameter("Fixed Rotate Z", "fixedRotateZ", versionHint, false);
}
RotateEffect::~RotateEffect() {}
Point RotateEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate) {
auto rotateSpeed = linearSpeedToActualSpeed(values[0]);
double baseRotateX, baseRotateY, baseRotateZ;
if (fixedRotateX->getBoolValue()) {
baseRotateX = 0;
currentRotateX = values[1] * std::numbers::pi;
} else {
baseRotateX = values[1] * std::numbers::pi;
}
if (fixedRotateY->getBoolValue()) {
baseRotateY = 0;
currentRotateY = values[2] * std::numbers::pi;
} else {
baseRotateY = values[2] * std::numbers::pi;
}
if (fixedRotateZ->getBoolValue()) {
baseRotateZ = 0;
currentRotateZ = values[3] * std::numbers::pi;
} else {
baseRotateZ = values[3] * std::numbers::pi;
}
currentRotateX = MathUtil::wrapAngle(currentRotateX + baseRotateX * rotateSpeed);
currentRotateY = MathUtil::wrapAngle(currentRotateY + baseRotateY * rotateSpeed);
currentRotateZ = MathUtil::wrapAngle(currentRotateZ + baseRotateZ * rotateSpeed);
auto rotateX = baseRotateX + currentRotateX;
auto rotateY = baseRotateY + currentRotateY;
auto rotateZ = baseRotateZ + currentRotateZ;
input.rotate(rotateX, rotateY, rotateZ);
return input;
}
void RotateEffect::resetRotation() {
currentRotateX = 0;
currentRotateY = 0;
currentRotateZ = 0;
}

Wyświetl plik

@ -1,31 +0,0 @@
#pragma once
#include "EffectApplication.h"
#include "../shape/Point.h"
#include "../audio/Effect.h"
class RotateEffect : public EffectApplication {
public:
RotateEffect(int versionHint);
~RotateEffect();
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
void resetRotation();
BooleanParameter* fixedRotateX;
BooleanParameter* fixedRotateY;
BooleanParameter* fixedRotateZ;
private:
float currentRotateX = 0;
float currentRotateY = 0;
float currentRotateZ = 0;
double linearSpeedToActualSpeed(double rotateSpeed) {
double actualSpeed = (std::exp(3 * juce::jmin(10.0, std::abs(rotateSpeed))) - 1) / 50000;
if (rotateSpeed < 0) {
actualSpeed *= -1;
}
return actualSpeed;
}
};

Wyświetl plik

@ -69,6 +69,7 @@ void EffectComponent::setupComponent() {
lfoSlider.setRange(parameter->lfoRate->min, parameter->lfoRate->max, parameter->lfoRate->step);
lfoSlider.setValue(parameter->lfoRate->getValueUnnormalised(), juce::dontSendNotification);
lfoSlider.setSkewFactorFromMidPoint(parameter->lfoRate->min + 0.2 * (parameter->lfoRate->max - parameter->lfoRate->min));
if (lfo.getSelectedId() == static_cast<int>(LfoType::Static)) {
lfoSlider.setVisible(false);

Wyświetl plik

@ -84,26 +84,7 @@ void EffectsListComponent::resized() {
}
std::shared_ptr<juce::Component> EffectsListComponent::createComponent(EffectParameter* parameter) {
if (parameter->paramID == "rotateX" || parameter->paramID == "rotateY" || parameter->paramID == "rotateZ") {
BooleanParameter* toggle;
juce::String axis;
if (parameter->paramID == "rotateX") {
toggle = audioProcessor.rotateEffect->fixedRotateX;
axis = "X";
} else if (parameter->paramID == "rotateY") {
toggle = audioProcessor.rotateEffect->fixedRotateY;
axis = "Y";
} else if (parameter->paramID == "rotateZ") {
toggle = audioProcessor.rotateEffect->fixedRotateZ;
axis = "Z";
}
std::shared_ptr<SvgButton> button = std::make_shared<SvgButton>(parameter->name, BinaryData::fixed_rotate_svg, juce::Colours::white, juce::Colours::red, toggle);
button->setTooltip("Toggles whether the rotation around the " + axis + " axis is fixed, or changes according to the rotation speed.");
button->onClick = [this, toggle] {
toggle->setBoolValueNotifyingHost(!toggle->getBoolValue());
};
return button;
} else if (parameter->paramID == "customEffectStrength") {
if (parameter->paramID == "customEffectStrength") {
std::shared_ptr<SvgButton> button = std::make_shared<SvgButton>(parameter->name, BinaryData::pencil_svg, juce::Colours::white, juce::Colours::red);
std::weak_ptr<SvgButton> weakButton = button;
button->setEdgeIndent(5);

Wyświetl plik

@ -165,9 +165,6 @@
<FILE id="rQC2gX" name="PitchDetector.h" compile="0" resource="0" file="Source/audio/PitchDetector.h"/>
<FILE id="t5g8pf" name="PublicSynthesiser.h" compile="0" resource="0"
file="Source/audio/PublicSynthesiser.h"/>
<FILE id="IwGnf3" name="RotateEffect.cpp" compile="1" resource="0"
file="Source/audio/RotateEffect.cpp"/>
<FILE id="iOgy18" name="RotateEffect.h" compile="0" resource="0" file="Source/audio/RotateEffect.h"/>
<FILE id="dBaZAV" name="ShapeSound.cpp" compile="1" resource="0" file="Source/audio/ShapeSound.cpp"/>
<FILE id="VKBirB" name="ShapeSound.h" compile="0" resource="0" file="Source/audio/ShapeSound.h"/>
<FILE id="UcPZ09" name="ShapeVoice.cpp" compile="1" resource="0" file="Source/audio/ShapeVoice.cpp"/>