Add twist effect, normalize smooth effect

pull/308/head
Anthony Hall 2025-08-13 00:41:13 -07:00
rodzic 47ed50a96c
commit 81437ed87a
7 zmienionych plików z 32 dodań i 25 usunięć

Wyświetl plik

@ -11,9 +11,11 @@
#include "PluginEditor.h"
#include "audio/BitCrushEffect.h"
#include "audio/BulgeEffect.h"
#include "audio/TwistEffect.h"
#include "audio/DistortEffect.h"
#include "audio/MultiplexEffect.h"
#include "audio/SmoothEffect.h"
#include "audio/WobbleEffect.h"
#include "audio/VectorCancellingEffect.h"
#include "parser/FileParser.h"
#include "parser/FrameProducer.h"
@ -121,11 +123,16 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
std::vector<osci::EffectParameter*>{
new osci::EffectParameter("Swirl", "Swirls the image in a spiral pattern.", "swirl", VERSION_HINT, 0.3, -1.0, 1.0),
}));
toggleableEffects.push_back(std::make_shared<osci::Effect>(
std::make_shared<TwistEffect>(),
std::vector<osci::EffectParameter *>{
new osci::EffectParameter("Twist", "Twists the image in a corkscrew pattern.", "twist", VERSION_HINT, 0.5, -1.0, 1.0),
}));
toggleableEffects.push_back(std::make_shared<osci::Effect>(
std::make_shared<SmoothEffect>(),
new osci::EffectParameter("Smoothing", "This works as a low-pass frequency filter that removes high frequencies, making the image look smoother, and audio sound less harsh.", "smoothing", VERSION_HINT, 0.75, 0.0, 1.0)));
std::shared_ptr<osci::Effect> wobble = std::make_shared<osci::Effect>(
wobbleEffect,
std::make_shared<WobbleEffect>(*this),
std::vector<osci::EffectParameter*>{
new osci::EffectParameter("Wobble Amount", "Adds a sine wave of the prominent frequency in the audio currently playing. The sine wave's frequency is slightly offset to create a subtle 'wobble' in the image. Increasing the slider increases the strength of the wobble.", "wobble", VERSION_HINT, 0.3, 0.0, 1.0),
new osci::EffectParameter("Wobble Phase", "Controls the phase of the wobble.", "wobblePhase", VERSION_HINT, 0.0, -1.0, 1.0),

Wyświetl plik

@ -25,7 +25,6 @@
#include "audio/SampleRateManager.h"
#include "audio/ShapeSound.h"
#include "audio/ShapeVoice.h"
#include "audio/WobbleEffect.h"
#include "obj/ObjectServer.h"
#if (JUCE_MAC || JUCE_WINDOWS) && OSCI_PREMIUM
@ -172,8 +171,6 @@ public:
std::atomic<double> animationFrame = 0.f;
std::shared_ptr<WobbleEffect> wobbleEffect = std::make_shared<WobbleEffect>(*this);
const double FONT_SIZE = 1.0f;
juce::Font font = juce::Font(juce::Font::getDefaultSansSerifFontName(), FONT_SIZE, juce::Font::plain);

Wyświetl plik

@ -8,7 +8,7 @@ public:
weight *= 0.95;
double strength = 10;
weight = std::log(strength * weight + 1) / std::log(strength + 1);
// TODO: This doesn't consider the sample rate!
weight = std::pow(weight, 48000 / sampleRate);
avg = weight * avg + (1 - weight) * input;
return avg;

Wyświetl plik

@ -0,0 +1,13 @@
#pragma once
#include <JuceHeader.h>
#include <numbers>
class TwistEffect : public osci::EffectApplication {
public:
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>> &values, double sampleRate) override {
double twistStrength = values[0] * 4 * std::numbers::pi;
double twistTheta = twistStrength * input.y;
input.rotate(0.0, twistTheta, 0.0);
return input;
}
};

Wyświetl plik

@ -1,14 +0,0 @@
#include "WobbleEffect.h"
#include "../PluginProcessor.h"
WobbleEffect::WobbleEffect(OscirenderAudioProcessor& p) : audioProcessor(p) {}
WobbleEffect::~WobbleEffect() {}
osci::Point WobbleEffect::apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) {
double wobblePhase = values[1] * std::numbers::pi;
double theta = nextPhase(audioProcessor.frequency, sampleRate) + wobblePhase;
double delta = 0.5 * values[0] * std::sin(theta);
return input + delta;
}

Wyświetl plik

@ -1,13 +1,18 @@
#pragma once
#include <JuceHeader.h>
#include "../PluginProcessor.h"
class OscirenderAudioProcessor;
class WobbleEffect : public osci::EffectApplication {
public:
WobbleEffect(OscirenderAudioProcessor& p);
~WobbleEffect();
WobbleEffect(OscirenderAudioProcessor &p) : audioProcessor(p) {}
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) override;
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) override {
double wobblePhase = values[1] * std::numbers::pi;
double theta = nextPhase(audioProcessor.frequency, sampleRate) + wobblePhase;
double delta = 0.5 * values[0] * std::sin(theta);
return input + delta;
}
private:
OscirenderAudioProcessor& audioProcessor;

Wyświetl plik

@ -104,10 +104,9 @@
<FILE id="WId4vx" name="ShapeVoice.h" compile="0" resource="0" file="Source/audio/ShapeVoice.h"/>
<FILE id="Vwjht7" name="SmoothEffect.h" compile="0" resource="0" file="Source/audio/SmoothEffect.h"/>
<FILE id="WACNMe" name="StereoEffect.h" compile="0" resource="0" file="Source/audio/StereoEffect.h"/>
<FILE id="RsHWPN" name="TwistEffect.h" compile="0" resource="0" file="Source/audio/TwistEffect.h"/>
<FILE id="Be21D0" name="VectorCancellingEffect.h" compile="0" resource="0"
file="Source/audio/VectorCancellingEffect.h"/>
<FILE id="VHRytO" name="WobbleEffect.cpp" compile="1" resource="0"
file="Source/audio/WobbleEffect.cpp"/>
<FILE id="sgdTlo" name="WobbleEffect.h" compile="0" resource="0" file="Source/audio/WobbleEffect.h"/>
</GROUP>
<GROUP id="{2A41BAF3-5E83-B018-5668-39D89ABFA00C}" name="chinese_postman">