From 9a6caa2453238ac3983b1541d20a3140deb252a4 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 25 Jan 2020 17:47:20 -0300 Subject: [PATCH] add gate cmd --- doc/README.md | 9 +++++++++ examples/gate.scri | 5 +++++ src/lang.zig | 2 ++ src/printer.zig | 1 + src/runner.zig | 16 ++++++++++++++++ 5 files changed, 33 insertions(+) create mode 100644 examples/gate.scri diff --git a/doc/README.md b/doc/README.md index c342bef..74a1445 100644 --- a/doc/README.md +++ b/doc/README.md @@ -178,3 +178,12 @@ with a suffix on the filename (before extension). Doing consecutive `quicksave`s will not overwrite any files, the suffixes will just be different. + +## `gate split index switch threshold attack hold decay gaterange` + + - switch (bool): 0..1, default 0 + - threshold (dB): -70..12, default -70 + - attack (ms): 0.1..500, default 30 + - hold (ms): 5..3000, default 500 + - decay (ms): 5..4000, default 1000 + - gaterange (dB): -90..-20, default -90 diff --git a/examples/gate.scri b/examples/gate.scri new file mode 100644 index 0000000..9269932 --- /dev/null +++ b/examples/gate.scri @@ -0,0 +1,5 @@ +load :0; +gate 5 1 0 1 100 500 1000 -50; +gate 5 2 1 1 100 500 1000 -50; +gate 5 3 1 1 150 1000 1000 -50; +quicksave; diff --git a/src/lang.zig b/src/lang.zig index a50f738..07e5fb1 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -26,6 +26,7 @@ pub const CommandType = enum { Delay, Vinyl, RevDelay, + Gate, Noise, WildNoise, @@ -184,6 +185,7 @@ pub const Lang = struct { _ = try self.keywords.put("delay", .Delay); _ = try self.keywords.put("vinyl", .Vinyl); _ = try self.keywords.put("revdelay", .RevDelay); + _ = try self.keywords.put("gate", .Gate); // custom implementations (not lv2) _ = try self.keywords.put("noise", .Noise); diff --git a/src/printer.zig b/src/printer.zig index a543325..faa863a 100644 --- a/src/printer.zig +++ b/src/printer.zig @@ -20,6 +20,7 @@ pub fn printList(list: langs.CommandList, stream: var) !void { .Delay => "delay", .Vinyl => "vinyl", .RevDelay => "revdelay", + .Gate => "gate", .Noise => "noise", .WildNoise => "wildnoise", diff --git a/src/runner.zig b/src/runner.zig index 33cacb2..44c9fb4 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -294,6 +294,11 @@ pub const Runner = struct { try magick.runRotate(image, deg, c_bgfill); } + fn gateCmd(self: *Runner, pos: Position, params: ParamList) !void { + var image = try self.getImage(); + try image.runPlugin("http://hippie.lt/lv2/gate", pos, params); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { var params = ParamList.init(self.allocator); defer params.deinit(); @@ -477,6 +482,17 @@ pub const Runner = struct { try self.rotateCmd(deg, bgfill); }, + .Gate => { + const pos = try cmd.consumePosition(); + try cmd.appendParam(¶ms, "switch"); + try cmd.appendParam(¶ms, "threshold"); + try cmd.appendParam(¶ms, "attack"); + try cmd.appendParam(¶ms, "hold"); + try cmd.appendParam(¶ms, "decay"); + try cmd.appendParam(¶ms, "gaterange"); + try self.gateCmd(pos, params); + }, + else => blk: { std.debug.warn("Unsupported command: {}\n", .{cmd.command}); break :blk RunError.UnknownCommand;