kopia lustrzana https://github.com/jameshball/osci-render
Add initial version of multiplex effect
rodzic
f7b02ca616
commit
4321de2f27
|
@ -3,7 +3,7 @@
|
|||
#include "CustomStandaloneFilterWindow.h"
|
||||
|
||||
CommonPluginEditor::CommonPluginEditor(CommonAudioProcessor& p, juce::String appName, juce::String projectFileType, int defaultWidth, int defaultHeight)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), appName(appName), projectFileType(projectFileType)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), appName(appName), projectFileType(projectFileType)
|
||||
{
|
||||
#if JUCE_LINUX
|
||||
// use OpenGL on Linux for much better performance. The default on Mac is CoreGraphics, and on Window is Direct2D which is much faster.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "audio/BitCrushEffect.h"
|
||||
#include "audio/BulgeEffect.h"
|
||||
#include "audio/DistortEffect.h"
|
||||
#include "audio/MultiplexEffect.h"
|
||||
#include "audio/SmoothEffect.h"
|
||||
#include "audio/VectorCancellingEffect.h"
|
||||
#include "parser/FileParser.h"
|
||||
|
@ -31,6 +32,19 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
|
|||
toggleableEffects.push_back(std::make_shared<osci::Effect>(
|
||||
std::make_shared<BulgeEffect>(),
|
||||
new osci::EffectParameter("Bulge", "Applies a bulge that makes the centre of the image larger, and squishes the edges of the image. This applies a distortion to the audio.", "bulge", VERSION_HINT, 0.5, 0.0, 1.0)));
|
||||
auto multiplexEffect = std::make_shared<osci::Effect>(
|
||||
std::make_shared<MultiplexEffect>(),
|
||||
std::vector<osci::EffectParameter*>{
|
||||
new osci::EffectParameter("Multiplex Grid X", "Controls the horizontal grid size for the multiplex effect.", "multiplexGridX", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||
new osci::EffectParameter("Multiplex Grid Y", "Controls the vertical grid size for the multiplex effect.", "multiplexGridY", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||
new osci::EffectParameter("Multiplex Grid Z", "Controls the depth grid size for the multiplex effect.", "multiplexGridZ", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||
new osci::EffectParameter("Multiplex Smooth", "Controls the smoothness of transitions between grid sizes.", "multiplexSmooth", VERSION_HINT, 1.0, 0.0, 1.0),
|
||||
new osci::EffectParameter("Grid Phase", "Controls the current phase of the grid animation.", "gridPhase", VERSION_HINT, 0.0, -1.0, 1.0),
|
||||
});
|
||||
// Set up the Grid Phase parameter with sawtooth LFO at 100Hz
|
||||
multiplexEffect->getParameter("gridPhase")->lfo->setUnnormalisedValueNotifyingHost((int)osci::LfoType::Sawtooth);
|
||||
multiplexEffect->getParameter("gridPhase")->lfoRate->setUnnormalisedValueNotifyingHost(100.0);
|
||||
toggleableEffects.push_back(multiplexEffect);
|
||||
toggleableEffects.push_back(std::make_shared<osci::Effect>(
|
||||
std::make_shared<VectorCancellingEffect>(),
|
||||
new osci::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)));
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include <cmath>
|
||||
|
||||
class MultiplexEffect : public osci::EffectApplication {
|
||||
public:
|
||||
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) override {
|
||||
jassert(values.size() >= 5);
|
||||
|
||||
double gridX = values[0].load();
|
||||
double gridY = values[1].load();
|
||||
double gridZ = values[2].load();
|
||||
double interpolation = values[3].load();
|
||||
double phase = values[4].load();
|
||||
|
||||
osci::Point grid = osci::Point(gridX, gridY, gridZ);
|
||||
osci::Point gridFloor = osci::Point(std::floor(gridX), std::floor(gridY), std::floor(gridZ));
|
||||
|
||||
gridFloor.x = std::max(gridFloor.x, 1.0);
|
||||
gridFloor.y = std::max(gridFloor.y, 1.0);
|
||||
gridFloor.z = std::max(gridFloor.z, 1.0);
|
||||
|
||||
double totalPositions = gridFloor.x * gridFloor.y * gridFloor.z;
|
||||
double position = phase * totalPositions;
|
||||
|
||||
osci::Point nextGrid = gridFloor + 1.0;
|
||||
|
||||
osci::Point current = multiplex(input, position, gridFloor);
|
||||
osci::Point next = multiplex(input, position, nextGrid);
|
||||
|
||||
// Calculate interpolation factors
|
||||
osci::Point gridDiff = grid - gridFloor;
|
||||
osci::Point interpolationFactor = gridDiff * interpolation;
|
||||
|
||||
return (1.0 - interpolationFactor) * current + interpolationFactor * next;
|
||||
}
|
||||
|
||||
private:
|
||||
osci::Point multiplex(osci::Point point, double position, osci::Point grid) {
|
||||
osci::Point unit = 1.0 / grid;
|
||||
|
||||
point *= unit;
|
||||
point.x = -point.x;
|
||||
point.y = -point.y;
|
||||
|
||||
double xPosRaw = std::floor(position);
|
||||
double yPosRaw = std::floor(position / grid.x);
|
||||
double zPosRaw = std::floor(position / (grid.x * grid.y));
|
||||
|
||||
// Use fmod for positive modulo with doubles
|
||||
double xPos = std::fmod(std::fmod(xPosRaw, grid.x) + grid.x, grid.x);
|
||||
double yPos = std::fmod(std::fmod(yPosRaw, grid.y) + grid.y, grid.y);
|
||||
double zPos = std::fmod(std::fmod(zPosRaw, grid.z) + grid.z, grid.z);
|
||||
|
||||
point.x -= (grid.x - 1.0) / grid.x;
|
||||
point.y += (grid.y - 1.0) / grid.y;
|
||||
point.z += (grid.z - 1.0) / grid.z;
|
||||
|
||||
point.x += xPos * 2.0 * unit.x;
|
||||
point.y -= yPos * 2.0 * unit.y;
|
||||
point.z -= zPos * 2.0 * unit.z;
|
||||
|
||||
return point;
|
||||
}
|
||||
};
|
|
@ -1 +1 @@
|
|||
Subproject commit a517f09beac37a919fe43772e98e779ffc1f0ba3
|
||||
Subproject commit 913c3b052404818c45ad93c5e6022244d57df5e9
|
|
@ -86,14 +86,12 @@
|
|||
<FILE id="uvMCNC" name="CustomEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/CustomEffect.cpp"/>
|
||||
<FILE id="qFZDUh" name="CustomEffect.h" compile="0" resource="0" file="Source/audio/CustomEffect.h"/>
|
||||
<FILE id="JtasnQ" name="DashedLineEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/DashedLineEffect.cpp"/>
|
||||
<FILE id="I7B78q" name="DashedLineEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/DashedLineEffect.h"/>
|
||||
<FILE id="kpI9pv" name="DelayEffect.h" compile="0" resource="0" file="Source/audio/DelayEffect.h"/>
|
||||
<FILE id="ux2dO2" name="DistortEffect.h" compile="0" resource="0" file="Source/audio/DistortEffect.h"/>
|
||||
<FILE id="QBWW9w" name="PerspectiveEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/PerspectiveEffect.cpp"/>
|
||||
<FILE id="SWC0tN" name="MultiplexEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/MultiplexEffect.h"/>
|
||||
<FILE id="h0dMim" name="PerspectiveEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/PerspectiveEffect.h"/>
|
||||
<FILE id="t5g8pf" name="PublicSynthesiser.h" compile="0" resource="0"
|
||||
|
|
|
@ -49,7 +49,7 @@ Name: "deletefiles"; Description: "Remove any existing settings (Clean installat
|
|||
Source: "..\Builds\osci-render\VisualStudio2022\x64\Release\Standalone Plugin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\Builds\osci-render\VisualStudio2022\x64\Release\VST3\osci-render.vst3\Contents\x86_64-win\{#MyAppVstName}"; DestDir: "{cf}\VST3"; Flags: ignoreversion
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{sys}"
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{sys}"; Flags: ignoreversion
|
||||
|
||||
[InstallDelete]
|
||||
Type: files; Name: {userappdata}\osci-render\osci-render.settings; Tasks: deletefiles
|
||||
|
|
|
@ -49,7 +49,7 @@ Name: "deletefiles"; Description: "Remove any existing settings (Clean installat
|
|||
Source: "..\Builds\sosci\VisualStudio2022\x64\Release\Standalone Plugin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\Builds\sosci\VisualStudio2022\x64\Release\VST3\{#MyAppVstName}\Contents\x86_64-win\{#MyAppVstName}"; DestDir: "{cf}\VST3"; Flags: ignoreversion
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{sys}"
|
||||
Source: "..\External\spout\SpoutLibrary.dll"; DestDir: "{sys}"; Flags: ignoreversion
|
||||
|
||||
[InstallDelete]
|
||||
Type: files; Name: {userappdata}\{#MyAppName}\{#MyAppName}.settings; Tasks: deletefiles
|
||||
|
|
Ładowanie…
Reference in New Issue