From 8b189914f703ae4c502a8efd5d013c451bc7d607 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 10 Jul 2019 13:24:03 -0300 Subject: [PATCH] add rflanger command, update readme --- README.md | 12 +++++++++--- doc/README.md | 4 ++++ examples/flanger.scri | 3 +++ examples/middle_amp.scri | 4 ++-- src/lang.zig | 4 ++++ src/runner.zig | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 examples/flanger.scri diff --git a/README.md b/README.md index 4a4c010..629374c 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,22 @@ scritcher glitch art "framework", ???????? language??? something? +![example of the amp command](https://estrogen.fun/i/57y7kn55.png) + +![example of the rflanger command](https://estrogen.fun/i/i2055hdf.png) + # how do? -currently it can't do much other than running the eg-amp default lv2 plugin. - -depedencies: +## build depedencies: - zig at https://ziglang.org - libc, lilv and libsndfile - an appreciation for glitched anime girls on your hard drive - optional: imagemagick to convert from whatever to bmp +## plugin depedencies: + - lv2 default plugins (most specifically the eg-amp plugin) + - the SWH plugins ( https://github.com/swh/lv2 ) + ```bash # build and install # assumes lilv headers are at /usr/include/lilv-0, check build.zig if different diff --git a/doc/README.md b/doc/README.md index 8ad22b7..5895910 100644 --- a/doc/README.md +++ b/doc/README.md @@ -32,6 +32,10 @@ be a bmp. feel free to put other files, no warranties are given.) Run the eg-amp plugin over the given slice of the file. +## `rflanger split index delay_depth_avg law_freq` + +Runs the Retro Flanger script from the SWH plugins. + ## TODO `echo split index delay` Run an echo filter on the given loaded file. diff --git a/examples/flanger.scri b/examples/flanger.scri new file mode 100644 index 0000000..f1fe18d --- /dev/null +++ b/examples/flanger.scri @@ -0,0 +1,3 @@ +load :0; +rflanger 3 1 2.5 1; +quicksave; diff --git a/examples/middle_amp.scri b/examples/middle_amp.scri index e1eed36..a1ed655 100644 --- a/examples/middle_amp.scri +++ b/examples/middle_amp.scri @@ -1,8 +1,8 @@ load :0; -amp 5 1 8; -amp 7 4 2; amp 80 70 10; amp 80 73 20; amp 80 75 20; amp 80 76 20; +amp 7 4 2; +amp 5 1 8; quicksave; diff --git a/src/lang.zig b/src/lang.zig index ed5b402..f3c9c71 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -10,6 +10,7 @@ pub const CommandType = enum { Noop, Load, Amp, + RFlanger, Quicksave, }; @@ -52,12 +53,15 @@ pub const CommandList = std.ArrayList(*Command); pub const ArgList = std.ArrayList([]const u8); pub fn commandToCmdType(command: []const u8) ParseError!CommandType { + // TODO make a hashmap for those if (std.mem.eql(u8, command, "noop")) { return CommandType.Noop; } else if (std.mem.eql(u8, command, "load")) { return CommandType.Load; } else if (std.mem.eql(u8, command, "amp")) { return CommandType.Amp; + } else if (std.mem.eql(u8, command, "rflanger")) { + return CommandType.RFlanger; } else if (std.mem.eql(u8, command, "quicksave")) { return CommandType.Quicksave; } else { diff --git a/src/runner.zig b/src/runner.zig index 30fc12a..baeedfe 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -154,9 +154,10 @@ pub const Runner = struct { var image = try self.getImage(); var params = plugin.ParamList.init(self.allocator); - try params.append(plugin.Param{ .sym = "gain", .value = gain }); defer params.deinit(); + try params.append(plugin.Param{ .sym = "gain", .value = gain }); + // TODO if we could detect that the next command is a quicksave then // we don't need the temporary file in runPlugin and instead we // dump it all on the output image for it. @@ -167,6 +168,27 @@ pub const Runner = struct { ); } + fn rFlangerCmd( + self: *Runner, + split: usize, + index: usize, + delay_depth_avg: f32, + law_freq: f32, + ) !void { + var image = try self.getImage(); + var params = plugin.ParamList.init(self.allocator); + defer params.deinit(); + + try params.append(plugin.Param{ .sym = "delay_depth_avg", .value = delay_depth_avg }); + try params.append(plugin.Param{ .sym = "law_freq", .value = law_freq }); + + try image.runPlugin( + "http://plugin.org.uk/swh-plugins/retroFlange", + plugin.Position{ .split = split, .index = index }, + params, + ); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { return switch (cmd.command) { .Noop => {}, @@ -184,6 +206,15 @@ pub const Runner = struct { try self.ampCmd(split, index, gain); }, + .RFlanger => blk: { + const split = try cmd.usizeArgAt(0); + const index = try cmd.usizeArgAt(1); + const delay_depth_avg = try cmd.floatArgAt(2); + const law_freq = try cmd.floatArgAt(3); + + try self.rFlangerCmd(split, index, delay_depth_avg, law_freq); + }, + else => blk: { std.debug.warn("Unknown command: {}\n", cmd.command); break :blk RunError.UnknownCommand;