Allow lua slider values to be used in perspective function

pull/170/head
James Ball 2023-10-19 12:20:24 +01:00
rodzic 9fa9d89cb7
commit 48a5f2bb20
5 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -256,6 +256,7 @@ void OscirenderAudioProcessorEditor::updateCodeDocument() {
if (editingPerspective) {
juce::String file = codeDocuments[0]->getAllContent();
audioProcessor.perspectiveEffect->updateCode(file);
audioProcessor.updateLuaValues();
} else {
int originalIndex = audioProcessor.getCurrentFileIndex();
int index = audioProcessor.getCurrentFileIndex();

Wyświetl plik

@ -225,6 +225,7 @@ public:
juce::String getFileName(int index);
std::shared_ptr<juce::MemoryBlock> getFileBlock(int index);
void setObjectServerRendering(bool enabled);
void updateLuaValues();
private:
std::atomic<double> volume = 1.0;
std::atomic<double> threshold = 1.0;
@ -241,7 +242,6 @@ private:
AudioWebSocketServer softwareOscilloscopeServer{*this};
ObjectServer objectServer{*this};
void updateLuaValues();
void updateObjValues();
std::shared_ptr<Effect> getEffect(juce::String id);
BooleanParameter* getBooleanParameter(juce::String id);

Wyświetl plik

@ -10,5 +10,8 @@ Vector2 LuaEffect::apply(int index, Vector2 input, const std::vector<double>& va
if (parser != nullptr) {
parser->setVariable("slider_" + name.toLowerCase(), values[0]);
}
audioProcessor.perspectiveEffect->setVariable("slider_" + name.toLowerCase(), values[0]);
return input;
}

Wyświetl plik

@ -93,6 +93,13 @@ void PerspectiveEffect::updateCode(const juce::String& newCode) {
parser = std::make_unique<LuaParser>(code);
}
void PerspectiveEffect::setVariable(juce::String variableName, double value) {
juce::SpinLock::ScopedLockType lock(codeLock);
if (!defaultScript) {
parser->setVariable(variableName, value);
}
}
juce::String PerspectiveEffect::getCode() {
juce::SpinLock::ScopedLockType lock(codeLock);
return code;

Wyświetl plik

@ -10,16 +10,20 @@ public:
Vector2 apply(int index, Vector2 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();
BooleanParameter* fixedRotateX;
BooleanParameter* fixedRotateY;
BooleanParameter* fixedRotateZ;
private:
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
juce::String code = DEFAULT_SCRIPT;
juce::SpinLock codeLock;
std::unique_ptr<LuaParser> parser = std::make_unique<LuaParser>(code);
juce::SpinLock codeLock;
bool defaultScript = true;
float currentRotateX = 0;