kopia lustrzana https://github.com/jameshball/osci-render
Add stereo effect
rodzic
eae2ccdcda
commit
04dab15870
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,35 @@
|
|||
#include "StereoEffect.h"
|
||||
|
||||
StereoEffect::StereoEffect() {}
|
||||
|
||||
StereoEffect::~StereoEffect() {}
|
||||
|
||||
OsciPoint StereoEffect::apply(int index, OsciPoint input, const std::vector<std::atomic<double>>& values, double sampleRate) {
|
||||
if (this->sampleRate != sampleRate) {
|
||||
this->sampleRate = sampleRate;
|
||||
initialiseBuffer(sampleRate);
|
||||
}
|
||||
double sampleOffset = values[0].load() / 10;
|
||||
sampleOffset = juce::jlimit(0.0, 1.0, sampleOffset);
|
||||
sampleOffset *= buffer.size();
|
||||
|
||||
head++;
|
||||
if (head >= buffer.size()) {
|
||||
head = 0;
|
||||
}
|
||||
|
||||
buffer[head] = input;
|
||||
|
||||
int readHead = head - sampleOffset;
|
||||
if (readHead < 0) {
|
||||
readHead += buffer.size();
|
||||
}
|
||||
|
||||
return OsciPoint(input.x, buffer[readHead].y, input.z);
|
||||
}
|
||||
|
||||
void StereoEffect::initialiseBuffer(double sampleRate) {
|
||||
buffer.clear();
|
||||
buffer.resize(bufferLength * sampleRate);
|
||||
head = 0;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include "EffectApplication.h"
|
||||
#include "../shape/OsciPoint.h"
|
||||
|
||||
class StereoEffect : public EffectApplication {
|
||||
public:
|
||||
StereoEffect();
|
||||
~StereoEffect();
|
||||
|
||||
OsciPoint apply(int index, OsciPoint input, const std::vector<std::atomic<double>>& values, double sampleRate) override;
|
||||
|
||||
private:
|
||||
void initialiseBuffer(double sampleRate);
|
||||
|
||||
const double bufferLength = 0.1;
|
||||
double sampleRate = -1;
|
||||
std::vector<OsciPoint> buffer;
|
||||
int head = 0;
|
||||
};
|
|
@ -21,6 +21,7 @@ VisualiserSettings::VisualiserSettings(VisualiserParameters& p, int numChannels)
|
|||
addAndMakeVisible(screenOverlay);
|
||||
#if SOSCI_FEATURES
|
||||
addAndMakeVisible(screenSaturation);
|
||||
addAndMakeVisible(stereo);
|
||||
addAndMakeVisible(xOffset);
|
||||
addAndMakeVisible(yOffset);
|
||||
addAndMakeVisible(xScale);
|
||||
|
@ -62,6 +63,7 @@ VisualiserSettings::VisualiserSettings(VisualiserParameters& p, int numChannels)
|
|||
|
||||
#if SOSCI_FEATURES
|
||||
screenSaturation.setSliderOnValueChange();
|
||||
stereo.setSliderOnValueChange();
|
||||
xOffset.setSliderOnValueChange();
|
||||
yOffset.setSliderOnValueChange();
|
||||
xScale.setSliderOnValueChange();
|
||||
|
@ -102,6 +104,7 @@ void VisualiserSettings::resized() {
|
|||
smooth.setBounds(area.removeFromTop(rowHeight));
|
||||
|
||||
#if SOSCI_FEATURES
|
||||
stereo.setBounds(area.removeFromTop(rowHeight));
|
||||
xScale.setBounds(area.removeFromTop(rowHeight));
|
||||
yScale.setBounds(area.removeFromTop(rowHeight));
|
||||
xOffset.setBounds(area.removeFromTop(rowHeight));
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "../LookAndFeel.h"
|
||||
#include "../components/SwitchButton.h"
|
||||
#include "../audio/SmoothEffect.h"
|
||||
#include "../audio/StereoEffect.h"
|
||||
|
||||
enum class ScreenOverlay : int {
|
||||
Empty = 1,
|
||||
|
@ -105,6 +106,16 @@ public:
|
|||
VERSION_HINT, 1.0, 0.0, 5.0
|
||||
)
|
||||
);
|
||||
std::shared_ptr<StereoEffect> stereoEffectApplication = std::make_shared<StereoEffect>();
|
||||
std::shared_ptr<Effect> stereoEffect = std::make_shared<Effect>(
|
||||
stereoEffectApplication,
|
||||
new EffectParameter(
|
||||
"Stereo",
|
||||
"Turns mono audio that is uninteresting to visualise into stereo audio that is interesting to visualise.",
|
||||
"stereo",
|
||||
VERSION_HINT, 0.0, 0.0, 1.0
|
||||
)
|
||||
);
|
||||
std::shared_ptr<Effect> scaleEffect = std::make_shared<Effect>(
|
||||
[this](int index, OsciPoint input, const std::vector<std::atomic<double>>& values, double sampleRate) {
|
||||
input.scale(values[0].load(), values[1].load(), 1.0);
|
||||
|
@ -249,6 +260,7 @@ public:
|
|||
smoothEffect,
|
||||
#if SOSCI_FEATURES
|
||||
screenSaturationEffect,
|
||||
stereoEffect,
|
||||
scaleEffect,
|
||||
offsetEffect,
|
||||
#endif
|
||||
|
@ -367,6 +379,7 @@ private:
|
|||
|
||||
#if SOSCI_FEATURES
|
||||
EffectComponent screenSaturation{*parameters.screenSaturationEffect};
|
||||
EffectComponent stereo{*parameters.stereoEffect};
|
||||
EffectComponent xScale{*parameters.scaleEffect, 0};
|
||||
EffectComponent yScale{*parameters.scaleEffect, 1};
|
||||
EffectComponent xOffset{*parameters.offsetEffect, 0};
|
||||
|
|
|
@ -108,6 +108,9 @@
|
|||
<FILE id="vj5mRC" name="SmoothEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/SmoothEffect.cpp"/>
|
||||
<FILE id="GSnwBW" name="SmoothEffect.h" compile="0" resource="0" file="Source/audio/SmoothEffect.h"/>
|
||||
<FILE id="Iq5LKp" name="StereoEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/StereoEffect.cpp"/>
|
||||
<FILE id="jq3EXV" name="StereoEffect.h" compile="0" resource="0" file="Source/audio/StereoEffect.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{CD81913A-7F0E-5898-DA77-5EBEB369DEB1}" name="components">
|
||||
<FILE id="URb7Ok" name="AboutComponent.cpp" compile="1" resource="0"
|
||||
|
|
Ładowanie…
Reference in New Issue