diff --git a/doc/README.md b/doc/README.md index df545b4..fe22674 100644 --- a/doc/README.md +++ b/doc/README.md @@ -23,6 +23,8 @@ where in the file you want the plugin to be ran. so, if you did `plugin 3 1...`, it would split the file in 3, then get the part that is of index 1 (starting at 0). +**Keep in mind parts start from the bottom of the file.** + ## `load path_or_arg` Load a file into memory. The file MUST end with the bmp extension (and so MUST @@ -46,6 +48,17 @@ Run the DJ EQ plugin from the SWH plugins. `lo`, `mid`, and `hi` are the respective dB gains for each frequency range. All three ranges accept gains from -70dB to +6dB. +Default is 0 for all (no action taken). + +## `phaser split index lfo_rate lfo_depth fb spread` + +Run the LFO Phaser plugin from the SWH plugins. + +Parameters: + - `lfo_rate`: LFO Rate (Hz), 0..100, default 25 + - `lfo_depth`: LFO depth, 0..1, default 0.25 + - `fb`: Feedback, -1..1, default 0 + - `spread`: Spread (octaves), 0..2, default 1 ## TODO `echo split index delay` diff --git a/examples/phaser.scri b/examples/phaser.scri new file mode 100644 index 0000000..9e8f2ce --- /dev/null +++ b/examples/phaser.scri @@ -0,0 +1,3 @@ +load :0; +phaser 3 1 25 0.25 0 1; +quicksave; diff --git a/src/lang.zig b/src/lang.zig index ddd4ba5..dc7010c 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -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 { diff --git a/src/runner.zig b/src/runner.zig index d71062b..0299838 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -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(¶ms, "lfo_rate", lfo_rate); + try appendParam(¶ms, "lfo_depth", lfo_depth); + try appendParam(¶ms, "fb", fb); + try appendParam(¶ms, "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;