Skip to content

Commit

Permalink
Make some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DJLevel3 committed Sep 23, 2024
1 parent 09044bf commit 762b183
Show file tree
Hide file tree
Showing 29 changed files with 79 additions and 295 deletions.
7 changes: 4 additions & 3 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,25 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, ju
currentVolume = juce::jlimit(0.0, 1.0, currentVolume);

Point channels = { outputBuffer3d.getSample(0, sample), outputBuffer3d.getSample(1, sample), outputBuffer3d.getSample(2, sample) };
Point extChannels = { left, right };

{
juce::SpinLock::ScopedLockType lock1(parsersLock);
juce::SpinLock::ScopedLockType lock2(effectsLock);
if (volume > EPSILON) {
for (auto& effect : toggleableEffects) {
if (effect->enabled->getValue()) {
channels = effect->apply(sample, channels, currentVolume);
channels = effect->apply(sample, channels, extChannels, currentVolume);
}
}
}
for (auto& effect : permanentEffects) {
channels = effect->apply(sample, channels, currentVolume);
channels = effect->apply(sample, channels, extChannels, currentVolume);
}
auto lua = currentFile >= 0 ? sounds[currentFile]->parser->getLua() : nullptr;
if (lua != nullptr || custom->enabled->getBoolValue()) {
for (auto& effect : luaEffects) {
effect->apply(sample, channels, currentVolume);
effect->apply(sample, channels, extChannels, currentVolume);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Source/audio/BitCrushEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ Point BitCrushEffect::apply(int index, Point input, const std::vector<double>& v
double dequant = 1.0f / quant;
return Point(dequant * (int)(input.x * quant), dequant * (int)(input.y * quant), dequant * (int)(input.z * quant));
}

Point BitCrushEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/BitCrushEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ class BitCrushEffect : public EffectApplication {
BitCrushEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;
};
4 changes: 4 additions & 0 deletions Source/audio/BulgeEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ Point BulgeEffect::apply(int index, Point input, const std::vector<double>& valu

return Point(rn * cos(theta), rn * sin(theta), input.z);
}

Point BulgeEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/BulgeEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ class BulgeEffect : public EffectApplication {
~BulgeEffect();

Point apply(int index, Point input, const std::vector<double>&, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>&, double sampleRate, Point extInput) override;
};
19 changes: 15 additions & 4 deletions Source/audio/CustomEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,36 @@ const juce::String CustomEffect::FILE_NAME = "Custom Lua Effect";

CustomEffect::CustomEffect(std::function<void(int, juce::String, juce::String)> errorCallback, double (&luaValues)[26]) : errorCallback(errorCallback), luaValues(luaValues) {
vars.isEffect = true;
lua = true;
}

CustomEffect::~CustomEffect() {
parser->close(L);
}

Point CustomEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate) {
auto effectScale = values[0];
return apply(index, input, values, sampleRate, Point(0, 0));
}

Point CustomEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
double effectScale = values[0];

auto x = input.x;
auto y = input.y;
auto z = input.z;
double ext_x = extInput.x;
double ext_y = extInput.y;

double x = input.x;
double y = input.y;
double z = input.z;

{
juce::SpinLock::ScopedLockType lock(codeLock);
if (!defaultScript) {
vars.sampleRate = sampleRate;
vars.frequency = frequency;

vars.ext_x = ext_x;
vars.ext_y = ext_y;

vars.x = x;
vars.y = y;
vars.z = z;
Expand Down
1 change: 1 addition & 0 deletions Source/audio/CustomEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CustomEffect : public EffectApplication {
static const juce::String UNIQUE_ID;
static const juce::String FILE_NAME;

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
void updateCode(const juce::String& newCode);

Expand Down
4 changes: 4 additions & 0 deletions Source/audio/DashedLineEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Point DashedLineEffect::apply(int index, Point vector, const std::vector<double>

return vector;
}

Point DashedLineEffect::apply(int index, Point vector, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, vector, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/DashedLineEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DashedLineEffect : public EffectApplication {
~DashedLineEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;

private:
const static int MAX_BUFFER = 192000;
Expand Down
4 changes: 4 additions & 0 deletions Source/audio/DelayEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Point DelayEffect::apply(int index, Point vector, const std::vector<double>& val

return vector;
}

Point DelayEffect::apply(int index, Point vector, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, vector, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/DelayEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DelayEffect : public EffectApplication {
~DelayEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;

private:
const static int MAX_DELAY = 192000 * 10;
Expand Down
8 changes: 6 additions & 2 deletions Source/audio/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ Effect::Effect(const std::vector<EffectParameter*>& parameters) : Effect([](int
Effect::Effect(EffectParameter* parameter) : Effect([](int index, Point input, const std::vector<double>& values, double sampleRate) {return input;}, parameter) {}

Point Effect::apply(int index, Point input, double volume) {
return(apply(index, input, Point(0, 0), volume));
}
Point Effect::apply(int index, Point input, Point extInput, double volume) {
animateValues(volume);
if (application) {
return application(index, input, actualValues, sampleRate);
} else if (effectApplication != nullptr) {
return effectApplication->apply(index, input, actualValues, sampleRate);
}
else if (effectApplication != nullptr) {
return effectApplication->apply(index, input, actualValues, sampleRate, extInput);
}
return input;
}
Expand Down
1 change: 1 addition & 0 deletions Source/audio/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Effect {
Effect(EffectParameter* parameter);

Point apply(int index, Point input, double volume = 0.0);
Point apply(int index, Point input, Point extInput, double volume = 0.0);

void apply();
double getValue(int index);
Expand Down
2 changes: 2 additions & 0 deletions Source/audio/EffectApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ class EffectApplication {
public:
EffectApplication() {};

virtual Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) = 0;
virtual Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) = 0;

bool lua = false;
void resetPhase();
double nextPhase(double frequency, double sampleRate);
private:
Expand Down
5 changes: 5 additions & 0 deletions Source/audio/PerspectiveEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ Point PerspectiveEffect::apply(int index, Point input, const std::vector<double>
0
);
}


Point PerspectiveEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/PerspectiveEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class PerspectiveEffect : public EffectApplication {
~PerspectiveEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;

private:

Expand Down
1 change: 0 additions & 1 deletion Source/audio/ShapeVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void ShapeVoice::stopNote(float velocity, bool allowTailOff) {

void ShapeVoice::noteStopped() {
clearCurrentNote();
sound = nullptr;
}

void ShapeVoice::pitchWheelMoved(int newPitchWheelValue) {
Expand Down
4 changes: 4 additions & 0 deletions Source/audio/SmoothEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ Point SmoothEffect::apply(int index, Point input, const std::vector<double>& val

return avg;
}

Point SmoothEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/SmoothEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SmoothEffect : public EffectApplication {
~SmoothEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;
private:
Point avg;
};
4 changes: 4 additions & 0 deletions Source/audio/VectorCancellingEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ Point VectorCancellingEffect::apply(int index, Point input, const std::vector<do
}
return input;
}

Point VectorCancellingEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/VectorCancellingEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class VectorCancellingEffect : public EffectApplication {
~VectorCancellingEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;
private:
int lastIndex = 0;
double nextInvert = 0;
Expand Down
4 changes: 4 additions & 0 deletions Source/audio/WobbleEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Point WobbleEffect::apply(int index, Point input, const std::vector<double>& val

return input + delta;
}

Point WobbleEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) {
return apply(index, input, values, sampleRate);
}
1 change: 1 addition & 0 deletions Source/audio/WobbleEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class WobbleEffect : public EffectApplication {
~WobbleEffect();

Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate, Point extInput) override;

private:
PitchDetector& pitchDetector;
Expand Down
2 changes: 2 additions & 0 deletions Source/lua/LuaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ void LuaParser::setGlobalVariables(lua_State*& L, LuaVariables& vars) {
setGlobalVariable(L, "sample_rate", vars.sampleRate);
setGlobalVariable(L, "frequency", vars.frequency);
setGlobalVariable(L, "phase", vars.phase);
setGlobalVariable(L, "ext_x", vars.ext_x);
setGlobalVariable(L, "ext_y", vars.ext_y);

for (int i = 0; i < NUM_SLIDERS; i++) {
setGlobalVariable(L, SLIDER_NAMES[i], vars.sliders[i]);
Expand Down
3 changes: 3 additions & 0 deletions Source/lua/LuaParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct LuaVariables {
double sampleRate = 0;
double frequency = 0;

double ext_x = 0;
double ext_y = 0;

// x, y, z are only used for effects
bool isEffect = false;

Expand Down
File renamed without changes.
Loading

0 comments on commit 762b183

Please sign in to comment.