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

@ -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 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). 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 path_or_arg`
Load a file into memory. The file MUST end with the bmp extension (and so MUST 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. `lo`, `mid`, and `hi` are the respective dB gains for each frequency range.
All three ranges accept gains from -70dB to +6dB. 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` ## TODO `echo split index delay`

3
examples/phaser.scri Normal file
View file

@ -0,0 +1,3 @@
load :0;
phaser 3 1 25 0.25 0 1;
quicksave;

View file

@ -16,6 +16,7 @@ pub const CommandType = enum {
Amp, Amp,
RFlanger, RFlanger,
Eq, Eq,
Phaser,
}; };
pub const Command = struct { pub const Command = struct {
@ -85,6 +86,7 @@ pub const Lang = struct {
_ = try self.keywords.put("amp", .Amp); _ = try self.keywords.put("amp", .Amp);
_ = try self.keywords.put("rflanger", .RFlanger); _ = try self.keywords.put("rflanger", .RFlanger);
_ = try self.keywords.put("eq", .Eq); _ = try self.keywords.put("eq", .Eq);
_ = try self.keywords.put("phaser", .Phaser);
} }
pub fn parse(self: *Lang, data: []const u8) !CommandList { 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); 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 { fn runCommand(self: *Runner, cmd: *lang.Command) !void {
return switch (cmd.command) { return switch (cmd.command) {
.Noop => {}, .Noop => {},
@ -247,6 +267,17 @@ pub const Runner = struct {
try self.eqCmd(pos, lo, mid, high); 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: { else => blk: {
std.debug.warn("Unknown command: {}\n", cmd.command); std.debug.warn("Unknown command: {}\n", cmd.command);
break :blk RunError.UnknownCommand; break :blk RunError.UnknownCommand;