kopia lustrzana https://github.com/jameshball/osci-render
Add vertical/horizontal distort, rotate, and vector cancelling effects
rodzic
a032a16b66
commit
e6c9cee6b1
|
@ -10,6 +10,9 @@
|
||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
#include "parser/FileParser.h"
|
#include "parser/FileParser.h"
|
||||||
#include "parser/FrameProducer.h"
|
#include "parser/FrameProducer.h"
|
||||||
|
#include "audio/RotateEffect.h"
|
||||||
|
#include "audio/VectorCancellingEffect.h"
|
||||||
|
#include "audio/DistortEffect.h"
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
OscirenderAudioProcessor::OscirenderAudioProcessor()
|
OscirenderAudioProcessor::OscirenderAudioProcessor()
|
||||||
|
@ -28,6 +31,10 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
||||||
|
|
||||||
allEffects.push_back(std::make_shared<Effect>(std::make_unique<BitCrushEffect>(), "Bit Crush", "bitCrush"));
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<BitCrushEffect>(), "Bit Crush", "bitCrush"));
|
||||||
allEffects.push_back(std::make_shared<Effect>(std::make_unique<BulgeEffect>(), "Bulge", "bulge"));
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<BulgeEffect>(), "Bulge", "bulge"));
|
||||||
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<RotateEffect>(), "2D Rotate Speed", "rotateSpeed"));
|
||||||
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<VectorCancellingEffect>(), "Vector cancelling", "vectorCancelling"));
|
||||||
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<DistortEffect>(true), "Vertical shift", "verticalDistort"));
|
||||||
|
allEffects.push_back(std::make_shared<Effect>(std::make_unique<DistortEffect>(false), "Horizontal shift", "horizontalDistort"));
|
||||||
}
|
}
|
||||||
|
|
||||||
OscirenderAudioProcessor::~OscirenderAudioProcessor()
|
OscirenderAudioProcessor::~OscirenderAudioProcessor()
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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, double value) {
|
Vector2 BitCrushEffect::apply(int index, Vector2 input, double value, double frequency, double sampleRate) {
|
||||||
// change rage of value from 0-1 to 0.0-0.78
|
// change rage of value from 0-1 to 0.0-0.78
|
||||||
double rangedValue = value * 0.78;
|
double rangedValue = value * 0.78;
|
||||||
double powValue = pow(2.0f, 1.0 - rangedValue) - 1.0;
|
double powValue = pow(2.0f, 1.0 - rangedValue) - 1.0;
|
||||||
|
|
|
@ -7,5 +7,5 @@ public:
|
||||||
BitCrushEffect();
|
BitCrushEffect();
|
||||||
~BitCrushEffect();
|
~BitCrushEffect();
|
||||||
|
|
||||||
Vector2 apply(int index, Vector2 input, double value) override;
|
Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) override;
|
||||||
};
|
};
|
|
@ -4,7 +4,7 @@ BulgeEffect::BulgeEffect() {}
|
||||||
|
|
||||||
BulgeEffect::~BulgeEffect() {}
|
BulgeEffect::~BulgeEffect() {}
|
||||||
|
|
||||||
Vector2 BulgeEffect::apply(int index, Vector2 input, double value) {
|
Vector2 BulgeEffect::apply(int index, Vector2 input, double value, double frequency, double sampleRate) {
|
||||||
double translatedBulge = -value + 1;
|
double translatedBulge = -value + 1;
|
||||||
|
|
||||||
double r = input.magnitude();
|
double r = input.magnitude();
|
||||||
|
|
|
@ -7,5 +7,5 @@ public:
|
||||||
BulgeEffect();
|
BulgeEffect();
|
||||||
~BulgeEffect();
|
~BulgeEffect();
|
||||||
|
|
||||||
Vector2 apply(int index, Vector2 input, double value) override;
|
Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) override;
|
||||||
};
|
};
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "DistortEffect.h"
|
||||||
|
|
||||||
|
DistortEffect::DistortEffect(bool vertical) : vertical(vertical) {}
|
||||||
|
|
||||||
|
DistortEffect::~DistortEffect() {}
|
||||||
|
|
||||||
|
Vector2 DistortEffect::apply(int index, Vector2 input, double value, double frequency, double sampleRate) {
|
||||||
|
int vertical = (int)this->vertical;
|
||||||
|
if (index % 2 == 0) {
|
||||||
|
input.translate((1 - vertical) * value, vertical * value);
|
||||||
|
} else {
|
||||||
|
input.translate((1 - vertical) * -value, vertical * -value);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include "EffectApplication.h"
|
||||||
|
#include "../shape/Vector2.h"
|
||||||
|
|
||||||
|
class DistortEffect : public EffectApplication {
|
||||||
|
public:
|
||||||
|
DistortEffect(bool vertical);
|
||||||
|
~DistortEffect();
|
||||||
|
|
||||||
|
Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) override;
|
||||||
|
private:
|
||||||
|
bool vertical;
|
||||||
|
};
|
|
@ -5,7 +5,7 @@ Effect::Effect(std::unique_ptr<EffectApplication> effectApplication, juce::Strin
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Effect::apply(int index, Vector2 input) {
|
Vector2 Effect::apply(int index, Vector2 input) {
|
||||||
return effectApplication->apply(index, input, value);
|
return effectApplication->apply(index, input, value, frequency, sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Effect::getValue() {
|
double Effect::getValue() {
|
||||||
|
|
|
@ -19,6 +19,7 @@ private:
|
||||||
double value = 0.0;
|
double value = 0.0;
|
||||||
double frequency = 1.0;
|
double frequency = 1.0;
|
||||||
int precedence = -1;
|
int precedence = -1;
|
||||||
|
int sampleRate = 192000;
|
||||||
juce::String name;
|
juce::String name;
|
||||||
juce::String id;
|
juce::String id;
|
||||||
|
|
||||||
|
|
|
@ -1 +1,16 @@
|
||||||
#include "EffectApplication.h"
|
#include "EffectApplication.h"
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
|
void EffectApplication::resetPhase() {
|
||||||
|
phase = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double EffectApplication::nextPhase(double frequency, double sampleRate) {
|
||||||
|
phase += frequency / sampleRate;
|
||||||
|
|
||||||
|
if (phase > 1) {
|
||||||
|
phase -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return phase * 2 * std::numbers::pi;
|
||||||
|
}
|
||||||
|
|
|
@ -6,5 +6,10 @@ class EffectApplication {
|
||||||
public:
|
public:
|
||||||
EffectApplication() {};
|
EffectApplication() {};
|
||||||
|
|
||||||
virtual Vector2 apply(int index, Vector2 input, double value) = 0;
|
virtual Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) = 0;
|
||||||
|
|
||||||
|
void resetPhase();
|
||||||
|
double nextPhase(double frequency, double sampleRate);
|
||||||
|
private:
|
||||||
|
double phase = 0.0;
|
||||||
};
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "RotateEffect.h"
|
||||||
|
|
||||||
|
RotateEffect::RotateEffect() {}
|
||||||
|
|
||||||
|
RotateEffect::~RotateEffect() {}
|
||||||
|
|
||||||
|
Vector2 RotateEffect::apply(int index, Vector2 input, double value, double frequency, double sampleRate) {
|
||||||
|
input.rotate(nextPhase(value, sampleRate));
|
||||||
|
return input;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
#include "EffectApplication.h"
|
||||||
|
#include "../shape/Vector2.h"
|
||||||
|
|
||||||
|
class RotateEffect : public EffectApplication {
|
||||||
|
public:
|
||||||
|
RotateEffect();
|
||||||
|
~RotateEffect();
|
||||||
|
|
||||||
|
Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) override;
|
||||||
|
};
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include "VectorCancellingEffect.h"
|
||||||
|
|
||||||
|
VectorCancellingEffect::VectorCancellingEffect() {}
|
||||||
|
|
||||||
|
VectorCancellingEffect::~VectorCancellingEffect() {}
|
||||||
|
|
||||||
|
Vector2 VectorCancellingEffect::apply(int index, Vector2 input, double value, double frequency, double sampleRate) {
|
||||||
|
frequency = 1.0 + 9.0 * value;
|
||||||
|
if (index < lastIndex) {
|
||||||
|
nextInvert = nextInvert - lastIndex + frequency;
|
||||||
|
}
|
||||||
|
lastIndex = index;
|
||||||
|
if (index >= nextInvert) {
|
||||||
|
nextInvert += frequency;
|
||||||
|
} else {
|
||||||
|
input.scale(-1, -1);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
#include "EffectApplication.h"
|
||||||
|
#include "../shape/Vector2.h"
|
||||||
|
|
||||||
|
class VectorCancellingEffect : public EffectApplication {
|
||||||
|
public:
|
||||||
|
VectorCancellingEffect();
|
||||||
|
~VectorCancellingEffect();
|
||||||
|
|
||||||
|
Vector2 apply(int index, Vector2 input, double value, double frequency, double sampleRate) override;
|
||||||
|
private:
|
||||||
|
int lastIndex = 0;
|
||||||
|
double nextInvert = 0;
|
||||||
|
};
|
|
@ -24,12 +24,22 @@
|
||||||
file="Source/audio/BitCrushEffect.h"/>
|
file="Source/audio/BitCrushEffect.h"/>
|
||||||
<FILE id="ATOFA9" name="BulgeEffect.cpp" compile="1" resource="0" file="Source/audio/BulgeEffect.cpp"/>
|
<FILE id="ATOFA9" name="BulgeEffect.cpp" compile="1" resource="0" file="Source/audio/BulgeEffect.cpp"/>
|
||||||
<FILE id="lOXxYe" name="BulgeEffect.h" compile="0" resource="0" file="Source/audio/BulgeEffect.h"/>
|
<FILE id="lOXxYe" name="BulgeEffect.h" compile="0" resource="0" file="Source/audio/BulgeEffect.h"/>
|
||||||
|
<FILE id="DiIoN4" name="DistortEffect.cpp" compile="1" resource="0"
|
||||||
|
file="Source/audio/DistortEffect.cpp"/>
|
||||||
|
<FILE id="ux2dO2" name="DistortEffect.h" compile="0" resource="0" file="Source/audio/DistortEffect.h"/>
|
||||||
<FILE id="mP5lpY" name="Effect.cpp" compile="1" resource="0" file="Source/audio/Effect.cpp"/>
|
<FILE id="mP5lpY" name="Effect.cpp" compile="1" resource="0" file="Source/audio/Effect.cpp"/>
|
||||||
<FILE id="LKeNnY" name="Effect.h" compile="0" resource="0" file="Source/audio/Effect.h"/>
|
<FILE id="LKeNnY" name="Effect.h" compile="0" resource="0" file="Source/audio/Effect.h"/>
|
||||||
<FILE id="ca2VrC" name="EffectApplication.cpp" compile="1" resource="0"
|
<FILE id="ca2VrC" name="EffectApplication.cpp" compile="1" resource="0"
|
||||||
file="Source/audio/EffectApplication.cpp"/>
|
file="Source/audio/EffectApplication.cpp"/>
|
||||||
<FILE id="MIYJ9y" name="EffectApplication.h" compile="0" resource="0"
|
<FILE id="MIYJ9y" name="EffectApplication.h" compile="0" resource="0"
|
||||||
file="Source/audio/EffectApplication.h"/>
|
file="Source/audio/EffectApplication.h"/>
|
||||||
|
<FILE id="PbbNqz" name="RotateEffect.cpp" compile="1" resource="0"
|
||||||
|
file="Source/audio/RotateEffect.cpp"/>
|
||||||
|
<FILE id="tUwNZV" name="RotateEffect.h" compile="0" resource="0" file="Source/audio/RotateEffect.h"/>
|
||||||
|
<FILE id="VBskjq" name="VectorCancellingEffect.cpp" compile="1" resource="0"
|
||||||
|
file="Source/audio/VectorCancellingEffect.cpp"/>
|
||||||
|
<FILE id="Be21D0" name="VectorCancellingEffect.h" compile="0" resource="0"
|
||||||
|
file="Source/audio/VectorCancellingEffect.h"/>
|
||||||
</GROUP>
|
</GROUP>
|
||||||
<GROUP id="{E81B1D7B-B0F7-1967-B271-71B3F838720F}" name="txt">
|
<GROUP id="{E81B1D7B-B0F7-1967-B271-71B3F838720F}" name="txt">
|
||||||
<FILE id="vIYWRG" name="TextParser.cpp" compile="1" resource="0" file="Source/txt/TextParser.cpp"/>
|
<FILE id="vIYWRG" name="TextParser.cpp" compile="1" resource="0" file="Source/txt/TextParser.cpp"/>
|
||||||
|
|
Ładowanie…
Reference in New Issue