osci-render/Source/audio/PerspectiveEffect.h

53 wiersze
1.5 KiB
C
Czysty Zwykły widok Historia

2023-07-21 16:42:29 +00:00
#pragma once
#include "EffectApplication.h"
2024-01-07 16:17:20 +00:00
#include "../shape/Point.h"
2023-07-21 16:42:29 +00:00
#include "../audio/Effect.h"
#include "../lua/LuaParser.h"
class PerspectiveEffect : public EffectApplication {
public:
PerspectiveEffect(int versionHint, std::function<void(int, juce::String, juce::String)> errorCallback);
~PerspectiveEffect();
2023-07-21 16:42:29 +00:00
// arbitrary UUID
static const juce::String FILE_NAME;
2024-01-07 16:17:20 +00:00
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override;
void updateCode(const juce::String& newCode);
void setVariable(juce::String variableName, double value);
juce::String getCode();
2023-09-01 18:52:36 +00:00
BooleanParameter* fixedRotateX;
BooleanParameter* fixedRotateY;
BooleanParameter* fixedRotateZ;
2023-07-21 16:42:29 +00:00
private:
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
juce::String code = DEFAULT_SCRIPT;
std::function<void(int, juce::String, juce::String)> errorCallback;
std::unique_ptr<LuaParser> parser = std::make_unique<LuaParser>(FILE_NAME, code, errorCallback);
juce::SpinLock codeLock;
bool defaultScript = true;
2023-07-21 16:42:29 +00:00
float currentRotateX = 0;
float currentRotateY = 0;
float currentRotateZ = 0;
lua_State *L = nullptr;
2023-09-01 18:52:36 +00:00
int versionHint;
2023-07-21 16:42:29 +00:00
long step = 1;
double phase = 0;
double linearSpeedToActualSpeed(double rotateSpeed) {
2023-09-09 12:47:02 +00:00
double actualSpeed = (std::exp(3 * juce::jmin(10.0, std::abs(rotateSpeed))) - 1) / 50000;
if (rotateSpeed < 0) {
actualSpeed *= -1;
}
return actualSpeed;
}
2023-09-01 18:52:36 +00:00
};