kopia lustrzana https://github.com/jameshball/osci-render
commit
8ec5e12e3a
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M298-200h364l123-369-305-213-305 213 123 369Zm-58 80L80-600l400-280 400 280-160 480H240Zm240-371Z"/></svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 222 B |
|
@ -12,6 +12,7 @@
|
|||
#include "audio/BitCrushEffect.h"
|
||||
#include "audio/BulgeEffect.h"
|
||||
#include "audio/TwistEffect.h"
|
||||
#include "audio/PolygonBitCrushEffect.h"
|
||||
#include "audio/SpiralBitCrushEffect.h"
|
||||
#include "audio/DistortEffect.h"
|
||||
#include "audio/KaleidoscopeEffect.h"
|
||||
|
@ -61,6 +62,7 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
|
|||
toggleableEffects.push_back(BounceEffect().build());
|
||||
toggleableEffects.push_back(TwistEffect().build());
|
||||
toggleableEffects.push_back(SkewEffect().build());
|
||||
toggleableEffects.push_back(PolygonBitCrushEffect().build());
|
||||
toggleableEffects.push_back(VortexEffect().build());
|
||||
toggleableEffects.push_back(GodRayEffect().build());
|
||||
toggleableEffects.push_back(SpiralBitCrushEffect().build());
|
||||
|
|
|
@ -7,11 +7,11 @@ public:
|
|||
double value = values[0];
|
||||
double translatedBulge = -value + 1;
|
||||
|
||||
double r = sqrt(pow(input.x, 2) + pow(input.y, 2));
|
||||
double theta = atan2(input.y, input.x);
|
||||
double rn = pow(r, translatedBulge);
|
||||
|
||||
return osci::Point(rn * cos(theta), rn * sin(theta), input.z);
|
||||
double r = std::hypot(input.x, input.y);
|
||||
if (r == 0) return input;
|
||||
double rn = std::pow(r, translatedBulge);
|
||||
double scale = rn / r;
|
||||
return osci::Point(scale * input.x, scale * input.y, input.z);
|
||||
}
|
||||
|
||||
std::shared_ptr<osci::Effect> build() const override {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include "../MathUtil.h"
|
||||
|
||||
// Inspired by xenontesla122
|
||||
class PolygonBitCrushEffect : public osci::EffectApplication {
|
||||
public:
|
||||
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>> &values, double sampleRate) override {
|
||||
const double pi = juce::MathConstants<double>::pi;
|
||||
const double twoPi = juce::MathConstants<double>::twoPi;
|
||||
double effectScale = juce::jlimit(0.0, 1.0, values[0].load());
|
||||
double nSides = juce::jmax(2.0, values[1].load());
|
||||
double stripeSize = juce::jmax(1e-4, values[2].load());
|
||||
stripeSize = std::pow(0.63 * stripeSize, 1.5); // Change range and bias toward smaller values
|
||||
double rotation = values[3] * twoPi;
|
||||
double stripePhase = values[4];
|
||||
|
||||
osci::Point output(0);
|
||||
if (input.x != 0 || input.y != 0) {
|
||||
// Note 90 degree rotation: Theta is treated relative to +Y rather than +X
|
||||
double r = std::hypot(input.x, input.y);
|
||||
double theta = std::atan2(-input.x, input.y) - rotation;
|
||||
theta = MathUtil::wrapAngle(theta + pi) - pi; // Move branch cut to +/-pi after angle offset is applied
|
||||
double regionCenterTheta = std::round(theta * nSides / twoPi) / nSides * twoPi;
|
||||
double localTheta = theta - regionCenterTheta;
|
||||
double dist = r * std::cos(localTheta);
|
||||
double newDist = juce::jmax(0.0, (std::round(dist / stripeSize - stripePhase) + stripePhase) * stripeSize);
|
||||
double scale = newDist / dist;
|
||||
output.x = scale * input.x;
|
||||
output.y = scale * input.y;
|
||||
}
|
||||
// Apply the same stripe quantization to abs(z) if the input is 3D
|
||||
double absZ = std::abs(input.z);
|
||||
if (absZ > 0.0001) {
|
||||
double signZ = input.z > 0 ? 1 : -1;
|
||||
output.z = signZ * juce::jmax(0.0, (std::round(absZ / stripeSize - stripePhase) + stripePhase) * stripeSize);
|
||||
}
|
||||
return (1 - effectScale) * input + effectScale * output;
|
||||
}
|
||||
|
||||
std::shared_ptr<osci::Effect> build() const override {
|
||||
auto eff = std::make_shared<osci::Effect>(
|
||||
std::make_shared<PolygonBitCrushEffect>(),
|
||||
std::vector<osci::EffectParameter*>{
|
||||
new osci::EffectParameter("Polygon Bit Crush",
|
||||
"Constrains points to a polygon pattern.",
|
||||
"polygonBitCrush", VERSION_HINT, 1.0, 0.0, 1.0),
|
||||
new osci::EffectParameter("Sides", "Controls the number of sides of the polygon pattern.",
|
||||
"polygonBitCrushSides", VERSION_HINT, 5.0, 3.0, 8.0),
|
||||
new osci::EffectParameter("Stripe Size",
|
||||
"Controls the spacing between the stripes of the polygon pattern.",
|
||||
"polygonBitCrushStripeSize", VERSION_HINT, 0.5, 0.0, 1.0),
|
||||
new osci::EffectParameter("Rotation", "Rotates the polygon pattern.",
|
||||
"polygonBitCrushRotation", VERSION_HINT, 0.0, 0.0, 1.0, 0.0001, osci::LfoType::Sawtooth, 0.1),
|
||||
new osci::EffectParameter("Stripe Phase", "Offsets the stripes of the polygon pattern.",
|
||||
"polygonBitCrushStripePhase", VERSION_HINT, 0.0, 0.0, 1.0, 0.0001, osci::LfoType::Sawtooth, 2.0)
|
||||
}
|
||||
);
|
||||
eff->setIcon(BinaryData::polygon_bitcrush_svg);
|
||||
return eff;
|
||||
}
|
||||
};
|
|
@ -127,6 +127,8 @@
|
|||
<FILE id="zFdUYi" name="planet.svg" compile="0" resource="1" file="Resources/svg/planet.svg"/>
|
||||
<FILE id="sfWuFd" name="play.svg" compile="0" resource="1" file="Resources/svg/play.svg"/>
|
||||
<FILE id="FJG3Ht" name="plus.svg" compile="0" resource="1" file="Resources/svg/plus.svg"/>
|
||||
<FILE id="NVf72g" name="polygon_bitcrush.svg" compile="0" resource="1"
|
||||
file="Resources/svg/polygon_bitcrush.svg"/>
|
||||
<FILE id="f0yiwT" name="puzzle.svg" compile="0" resource="1" file="Resources/svg/puzzle.svg"/>
|
||||
<FILE id="ElMcEN" name="pyramid.svg" compile="0" resource="1" file="Resources/svg/pyramid.svg"/>
|
||||
<FILE id="PFc2q2" name="random.svg" compile="0" resource="1" file="Resources/svg/random.svg"/>
|
||||
|
@ -176,6 +178,8 @@
|
|||
<FILE id="tU2pQl" name="SkewEffect.h" compile="0" resource="0" file="Source/audio/SkewEffect.h"/>
|
||||
<FILE id="yxWOsR" name="DuplicatorEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/DuplicatorEffect.h"/>
|
||||
<FILE id="GJoA2i" name="PolygonBitCrushEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/PolygonBitCrushEffect.h"/>
|
||||
<FILE id="GbAmhn" name="SpiralBitCrushEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/SpiralBitCrushEffect.h"/>
|
||||
<FILE id="HE3dFE" name="AudioRecorder.h" compile="0" resource="0" file="Source/audio/AudioRecorder.h"/>
|
||||
|
@ -912,4 +916,3 @@
|
|||
<MODULE id="osci_render_core" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/>
|
||||
</MODULES>
|
||||
</JUCERPROJECT>
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue