add gate cmd

This commit is contained in:
Luna 2020-01-25 17:47:20 -03:00
parent 182d368363
commit 9a6caa2453
5 changed files with 33 additions and 0 deletions

View File

@ -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

5
examples/gate.scri Normal file
View File

@ -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;

View File

@ -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);

View File

@ -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",

View File

@ -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(&params, "switch");
try cmd.appendParam(&params, "threshold");
try cmd.appendParam(&params, "attack");
try cmd.appendParam(&params, "hold");
try cmd.appendParam(&params, "decay");
try cmd.appendParam(&params, "gaterange");
try self.gateCmd(pos, params);
},
else => blk: {
std.debug.warn("Unsupported command: {}\n", .{cmd.command});
break :blk RunError.UnknownCommand;