kopia lustrzana https://github.com/jameshball/osci-render
Add scale X/Y/Z, distort Z, Swirl effects, and support 3D Lua files
rodzic
3423ccd893
commit
ff1b62dfb3
|
@ -35,7 +35,7 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
|||
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
std::make_shared<BitCrushEffect>(),
|
||||
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<Effect>(
|
||||
std::make_shared<BulgeEffect>(),
|
||||
|
@ -45,13 +45,25 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
|||
std::make_shared<VectorCancellingEffect>(),
|
||||
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<Effect>(
|
||||
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
|
||||
return input * Point(values[0], values[1], values[2]);
|
||||
}, std::vector<EffectParameter*>{
|
||||
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<Effect>(
|
||||
std::make_shared<DistortEffect>(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<Effect>(
|
||||
std::make_shared<DistortEffect>(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<double>& 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<EffectParameter*>{
|
||||
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<Effect>(
|
||||
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
|
||||
|
@ -77,16 +89,23 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
|
|||
));
|
||||
toggleableEffects.push_back(std::make_shared<Effect>(
|
||||
[this](int index, Point input, const std::vector<double>& 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<EffectParameter*>{
|
||||
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<Effect>(
|
||||
[this](int index, Point input, const std::vector<double>& 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<EffectParameter*>{
|
||||
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<Effect>(
|
||||
std::make_shared<SmoothEffect>(),
|
||||
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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<float> 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;
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue