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) {
|
if (editingPerspective) {
|
||||||
juce::String file = codeDocuments[0]->getAllContent();
|
juce::String file = codeDocuments[0]->getAllContent();
|
||||||
audioProcessor.perspectiveEffect->updateCode(file);
|
audioProcessor.perspectiveEffect->updateCode(file);
|
||||||
|
audioProcessor.updateLuaValues();
|
||||||
} else {
|
} else {
|
||||||
int originalIndex = audioProcessor.getCurrentFileIndex();
|
int originalIndex = audioProcessor.getCurrentFileIndex();
|
||||||
int index = audioProcessor.getCurrentFileIndex();
|
int index = audioProcessor.getCurrentFileIndex();
|
||||||
|
|
|
@ -225,6 +225,7 @@ public:
|
||||||
juce::String getFileName(int index);
|
juce::String getFileName(int index);
|
||||||
std::shared_ptr<juce::MemoryBlock> getFileBlock(int index);
|
std::shared_ptr<juce::MemoryBlock> getFileBlock(int index);
|
||||||
void setObjectServerRendering(bool enabled);
|
void setObjectServerRendering(bool enabled);
|
||||||
|
void updateLuaValues();
|
||||||
private:
|
private:
|
||||||
std::atomic<double> volume = 1.0;
|
std::atomic<double> volume = 1.0;
|
||||||
std::atomic<double> threshold = 1.0;
|
std::atomic<double> threshold = 1.0;
|
||||||
|
@ -241,7 +242,6 @@ private:
|
||||||
AudioWebSocketServer softwareOscilloscopeServer{*this};
|
AudioWebSocketServer softwareOscilloscopeServer{*this};
|
||||||
ObjectServer objectServer{*this};
|
ObjectServer objectServer{*this};
|
||||||
|
|
||||||
void updateLuaValues();
|
|
||||||
void updateObjValues();
|
void updateObjValues();
|
||||||
std::shared_ptr<Effect> getEffect(juce::String id);
|
std::shared_ptr<Effect> getEffect(juce::String id);
|
||||||
BooleanParameter* getBooleanParameter(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) {
|
if (parser != nullptr) {
|
||||||
parser->setVariable("slider_" + name.toLowerCase(), values[0]);
|
parser->setVariable("slider_" + name.toLowerCase(), values[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioProcessor.perspectiveEffect->setVariable("slider_" + name.toLowerCase(), values[0]);
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,13 @@ void PerspectiveEffect::updateCode(const juce::String& newCode) {
|
||||||
parser = std::make_unique<LuaParser>(code);
|
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::String PerspectiveEffect::getCode() {
|
||||||
juce::SpinLock::ScopedLockType lock(codeLock);
|
juce::SpinLock::ScopedLockType lock(codeLock);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -10,16 +10,20 @@ public:
|
||||||
|
|
||||||
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
Vector2 apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) override;
|
||||||
void updateCode(const juce::String& newCode);
|
void updateCode(const juce::String& newCode);
|
||||||
|
void setVariable(juce::String variableName, double value);
|
||||||
|
|
||||||
juce::String getCode();
|
juce::String getCode();
|
||||||
|
|
||||||
BooleanParameter* fixedRotateX;
|
BooleanParameter* fixedRotateX;
|
||||||
BooleanParameter* fixedRotateY;
|
BooleanParameter* fixedRotateY;
|
||||||
BooleanParameter* fixedRotateZ;
|
BooleanParameter* fixedRotateZ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
|
const juce::String DEFAULT_SCRIPT = "return { x, y, z }";
|
||||||
juce::String code = DEFAULT_SCRIPT;
|
juce::String code = DEFAULT_SCRIPT;
|
||||||
juce::SpinLock codeLock;
|
|
||||||
std::unique_ptr<LuaParser> parser = std::make_unique<LuaParser>(code);
|
std::unique_ptr<LuaParser> parser = std::make_unique<LuaParser>(code);
|
||||||
|
juce::SpinLock codeLock;
|
||||||
|
|
||||||
bool defaultScript = true;
|
bool defaultScript = true;
|
||||||
|
|
||||||
float currentRotateX = 0;
|
float currentRotateX = 0;
|
||||||
|
|
Ładowanie…
Reference in New Issue