From f07c989407a47f7ab71397044d2392ab7c270ed6 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 13 Jul 2019 16:40:08 -0300 Subject: [PATCH 1/3] allow for stereo input (unused, though) --- doc/README.md | 17 ++++++++++++++++- src/plugin.zig | 8 +++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/README.md b/doc/README.md index e895de2..cd0ccd1 100644 --- a/doc/README.md +++ b/doc/README.md @@ -104,7 +104,7 @@ Parameters: - `gain`: Gain, 0..12, default 0 - `noClip`: Soft Clip (assumed boolean), 0..1, default 0 -## `delay seed gain` +## `delay seed gain feedback_pc tap_count first_delay delay_range delay_scale delay_rand_pc gain_scale wet` Parameters: - `seed`: Random seed, 0..1000, default 0 @@ -118,10 +118,25 @@ 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` + +VyNil effect from SWH. + +Parameters: + - `year`: Year (int), 1900..1990, default 1990 + - `rpm`: RPM (int), 33..78, default 33 + - `warp`: Surface Warping, 0..1, default 0 + - `click`: Crackle, 0..1, default 0 + - `wear`: Wear, 0..1, default 0 + ## TODO `echo split index delay` Run an echo filter on the given loaded file. +## TODO `noise split index seed` + +Inject white noise on the image. + ## `quicksave` Save the file on the same directory of the file specified by `load`, but diff --git a/src/plugin.zig b/src/plugin.zig index 79094f6..abc22f5 100644 --- a/src/plugin.zig +++ b/src/plugin.zig @@ -72,8 +72,14 @@ pub const RunContext = struct { return ImageError.InstantiateFail; } + // we allocate []f32 with size 2 to account for stereo plugins, however + // we only use &in_buf[0] and &out_buf[0], and don't use the + // (supposedly) right side of neither input or output. + var in_buf = try allocator.alloc(f32, 2); + std.mem.secureZero(f32, in_buf); + return RunContext{ - .in_buf = try allocator.alloc(f32, 1), + .in_buf = in_buf, .out_buf = try allocator.alloc(f32, 2), .instance = instance.?, }; From 8d3cd47665b34df45c66b8bcadd0d7ced496d50a Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 13 Jul 2019 16:46:26 -0300 Subject: [PATCH 2/3] 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; From 223fb6628ce9582c05267aac63905983640080ab Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 13 Jul 2019 16:48:53 -0300 Subject: [PATCH 3/3] change mono plugin check to a 3+ channel plugin check i'm not sure if there's anyone with more than two ears who is biological --- src/image.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image.zig b/src/image.zig index 47991b3..6fd37db 100644 --- a/src/image.zig +++ b/src/image.zig @@ -212,12 +212,12 @@ pub const Image = struct { var ports = try lv2.setupPorts(&ctx); - if (ctx.n_audio_in != 1) { - std.debug.warn("plugin <{}> does not accept mono input.\n", plugin_uri); + if (ctx.n_audio_in > 2) { + std.debug.warn("plugin <{}> accepts more than two channels.\n", plugin_uri); return ImageError.InvalidPlugin; } - // TODO check n_audio_out + // TODO check n_audio_out > 2 // now, for each param for the plugin, we find its port, and set // the value for the port there.