diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index f865587..caac35c 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -35,7 +35,7 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() toggleableEffects.push_back(std::make_shared( std::make_shared(), - new EffectParameter("Bit Crush", "Limits the resolution of points drawn to the screen, making the image look pixelated, and making the audio sound more 'digital' and distorted.", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Bit Crush", "Limits the resolution of points drawn to the screen, making the object look pixelated, and making the audio sound more 'digital' and distorted.", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( std::make_shared(), @@ -45,13 +45,25 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() std::make_shared(), new EffectParameter("Vector Cancelling", "Inverts the audio and image every few samples to 'cancel out' the audio, making the audio quiet, and distorting the image.", "vectorCancelling", VERSION_HINT, 0.0, 0.0, 1.0) )); + toggleableEffects.push_back(std::make_shared( + [this](int index, Point input, const std::vector& values, double sampleRate) { + return input * Point(values[0], values[1], values[2]); + }, std::vector{ + new EffectParameter("Scale X", "Scales the object in the horizontal direction.", "scaleX", VERSION_HINT, 1.0, -5.0, 5.0), + new EffectParameter("Scale Y", "Scales the object in the vertical direction.", "scaleY", VERSION_HINT, 1.0, -5.0, 5.0), + new EffectParameter("Scale Z", "Scales the depth of the object.", "scaleZ", VERSION_HINT, 1.0, -5.0, 5.0), + } + )); toggleableEffects.push_back(std::make_shared( - std::make_shared(false), - new EffectParameter("Distort X", "Distorts the image in the horizontal direction by jittering the audio sample being drawn.", "distortX", VERSION_HINT, 0.0, 0.0, 1.0) - )); - toggleableEffects.push_back(std::make_shared( - std::make_shared(true), - new EffectParameter("Distort Y", "Distorts the image in the vertical direction by jittering the audio sample being drawn.", "distortY", VERSION_HINT, 0.0, 0.0, 1.0) + [this](int index, Point input, const std::vector& values, double sampleRate) { + int flip = index % 2 == 0 ? 1 : -1; + Point jitter = Point(flip * values[0], flip * values[1], flip * values[2]); + return input + jitter; + }, std::vector{ + new EffectParameter("Distort X", "Distorts the image in the horizontal direction by jittering the audio sample being drawn.", "distortX", VERSION_HINT, 0.0, 0.0, 1.0), + new EffectParameter("Distort Y", "Distorts the image in the vertical direction by jittering the audio sample being drawn.", "distortY", VERSION_HINT, 0.0, 0.0, 1.0), + new EffectParameter("Distort Z", "Distorts the depth of the image by jittering the audio sample being drawn.", "distortZ", VERSION_HINT, 0.0, 0.0, 1.0), + } )); toggleableEffects.push_back(std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { @@ -77,16 +89,23 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() )); toggleableEffects.push_back(std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { - input.x += values[0]; - input.y += values[1]; - input.z += values[2]; - return input; + return input + Point(values[0], values[1], values[2]); }, std::vector{ new EffectParameter("Translate X", "Moves the object horizontally.", "translateX", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "Moves the object vertically.", "translateY", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Z", "Moves the object away from the camera.", "translateZ", VERSION_HINT, 0.0, -1.0, 1.0), } )); + toggleableEffects.push_back(std::make_shared( + [this](int index, Point input, const std::vector& values, double sampleRate) { + double length = 10 * values[0] * input.magnitude(); + double newX = input.x * std::cos(length) - input.y * std::sin(length); + double newY = input.x * std::sin(length) + input.y * std::cos(length); + return Point(newX, newY, input.z); + }, std::vector{ + new EffectParameter("Swirl", "Swirls the image in a spiral pattern.", "swirl", VERSION_HINT, 0.0, -1.0, 1.0), + } + )); toggleableEffects.push_back(std::make_shared( std::make_shared(), new EffectParameter("Smoothing", "This works as a low-pass frequency filter that removes high frequencies, making the image look smoother, and audio sound less harsh.", "smoothing", VERSION_HINT, 0.0, 0.0, 1.0) diff --git a/Source/SettingsComponent.cpp b/Source/SettingsComponent.cpp index 5745169..4a8c573 100644 --- a/Source/SettingsComponent.cpp +++ b/Source/SettingsComponent.cpp @@ -86,7 +86,7 @@ void SettingsComponent::mouseMove(const juce::MouseEvent& event) { } void SettingsComponent::mouseDown(const juce::MouseEvent& event) { - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 1; i++) { if (toggleComponents[i]->getBounds().removeFromTop(pluginEditor.CLOSED_PREF_SIZE).contains(event.getPosition())) { pluginEditor.toggleLayout(*toggleLayouts[i], prefSizes[i]); resized(); diff --git a/Source/lua/LuaParser.cpp b/Source/lua/LuaParser.cpp index b6c2db8..056aee6 100644 --- a/Source/lua/LuaParser.cpp +++ b/Source/lua/LuaParser.cpp @@ -18,33 +18,33 @@ void LuaParser::reset(lua_State*& L, juce::String script) { void LuaParser::reportError(const char* errorChars) { std::string error = errorChars; - std::regex nilRegex = std::regex(R"(attempt to.*nil value.*'slider_\w')"); - // ignore nil errors about global variables, these are likely caused by other errors - if (std::regex_search(error, nilRegex)) { - return; + std::regex nilRegex = std::regex(R"(attempt to.*nil value.*'slider_\w')"); + // ignore nil errors about global variables, these are likely caused by other errors + if (std::regex_search(error, nilRegex)) { + return; } // remove any newlines from error message error = std::regex_replace(error, std::regex(R"(\n|\r)"), ""); // remove script content from error message - error = std::regex_replace(error, std::regex(R"(^\[string ".*"\]:)"), ""); - // extract line number from start of error message - std::regex lineRegex(R"(^(\d+): )"); - std::smatch lineMatch; - std::regex_search(error, lineMatch, lineRegex); - - if (lineMatch.size() > 1) { - int line = std::stoi(lineMatch[1]); - // remove line number from error message - error = std::regex_replace(error, lineRegex, ""); - errorCallback(line, fileName, error); + error = std::regex_replace(error, std::regex(R"(^\[string ".*"\]:)"), ""); + // extract line number from start of error message + std::regex lineRegex(R"(^(\d+): )"); + std::smatch lineMatch; + std::regex_search(error, lineMatch, lineRegex); + + if (lineMatch.size() > 1) { + int line = std::stoi(lineMatch[1]); + // remove line number from error message + error = std::regex_replace(error, lineRegex, ""); + errorCallback(line, fileName, error); } } void LuaParser::parse(lua_State*& L) { const int ret = luaL_loadstring(L, script.toUTF8()); - if (ret != 0) { - const char* error = lua_tostring(L, -1); + if (ret != 0) { + const char* error = lua_tostring(L, -1); reportError(error); lua_pop(L, 1); functionRef = -1; @@ -96,8 +96,8 @@ std::vector LuaParser::run(lua_State*& L, const LuaVariables vars, long& if (lua_isfunction(L, -1)) { const int ret = lua_pcall(L, 0, LUA_MULTRET, 0); - if (ret != LUA_OK) { - const char* error = lua_tostring(L, -1); + if (ret != LUA_OK) { + const char* error = lua_tostring(L, -1); reportError(error); functionRef = -1; usingFallbackScript = true; diff --git a/Source/parser/FileParser.cpp b/Source/parser/FileParser.cpp index 711e23c..2baf0dc 100644 --- a/Source/parser/FileParser.cpp +++ b/Source/parser/FileParser.cpp @@ -53,7 +53,7 @@ Point FileParser::nextSample(lua_State*& L, const LuaVariables vars, long& step, if (values.size() < 2) { return Point(); } - return Point(values[0], values[1]); + return Point(values[0], values[1], values[2]); } }