kopia lustrzana https://github.com/jameshball/osci-render
Start trying to support mac
rodzic
5be6ec80e9
commit
adf5624e4e
|
@ -6,7 +6,7 @@
|
||||||
#include "components/SvgButton.h"
|
#include "components/SvgButton.h"
|
||||||
|
|
||||||
class OscirenderAudioProcessorEditor;
|
class OscirenderAudioProcessorEditor;
|
||||||
class ObjComponent : public juce::GroupComponent, public juce::MouseListener {
|
class ObjComponent : public juce::GroupComponent {
|
||||||
public:
|
public:
|
||||||
ObjComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&);
|
ObjComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&);
|
||||||
~ObjComponent();
|
~ObjComponent();
|
||||||
|
@ -32,4 +32,4 @@ private:
|
||||||
std::shared_ptr<SvgButton> fixedRotateZ = std::make_shared<SvgButton>("fixedRotateZ", juce::String(BinaryData::fixed_rotate_svg), "white", "red", audioProcessor.fixedRotateZ);
|
std::shared_ptr<SvgButton> fixedRotateZ = std::make_shared<SvgButton>("fixedRotateZ", juce::String(BinaryData::fixed_rotate_svg), "white", "red", audioProcessor.fixedRotateZ);
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ObjComponent)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ObjComponent)
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,56 +38,56 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
||||||
|
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<BitCrushEffect>(),
|
std::make_shared<BitCrushEffect>(),
|
||||||
new EffectParameter("Bit Crush", "bitCrush", 0.0, 0.0, 1.0)
|
new EffectParameter("Bit Crush", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<BulgeEffect>(),
|
std::make_shared<BulgeEffect>(),
|
||||||
new EffectParameter("Bulge", "bulge", 0.0, 0.0, 1.0)
|
new EffectParameter("Bulge", "bulge", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<RotateEffect>(),
|
std::make_shared<RotateEffect>(),
|
||||||
new EffectParameter("2D Rotate", "2DRotateSpeed", 0.0, 0.0, 1.0)
|
new EffectParameter("2D Rotate", "2DRotateSpeed", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<VectorCancellingEffect>(),
|
std::make_shared<VectorCancellingEffect>(),
|
||||||
new EffectParameter("Vector Cancelling", "vectorCancelling", 0.0, 0.0, 1.0)
|
new EffectParameter("Vector Cancelling", "vectorCancelling", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<DistortEffect>(false),
|
std::make_shared<DistortEffect>(false),
|
||||||
new EffectParameter("Distort X", "distortX", 0.0, 0.0, 1.0)
|
new EffectParameter("Distort X", "distortX", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<DistortEffect>(true),
|
std::make_shared<DistortEffect>(true),
|
||||||
new EffectParameter("Distort Y", "distortY", 0.0, 0.0, 1.0)
|
new EffectParameter("Distort Y", "distortY", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
input.x += values[0];
|
input.x += values[0];
|
||||||
input.y += values[1];
|
input.y += values[1];
|
||||||
return input;
|
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", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "translateY", VERSION_HINT, 0.0, -1.0, 1.0)}
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<SmoothEffect>(),
|
std::make_shared<SmoothEffect>(),
|
||||||
new EffectParameter("Smoothing", "smoothing", 0.0, 0.0, 1.0)
|
new EffectParameter("Smoothing", "smoothing", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
wobbleEffect,
|
wobbleEffect,
|
||||||
new EffectParameter("Wobble", "wobble", 0.0, 0.0, 1.0)
|
new EffectParameter("Wobble", "wobble", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
delayEffect,
|
delayEffect,
|
||||||
std::vector<EffectParameter*>{new EffectParameter("Delay Decay", "delayDecay", 0.0, 0.0, 1.0), new EffectParameter("Delay Length", "delayLength", 0.5, 0.0, 1.0)}
|
std::vector<EffectParameter*>{new EffectParameter("Delay Decay", "delayDecay", VERSION_HINT, 0.0, 0.0, 1.0), new EffectParameter("Delay Length", "delayLength", VERSION_HINT, 0.5, 0.0, 1.0)}
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||||
perspectiveEffect,
|
perspectiveEffect,
|
||||||
std::vector<EffectParameter*>{
|
std::vector<EffectParameter*>{
|
||||||
new EffectParameter("3D Perspective", "perspectiveStrength", 0.0, 0.0, 1.0),
|
new EffectParameter("3D Perspective", "perspectiveStrength", VERSION_HINT, 0.0, 0.0, 1.0),
|
||||||
new EffectParameter("Depth (z)", "perspectiveZPos", 0.1, 0.0, 1.0),
|
new EffectParameter("Depth (z)", "perspectiveZPos", VERSION_HINT, 0.1, 0.0, 1.0),
|
||||||
new EffectParameter("Rotate Speed", "perspectiveRotateSpeed", 0.0, -1.0, 1.0),
|
new EffectParameter("Rotate Speed", "perspectiveRotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0),
|
||||||
new EffectParameter("Rotate X", "perspectiveRotateX", 1.0, -1.0, 1.0),
|
new EffectParameter("Rotate X", "perspectiveRotateX", VERSION_HINT, 1.0, -1.0, 1.0),
|
||||||
new EffectParameter("Rotate Y", "perspectiveRotateY", 1.0, -1.0, 1.0),
|
new EffectParameter("Rotate Y", "perspectiveRotateY", VERSION_HINT, 1.0, -1.0, 1.0),
|
||||||
new EffectParameter("Rotate Z", "perspectiveRotateZ", 0.0, -1.0, 1.0),
|
new EffectParameter("Rotate Z", "perspectiveRotateZ", VERSION_HINT, 0.0, -1.0, 1.0),
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
toggleableEffects.push_back(traceMax);
|
toggleableEffects.push_back(traceMax);
|
||||||
|
@ -240,7 +240,7 @@ void OscirenderAudioProcessor::addLuaSlider() {
|
||||||
|
|
||||||
luaEffects.push_back(std::make_shared<Effect>(
|
luaEffects.push_back(std::make_shared<Effect>(
|
||||||
std::make_shared<LuaEffect>(sliderName, *this),
|
std::make_shared<LuaEffect>(sliderName, *this),
|
||||||
new EffectParameter("Lua " + sliderName, "lua" + sliderName, 0.0, 0.0, 1.0, 0.001, false)
|
new EffectParameter("Lua " + sliderName, "lua" + sliderName, VERSION_HINT, 0.0, 0.0, 1.0, 0.001, false)
|
||||||
));
|
));
|
||||||
|
|
||||||
auto& effect = luaEffects.back();
|
auto& effect = luaEffects.back();
|
||||||
|
|
|
@ -60,6 +60,8 @@ public:
|
||||||
void changeProgramName(int index, const juce::String& newName) override;
|
void changeProgramName(int index, const juce::String& newName) override;
|
||||||
void getStateInformation(juce::MemoryBlock& destData) override;
|
void getStateInformation(juce::MemoryBlock& destData) override;
|
||||||
void setStateInformation(const void* data, int sizeInBytes) override;
|
void setStateInformation(const void* data, int sizeInBytes) override;
|
||||||
|
|
||||||
|
int VERSION_HINT = 1;
|
||||||
|
|
||||||
std::atomic<double> currentSampleRate = 0.0;
|
std::atomic<double> currentSampleRate = 0.0;
|
||||||
|
|
||||||
|
@ -71,21 +73,21 @@ public:
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
frequency = values[0];
|
frequency = values[0];
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Frequency", "frequency", 440.0, 0.0, 12000.0, 0.1)
|
}, new EffectParameter("Frequency", "frequency", VERSION_HINT, 440.0, 0.0, 12000.0, 0.1)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::shared_ptr<Effect> volumeEffect = std::make_shared<Effect>(
|
std::shared_ptr<Effect> volumeEffect = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
volume = values[0];
|
volume = values[0];
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Volume", "volume", 1.0, 0.0, 3.0)
|
}, new EffectParameter("Volume", "volume", VERSION_HINT, 1.0, 0.0, 3.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::shared_ptr<Effect> thresholdEffect = std::make_shared<Effect>(
|
std::shared_ptr<Effect> thresholdEffect = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
threshold = values[0];
|
threshold = values[0];
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Threshold", "threshold", 1.0, 0.0, 1.0)
|
}, new EffectParameter("Threshold", "threshold", VERSION_HINT, 1.0, 0.0, 1.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::shared_ptr<Effect> focalLength = std::make_shared<Effect>(
|
std::shared_ptr<Effect> focalLength = std::make_shared<Effect>(
|
||||||
|
@ -96,12 +98,12 @@ public:
|
||||||
camera->setFocalLength(values[0]);
|
camera->setFocalLength(values[0]);
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Focal length", "objFocalLength", 1.0, 0.0, 2.0)
|
}, new EffectParameter("Focal length", "objFocalLength", VERSION_HINT, 1.0, 0.0, 2.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
BooleanParameter* fixedRotateX = new BooleanParameter("Object Fixed Rotate X", "objFixedRotateX", false);
|
BooleanParameter* fixedRotateX = new BooleanParameter("Object Fixed Rotate X", "objFixedRotateX", VERSION_HINT, false);
|
||||||
BooleanParameter* fixedRotateY = new BooleanParameter("Object Fixed Rotate Y", "objFixedRotateY", false);
|
BooleanParameter* fixedRotateY = new BooleanParameter("Object Fixed Rotate Y", "objFixedRotateY", VERSION_HINT, false);
|
||||||
BooleanParameter* fixedRotateZ = new BooleanParameter("Object Fixed Rotate Z", "objFixedRotateZ", false);
|
BooleanParameter* fixedRotateZ = new BooleanParameter("Object Fixed Rotate Z", "objFixedRotateZ", VERSION_HINT, false);
|
||||||
std::shared_ptr<Effect> rotateX = std::make_shared<Effect>(
|
std::shared_ptr<Effect> rotateX = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
if (getCurrentFileIndex() != -1) {
|
if (getCurrentFileIndex() != -1) {
|
||||||
|
@ -115,7 +117,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Rotate X", "objRotateX", 1.0, -1.0, 1.0)
|
}, new EffectParameter("Rotate X", "objRotateX", VERSION_HINT, 1.0, -1.0, 1.0)
|
||||||
);
|
);
|
||||||
std::shared_ptr<Effect> rotateY = std::make_shared<Effect>(
|
std::shared_ptr<Effect> rotateY = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
|
@ -130,7 +132,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Rotate Y", "objRotateY", 1.0, -1.0, 1.0)
|
}, new EffectParameter("Rotate Y", "objRotateY", VERSION_HINT, 1.0, -1.0, 1.0)
|
||||||
);
|
);
|
||||||
std::shared_ptr<Effect> rotateZ = std::make_shared<Effect>(
|
std::shared_ptr<Effect> rotateZ = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
|
@ -145,7 +147,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Rotate Z", "objRotateZ", 0.0, -1.0, 1.0)
|
}, new EffectParameter("Rotate Z", "objRotateZ", VERSION_HINT, 0.0, -1.0, 1.0)
|
||||||
);
|
);
|
||||||
std::shared_ptr<Effect> rotateSpeed = std::make_shared<Effect>(
|
std::shared_ptr<Effect> rotateSpeed = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
|
@ -155,11 +157,11 @@ public:
|
||||||
obj->setRotationSpeed(values[0]);
|
obj->setRotationSpeed(values[0]);
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Rotate Speed", "objRotateSpeed", 0.0, -1.0, 1.0)
|
}, new EffectParameter("Rotate Speed", "objRotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();
|
std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();
|
||||||
std::shared_ptr<PerspectiveEffect> perspectiveEffect = std::make_shared<PerspectiveEffect>();
|
std::shared_ptr<PerspectiveEffect> perspectiveEffect = std::make_shared<PerspectiveEffect>(VERSION_HINT);
|
||||||
|
|
||||||
juce::SpinLock parsersLock;
|
juce::SpinLock parsersLock;
|
||||||
std::vector<std::shared_ptr<FileParser>> parsers;
|
std::vector<std::shared_ptr<FileParser>> parsers;
|
||||||
|
@ -226,14 +228,14 @@ private:
|
||||||
traceMaxValue = values[0];
|
traceMaxValue = values[0];
|
||||||
traceMaxEnabled = true;
|
traceMaxEnabled = true;
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Trace max", "traceMax", 1.0, 0.0, 1.0)
|
}, new EffectParameter("Trace max", "traceMax", VERSION_HINT, 1.0, 0.0, 1.0)
|
||||||
);
|
);
|
||||||
std::shared_ptr<Effect> traceMin = std::make_shared<Effect>(
|
std::shared_ptr<Effect> traceMin = std::make_shared<Effect>(
|
||||||
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
traceMinValue = values[0];
|
traceMinValue = values[0];
|
||||||
traceMinEnabled = true;
|
traceMinEnabled = true;
|
||||||
return input;
|
return input;
|
||||||
}, new EffectParameter("Trace min", "traceMin", 0.0, 0.0, 1.0)
|
}, new EffectParameter("Trace min", "traceMin", VERSION_HINT, 0.0, 0.0, 1.0)
|
||||||
);
|
);
|
||||||
const double MIN_TRACE = 0.005;
|
const double MIN_TRACE = 0.005;
|
||||||
double traceMaxValue = traceMax->getValue();
|
double traceMaxValue = traceMax->getValue();
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
BitCrushEffect::BitCrushEffect() {}
|
BitCrushEffect::BitCrushEffect() {}
|
||||||
|
|
||||||
BitCrushEffect::~BitCrushEffect() {}
|
|
||||||
|
|
||||||
// algorithm from https://www.kvraudio.com/forum/viewtopic.php?t=163880
|
// algorithm from https://www.kvraudio.com/forum/viewtopic.php?t=163880
|
||||||
Vector2 BitCrushEffect::apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
Vector2 BitCrushEffect::apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
double value = values[0];
|
double value = values[0];
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
class BitCrushEffect : public EffectApplication {
|
class BitCrushEffect : public EffectApplication {
|
||||||
public:
|
public:
|
||||||
BitCrushEffect();
|
BitCrushEffect();
|
||||||
~BitCrushEffect();
|
|
||||||
|
|
||||||
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
class BooleanParameter : public juce::AudioProcessorParameterWithID {
|
class BooleanParameter : public juce::AudioProcessorParameterWithID {
|
||||||
public:
|
public:
|
||||||
BooleanParameter(juce::String name, juce::String id, bool value) : AudioProcessorParameterWithID(id, name), value(value) {}
|
BooleanParameter(juce::String name, juce::String id, int versionHint, bool value) : AudioProcessorParameterWithID(juce::ParameterID(id, versionHint), name), value(value) {}
|
||||||
|
|
||||||
juce::String getName(int maximumStringLength) const override {
|
juce::String getName(int maximumStringLength) const override {
|
||||||
return name.substring(0, maximumStringLength);
|
return name.substring(0, maximumStringLength);
|
||||||
|
@ -86,4 +86,4 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::atomic<bool> value = false;
|
std::atomic<bool> value = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,47 +33,47 @@ void Effect::animateValues() {
|
||||||
float percentage = phase / (2 * std::numbers::pi);
|
float percentage = phase / (2 * std::numbers::pi);
|
||||||
LfoType type = lfoEnabled ? (LfoType)(int)parameter->lfo->getValueUnnormalised() : LfoType::Static;
|
LfoType type = lfoEnabled ? (LfoType)(int)parameter->lfo->getValueUnnormalised() : LfoType::Static;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LfoType::Sine:
|
case LfoType::Sine:
|
||||||
actualValues[i] = std::sin(phase) * 0.5 + 0.5;
|
actualValues[i] = std::sin(phase) * 0.5 + 0.5;
|
||||||
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::Square:
|
case LfoType::Square:
|
||||||
actualValues[i] = (percentage < 0.5) ? maxValue : minValue;
|
actualValues[i] = (percentage < 0.5) ? maxValue : minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::Seesaw:
|
case LfoType::Seesaw:
|
||||||
// modified sigmoid function
|
// modified sigmoid function
|
||||||
actualValues[i] = (percentage < 0.5) ? percentage * 2 : (1 - percentage) * 2;
|
actualValues[i] = (percentage < 0.5) ? percentage * 2 : (1 - percentage) * 2;
|
||||||
actualValues[i] = 1 / (1 + std::exp(-16 * (actualValues[i] - 0.5)));
|
actualValues[i] = 1 / (1 + std::exp(-16 * (actualValues[i] - 0.5)));
|
||||||
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::Triangle:
|
case LfoType::Triangle:
|
||||||
actualValues[i] = (percentage < 0.5) ? percentage * 2 : (1 - percentage) * 2;
|
actualValues[i] = (percentage < 0.5) ? percentage * 2 : (1 - percentage) * 2;
|
||||||
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
actualValues[i] = actualValues[i] * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::Sawtooth:
|
case LfoType::Sawtooth:
|
||||||
actualValues[i] = percentage * (maxValue - minValue) + minValue;
|
actualValues[i] = percentage * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::ReverseSawtooth:
|
case LfoType::ReverseSawtooth:
|
||||||
actualValues[i] = (1 - percentage) * (maxValue - minValue) + minValue;
|
actualValues[i] = (1 - percentage) * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
case LfoType::Noise:
|
case LfoType::Noise:
|
||||||
actualValues[i] = ((float)rand() / RAND_MAX) * (maxValue - minValue) + minValue;
|
actualValues[i] = ((float)rand() / RAND_MAX) * (maxValue - minValue) + minValue;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
double weight = parameter->smoothValueChange ? 0.0005 : 1.0;
|
double weight = parameter->smoothValueChange ? 0.0005 : 1.0;
|
||||||
actualValues[i] = (1.0 - weight) * actualValues[i] + weight * parameter->getValueUnnormalised();
|
actualValues[i] = (1.0 - weight) * actualValues[i] + weight * parameter->getValueUnnormalised();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// should only be the audio thread calling this, but either way it's not a big deal
|
// should only be the audio thread calling this, but either way it's not a big deal
|
||||||
float Effect::nextPhase(EffectParameter* parameter) {
|
float Effect::nextPhase(EffectParameter* parameter) {
|
||||||
parameter->phase += parameter->lfoRate->getValueUnnormalised() / sampleRate;
|
parameter->phase = parameter->phase + parameter->lfoRate->getValueUnnormalised() / sampleRate;
|
||||||
|
|
||||||
if (parameter->phase > 1) {
|
if (parameter->phase > 1) {
|
||||||
parameter->phase -= 1;
|
parameter->phase = parameter->phase - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameter->phase * 2 * std::numbers::pi;
|
return parameter->phase * 2 * std::numbers::pi;
|
||||||
|
@ -137,7 +137,7 @@ void Effect::markEnableable(bool enable) {
|
||||||
if (enabled != nullptr) {
|
if (enabled != nullptr) {
|
||||||
enabled->setValue(enable);
|
enabled->setValue(enable);
|
||||||
} else {
|
} else {
|
||||||
enabled = new BooleanParameter(getName() + " Enabled", getId() + "Enabled", enable);
|
enabled = new BooleanParameter(getName() + " Enabled", getId() + "Enabled", parameters[0]->getVersionHint(), enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,14 +150,14 @@ juce::String Effect::getName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Effect::save(juce::XmlElement* xml) {
|
void Effect::save(juce::XmlElement* xml) {
|
||||||
if (enabled != nullptr) {
|
if (enabled != nullptr) {
|
||||||
auto enabledXml = xml->createNewChildElement("enabled");
|
auto enabledXml = xml->createNewChildElement("enabled");
|
||||||
enabled->save(enabledXml);
|
enabled->save(enabledXml);
|
||||||
}
|
}
|
||||||
xml->setAttribute("id", getId());
|
xml->setAttribute("id", getId());
|
||||||
xml->setAttribute("precedence", precedence);
|
xml->setAttribute("precedence", precedence);
|
||||||
for (auto parameter : parameters) {
|
for (auto parameter : parameters) {
|
||||||
parameter->save(xml->createNewChildElement("parameter"));
|
parameter->save(xml->createNewChildElement("parameter"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
class FloatParameter : public juce::AudioProcessorParameterWithID {
|
class FloatParameter : public juce::AudioProcessorParameterWithID {
|
||||||
public:
|
public:
|
||||||
std::atomic<float> min = 0.0;
|
std::atomic<float> min = 0.0;
|
||||||
std::atomic<float> max = 1.0;
|
std::atomic<float> max = 0.0;
|
||||||
std::atomic<float> step = 0.001;
|
std::atomic<float> step = 0.0;
|
||||||
|
|
||||||
FloatParameter(juce::String name, juce::String id, float value, float min, float max, float step = 0.001, juce::String label = "") : juce::AudioProcessorParameterWithID(id, name), value(value), min(min), max(max), step(step), label(label) {}
|
FloatParameter(juce::String name, juce::String id, int versionHint, float value, float min, float max, float step = 0.69, juce::String label = "") : juce::AudioProcessorParameterWithID(juce::ParameterID(id, versionHint), name), min(min), max(max), step(step), value(value), label(label) {}
|
||||||
|
|
||||||
juce::String getName(int maximumStringLength) const override {
|
juce::String getName(int maximumStringLength) const override {
|
||||||
return name.substring(0, maximumStringLength);
|
return name.substring(0, maximumStringLength);
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
std::atomic<int> min = 0;
|
std::atomic<int> min = 0;
|
||||||
std::atomic<int> max = 10;
|
std::atomic<int> max = 10;
|
||||||
|
|
||||||
IntParameter(juce::String name, juce::String id, int value, int min, int max) : AudioProcessorParameterWithID(id, name), value(value), min(min), max(max) {}
|
IntParameter(juce::String name, juce::String id, int versionHint, int value, int min, int max) : AudioProcessorParameterWithID(juce::ParameterID(id, versionHint), name), min(min), max(max), value(value) {}
|
||||||
|
|
||||||
juce::String getName(int maximumStringLength) const override {
|
juce::String getName(int maximumStringLength) const override {
|
||||||
return name.substring(0, maximumStringLength);
|
return name.substring(0, maximumStringLength);
|
||||||
|
@ -237,7 +237,7 @@ enum class LfoType : int {
|
||||||
|
|
||||||
class LfoTypeParameter : public IntParameter {
|
class LfoTypeParameter : public IntParameter {
|
||||||
public:
|
public:
|
||||||
LfoTypeParameter(juce::String name, juce::String id, int value) : IntParameter(name, id, value, 1, 8) {}
|
LfoTypeParameter(juce::String name, juce::String id, int versionHint, int value) : IntParameter(name, id, versionHint, value, 1, 8) {}
|
||||||
|
|
||||||
juce::String getText(float value, int maximumStringLength) const override {
|
juce::String getText(float value, int maximumStringLength) const override {
|
||||||
switch ((LfoType)(int)getUnnormalisedValue(value)) {
|
switch ((LfoType)(int)getUnnormalisedValue(value)) {
|
||||||
|
@ -298,8 +298,8 @@ public:
|
||||||
class EffectParameter : public FloatParameter {
|
class EffectParameter : public FloatParameter {
|
||||||
public:
|
public:
|
||||||
std::atomic<bool> smoothValueChange = true;
|
std::atomic<bool> smoothValueChange = true;
|
||||||
LfoTypeParameter* lfo = new LfoTypeParameter(name + " LFO", paramID + "Lfo", 1);
|
LfoTypeParameter* lfo = new LfoTypeParameter(name + " LFO", paramID + "Lfo", getVersionHint(), 1);
|
||||||
FloatParameter* lfoRate = new FloatParameter(name + " LFO Rate", paramID + "LfoRate", 1.0f, 0.0f, 100.0f, 0.1f, "Hz");
|
FloatParameter* lfoRate = new FloatParameter(name + " LFO Rate", paramID + "LfoRate", getVersionHint(), 1.0f, 0.0f, 100.0f, 0.1f, "Hz");
|
||||||
std::atomic<float> phase = 0.0f;
|
std::atomic<float> phase = 0.0f;
|
||||||
|
|
||||||
std::vector<juce::AudioProcessorParameter*> getParameters() {
|
std::vector<juce::AudioProcessorParameter*> getParameters() {
|
||||||
|
@ -341,5 +341,5 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectParameter(juce::String name, juce::String id, float value, float min, float max, float step = 0.001, bool smoothValueChange = true) : FloatParameter(name, id, value, min, max, step), smoothValueChange(smoothValueChange) {}
|
EffectParameter(juce::String name, juce::String id, int versionHint, float value, float min, float max, float step = 0.01, bool smoothValueChange = true) : FloatParameter(name, id, versionHint, value, min, max, step), smoothValueChange(smoothValueChange) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#include "PerspectiveEffect.h"
|
#include "PerspectiveEffect.h"
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
|
|
||||||
PerspectiveEffect::PerspectiveEffect() {}
|
PerspectiveEffect::PerspectiveEffect(int versionHint) : versionHint(versionHint) {
|
||||||
|
fixedRotateX = new BooleanParameter("Perspective Fixed Rotate X", "perspectiveFixedRotateX", versionHint, false);
|
||||||
|
fixedRotateY = new BooleanParameter("Perspective Fixed Rotate Y", "perspectiveFixedRotateY", versionHint, false);
|
||||||
|
fixedRotateZ = new BooleanParameter("Perspective Fixed Rotate Z", "perspectiveFixedRotateZ", versionHint, false);
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 PerspectiveEffect::apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
Vector2 PerspectiveEffect::apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
||||||
auto effectScale = values[0];
|
auto effectScale = values[0];
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
class PerspectiveEffect : public EffectApplication {
|
class PerspectiveEffect : public EffectApplication {
|
||||||
public:
|
public:
|
||||||
PerspectiveEffect();
|
PerspectiveEffect(int versionHint);
|
||||||
|
|
||||||
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
||||||
void updateCode(const juce::String& newCode);
|
void updateCode(const juce::String& newCode);
|
||||||
juce::String getCode();
|
juce::String getCode();
|
||||||
|
|
||||||
BooleanParameter* fixedRotateX = new BooleanParameter("Perspective Fixed Rotate X", "perspectiveFixedRotateX", false);
|
BooleanParameter* fixedRotateX;
|
||||||
BooleanParameter* fixedRotateY = new BooleanParameter("Perspective Fixed Rotate Y", "perspectiveFixedRotateY", false);
|
BooleanParameter* fixedRotateY;
|
||||||
BooleanParameter* fixedRotateZ = new BooleanParameter("Perspective Fixed Rotate Z", "perspectiveFixedRotateZ", false);
|
BooleanParameter* fixedRotateZ;
|
||||||
private:
|
private:
|
||||||
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
|
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
|
||||||
juce::String code = DEFAULT_SCRIPT;
|
juce::String code = DEFAULT_SCRIPT;
|
||||||
|
@ -25,8 +25,10 @@ private:
|
||||||
float currentRotateX = 0;
|
float currentRotateX = 0;
|
||||||
float currentRotateY = 0;
|
float currentRotateY = 0;
|
||||||
float currentRotateZ = 0;
|
float currentRotateZ = 0;
|
||||||
|
|
||||||
|
int versionHint;
|
||||||
|
|
||||||
float linearSpeedToActualSpeed(float rotateSpeed) {
|
float linearSpeedToActualSpeed(float rotateSpeed) {
|
||||||
return (std::exp(3 * juce::jmin(10.0f, std::abs(rotateSpeed))) - 1) / 50000.0;
|
return (std::exp(3 * juce::jmin(10.0f, std::abs(rotateSpeed))) - 1) / 50000.0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,16 +116,16 @@ EffectComponent::~EffectComponent() {
|
||||||
effect.removeListener(index, this);
|
effect.removeListener(index, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectComponent::resized() {
|
void EffectComponent::resized() {
|
||||||
auto bounds = getLocalBounds();
|
auto bounds = getLocalBounds();
|
||||||
auto componentBounds = bounds.removeFromRight(25);
|
auto componentBounds = bounds.removeFromRight(25);
|
||||||
if (component != nullptr) {
|
if (component != nullptr) {
|
||||||
component->setBounds(componentBounds);
|
component->setBounds(componentBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lfoEnabled) {
|
if (lfoEnabled) {
|
||||||
lfo.setBounds(bounds.removeFromRight(100).reduced(5));
|
lfo.setBounds(bounds.removeFromRight(100).reduced(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto checkboxLabel = bounds.removeFromLeft(120);
|
auto checkboxLabel = bounds.removeFromLeft(120);
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ std::vector<Vector2> Camera::sampleVerticesInRender(WorldObject& object) {
|
||||||
double z = object.vs[j * 3 + 2];
|
double z = object.vs[j * 3 + 2];
|
||||||
vertices.push_back(project(object.rotateX, object.rotateY, object.rotateZ, x, y, z));
|
vertices.push_back(project(object.rotateX, object.rotateY, object.rotateZ, x, y, z));
|
||||||
}
|
}
|
||||||
object.rotateY += rotation;
|
object.rotateY = object.rotateY + rotation;
|
||||||
object.rotateZ += rotation;
|
object.rotateZ = object.rotateY + rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vertices;
|
return vertices;
|
||||||
|
|
|
@ -238,9 +238,9 @@ void WorldObject::setRotationSpeed(double rotateSpeed) {
|
||||||
// called whenever a new frame is drawn, so that the object can update its
|
// called whenever a new frame is drawn, so that the object can update its
|
||||||
// rotation
|
// rotation
|
||||||
void WorldObject::nextFrame() {
|
void WorldObject::nextFrame() {
|
||||||
currentRotateX += baseRotateX * rotateSpeed;
|
currentRotateX = currentRotateX + baseRotateX * rotateSpeed;
|
||||||
currentRotateY += baseRotateY * rotateSpeed;
|
currentRotateY = currentRotateY + baseRotateY * rotateSpeed;
|
||||||
currentRotateZ += baseRotateZ * rotateSpeed;
|
currentRotateZ = currentRotateZ + baseRotateZ * rotateSpeed;
|
||||||
rotateX = baseRotateX + currentRotateX;
|
rotateX = baseRotateX + currentRotateX;
|
||||||
rotateY = baseRotateY + currentRotateY;
|
rotateY = baseRotateY + currentRotateY;
|
||||||
rotateZ = baseRotateZ + currentRotateZ;
|
rotateZ = baseRotateZ + currentRotateZ;
|
||||||
|
|
|
@ -26,4 +26,4 @@ private:
|
||||||
std::atomic<double> baseRotateX = 0.0, baseRotateY = 0.0, baseRotateZ = 0.0;
|
std::atomic<double> baseRotateX = 0.0, baseRotateY = 0.0, baseRotateZ = 0.0;
|
||||||
std::atomic<double> currentRotateX = 0.0, currentRotateY = 0.0, currentRotateZ = 0.0;
|
std::atomic<double> currentRotateX = 0.0, currentRotateY = 0.0, currentRotateZ = 0.0;
|
||||||
std::atomic<double> rotateSpeed;
|
std::atomic<double> rotateSpeed;
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,8 +56,6 @@ void CircleArc::translate(double x, double y) {
|
||||||
double CircleArc::length() {
|
double CircleArc::length() {
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
len = 0;
|
len = 0;
|
||||||
double angle = startAngle;
|
|
||||||
double step = (endAngle - startAngle) / 500;
|
|
||||||
for (int i = 0; i < 500; i++) {
|
for (int i = 0; i < 500; i++) {
|
||||||
Vector2 v1 = nextVector(i / 500.0);
|
Vector2 v1 = nextVector(i / 500.0);
|
||||||
Vector2 v2 = nextVector((i + 1) / 500.0);
|
Vector2 v2 = nextVector((i + 1) / 500.0);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<JUCERPROJECT id="HH2E72" name="osci-render" projectType="audioplug" useAppConfig="0"
|
<JUCERPROJECT id="HH2E72" name="osci-render" projectType="audioplug" useAppConfig="0"
|
||||||
addUsingNamespaceToJuceHeader="0" displaySplashScreen="0" jucerFormatVersion="1"
|
addUsingNamespaceToJuceHeader="0" displaySplashScreen="1" jucerFormatVersion="1"
|
||||||
pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn"
|
pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn"
|
||||||
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
|
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
|
||||||
cppLanguageStandard="20" projectLineFeed=" " headerPath="./include"
|
cppLanguageStandard="20" projectLineFeed=" " headerPath="./include"
|
||||||
|
|
Ładowanie…
Reference in New Issue