add phaser cmd

This commit is contained in:
Luna 2019-07-10 16:24:43 -03:00
parent 20aeedeef2
commit 6bc54f8e46
4 changed files with 49 additions and 0 deletions

View file

@ -16,6 +16,7 @@ pub const CommandType = enum {
Amp,
RFlanger,
Eq,
Phaser,
};
pub const Command = struct {
@ -85,6 +86,7 @@ pub const Lang = struct {
_ = try self.keywords.put("amp", .Amp);
_ = try self.keywords.put("rflanger", .RFlanger);
_ = try self.keywords.put("eq", .Eq);
_ = try self.keywords.put("phaser", .Phaser);
}
pub fn parse(self: *Lang, data: []const u8) !CommandList {

View file

@ -211,6 +211,26 @@ pub const Runner = struct {
try image.runPlugin("http://plugin.org.uk/swh-plugins/dj_eq_mono", position, params);
}
fn phaserCmd(
self: *Runner,
position: plugin.Position,
lfo_rate: f32,
lfo_depth: f32,
fb: f32,
spread: f32,
) !void {
var image = try self.getImage();
var params = plugin.ParamList.init(self.allocator);
defer params.deinit();
try appendParam(&params, "lfo_rate", lfo_rate);
try appendParam(&params, "lfo_depth", lfo_depth);
try appendParam(&params, "fb", fb);
try appendParam(&params, "spread", spread);
try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params);
}
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
return switch (cmd.command) {
.Noop => {},
@ -247,6 +267,17 @@ pub const Runner = struct {
try self.eqCmd(pos, lo, mid, high);
},
.Phaser => blk: {
const pos = try cmd.consumePosition();
const lfo_rate = try cmd.floatArgAt(2);
const lfo_depth = try cmd.floatArgAt(3);
const fb = try cmd.floatArgAt(4);
const spread = try cmd.floatArgAt(5);
try self.phaserCmd(pos, lfo_rate, lfo_depth, fb, spread);
},
else => blk: {
std.debug.warn("Unknown command: {}\n", cmd.command);
break :blk RunError.UnknownCommand;