kopia lustrzana https://github.com/jameshball/osci-render
Add initial audio effect functionality
rodzic
f2719d85b5
commit
cd07ce20a8
|
@ -15,5 +15,6 @@ EffectComponentGroup::~EffectComponentGroup() {
|
|||
}
|
||||
|
||||
void EffectComponentGroup::resized() {
|
||||
slider.setBounds(0, 0, getWidth() - 100, 20);
|
||||
auto sliderLeft = 100;
|
||||
slider.setBounds(sliderLeft, 0, getWidth() - 200, 20);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "EffectsComponent.h"
|
||||
#include "audio/BitCrushEffect.h"
|
||||
|
||||
EffectsComponent::EffectsComponent(OscirenderAudioProcessor& p) : audioProcessor(p) {
|
||||
setText("Audio Effects");
|
||||
|
@ -19,6 +20,7 @@ EffectsComponent::EffectsComponent(OscirenderAudioProcessor& p) : audioProcessor
|
|||
}
|
||||
|
||||
EffectsComponent::~EffectsComponent() {
|
||||
|
||||
}
|
||||
|
||||
void EffectsComponent::resized() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "audio/BitCrushEffect.h"
|
||||
#include "EffectComponentGroup.h"
|
||||
#include "PluginProcessor.h"
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor (OscirenderAudioP
|
|||
addAndMakeVisible(main);
|
||||
}
|
||||
|
||||
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor()
|
||||
{
|
||||
}
|
||||
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {}
|
||||
|
||||
//==============================================================================
|
||||
void OscirenderAudioProcessorEditor::paint (juce::Graphics& g)
|
||||
|
|
|
@ -25,6 +25,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
|||
#endif
|
||||
, producer(std::make_unique<FrameProducer>(*this, parser)) {
|
||||
producer->startThread();
|
||||
bitCrushEffect.value = 0.5;
|
||||
effects.push_back(std::ref(bitCrushEffect));
|
||||
}
|
||||
|
||||
OscirenderAudioProcessor::~OscirenderAudioProcessor()
|
||||
|
@ -200,7 +202,8 @@ void OscirenderAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, j
|
|||
|
||||
for (auto sample = 0; sample < numSamples; ++sample) {
|
||||
updateLengthIncrement();
|
||||
|
||||
|
||||
Vector2 channels;
|
||||
double x = 0.0;
|
||||
double y = 0.0;
|
||||
double length = 0.0;
|
||||
|
@ -210,11 +213,16 @@ void OscirenderAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, j
|
|||
auto& shape = frame[currentShape];
|
||||
length = shape->length();
|
||||
double drawingProgress = length == 0.0 ? 1 : shapeDrawn / length;
|
||||
Vector2 channels = shape->nextVector(drawingProgress);
|
||||
x = channels.x;
|
||||
y = channels.y;
|
||||
channels = shape->nextVector(drawingProgress);
|
||||
}
|
||||
|
||||
for (auto effect : effects) {
|
||||
channels = effect.get().apply(sample, channels);
|
||||
}
|
||||
|
||||
x = channels.x;
|
||||
y = channels.y;
|
||||
|
||||
if (totalNumOutputChannels >= 2) {
|
||||
channelData[0][sample] = x;
|
||||
channelData[1][sample] = y;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "parser/FileParser.h"
|
||||
#include "parser/FrameProducer.h"
|
||||
#include "parser/FrameConsumer.h"
|
||||
#include "audio/Effect.h"
|
||||
#include "audio/BitCrushEffect.h"
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
@ -66,6 +68,10 @@ public:
|
|||
|
||||
double currentSampleRate = 0.0;
|
||||
|
||||
std::vector<std::reference_wrapper<Effect>> effects;
|
||||
|
||||
BitCrushEffect bitCrushEffect = BitCrushEffect();
|
||||
|
||||
FileParser parser;
|
||||
std::unique_ptr<FrameProducer> producer;
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "BitCrushEffect.h"
|
||||
|
||||
BitCrushEffect::BitCrushEffect() {}
|
||||
|
||||
BitCrushEffect::~BitCrushEffect() {}
|
||||
|
||||
Vector2 BitCrushEffect::apply(int index, Vector2 input) {
|
||||
double crush = 3.0 * (1.0 - value);
|
||||
return Vector2(bitCrush(input.x, crush), bitCrush(input.y, crush));
|
||||
}
|
||||
|
||||
double BitCrushEffect::bitCrush(double value, double places) {
|
||||
long factor = (long) pow(10, places);
|
||||
value = value * factor;
|
||||
long tmp = round(value);
|
||||
return (double) tmp / factor;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include "Effect.h"
|
||||
#include "../shape/Vector2.h"
|
||||
|
||||
class BitCrushEffect : public Effect {
|
||||
public:
|
||||
BitCrushEffect();
|
||||
~BitCrushEffect();
|
||||
|
||||
double value = 0.0;
|
||||
double frequency = 1.0;
|
||||
int precedence = -1;
|
||||
|
||||
Vector2 apply(int index, Vector2 input) override;
|
||||
private:
|
||||
double bitCrush(double value, double places);
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
#include "Effect.h"
|
||||
|
||||
|
||||
Effect::Effect() {
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
#include "../shape/Vector2.h"
|
||||
|
||||
class Effect {
|
||||
public:
|
||||
Effect();
|
||||
|
||||
virtual Vector2 apply(int index, Vector2 input) = 0;
|
||||
};
|
|
@ -6,7 +6,6 @@ Camera::Camera(double focalLength, double x, double y, double z) : focalLength(f
|
|||
|
||||
std::vector<std::unique_ptr<Shape>> Camera::draw(WorldObject& object) {
|
||||
std::vector<std::unique_ptr<Shape>> shapes;
|
||||
object.rotateY += 0.001;
|
||||
for (auto& edge : object.edges) {
|
||||
Vector2 start = project(object.rotateX, object.rotateY, object.rotateZ, edge.x1, edge.y1, edge.z1);
|
||||
Vector2 end = project(object.rotateX, object.rotateY, object.rotateZ, edge.x2, edge.y2, edge.z2);
|
||||
|
|
|
@ -7,6 +7,14 @@
|
|||
cppLanguageStandard="20" projectLineFeed=" " headerPath="./include">
|
||||
<MAINGROUP id="j5Ge2T" name="osci-render">
|
||||
<GROUP id="{75439074-E50C-362F-1EDF-8B4BE9011259}" name="Source">
|
||||
<GROUP id="{85A33213-D880-BD92-70D8-1901DA6D23F0}" name="audio">
|
||||
<FILE id="NWuowi" name="BitCrushEffect.cpp" compile="1" resource="0"
|
||||
file="Source/audio/BitCrushEffect.cpp"/>
|
||||
<FILE id="Bc8UeW" name="BitCrushEffect.h" compile="0" resource="0"
|
||||
file="Source/audio/BitCrushEffect.h"/>
|
||||
<FILE id="mP5lpY" name="Effect.cpp" compile="1" resource="0" file="Source/audio/Effect.cpp"/>
|
||||
<FILE id="LKeNnY" name="Effect.h" compile="0" resource="0" file="Source/audio/Effect.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{E81B1D7B-B0F7-1967-B271-71B3F838720F}" name="txt">
|
||||
<FILE id="vIYWRG" name="TextParser.cpp" compile="1" resource="0" file="Source/txt/TextParser.cpp"/>
|
||||
<FILE id="LlefOK" name="TextParser.h" compile="0" resource="0" file="Source/txt/TextParser.h"/>
|
||||
|
|
Ładowanie…
Reference in New Issue