From 8d3cd47665b34df45c66b8bcadd0d7ced496d50a Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 13 Jul 2019 16:46:26 -0300 Subject: [PATCH] add vinyl cmd --- doc/README.md | 2 +- examples/vinyl.scri | 3 +++ src/lang.zig | 2 ++ src/runner.zig | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 examples/vinyl.scri diff --git a/doc/README.md b/doc/README.md index cd0ccd1..6ab542d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -118,7 +118,7 @@ Parameters: - `gain_scale`: Amplitude change, 0.2..5, default 1 - `wet`: Dry/wet mix, 0..1, default 1 -## TODO `vynil split index year warp click wear` +## TODO `vinyl split index year warp click wear` VyNil effect from SWH. diff --git a/examples/vinyl.scri b/examples/vinyl.scri new file mode 100644 index 0000000..940d089 --- /dev/null +++ b/examples/vinyl.scri @@ -0,0 +1,3 @@ +load :0; +vinyl 3 1 1990 33 0 0 0; +quicksave; diff --git a/src/lang.zig b/src/lang.zig index fc5f1d6..bacb55a 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -24,6 +24,7 @@ pub const CommandType = enum { Reverb, Highpass, Delay, + Vinyl, }; pub const Command = struct { @@ -139,6 +140,7 @@ pub const Lang = struct { _ = try self.keywords.put("reverb", .Reverb); _ = try self.keywords.put("highpass", .Highpass); _ = try self.keywords.put("delay", .Delay); + _ = try self.keywords.put("vinyl", .Vinyl); } pub fn parse(self: *Lang, data: []const u8) !CommandList { diff --git a/src/runner.zig b/src/runner.zig index a8042ca..0ebc0eb 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -235,6 +235,11 @@ pub const Runner = struct { try image.runPlugin("http://plugin.org.uk/swh-plugins/delayorama", pos, params); } + fn vinylCmd(self: *Runner, pos: Position, params: ParamList) !void { + var image = try self.getImage(); + try image.runPlugin("http://plugin.org.uk/swh-plugins/vynil", pos, params); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { var params = ParamList.init(self.allocator); defer params.deinit(); @@ -350,6 +355,18 @@ pub const Runner = struct { try self.delayCmd(pos, params); }, + .Vinyl => blk: { + const pos = try cmd.consumePosition(); + + try cmd.appendParam(¶ms, "year"); + try cmd.appendParam(¶ms, "rpm"); + try cmd.appendParam(¶ms, "warp"); + try cmd.appendParam(¶ms, "click"); + try cmd.appendParam(¶ms, "wear"); + + try self.vinylCmd(pos, params); + }, + else => blk: { std.debug.warn("Unsupported command: {}\n", cmd.command); break :blk RunError.UnknownCommand;