kopia lustrzana https://github.com/jameshball/osci-render
Allow lua slider values to be used in perspective function
rodzic
9fa9d89cb7
commit
48a5f2bb20
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Ładowanie…
Reference in New Issue