From eff8b3f63514a44ee0db5bd120c62b2b5df96e0c Mon Sep 17 00:00:00 2001 From: James H Ball Date: Wed, 23 Oct 2024 12:44:31 +0100 Subject: [PATCH] Refactor Point to OsciPoint due to naming conflicts --- .gitmodules | 3 + Source/PluginProcessor.cpp | 26 ++-- Source/PluginProcessor.h | 10 +- Source/SosciPluginProcessor.cpp | 2 +- Source/audio/BitCrushEffect.cpp | 4 +- Source/audio/BitCrushEffect.h | 4 +- Source/audio/BooleanParameter.h | 2 +- Source/audio/BulgeEffect.cpp | 4 +- Source/audio/BulgeEffect.h | 4 +- Source/audio/CustomEffect.cpp | 4 +- Source/audio/CustomEffect.h | 4 +- Source/audio/DashedLineEffect.cpp | 2 +- Source/audio/DashedLineEffect.h | 6 +- Source/audio/DelayEffect.cpp | 6 +- Source/audio/DelayEffect.h | 6 +- Source/audio/DistortEffect.cpp | 2 +- Source/audio/DistortEffect.h | 4 +- Source/audio/Effect.cpp | 8 +- Source/audio/Effect.h | 6 +- Source/audio/EffectApplication.h | 4 +- Source/audio/EffectParameter.h | 2 +- Source/audio/PerspectiveEffect.cpp | 4 +- Source/audio/PerspectiveEffect.h | 4 +- Source/audio/PitchDetector.h | 2 +- Source/audio/ShapeVoice.cpp | 2 +- Source/audio/SmoothEffect.cpp | 2 +- Source/audio/SmoothEffect.h | 6 +- Source/audio/VectorCancellingEffect.cpp | 2 +- Source/audio/VectorCancellingEffect.h | 4 +- Source/audio/WobbleEffect.cpp | 2 +- Source/audio/WobbleEffect.h | 4 +- Source/components/VisualiserComponent.cpp | 4 +- Source/components/VisualiserComponent.h | 6 +- .../components/VisualiserOpenGLComponent.cpp | 14 +- Source/components/VisualiserOpenGLComponent.h | 19 ++- Source/components/VolumeComponent.cpp | 2 +- Source/components/VolumeComponent.h | 2 +- Source/concurrency/BufferConsumer.h | 8 +- Source/concurrency/ConsumerManager.h | 4 +- Source/gpla/LineArtParser.cpp | 14 +- Source/gpla/LineArtParser.h | 4 +- Source/img/ImageParser.cpp | 4 +- Source/img/ImageParser.h | 4 +- Source/lua/LuaParser.cpp | 62 ++++----- Source/parser/FileParser.cpp | 16 +-- Source/parser/FileParser.h | 2 +- Source/parser/FrameSource.h | 4 +- Source/shape/CircleArc.cpp | 8 +- Source/shape/CircleArc.h | 6 +- Source/shape/CubicBezierCurve.cpp | 4 +- Source/shape/CubicBezierCurve.h | 6 +- Source/shape/Line.cpp | 6 +- Source/shape/Line.h | 8 +- Source/shape/OsciPoint.cpp | 127 ++++++++++++++++++ Source/shape/OsciPoint.h | 43 ++++++ Source/shape/Point.cpp | 127 ------------------ Source/shape/Point.h | 43 ------ Source/shape/Shape.cpp | 24 ++-- Source/shape/Shape.h | 8 +- Source/svg/SvgParser.h | 4 +- Source/txt/TextParser.h | 4 +- Source/wav/WavParser.cpp | 8 +- Source/wav/WavParser.h | 6 +- modules/chowdsp_utils | 1 + osci-render.jucer | 38 +++++- sosci.jucer | 38 +++++- 66 files changed, 457 insertions(+), 366 deletions(-) create mode 100644 .gitmodules create mode 100644 Source/shape/OsciPoint.cpp create mode 100644 Source/shape/OsciPoint.h delete mode 100644 Source/shape/Point.cpp delete mode 100644 Source/shape/Point.h create mode 160000 modules/chowdsp_utils diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e22f5950 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/chowdsp_utils"] + path = modules/chowdsp_utils + url = git@github.com:Chowdhury-DSP/chowdsp_utils.git diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index ea6e2a43..871bbd64 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -45,8 +45,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() new EffectParameter("Vector Cancelling", "Inverts the audio and image every few samples to 'cancel out' the audio, making the audio quiet, and distorting the image.", "vectorCancelling", VERSION_HINT, 0.1111111, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { - return input * Point(values[0], values[1], values[2]); + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { + return input * OsciPoint(values[0], values[1], values[2]); }, std::vector{ new EffectParameter("Scale X", "Scales the object in the horizontal direction.", "scaleX", VERSION_HINT, 1.0, -5.0, 5.0), new EffectParameter("Scale Y", "Scales the object in the vertical direction.", "scaleY", VERSION_HINT, 1.0, -5.0, 5.0), @@ -54,9 +54,9 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() } )); toggleableEffects.push_back(std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { int flip = index % 2 == 0 ? 1 : -1; - Point jitter = Point(flip * values[0], flip * values[1], flip * values[2]); + OsciPoint jitter = OsciPoint(flip * values[0], flip * values[1], flip * values[2]); return input + jitter; }, std::vector{ new EffectParameter("Distort X", "Distorts the image in the horizontal direction by jittering the audio sample being drawn.", "distortX", VERSION_HINT, 0.0, 0.0, 1.0), @@ -65,7 +65,7 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() } )); auto rippleEffect = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { double phase = values[1] * std::numbers::pi; double distance = 100 * values[2] * (input.x * input.x + input.y * input.y); input.z += values[0] * std::sin(phase + distance); @@ -79,7 +79,7 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() rippleEffect->getParameter("ripplePhase")->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Sawtooth); toggleableEffects.push_back(rippleEffect); auto rotateEffect = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { input.rotate(values[0] * std::numbers::pi, values[1] * std::numbers::pi, values[2] * std::numbers::pi); return input; }, std::vector{ @@ -92,8 +92,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() rotateEffect->getParameter("rotateY")->lfoRate->setUnnormalisedValueNotifyingHost(0.2); toggleableEffects.push_back(rotateEffect); toggleableEffects.push_back(std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { - return input + Point(values[0], values[1], values[2]); + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { + return input + OsciPoint(values[0], values[1], values[2]); }, std::vector{ new EffectParameter("Translate X", "Moves the object horizontally.", "translateX", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "Moves the object vertically.", "translateY", VERSION_HINT, 0.0, -1.0, 1.0), @@ -101,11 +101,11 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() } )); toggleableEffects.push_back(std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { double length = 10 * values[0] * input.magnitude(); double newX = input.x * std::cos(length) - input.y * std::sin(length); double newY = input.x * std::sin(length) + input.y * std::cos(length); - return Point(newX, newY, input.z); + return OsciPoint(newX, newY, input.z); }, std::vector{ new EffectParameter("Swirl", "Swirls the image in a spiral pattern.", "swirl", VERSION_HINT, 0.3, -1.0, 1.0), } @@ -340,7 +340,7 @@ void OscirenderAudioProcessor::addLuaSlider() { } luaEffects.push_back(std::make_shared( - [this, sliderIndex](int index, Point input, const std::vector>& values, double sampleRate) { + [this, sliderIndex](int index, OsciPoint input, const std::vector>& values, double sampleRate) { luaValues[sliderIndex].store(values[0]); return input; }, new EffectParameter( @@ -710,7 +710,7 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer& buffer, ju currentVolume = std::sqrt(squaredVolume); currentVolume = juce::jlimit(0.0, 1.0, currentVolume); - Point channels = { outputBuffer3d.getSample(0, sample), outputBuffer3d.getSample(1, sample), outputBuffer3d.getSample(2, sample) }; + OsciPoint channels = { outputBuffer3d.getSample(0, sample), outputBuffer3d.getSample(1, sample), outputBuffer3d.getSample(2, sample) }; { juce::SpinLock::ScopedLockType lock1(parsersLock); @@ -753,7 +753,7 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer& buffer, ju { juce::SpinLock::ScopedLockType scope(consumerLock); for (auto consumer : consumers) { - consumer->write(Point(x, y, 1)); + consumer->write(OsciPoint(x, y, 1)); consumer->notifyIfFull(); } } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index af243850..9d83b909 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -82,7 +82,7 @@ public: std::atomic luaValues[26] = { 0.0 }; std::shared_ptr frequencyEffect = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { frequency = values[0].load(); return input; }, new EffectParameter( @@ -94,7 +94,7 @@ public: ); std::shared_ptr volumeEffect = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { volume = values[0].load(); return input; }, new EffectParameter( @@ -106,7 +106,7 @@ public: ); std::shared_ptr thresholdEffect = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { threshold = values[0].load(); return input; }, new EffectParameter( @@ -202,7 +202,7 @@ public: BooleanParameter* invertImage = new BooleanParameter("Invert Image", "invertImage", VERSION_HINT, false, "Inverts the image so that dark pixels become light, and vice versa."); std::shared_ptr imageThreshold = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { return input; }, new EffectParameter( "Image Threshold", @@ -212,7 +212,7 @@ public: ) ); std::shared_ptr imageStride = std::make_shared( - [this](int index, Point input, const std::vector>& values, double sampleRate) { + [this](int index, OsciPoint input, const std::vector>& values, double sampleRate) { return input; }, new EffectParameter( "Image Stride", diff --git a/Source/SosciPluginProcessor.cpp b/Source/SosciPluginProcessor.cpp index 2def84de..c3c1aee7 100644 --- a/Source/SosciPluginProcessor.cpp +++ b/Source/SosciPluginProcessor.cpp @@ -190,7 +190,7 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer& buffer, juce::M } } - Point point = { x, y, brightness }; + OsciPoint point = { x, y, brightness }; for (auto& effect : allEffects) { point = effect->apply(sample, point); diff --git a/Source/audio/BitCrushEffect.cpp b/Source/audio/BitCrushEffect.cpp index 090f2e2c..506c02b8 100644 --- a/Source/audio/BitCrushEffect.cpp +++ b/Source/audio/BitCrushEffect.cpp @@ -3,7 +3,7 @@ BitCrushEffect::BitCrushEffect() {} // algorithm from https://www.kvraudio.com/forum/viewtopic.php?t=163880 -Point BitCrushEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint BitCrushEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { double value = values[0]; // change rage of value from 0-1 to 0.0-0.78 double rangedValue = value * 0.78; @@ -12,5 +12,5 @@ Point BitCrushEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; }; diff --git a/Source/audio/BooleanParameter.h b/Source/audio/BooleanParameter.h index baf3d8fd..4d4fc612 100644 --- a/Source/audio/BooleanParameter.h +++ b/Source/audio/BooleanParameter.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include class BooleanParameter : public juce::AudioProcessorParameterWithID { diff --git a/Source/audio/BulgeEffect.cpp b/Source/audio/BulgeEffect.cpp index 9aeffbab..0fa7d2c8 100644 --- a/Source/audio/BulgeEffect.cpp +++ b/Source/audio/BulgeEffect.cpp @@ -4,7 +4,7 @@ BulgeEffect::BulgeEffect() {} BulgeEffect::~BulgeEffect() {} -Point BulgeEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint BulgeEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { double value = values[0]; double translatedBulge = -value + 1; @@ -12,5 +12,5 @@ Point BulgeEffect::apply(int index, Point input, const std::vector>&, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>&, double sampleRate) override; }; diff --git a/Source/audio/CustomEffect.cpp b/Source/audio/CustomEffect.cpp index 665efe6b..1773035e 100644 --- a/Source/audio/CustomEffect.cpp +++ b/Source/audio/CustomEffect.cpp @@ -13,7 +13,7 @@ CustomEffect::~CustomEffect() { parser->close(L); } -Point CustomEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint CustomEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { auto effectScale = values[0].load(); auto x = input.x; @@ -45,7 +45,7 @@ Point CustomEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; void updateCode(const juce::String& newCode); juce::String getCode(); diff --git a/Source/audio/DashedLineEffect.cpp b/Source/audio/DashedLineEffect.cpp index ac4e2f01..feb24e11 100644 --- a/Source/audio/DashedLineEffect.cpp +++ b/Source/audio/DashedLineEffect.cpp @@ -4,7 +4,7 @@ DashedLineEffect::DashedLineEffect() {} DashedLineEffect::~DashedLineEffect() {} -Point DashedLineEffect::apply(int index, Point vector, const std::vector>& values, double sampleRate) { +OsciPoint DashedLineEffect::apply(int index, OsciPoint vector, const std::vector>& values, double sampleRate) { // dash length in seconds double dashLength = values[0] / 400; int dashLengthSamples = (int)(dashLength * sampleRate); diff --git a/Source/audio/DashedLineEffect.h b/Source/audio/DashedLineEffect.h index a5321604..d7c917b3 100644 --- a/Source/audio/DashedLineEffect.h +++ b/Source/audio/DashedLineEffect.h @@ -1,17 +1,17 @@ #pragma once #include "EffectApplication.h" -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" class DashedLineEffect : public EffectApplication { public: DashedLineEffect(); ~DashedLineEffect(); - Point apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: const static int MAX_BUFFER = 192000; - std::vector buffer = std::vector(MAX_BUFFER); + std::vector buffer = std::vector(MAX_BUFFER); int dashIndex = 0; int bufferIndex = 0; }; diff --git a/Source/audio/DelayEffect.cpp b/Source/audio/DelayEffect.cpp index dd7dc581..cf702be9 100644 --- a/Source/audio/DelayEffect.cpp +++ b/Source/audio/DelayEffect.cpp @@ -4,7 +4,7 @@ DelayEffect::DelayEffect() {} DelayEffect::~DelayEffect() {} -Point DelayEffect::apply(int index, Point vector, const std::vector>& values, double sampleRate) { +OsciPoint DelayEffect::apply(int index, OsciPoint vector, const std::vector>& values, double sampleRate) { double decay = values[0]; double decayLength = values[1]; int delayBufferLength = (int)(sampleRate * decayLength); @@ -22,8 +22,8 @@ Point DelayEffect::apply(int index, Point vector, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: const static int MAX_DELAY = 192000 * 10; - std::vector delayBuffer = std::vector(MAX_DELAY); + std::vector delayBuffer = std::vector(MAX_DELAY); int head = 0; int position = 0; int samplesSinceLastDelay = 0; diff --git a/Source/audio/DistortEffect.cpp b/Source/audio/DistortEffect.cpp index 6ebcbdf9..1c6c508b 100644 --- a/Source/audio/DistortEffect.cpp +++ b/Source/audio/DistortEffect.cpp @@ -4,7 +4,7 @@ DistortEffect::DistortEffect(bool vertical) : vertical(vertical) {} DistortEffect::~DistortEffect() {} -Point DistortEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint DistortEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { double value = values[0]; int vertical = (int)this->vertical; if (index % 2 == 0) { diff --git a/Source/audio/DistortEffect.h b/Source/audio/DistortEffect.h index bb5ec93f..451f3aa5 100644 --- a/Source/audio/DistortEffect.h +++ b/Source/audio/DistortEffect.h @@ -1,13 +1,13 @@ #pragma once #include "EffectApplication.h" -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" class DistortEffect : public EffectApplication { public: DistortEffect(bool vertical); ~DistortEffect(); - Point apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: bool vertical; }; diff --git a/Source/audio/Effect.cpp b/Source/audio/Effect.cpp index 8b2c9f0f..4fa2c789 100644 --- a/Source/audio/Effect.cpp +++ b/Source/audio/Effect.cpp @@ -17,11 +17,11 @@ Effect::Effect(EffectApplicationType application, const std::vector{parameter}) {} -Effect::Effect(const std::vector& parameters) : Effect([](int index, Point input, const std::vector>& values, double sampleRate) {return input;}, parameters) {} +Effect::Effect(const std::vector& parameters) : Effect([](int index, OsciPoint input, const std::vector>& values, double sampleRate) {return input;}, parameters) {} -Effect::Effect(EffectParameter* parameter) : Effect([](int index, Point input, const std::vector>& values, double sampleRate) {return input;}, parameter) {} +Effect::Effect(EffectParameter* parameter) : Effect([](int index, OsciPoint input, const std::vector>& values, double sampleRate) {return input;}, parameter) {} -Point Effect::apply(int index, Point input, double volume) { +OsciPoint Effect::apply(int index, OsciPoint input, double volume) { animateValues(volume); if (application) { return application(index, input, actualValues, sampleRate); @@ -94,7 +94,7 @@ float Effect::nextPhase(EffectParameter* parameter) { } void Effect::apply() { - apply(0, Point()); + apply(0, OsciPoint()); } double Effect::getValue(int index) { diff --git a/Source/audio/Effect.h b/Source/audio/Effect.h index 2d8cf5cf..957972e2 100644 --- a/Source/audio/Effect.h +++ b/Source/audio/Effect.h @@ -1,11 +1,11 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "EffectApplication.h" #include "EffectParameter.h" #include "BooleanParameter.h" -typedef std::function>& values, double sampleRate)> EffectApplicationType; +typedef std::function>& values, double sampleRate)> EffectApplicationType; class Effect { public: @@ -16,7 +16,7 @@ public: Effect(const std::vector& parameters); Effect(EffectParameter* parameter); - Point apply(int index, Point input, double volume = 0.0); + OsciPoint apply(int index, OsciPoint input, double volume = 0.0); void apply(); double getValue(int index); diff --git a/Source/audio/EffectApplication.h b/Source/audio/EffectApplication.h index 60691379..398f98cc 100644 --- a/Source/audio/EffectApplication.h +++ b/Source/audio/EffectApplication.h @@ -1,12 +1,12 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include class EffectApplication { public: EffectApplication() {}; - virtual Point apply(int index, Point input, const std::vector>& values, double sampleRate) = 0; + virtual OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) = 0; void resetPhase(); double nextPhase(double frequency, double sampleRate); diff --git a/Source/audio/EffectParameter.h b/Source/audio/EffectParameter.h index bb074c1a..e27827de 100644 --- a/Source/audio/EffectParameter.h +++ b/Source/audio/EffectParameter.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "BooleanParameter.h" diff --git a/Source/audio/PerspectiveEffect.cpp b/Source/audio/PerspectiveEffect.cpp index 9820641d..b3aa043e 100644 --- a/Source/audio/PerspectiveEffect.cpp +++ b/Source/audio/PerspectiveEffect.cpp @@ -7,7 +7,7 @@ PerspectiveEffect::PerspectiveEffect() {} PerspectiveEffect::~PerspectiveEffect() {} -Point PerspectiveEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint PerspectiveEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { auto effectScale = values[0].load(); auto focalLength = juce::jmax(values[1].load(), 0.001); @@ -18,7 +18,7 @@ Point PerspectiveEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: diff --git a/Source/audio/PitchDetector.h b/Source/audio/PitchDetector.h index e2f96dc6..5e745a15 100644 --- a/Source/audio/PitchDetector.h +++ b/Source/audio/PitchDetector.h @@ -22,7 +22,7 @@ private: juce::CriticalSection consumerLock; std::shared_ptr consumer; - std::vector buffer = std::vector(fftSize); + std::vector buffer = std::vector(fftSize); juce::dsp::FFT forwardFFT{fftOrder}; std::array fftData; OscirenderAudioProcessor& audioProcessor; diff --git a/Source/audio/ShapeVoice.cpp b/Source/audio/ShapeVoice.cpp index 5e75e3d1..a5876629 100644 --- a/Source/audio/ShapeVoice.cpp +++ b/Source/audio/ShapeVoice.cpp @@ -96,7 +96,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star double proportionalLength = (traceMax - traceMin) * frameLength; lengthIncrement = juce::jmax(proportionalLength / (audioProcessor.currentSampleRate / actualFrequency), MIN_LENGTH_INCREMENT); - Point channels; + OsciPoint channels; double x = 0.0; double y = 0.0; double z = 0.0; diff --git a/Source/audio/SmoothEffect.cpp b/Source/audio/SmoothEffect.cpp index f81ab135..e0d4e7fe 100644 --- a/Source/audio/SmoothEffect.cpp +++ b/Source/audio/SmoothEffect.cpp @@ -4,7 +4,7 @@ SmoothEffect::SmoothEffect() {} SmoothEffect::~SmoothEffect() {} -Point SmoothEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint SmoothEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { double weight = juce::jmax(values[0].load(), 0.00001); weight *= 0.95; double strength = 10; diff --git a/Source/audio/SmoothEffect.h b/Source/audio/SmoothEffect.h index 723946d8..95878db8 100644 --- a/Source/audio/SmoothEffect.h +++ b/Source/audio/SmoothEffect.h @@ -1,13 +1,13 @@ #pragma once #include "EffectApplication.h" -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" class SmoothEffect : public EffectApplication { public: SmoothEffect(); ~SmoothEffect(); - Point apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: - Point avg; + OsciPoint avg; }; diff --git a/Source/audio/VectorCancellingEffect.cpp b/Source/audio/VectorCancellingEffect.cpp index c41b68cc..0d9fdce6 100644 --- a/Source/audio/VectorCancellingEffect.cpp +++ b/Source/audio/VectorCancellingEffect.cpp @@ -4,7 +4,7 @@ VectorCancellingEffect::VectorCancellingEffect() {} VectorCancellingEffect::~VectorCancellingEffect() {} -Point VectorCancellingEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint VectorCancellingEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { double value = values[0]; if (value < 0.001) { return input; diff --git a/Source/audio/VectorCancellingEffect.h b/Source/audio/VectorCancellingEffect.h index a0ef1958..fac1d080 100644 --- a/Source/audio/VectorCancellingEffect.h +++ b/Source/audio/VectorCancellingEffect.h @@ -1,13 +1,13 @@ #pragma once #include "EffectApplication.h" -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" class VectorCancellingEffect : public EffectApplication { public: VectorCancellingEffect(); ~VectorCancellingEffect(); - Point apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: int lastIndex = 0; double nextInvert = 0; diff --git a/Source/audio/WobbleEffect.cpp b/Source/audio/WobbleEffect.cpp index 0067b2c9..3688f556 100644 --- a/Source/audio/WobbleEffect.cpp +++ b/Source/audio/WobbleEffect.cpp @@ -4,7 +4,7 @@ WobbleEffect::WobbleEffect(PitchDetector& pitchDetector) : pitchDetector(pitchDe WobbleEffect::~WobbleEffect() {} -Point WobbleEffect::apply(int index, Point input, const std::vector>& values, double sampleRate) { +OsciPoint WobbleEffect::apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) { // TODO: this doesn't consider sample rate smoothedFrequency = smoothedFrequency * 0.99995 + pitchDetector.frequency * 0.00005; double theta = nextPhase(smoothedFrequency, sampleRate); diff --git a/Source/audio/WobbleEffect.h b/Source/audio/WobbleEffect.h index c33086ba..35d72b40 100644 --- a/Source/audio/WobbleEffect.h +++ b/Source/audio/WobbleEffect.h @@ -1,6 +1,6 @@ #pragma once #include "EffectApplication.h" -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include "PitchDetector.h" class WobbleEffect : public EffectApplication { @@ -8,7 +8,7 @@ public: WobbleEffect(PitchDetector& pitchDetector); ~WobbleEffect(); - Point apply(int index, Point input, const std::vector>& values, double sampleRate) override; + OsciPoint apply(int index, OsciPoint input, const std::vector>& values, double sampleRate) override; private: PitchDetector& pitchDetector; diff --git a/Source/components/VisualiserComponent.cpp b/Source/components/VisualiserComponent.cpp index dcf7a3f4..a68e73b3 100644 --- a/Source/components/VisualiserComponent.cpp +++ b/Source/components/VisualiserComponent.cpp @@ -90,7 +90,7 @@ void VisualiserComponent::mouseDoubleClick(const juce::MouseEvent& event) { enableFullScreen(); } -void VisualiserComponent::setBuffer(std::vector& newBuffer) { +void VisualiserComponent::setBuffer(std::vector& newBuffer) { juce::CriticalSection::ScopedLockType scope(lock); if (!oldVisualiser) { openGLVisualiser.updateBuffer(newBuffer); @@ -246,7 +246,7 @@ void VisualiserComponent::paintXY(juce::Graphics& g, juce::Rectangle area void VisualiserComponent::resetBuffer() { sampleRate = (int) sampleRateManager.getSampleRate(); - tempBuffer = std::vector(sampleRate * BUFFER_LENGTH_SECS); + tempBuffer = std::vector(sampleRate * BUFFER_LENGTH_SECS); } void VisualiserComponent::toggleRecording() { diff --git a/Source/components/VisualiserComponent.h b/Source/components/VisualiserComponent.h index 1534384b..c4a43960 100644 --- a/Source/components/VisualiserComponent.h +++ b/Source/components/VisualiserComponent.h @@ -29,7 +29,7 @@ public: void enableFullScreen(); void setFullScreenCallback(std::function callback); void mouseDoubleClick(const juce::MouseEvent& event) override; - void setBuffer(std::vector& buffer); + void setBuffer(std::vector& buffer); void setColours(juce::Colour backgroundColour, juce::Colour waveformColour); void paintXY(juce::Graphics&, juce::Rectangle bounds); void paint(juce::Graphics&) override; @@ -67,7 +67,7 @@ private: bool visualiserOnly; juce::CriticalSection lock; - std::vector buffer; + std::vector buffer; std::vector> prevLines; juce::Colour backgroundColour, waveformColour; SampleRateManager& sampleRateManager; @@ -80,7 +80,7 @@ private: SvgButton popOutButton{ "popOut", BinaryData::open_in_new_svg, juce::Colours::white, juce::Colours::white }; SvgButton settingsButton{ "settings", BinaryData::cog_svg, juce::Colours::white, juce::Colours::white }; - std::vector tempBuffer; + std::vector tempBuffer; int precision = 4; juce::CriticalSection consumerLock; diff --git a/Source/components/VisualiserOpenGLComponent.cpp b/Source/components/VisualiserOpenGLComponent.cpp index 51b15689..fa0986c4 100644 --- a/Source/components/VisualiserOpenGLComponent.cpp +++ b/Source/components/VisualiserOpenGLComponent.cpp @@ -303,9 +303,11 @@ void VisualiserOpenGLComponent::openGLContextClosing() { outputShader.reset(); } -void VisualiserOpenGLComponent::updateBuffer(std::vector& buffer) { +void VisualiserOpenGLComponent::updateBuffer(std::vector& buffer) { juce::CriticalSection::ScopedLockType lock(samplesLock); + int newResampledSize = buffer.size() * RESAMPLE_RATIO + 1; + if (samples.size() != buffer.size()) { needsReattach = true; } @@ -313,6 +315,12 @@ void VisualiserOpenGLComponent::updateBuffer(std::vector& buffer) { for (auto& point : buffer) { samples.push_back(point); } + + if (sampleRate != sampleRateManager.getSampleRate()) { + sampleRate = sampleRateManager.getSampleRate(); + resampler.prepare(sampleRate, RESAMPLE_RATIO); + } + juce::MessageManager::getInstance()->callAsync([this] { if (needsReattach) { openGLContext.detach(); @@ -444,7 +452,7 @@ Texture VisualiserOpenGLComponent::makeTexture(int width, int height) { return { textureID, width, height }; } -void VisualiserOpenGLComponent::drawLineTexture(std::vector& points) { +void VisualiserOpenGLComponent::drawLineTexture(std::vector& points) { using namespace juce::gl; fadeAmount = juce::jmin(1.0, std::pow(0.5, settings.getPersistence()) * 0.4); @@ -573,7 +581,7 @@ void VisualiserOpenGLComponent::setNormalBlending() { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -void VisualiserOpenGLComponent::drawLine(std::vector& points) { +void VisualiserOpenGLComponent::drawLine(std::vector& points) { using namespace juce::gl; setAdditiveBlending(); diff --git a/Source/components/VisualiserOpenGLComponent.h b/Source/components/VisualiserOpenGLComponent.h index 60fe30cf..e295b0a8 100644 --- a/Source/components/VisualiserOpenGLComponent.h +++ b/Source/components/VisualiserOpenGLComponent.h @@ -3,6 +3,7 @@ #include #include "VisualiserSettings.h" #include "../audio/SampleRateManager.h" +#include "../shape/OsciPoint.h" struct Texture { GLuint id; @@ -20,7 +21,7 @@ public: void openGLContextClosing() override; void resized() override; void paint(juce::Graphics& g) override; - void updateBuffer(std::vector& buffer); + void updateBuffer(std::vector& buffer); void setPaused(bool paused); private: @@ -37,7 +38,13 @@ private: juce::CriticalSection samplesLock; bool needsReattach = true; - std::vector samples = std::vector(2); + std::vector samples = std::vector(2); + std::vector xSamples; + std::vector ySamples; + std::vector zSamples; + std::vector smoothedXSamples; + std::vector smoothedYSamples; + std::vector smoothedZSamples; std::vector scratchVertices; std::vector fullScreenQuad; @@ -69,17 +76,21 @@ private: bool paused = false; + const double RESAMPLE_RATIO = 6.0; + double sampleRate = -1; + chowdsp::ResamplingTypes::LanczosResampler<4096, 8> resampler; + Texture makeTexture(int width, int height); void setupArrays(int num_points); void setupTextures(); - void drawLineTexture(std::vector& points); + void drawLineTexture(std::vector& points); void saveTextureToFile(GLuint textureID, int width, int height, const juce::File& file); void activateTargetTexture(std::optional texture); void setShader(juce::OpenGLShaderProgram* program); void drawTexture(std::optional texture0, std::optional texture1 = std::nullopt, std::optional texture2 = std::nullopt, std::optional texture3 = std::nullopt); void setAdditiveBlending(); void setNormalBlending(); - void drawLine(std::vector& points); + void drawLine(std::vector& points); void fade(); void drawCRT(); void checkGLErrors(const juce::String& location); diff --git a/Source/components/VolumeComponent.cpp b/Source/components/VolumeComponent.cpp index e4053907..bce1c857 100644 --- a/Source/components/VolumeComponent.cpp +++ b/Source/components/VolumeComponent.cpp @@ -149,5 +149,5 @@ void VolumeComponent::resized() { void VolumeComponent::resetBuffer() { sampleRate = (int) audioProcessor.currentSampleRate; - buffer = std::vector(BUFFER_DURATION_SECS * sampleRate); + buffer = std::vector(BUFFER_DURATION_SECS * sampleRate); } diff --git a/Source/components/VolumeComponent.h b/Source/components/VolumeComponent.h index 81cd02bb..d5244234 100644 --- a/Source/components/VolumeComponent.h +++ b/Source/components/VolumeComponent.h @@ -76,7 +76,7 @@ private: const double BUFFER_DURATION_SECS = 0.02; int sampleRate = DEFAULT_SAMPLE_RATE; - std::vector buffer = std::vector(BUFFER_DURATION_SECS * DEFAULT_SAMPLE_RATE); + std::vector buffer = std::vector(BUFFER_DURATION_SECS * DEFAULT_SAMPLE_RATE); std::atomic leftVolume = 0; std::atomic rightVolume = 0; diff --git a/Source/concurrency/BufferConsumer.h b/Source/concurrency/BufferConsumer.h index 9a8bbb9a..b70430f2 100644 --- a/Source/concurrency/BufferConsumer.h +++ b/Source/concurrency/BufferConsumer.h @@ -1,7 +1,7 @@ #pragma once #include -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include @@ -42,7 +42,7 @@ public: class BufferConsumer { public: - BufferConsumer(std::vector& buffer) : buffer(buffer) {} + BufferConsumer(std::vector& buffer) : buffer(buffer) {} ~BufferConsumer() {} @@ -62,14 +62,14 @@ public: sema.release(); } - void write(Point point) { + void write(OsciPoint point) { if (offset < buffer.size()) { buffer[offset++] = point; } } private: - std::vector& buffer; + std::vector& buffer; Semaphore sema{0}; int offset = 0; }; diff --git a/Source/concurrency/ConsumerManager.h b/Source/concurrency/ConsumerManager.h index 99a09c4a..f40e0257 100644 --- a/Source/concurrency/ConsumerManager.h +++ b/Source/concurrency/ConsumerManager.h @@ -1,7 +1,7 @@ #pragma once #include -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include "BufferConsumer.h" @@ -10,7 +10,7 @@ public: ConsumerManager() {} ~ConsumerManager() {} - std::shared_ptr consumerRegister(std::vector& buffer) { + std::shared_ptr consumerRegister(std::vector& buffer) { std::shared_ptr consumer = std::make_shared(buffer); juce::SpinLock::ScopedLockType scope(consumerLock); consumers.push_back(consumer); diff --git a/Source/gpla/LineArtParser.cpp b/Source/gpla/LineArtParser.cpp index eb71f32a..777a8bd9 100644 --- a/Source/gpla/LineArtParser.cpp +++ b/Source/gpla/LineArtParser.cpp @@ -101,20 +101,20 @@ std::vector> LineArtParser::draw() { std::vector LineArtParser::generateFrame(juce::Array objects, double focalLength) { std::vector> allMatrices; - std::vector>> allVertices; + std::vector>> allVertices; for (int i = 0; i < objects.size(); i++) { auto verticesArray = *objects[i].getProperty("vertices", juce::Array()).getArray(); - std::vector> vertices; + std::vector> vertices; for (auto& vertexArrayVar : verticesArray) { - vertices.push_back(std::vector()); + vertices.push_back(std::vector()); auto& vertexArray = *vertexArrayVar.getArray(); for (auto& vertex : vertexArray) { double x = vertex.getProperty("x", 0); double y = vertex.getProperty("y", 0); double z = vertex.getProperty("z", 0); - vertices[vertices.size() - 1].push_back(Point(x, y, z)); + vertices[vertices.size() - 1].push_back(OsciPoint(x, y, z)); } } auto matrix = *objects[i].getProperty("matrix", juce::Array()).getArray(); @@ -124,7 +124,7 @@ std::vector LineArtParser::generateFrame(juce::Array objects, allMatrices[i].push_back(value); } - std::vector> reorderedVertices; + std::vector> reorderedVertices; if (vertices.size() > 0 && matrix.size() == 16) { std::vector visited = std::vector(vertices.size(), false); @@ -157,7 +157,7 @@ std::vector LineArtParser::generateFrame(juce::Array objects, } for (int i = 0; i < vertices.size(); i++) { - std::vector reorderedVertex; + std::vector reorderedVertex; int index = order[i]; for (int j = 0; j < vertices[index].size(); j++) { reorderedVertex.push_back(vertices[index][j]); @@ -203,4 +203,4 @@ std::vector LineArtParser::generateFrame(juce::Array objects, } } return frame; -} \ No newline at end of file +} diff --git a/Source/gpla/LineArtParser.h b/Source/gpla/LineArtParser.h index d2d99e5f..62c83837 100644 --- a/Source/gpla/LineArtParser.h +++ b/Source/gpla/LineArtParser.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "../shape/Shape.h" #include "../svg/SvgParser.h" @@ -19,4 +19,4 @@ private: int frameNumber = 0; std::vector> frames; int numFrames = 0; -}; \ No newline at end of file +}; diff --git a/Source/img/ImageParser.cpp b/Source/img/ImageParser.cpp index 7b9b428a..33d76946 100644 --- a/Source/img/ImageParser.cpp +++ b/Source/img/ImageParser.cpp @@ -146,7 +146,7 @@ void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int findWhite(thresholdPow, invert); } -Point ImageParser::getSample() { +OsciPoint ImageParser::getSample() { if (count % jumpFrequency() == 0) { resetPosition(); } @@ -162,5 +162,5 @@ Point ImageParser::getSample() { count++; float widthDiff = (maxDim - width) / 2; float heightDiff = (maxDim - height) / 2; - return Point(2 * (currentX + widthDiff) / maxDim - 1, 2 * (currentY + heightDiff) / maxDim - 1); + return OsciPoint(2 * (currentX + widthDiff) / maxDim - 1, 2 * (currentY + heightDiff) / maxDim - 1); } diff --git a/Source/img/ImageParser.h b/Source/img/ImageParser.h index 22591105..8c089402 100644 --- a/Source/img/ImageParser.h +++ b/Source/img/ImageParser.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "../shape/Shape.h" #include "../svg/SvgParser.h" @@ -12,7 +12,7 @@ public: ~ImageParser(); void setFrame(int index); - Point getSample(); + OsciPoint getSample(); private: void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert); diff --git a/Source/lua/LuaParser.cpp b/Source/lua/LuaParser.cpp index a996d5a4..3b9eeb15 100644 --- a/Source/lua/LuaParser.cpp +++ b/Source/lua/LuaParser.cpp @@ -24,7 +24,7 @@ void LuaParser::resetMaximumInstructions(lua_State*& L) { lua_sethook(L, LuaParser::maximumInstructionsReached, 0, 0); } -static int pointToTable(lua_State* L, Point point, int numDims) { +static int pointToTable(lua_State* L, OsciPoint point, int numDims) { lua_newtable(L); if (numDims == 1) { lua_pushnumber(L, point.x); @@ -46,8 +46,8 @@ static int pointToTable(lua_State* L, Point point, int numDims) { return 1; } -static Point tableToPoint(lua_State* L, int index) { - Point point; +static OsciPoint tableToPoint(lua_State* L, int index) { + OsciPoint point; lua_pushinteger(L, 1); lua_gettable(L, index); point.x = lua_tonumber(L, -1); @@ -70,16 +70,16 @@ static int luaLine(lua_State* L) { int nargs = lua_gettop(L); double t = lua_tonumber(L, 1) / juce::MathConstants::twoPi; - Point point1 = nargs == 3 ? tableToPoint(L, 2) : Point(-1, -1); - Point point2 = nargs == 3 ? tableToPoint(L, 3) : Point(1, 1); + OsciPoint point1 = nargs == 3 ? tableToPoint(L, 2) : OsciPoint(-1, -1); + OsciPoint point2 = nargs == 3 ? tableToPoint(L, 3) : OsciPoint(1, 1); Line line = Line(point1, point2); - Point point = line.nextVector(t); + OsciPoint point = line.nextVector(t); return pointToTable(L, point, 3); } -static Point genericRect(double phase, Point topLeft, double width, double height) { +static OsciPoint genericRect(double phase, OsciPoint topLeft, double width, double height) { double t = phase / juce::MathConstants::twoPi; double totalLength = 2 * (width + height); double progress = t * totalLength; @@ -113,8 +113,8 @@ static int luaRect(lua_State* L) { double width = nargs == 1 ? 1 : lua_tonumber(L, 2); double height = nargs == 1 ? 1.5 : lua_tonumber(L, 3); - Point topLeft = nargs == 4 ? tableToPoint(L, 4) : Point(-width / 2, -height / 2); - Point point = genericRect(phase, topLeft, width, height); + OsciPoint topLeft = nargs == 4 ? tableToPoint(L, 4) : OsciPoint(-width / 2, -height / 2); + OsciPoint point = genericRect(phase, topLeft, width, height); return pointToTable(L, point, 2); } @@ -125,8 +125,8 @@ static int luaSquare(lua_State* L) { double phase = lua_tonumber(L, 1); double width = nargs == 1 ? 1 : lua_tonumber(L,2); - Point topLeft = nargs == 3 ? tableToPoint(L, 3) : Point(-width / 2, -width / 2); - Point point = genericRect(phase, topLeft, width, width); + OsciPoint topLeft = nargs == 3 ? tableToPoint(L, 3) : OsciPoint(-width / 2, -width / 2); + OsciPoint point = genericRect(phase, topLeft, width, width); return pointToTable(L, point, 2); } @@ -139,7 +139,7 @@ static int luaEllipse(lua_State* L) { double radiuxY = nargs == 1 ? 0.8 : lua_tonumber(L, 3); CircleArc ellipse = CircleArc(0, 0, radiusX, radiuxY, 0, juce::MathConstants::twoPi); - Point point = ellipse.nextVector(t); + OsciPoint point = ellipse.nextVector(t); return pointToTable(L, point, 2); } @@ -151,7 +151,7 @@ static int luaCircle(lua_State* L) { double radius = nargs == 1 ? 0.8 : lua_tonumber(L, 2); CircleArc ellipse = CircleArc(0, 0, radius, radius, 0, juce::MathConstants::twoPi); - Point point = ellipse.nextVector(t); + OsciPoint point = ellipse.nextVector(t); return pointToTable(L, point, 2); } @@ -166,7 +166,7 @@ static int luaArc(lua_State* L) { double endAngle = nargs == 1 ? juce::MathConstants::halfPi : lua_tonumber(L, 5); CircleArc arc = CircleArc(0, 0, radiusX, radiusY, startAngle, endAngle); - Point point = arc.nextVector(t); + OsciPoint point = arc.nextVector(t); return pointToTable(L, point, 2); } @@ -188,21 +188,21 @@ static int luaPolygon(lua_State* L) { double x = cos(pi_n) * inner_cos - multiplier * sin(pi_n) * inner_sin; double y = cos(pi_n) * inner_sin + multiplier * sin(pi_n) * inner_cos; - return pointToTable(L, Point(x, y), 2); + return pointToTable(L, OsciPoint(x, y), 2); } static int luaBezier(lua_State* L) { int nargs = lua_gettop(L); double t = lua_tonumber(L, 1) / juce::MathConstants::twoPi; - Point point1 = nargs == 1 ? Point(-1, -1) : tableToPoint(L, 2); - Point point2 = nargs == 1 ? Point(-1, 1) : tableToPoint(L, 3); - Point point3 = nargs == 1 ? Point(1, 1) : tableToPoint(L, 4); + OsciPoint point1 = nargs == 1 ? OsciPoint(-1, -1) : tableToPoint(L, 2); + OsciPoint point2 = nargs == 1 ? OsciPoint(-1, 1) : tableToPoint(L, 3); + OsciPoint point3 = nargs == 1 ? OsciPoint(1, 1) : tableToPoint(L, 4); - Point point; + OsciPoint point; if (nargs == 5) { - Point point4 = tableToPoint(L, 5); + OsciPoint point4 = tableToPoint(L, 5); CubicBezierCurve curve = CubicBezierCurve(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y, point4.x, point4.y); point = curve.nextVector(t); @@ -226,7 +226,7 @@ static int luaLissajous(lua_State* L) { double x = radius * sin(ratioA * phase); double y = radius * cos(ratioB * phase + theta); - return pointToTable(L, Point(x, y), 2); + return pointToTable(L, OsciPoint(x, y), 2); } static double squareWave(double phase) { @@ -265,11 +265,11 @@ static int luaTriangleWave(lua_State* L) { static int luaMix(lua_State* L) { int nargs = lua_gettop(L); - Point point1 = tableToPoint(L, 1); - Point point2 = tableToPoint(L, 2); + OsciPoint point1 = tableToPoint(L, 1); + OsciPoint point2 = tableToPoint(L, 2); double weight = lua_tonumber(L, 3); - Point point = Point( + OsciPoint point = OsciPoint( point1.x * (1 - weight) + point2.x * weight, point1.y * (1 - weight) + point2.y * weight, point1.z * (1 - weight) + point2.z * weight @@ -279,8 +279,8 @@ static int luaMix(lua_State* L) { } static int luaTranslate(lua_State* L) { - Point point = tableToPoint(L, 1); - Point translation = tableToPoint(L, 2); + OsciPoint point = tableToPoint(L, 1); + OsciPoint translation = tableToPoint(L, 2); point.translate(translation.x, translation.y, translation.z); @@ -288,8 +288,8 @@ static int luaTranslate(lua_State* L) { } static int luaScale(lua_State* L) { - Point point = tableToPoint(L, 1); - Point scale = tableToPoint(L, 2); + OsciPoint point = tableToPoint(L, 1); + OsciPoint scale = tableToPoint(L, 2); point.scale(scale.x, scale.y, scale.z); @@ -300,17 +300,17 @@ static int luaRotate(lua_State* L) { double nargs = lua_gettop(L); bool twoDimRotate = nargs == 2; - Point point; + OsciPoint point; if (twoDimRotate) { - Point point = tableToPoint(L, 1); + OsciPoint point = tableToPoint(L, 1); double angle = lua_tonumber(L, 2); point.rotate(0, 0, angle); return pointToTable(L, point, 2); } else { - Point point = tableToPoint(L, 1); + OsciPoint point = tableToPoint(L, 1); double xRotate = lua_tonumber(L, 2); double yRotate = lua_tonumber(L, 3); double zRotate = lua_tonumber(L, 4); diff --git a/Source/parser/FileParser.cpp b/Source/parser/FileParser.cpp index 568b3236..7ac33e95 100644 --- a/Source/parser/FileParser.cpp +++ b/Source/parser/FileParser.cpp @@ -56,22 +56,22 @@ std::vector> FileParser::nextFrame() { } auto tempShapes = std::vector>(); // return a square - tempShapes.push_back(std::make_unique(Point(-0.5, -0.5, 0), Point(0.5, -0.5, 0))); - tempShapes.push_back(std::make_unique(Point(0.5, -0.5, 0), Point(0.5, 0.5, 0))); - tempShapes.push_back(std::make_unique(Point(0.5, 0.5, 0), Point(-0.5, 0.5, 0))); - tempShapes.push_back(std::make_unique(Point(-0.5, 0.5, 0), Point(-0.5, -0.5, 0))); + tempShapes.push_back(std::make_unique(OsciPoint(-0.5, -0.5, 0), OsciPoint(0.5, -0.5, 0))); + tempShapes.push_back(std::make_unique(OsciPoint(0.5, -0.5, 0), OsciPoint(0.5, 0.5, 0))); + tempShapes.push_back(std::make_unique(OsciPoint(0.5, 0.5, 0), OsciPoint(-0.5, 0.5, 0))); + tempShapes.push_back(std::make_unique(OsciPoint(-0.5, 0.5, 0), OsciPoint(-0.5, -0.5, 0))); return tempShapes; } -Point FileParser::nextSample(lua_State*& L, LuaVariables& vars) { +OsciPoint FileParser::nextSample(lua_State*& L, LuaVariables& vars) { juce::SpinLock::ScopedLockType scope(lock); if (lua != nullptr) { auto values = lua->run(L, vars); if (values.size() == 2) { - return Point(values[0], values[1], 0); + return OsciPoint(values[0], values[1], 0); } else if (values.size() > 2) { - return Point(values[0], values[1], values[2]); + return OsciPoint(values[0], values[1], values[2]); } } else if (img != nullptr) { return img->getSample(); @@ -79,7 +79,7 @@ Point FileParser::nextSample(lua_State*& L, LuaVariables& vars) { return wav->getSample(); } - return Point(); + return OsciPoint(); } void FileParser::closeLua(lua_State*& L) { diff --git a/Source/parser/FileParser.h b/Source/parser/FileParser.h index 5755fc7d..88a59d8f 100644 --- a/Source/parser/FileParser.h +++ b/Source/parser/FileParser.h @@ -17,7 +17,7 @@ public: void parse(juce::String fileName, juce::String extension, std::unique_ptr stream, juce::Font font); std::vector> nextFrame(); - Point nextSample(lua_State*& L, LuaVariables& vars); + OsciPoint nextSample(lua_State*& L, LuaVariables& vars); void closeLua(lua_State*& L); bool isSample(); bool isActive(); diff --git a/Source/parser/FrameSource.h b/Source/parser/FrameSource.h index fda90b9b..7b15ada1 100644 --- a/Source/parser/FrameSource.h +++ b/Source/parser/FrameSource.h @@ -8,9 +8,9 @@ class FrameSource { public: virtual std::vector> nextFrame() = 0; - virtual Point nextSample() = 0; + virtual OsciPoint nextSample() = 0; virtual bool isSample() = 0; virtual bool isActive() = 0; virtual void disable() = 0; virtual void enable() = 0; -}; \ No newline at end of file +}; diff --git a/Source/shape/CircleArc.cpp b/Source/shape/CircleArc.cpp index 5a490a85..ee7fa17e 100644 --- a/Source/shape/CircleArc.cpp +++ b/Source/shape/CircleArc.cpp @@ -4,10 +4,10 @@ CircleArc::CircleArc(double x, double y, double radiusX, double radiusY, double startAngle, double endAngle) : x(x), y(y), radiusX(radiusX), radiusY(radiusY), startAngle(startAngle), endAngle(endAngle) {} -Point CircleArc::nextVector(double drawingProgress) { +OsciPoint CircleArc::nextVector(double drawingProgress) { // scale between start and end angle in the positive direction double angle = startAngle + endAngle * drawingProgress; - return Point( + return OsciPoint( x + radiusX * std::cos(angle), y + radiusY * std::sin(angle) ); @@ -30,8 +30,8 @@ double CircleArc::length() { len = 0; // TODO: Replace this, it's stupid. Do a real approximation. int segments = 5; - Point start; - Point end = nextVector(0); + OsciPoint start; + OsciPoint end = nextVector(0); for (int i = 0; i < segments; i++) { start = end; end = nextVector((i + 1) / (double) segments); diff --git a/Source/shape/CircleArc.h b/Source/shape/CircleArc.h index 0a12e679..1f63c568 100644 --- a/Source/shape/CircleArc.h +++ b/Source/shape/CircleArc.h @@ -1,13 +1,13 @@ #pragma once #include "Shape.h" -#include "Point.h" +#include "OsciPoint.h" class CircleArc : public Shape { public: CircleArc(double x, double y, double radiusX, double radiusY, double startAngle, double endAngle); - Point nextVector(double drawingProgress) override; + OsciPoint nextVector(double drawingProgress) override; void scale(double x, double y, double z) override; void translate(double x, double y, double z) override; double length() override; @@ -16,4 +16,4 @@ public: double x, y, radiusX, radiusY, startAngle, endAngle; -}; \ No newline at end of file +}; diff --git a/Source/shape/CubicBezierCurve.cpp b/Source/shape/CubicBezierCurve.cpp index cd082b2e..65d8416c 100644 --- a/Source/shape/CubicBezierCurve.cpp +++ b/Source/shape/CubicBezierCurve.cpp @@ -2,7 +2,7 @@ CubicBezierCurve::CubicBezierCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) : x1(x1), y1(y1), x2(x2), y2(y2), x3(x3), y3(y3), x4(x4), y4(y4) {} -Point CubicBezierCurve::nextVector(double t) { +OsciPoint CubicBezierCurve::nextVector(double t) { double pow1 = pow(1 - t, 3); double pow2 = pow(1 - t, 2); double pow3 = pow(t, 2); @@ -11,7 +11,7 @@ Point CubicBezierCurve::nextVector(double t) { double x = pow1 * x1 + 3 * pow2 * t * x2 + 3 * (1 - t) * pow3 * x3 + pow4 * x4; double y = pow1 * y1 + 3 * pow2 * t * y2 + 3 * (1 - t) * pow3 * y3 + pow4 * y4; - return Point(x, y); + return OsciPoint(x, y); } void CubicBezierCurve::scale(double x, double y, double z) { diff --git a/Source/shape/CubicBezierCurve.h b/Source/shape/CubicBezierCurve.h index 8d63f0e2..73236971 100644 --- a/Source/shape/CubicBezierCurve.h +++ b/Source/shape/CubicBezierCurve.h @@ -1,13 +1,13 @@ #pragma once #include "Shape.h" -#include "Point.h" +#include "OsciPoint.h" class CubicBezierCurve : public Shape { public: CubicBezierCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); - Point nextVector(double drawingProgress) override; + OsciPoint nextVector(double drawingProgress) override; void scale(double x, double y, double z) override; void translate(double x, double y, double z) override; double length() override; @@ -16,4 +16,4 @@ public: double x1, y1, x2, y2, x3, y3, x4, y4; -}; \ No newline at end of file +}; diff --git a/Source/shape/Line.cpp b/Source/shape/Line.cpp index dc812db9..a97fab03 100644 --- a/Source/shape/Line.cpp +++ b/Source/shape/Line.cpp @@ -4,10 +4,10 @@ Line::Line(double x1, double y1, double x2, double y2) : x1(x1), y1(y1), z1(0), Line::Line(double x1, double y1, double z1, double x2, double y2, double z2) : x1(x1), y1(y1), z1(z1), x2(x2), y2(y2), z2(z2) {} -Line::Line(Point p1, Point p2) : x1(p1.x), y1(p1.y), z1(p1.z), x2(p2.x), y2(p2.y), z2(p2.z) {} +Line::Line(OsciPoint p1, OsciPoint p2) : x1(p1.x), y1(p1.y), z1(p1.z), x2(p2.x), y2(p2.y), z2(p2.z) {} -Point Line::nextVector(double drawingProgress) { - return Point( +OsciPoint Line::nextVector(double drawingProgress) { + return OsciPoint( x1 + (x2 - x1) * drawingProgress, y1 + (y2 - y1) * drawingProgress, z1 + (z2 - z1) * drawingProgress diff --git a/Source/shape/Line.h b/Source/shape/Line.h index e55286ac..293aeaab 100644 --- a/Source/shape/Line.h +++ b/Source/shape/Line.h @@ -1,15 +1,15 @@ #pragma once #include "Shape.h" -#include "Point.h" +#include "OsciPoint.h" class Line : public Shape { public: Line(double x1, double y1, double x2, double y2); Line(double x1, double y1, double z1, double x2, double y2, double z2); - Line(Point p1, Point p2); + Line(OsciPoint p1, OsciPoint p2); - Point nextVector(double drawingProgress) override; + OsciPoint nextVector(double drawingProgress) override; void scale(double x, double y, double z) override; void translate(double x, double y, double z) override; static double length(double x1, double y1, double z1, double x2, double y2, double z2); @@ -20,4 +20,4 @@ public: double x1, y1, z1, x2, y2, z2; -}; \ No newline at end of file +}; diff --git a/Source/shape/OsciPoint.cpp b/Source/shape/OsciPoint.cpp new file mode 100644 index 00000000..fb51fff5 --- /dev/null +++ b/Source/shape/OsciPoint.cpp @@ -0,0 +1,127 @@ +#include "OsciPoint.h" + +double OsciPoint::EPSILON = 0.0001; + +OsciPoint::OsciPoint() : x(0), y(0), z(0) {} + +OsciPoint::OsciPoint(double val) : x(val), y(val), z(0) {} + +OsciPoint::OsciPoint(double x, double y) : x(x), y(y), z(0) {} + +OsciPoint::OsciPoint(double x, double y, double z) : x(x), y(y), z(z) {} + +OsciPoint OsciPoint::nextVector(double drawingProgress){ + return OsciPoint(x, y, z); +} + +void OsciPoint::rotate(double rotateX, double rotateY, double rotateZ) { + // rotate around x-axis + double cosValue = std::cos(rotateX); + double sinValue = std::sin(rotateX); + double y2 = cosValue * y - sinValue * z; + double z2 = sinValue * y + cosValue * z; + + // rotate around y-axis + cosValue = std::cos(rotateY); + sinValue = std::sin(rotateY); + double x2 = cosValue * x + sinValue * z2; + z = -sinValue * x + cosValue * z2; + + // rotate around z-axis + cosValue = cos(rotateZ); + sinValue = sin(rotateZ); + x = cosValue * x2 - sinValue * y2; + y = sinValue * x2 + cosValue * y2; +} + +void OsciPoint::normalize() { + double mag = magnitude(); + x /= mag; + y /= mag; + z /= mag; +} + +double OsciPoint::innerProduct(OsciPoint& other) { + return x * other.x + y * other.y + z * other.z; +} + +void OsciPoint::scale(double x, double y, double z) { + this->x *= x; + this->y *= y; + this->z *= z; +} + +void OsciPoint::translate(double x, double y, double z) { + this->x += x; + this->y += y; + this->z += z; +} + +double OsciPoint::length() { + return 0.0; +} + +double OsciPoint::magnitude() { + return sqrt(x * x + y * y + z * z); +} + +std::unique_ptr OsciPoint::clone() { + return std::make_unique(x, y, z); +} + +std::string OsciPoint::type() { + return std::string(); +} + +OsciPoint& OsciPoint::operator=(const OsciPoint& other) { + x = other.x; + y = other.y; + z = other.z; + return *this; +} + +bool OsciPoint::operator==(const OsciPoint& other) { + return std::abs(x - other.x) < EPSILON && std::abs(y - other.y) < EPSILON && std::abs(z - other.z) < EPSILON; +} + +bool OsciPoint::operator!=(const OsciPoint& other) { + return !(*this == other); +} + +OsciPoint OsciPoint::operator+(const OsciPoint& other) { + return OsciPoint(x + other.x, y + other.y, z + other.z); +} + +OsciPoint OsciPoint::operator+(double scalar) { + return OsciPoint(x + scalar, y + scalar, z + scalar); +} + + + +OsciPoint OsciPoint::operator-(const OsciPoint& other) { + return OsciPoint(x - other.x, y - other.y, z - other.z); +} + +OsciPoint OsciPoint::operator-() { + return OsciPoint(-x, -y, -z); +} + +OsciPoint OsciPoint::operator*(const OsciPoint& other) { + return OsciPoint(x * other.x, y * other.y, z * other.z); +} + +OsciPoint OsciPoint::operator*(double scalar) { + return OsciPoint(x * scalar, y * scalar, z * scalar); +} + +std::string OsciPoint::toString() { + return std::string("(" + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + ")"); +} + +OsciPoint operator+(double scalar, const OsciPoint& point) { + return OsciPoint(point.x + scalar, point.y + scalar, point.z + scalar); +} + +OsciPoint operator*(double scalar, const OsciPoint& point) { + return OsciPoint(point.x * scalar, point.y * scalar, point.z * scalar); +} diff --git a/Source/shape/OsciPoint.h b/Source/shape/OsciPoint.h new file mode 100644 index 00000000..acd471c0 --- /dev/null +++ b/Source/shape/OsciPoint.h @@ -0,0 +1,43 @@ +#pragma once + +#include "Shape.h" +#include +#include + +class OsciPoint : public Shape { +public: + OsciPoint(double x, double y, double z); + OsciPoint(double x, double y); + OsciPoint(double val); + OsciPoint(); + + OsciPoint nextVector(double drawingProgress) override; + void scale(double x, double y, double z) override; + void translate(double x, double y, double z) override; + double length() override; + double magnitude(); + std::unique_ptr clone() override; + std::string type() override; + + void rotate(double rotateX, double rotateY, double rotateZ); + void normalize(); + double innerProduct(OsciPoint& other); + + std::string toString(); + + OsciPoint& operator=(const OsciPoint& other); + bool operator==(const OsciPoint& other); + bool operator!=(const OsciPoint& other); + OsciPoint operator+(const OsciPoint& other); + OsciPoint operator+(double scalar); + friend OsciPoint operator+(double scalar, const OsciPoint& point); + OsciPoint operator-(const OsciPoint& other); + OsciPoint operator-(); + OsciPoint operator*(const OsciPoint& other); + OsciPoint operator*(double scalar); + friend OsciPoint operator*(double scalar, const OsciPoint& point); + + double x, y, z; + + static double EPSILON; +}; diff --git a/Source/shape/Point.cpp b/Source/shape/Point.cpp deleted file mode 100644 index 5ef964a9..00000000 --- a/Source/shape/Point.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "Point.h" - -double Point::EPSILON = 0.0001; - -Point::Point() : x(0), y(0), z(0) {} - -Point::Point(double val) : x(val), y(val), z(0) {} - -Point::Point(double x, double y) : x(x), y(y), z(0) {} - -Point::Point(double x, double y, double z) : x(x), y(y), z(z) {} - -Point Point::nextVector(double drawingProgress){ - return Point(x, y, z); -} - -void Point::rotate(double rotateX, double rotateY, double rotateZ) { - // rotate around x-axis - double cosValue = std::cos(rotateX); - double sinValue = std::sin(rotateX); - double y2 = cosValue * y - sinValue * z; - double z2 = sinValue * y + cosValue * z; - - // rotate around y-axis - cosValue = std::cos(rotateY); - sinValue = std::sin(rotateY); - double x2 = cosValue * x + sinValue * z2; - z = -sinValue * x + cosValue * z2; - - // rotate around z-axis - cosValue = cos(rotateZ); - sinValue = sin(rotateZ); - x = cosValue * x2 - sinValue * y2; - y = sinValue * x2 + cosValue * y2; -} - -void Point::normalize() { - double mag = magnitude(); - x /= mag; - y /= mag; - z /= mag; -} - -double Point::innerProduct(Point& other) { - return x * other.x + y * other.y + z * other.z; -} - -void Point::scale(double x, double y, double z) { - this->x *= x; - this->y *= y; - this->z *= z; -} - -void Point::translate(double x, double y, double z) { - this->x += x; - this->y += y; - this->z += z; -} - -double Point::length() { - return 0.0; -} - -double Point::magnitude() { - return sqrt(x * x + y * y + z * z); -} - -std::unique_ptr Point::clone() { - return std::make_unique(x, y, z); -} - -std::string Point::type() { - return std::string(); -} - -Point& Point::operator=(const Point& other) { - x = other.x; - y = other.y; - z = other.z; - return *this; -} - -bool Point::operator==(const Point& other) { - return std::abs(x - other.x) < EPSILON && std::abs(y - other.y) < EPSILON && std::abs(z - other.z) < EPSILON; -} - -bool Point::operator!=(const Point& other) { - return !(*this == other); -} - -Point Point::operator+(const Point& other) { - return Point(x + other.x, y + other.y, z + other.z); -} - -Point Point::operator+(double scalar) { - return Point(x + scalar, y + scalar, z + scalar); -} - - - -Point Point::operator-(const Point& other) { - return Point(x - other.x, y - other.y, z - other.z); -} - -Point Point::operator-() { - return Point(-x, -y, -z); -} - -Point Point::operator*(const Point& other) { - return Point(x * other.x, y * other.y, z * other.z); -} - -Point Point::operator*(double scalar) { - return Point(x * scalar, y * scalar, z * scalar); -} - -std::string Point::toString() { - return std::string("(" + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + ")"); -} - -Point operator+(double scalar, const Point& point) { - return Point(point.x + scalar, point.y + scalar, point.z + scalar); -} - -Point operator*(double scalar, const Point& point) { - return Point(point.x * scalar, point.y * scalar, point.z * scalar); -} diff --git a/Source/shape/Point.h b/Source/shape/Point.h deleted file mode 100644 index d744196d..00000000 --- a/Source/shape/Point.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "Shape.h" -#include -#include - -class Point : public Shape { -public: - Point(double x, double y, double z); - Point(double x, double y); - Point(double val); - Point(); - - Point nextVector(double drawingProgress) override; - void scale(double x, double y, double z) override; - void translate(double x, double y, double z) override; - double length() override; - double magnitude(); - std::unique_ptr clone() override; - std::string type() override; - - void rotate(double rotateX, double rotateY, double rotateZ); - void normalize(); - double innerProduct(Point& other); - - std::string toString(); - - Point& operator=(const Point& other); - bool operator==(const Point& other); - bool operator!=(const Point& other); - Point operator+(const Point& other); - Point operator+(double scalar); - friend Point operator+(double scalar, const Point& point); - Point operator-(const Point& other); - Point operator-(); - Point operator*(const Point& other); - Point operator*(double scalar); - friend Point operator*(double scalar, const Point& point); - - double x, y, z; - - static double EPSILON; -}; \ No newline at end of file diff --git a/Source/shape/Shape.cpp b/Source/shape/Shape.cpp index 1437d400..378e8491 100644 --- a/Source/shape/Shape.cpp +++ b/Source/shape/Shape.cpp @@ -1,6 +1,6 @@ #include "Shape.h" #include "Line.h" -#include "Point.h" +#include "OsciPoint.h" double Shape::totalLength(std::vector>& shapes) { double length = 0.0; @@ -30,7 +30,7 @@ void Shape::normalize(std::vector>& shapes) { shape->scale(2.0 / maxDim, -2.0 / maxDim, 2.0 / maxDim); } - Point max = maxVector(shapes); + OsciPoint max = maxVector(shapes); double newHeight = height(shapes); for (auto& shape : shapes) { @@ -42,7 +42,7 @@ double Shape::height(std::vector>& shapes) { double maxY = std::numeric_limits::min(); double minY = std::numeric_limits::max(); - Point vectors[4]; + OsciPoint vectors[4]; for (auto& shape : shapes) { for (int i = 0; i < 4; i++) { @@ -62,7 +62,7 @@ double Shape::width(std::vector>& shapes) { double maxX = std::numeric_limits::min(); double minX = std::numeric_limits::max(); - Point vectors[4]; + OsciPoint vectors[4]; for (auto& shape : shapes) { for (int i = 0; i < 4; i++) { @@ -78,13 +78,13 @@ double Shape::width(std::vector>& shapes) { return std::abs(maxX - minX); } -Point Shape::maxVector(std::vector>& shapes) { +OsciPoint Shape::maxVector(std::vector>& shapes) { double maxX = std::numeric_limits::min(); double maxY = std::numeric_limits::min(); for (auto& shape : shapes) { - Point startVector = shape->nextVector(0); - Point endVector = shape->nextVector(1); + OsciPoint startVector = shape->nextVector(0); + OsciPoint endVector = shape->nextVector(1); double x = std::max(startVector.x, endVector.x); double y = std::max(startVector.y, endVector.y); @@ -93,22 +93,22 @@ Point Shape::maxVector(std::vector>& shapes) { maxY = std::max(y, maxY); } - return Point(maxX, maxY); + return OsciPoint(maxX, maxY); } void Shape::removeOutOfBounds(std::vector>& shapes) { std::vector toRemove; for (int i = 0; i < shapes.size(); i++) { - Point start = shapes[i]->nextVector(0); - Point end = shapes[i]->nextVector(1); + OsciPoint start = shapes[i]->nextVector(0); + OsciPoint end = shapes[i]->nextVector(1); bool keep = false; if ((start.x < 1 && start.x > -1) || (start.y < 1 && start.y > -1)) { if ((end.x < 1 && end.x > -1) || (end.y < 1 && end.y > -1)) { if (shapes[i]->type() == "Line") { - Point newStart(std::min(std::max(start.x, -1.0), 1.0), std::min(std::max(start.y, -1.0), 1.0)); - Point newEnd(std::min(std::max(end.x, -1.0), 1.0), std::min(std::max(end.y, -1.0), 1.0)); + OsciPoint newStart(std::min(std::max(start.x, -1.0), 1.0), std::min(std::max(start.y, -1.0), 1.0)); + OsciPoint newEnd(std::min(std::max(end.x, -1.0), 1.0), std::min(std::max(end.y, -1.0), 1.0)); shapes[i] = std::make_unique(newStart.x, newStart.y, newEnd.x, newEnd.y); } keep = true; diff --git a/Source/shape/Shape.h b/Source/shape/Shape.h index 5bd992ae..abe5bfa0 100644 --- a/Source/shape/Shape.h +++ b/Source/shape/Shape.h @@ -6,10 +6,10 @@ #include #include -class Point; +class OsciPoint; class Shape { public: - virtual Point nextVector(double drawingProgress) = 0; + virtual OsciPoint nextVector(double drawingProgress) = 0; virtual void scale(double x, double y, double z) = 0; virtual void translate(double x, double y, double z) = 0; virtual double length() = 0; @@ -21,10 +21,10 @@ public: static void normalize(std::vector>&); static double height(std::vector>&); static double width(std::vector>&); - static Point maxVector(std::vector>&); + static OsciPoint maxVector(std::vector>&); static void removeOutOfBounds(std::vector>&); const double INVALID_LENGTH = -1.0; double len = INVALID_LENGTH; -}; \ No newline at end of file +}; diff --git a/Source/svg/SvgParser.h b/Source/svg/SvgParser.h index 6baafecb..ddbe697a 100644 --- a/Source/svg/SvgParser.h +++ b/Source/svg/SvgParser.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "../shape/Shape.h" @@ -14,4 +14,4 @@ public: private: std::vector> shapes; -}; \ No newline at end of file +}; diff --git a/Source/txt/TextParser.h b/Source/txt/TextParser.h index 2640f690..31f50540 100644 --- a/Source/txt/TextParser.h +++ b/Source/txt/TextParser.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include #include "../shape/Shape.h" @@ -11,4 +11,4 @@ public: std::vector> draw(); private: std::vector> shapes; -}; \ No newline at end of file +}; diff --git a/Source/wav/WavParser.cpp b/Source/wav/WavParser.cpp index 45b1fed2..657414c3 100644 --- a/Source/wav/WavParser.cpp +++ b/Source/wav/WavParser.cpp @@ -25,19 +25,19 @@ void WavParser::setSampleRate(double sampleRate) { currentSampleRate = sampleRate; } -Point WavParser::getSample() { +OsciPoint WavParser::getSample() { if (currentSampleRate != audioProcessor.currentSampleRate) { setSampleRate(audioProcessor.currentSampleRate); } if (source == nullptr) { - return Point(); + return OsciPoint(); } source->getNextAudioBlock(juce::AudioSourceChannelInfo(audioBuffer)); if (audioBuffer.getNumChannels() == 1) { - return Point(audioBuffer.getSample(0, 0), audioBuffer.getSample(0, 0)); + return OsciPoint(audioBuffer.getSample(0, 0), audioBuffer.getSample(0, 0)); } else { - return Point(audioBuffer.getSample(0, 0), audioBuffer.getSample(1, 0)); + return OsciPoint(audioBuffer.getSample(0, 0), audioBuffer.getSample(1, 0)); } } diff --git a/Source/wav/WavParser.h b/Source/wav/WavParser.h index 7504508a..13cf3d20 100644 --- a/Source/wav/WavParser.h +++ b/Source/wav/WavParser.h @@ -1,5 +1,5 @@ #pragma once -#include "../shape/Point.h" +#include "../shape/OsciPoint.h" #include class OscirenderAudioProcessor; @@ -8,7 +8,7 @@ public: WavParser(OscirenderAudioProcessor& p, std::unique_ptr stream); ~WavParser(); - Point getSample(); + OsciPoint getSample(); private: void setSampleRate(double sampleRate); @@ -19,4 +19,4 @@ private: int fileSampleRate; int currentSampleRate; OscirenderAudioProcessor& audioProcessor; -}; \ No newline at end of file +}; diff --git a/modules/chowdsp_utils b/modules/chowdsp_utils new file mode 160000 index 00000000..17edebcc --- /dev/null +++ b/modules/chowdsp_utils @@ -0,0 +1 @@ +Subproject commit 17edebcc64d9dc96a9c0b0c7e9b9bd1673a585f9 diff --git a/osci-render.jucer b/osci-render.jucer index 72ad63db..be3b0775 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -556,6 +556,8 @@ + + @@ -569,8 +571,6 @@ file="Source/shape/QuadraticBezierCurve.h"/> - - @@ -666,6 +666,14 @@ + + + + + + + + @@ -690,6 +698,14 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sosci.jucer b/sosci.jucer index 3a4991d1..2c6eeb27 100644 --- a/sosci.jucer +++ b/sosci.jucer @@ -103,9 +103,9 @@ file="Source/concurrency/ConsumerManager.h"/> + + - - @@ -146,6 +146,14 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +