From ab9eaa14004bf9acfd66086059b62ba20a24107d Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 10 Jul 2019 17:31:18 -0300 Subject: [PATCH 1/4] add pitchscaler cmd --- doc/README.md | 6 ++++++ examples/pitch.scri | 4 ++++ src/lang.zig | 2 ++ src/runner.zig | 23 +++++++++++++---------- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 examples/pitch.scri diff --git a/doc/README.md b/doc/README.md index 3182f7d..9792d7a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -83,6 +83,12 @@ Parameters: - `law_freq`: LFO frequency (Hz), 2..30, default 9 - `attendb`: Output attenuation (dB), -20..0, default 0 +## `pitchscaler split index mult` + +Runs the Higher Quality Pitch Scaler from the SWH plugins. + +The `mult` parameter is the pitch coefficient, range from 0.5..2, default 1. + ## TODO `echo split index delay` Run an echo filter on the given loaded file. diff --git a/examples/pitch.scri b/examples/pitch.scri new file mode 100644 index 0000000..4aeb707 --- /dev/null +++ b/examples/pitch.scri @@ -0,0 +1,4 @@ +load :0; +pitchscaler 3 1 1.0000000000001; +pitchscaler 10 8 0.999999999999; +quicksave; diff --git a/src/lang.zig b/src/lang.zig index 802ba82..015e65b 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -19,6 +19,7 @@ pub const CommandType = enum { Phaser, Mbeq, Chorus, + PitchScaler, }; pub const Command = struct { @@ -126,6 +127,7 @@ pub const Lang = struct { _ = try self.keywords.put("mbeq", .Mbeq); _ = try self.keywords.put("phaser", .Phaser); _ = try self.keywords.put("chorus", .Chorus); + _ = try self.keywords.put("pitchscaler", .PitchScaler); } pub fn parse(self: *Lang, data: []const u8) !CommandList { diff --git a/src/runner.zig b/src/runner.zig index b0d7c33..7121ee7 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -173,11 +173,7 @@ pub const Runner = struct { try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params); } - fn mbeqCmd( - self: *Runner, - position: Position, - bands: []const f32, - ) !void { + fn mbeqCmd(self: *Runner, position: Position, bands: []const f32) !void { var image = try self.getImage(); var params = ParamList.init(self.allocator); defer params.deinit(); @@ -193,15 +189,16 @@ pub const Runner = struct { try image.runPlugin("http://plugin.org.uk/swh-plugins/mbeq", position, params); } - fn chorusCmd( - self: *Runner, - pos: Position, - params: ParamList, - ) !void { + fn chorusCmd(self: *Runner, pos: Position, params: ParamList) !void { var image = try self.getImage(); try image.runPlugin("http://plugin.org.uk/swh-plugins/multivoiceChorus", pos, params); } + fn pitchScalerCmd(self: *Runner, pos: Position, params: ParamList) !void { + var image = try self.getImage(); + try image.runPlugin("http://plugin.org.uk/swh-plugins/pitchScaleHQ", pos, params); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { var params = ParamList.init(self.allocator); defer params.deinit(); @@ -267,6 +264,12 @@ pub const Runner = struct { try self.chorusCmd(pos, params); }, + .PitchScaler => blk: { + const pos = try cmd.consumePosition(); + try cmd.appendParam(¶ms, "mult", 2); + try self.pitchScalerCmd(pos, params); + }, + else => blk: { std.debug.warn("Unsupported command: {}\n", cmd.command); break :blk RunError.UnknownCommand; From 159048550d66e1fa15ba08b724dff76c220111b6 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 10 Jul 2019 20:19:40 -0300 Subject: [PATCH 2/4] add reverb command --- README.md | 1 + doc/README.md | 6 ++++++ examples/reverb.scri | 3 +++ src/lang.zig | 2 ++ src/plugin.zig | 2 +- src/runner.zig | 22 ++++++++++++++++++++++ 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 examples/reverb.scri diff --git a/README.md b/README.md index 629374c..1d172d9 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ glitch art "framework", ???????? language??? something? ## plugin depedencies: - lv2 default plugins (most specifically the eg-amp plugin) - the SWH plugins ( https://github.com/swh/lv2 ) + - the Invada Studio plugins ( https://launchpad.net/invada-studio/ ) ```bash # build and install diff --git a/doc/README.md b/doc/README.md index 9792d7a..205d950 100644 --- a/doc/README.md +++ b/doc/README.md @@ -89,6 +89,12 @@ Runs the Higher Quality Pitch Scaler from the SWH plugins. The `mult` parameter is the pitch coefficient, range from 0.5..2, default 1. +## `reverb split index bypass roomLength roomHeight sourceLR sourceFB listLR listFB hpf warmth diffusion` + +Run the Early Reflection Reverb from the Invada Studio plugins. + +**TODO** Parameters. + ## TODO `echo split index delay` Run an echo filter on the given loaded file. diff --git a/examples/reverb.scri b/examples/reverb.scri new file mode 100644 index 0000000..619faf9 --- /dev/null +++ b/examples/reverb.scri @@ -0,0 +1,3 @@ +load :0; +reverb 3 1 0 25 30 0 0.8 0 0.2 1000 50 50; +quicksave; diff --git a/src/lang.zig b/src/lang.zig index 015e65b..7add67f 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -20,6 +20,7 @@ pub const CommandType = enum { Mbeq, Chorus, PitchScaler, + Reverb, }; pub const Command = struct { @@ -128,6 +129,7 @@ pub const Lang = struct { _ = try self.keywords.put("phaser", .Phaser); _ = try self.keywords.put("chorus", .Chorus); _ = try self.keywords.put("pitchscaler", .PitchScaler); + _ = try self.keywords.put("reverb", .Reverb); } pub fn parse(self: *Lang, data: []const u8) !CommandList { diff --git a/src/plugin.zig b/src/plugin.zig index 6ee0c94..79094f6 100644 --- a/src/plugin.zig +++ b/src/plugin.zig @@ -74,7 +74,7 @@ pub const RunContext = struct { return RunContext{ .in_buf = try allocator.alloc(f32, 1), - .out_buf = try allocator.alloc(f32, 1), + .out_buf = try allocator.alloc(f32, 2), .instance = instance.?, }; } diff --git a/src/runner.zig b/src/runner.zig index 7121ee7..92f450f 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -199,6 +199,11 @@ pub const Runner = struct { try image.runPlugin("http://plugin.org.uk/swh-plugins/pitchScaleHQ", pos, params); } + fn reverbCmd(self: *Runner, pos: Position, params: ParamList) !void { + var image = try self.getImage(); + try image.runPlugin("http://invadarecords.com/plugins/lv2/erreverb/mono", pos, params); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { var params = ParamList.init(self.allocator); defer params.deinit(); @@ -270,6 +275,23 @@ pub const Runner = struct { try self.pitchScalerCmd(pos, params); }, + .Reverb => blk: { + const pos = try cmd.consumePosition(); + + try cmd.appendParam(¶ms, "bypass", 2); + try cmd.appendParam(¶ms, "roomLength", 3); + try cmd.appendParam(¶ms, "roomHeight", 4); + try cmd.appendParam(¶ms, "sourceLR", 5); + try cmd.appendParam(¶ms, "sourceFB", 6); + try cmd.appendParam(¶ms, "listLR", 7); + try cmd.appendParam(¶ms, "listFB", 8); + try cmd.appendParam(¶ms, "hpf", 9); + try cmd.appendParam(¶ms, "warmth", 10); + try cmd.appendParam(¶ms, "diffusion", 11); + + try self.reverbCmd(pos, params); + }, + else => blk: { std.debug.warn("Unsupported command: {}\n", cmd.command); break :blk RunError.UnknownCommand; From c7436815153ff55fe5039ce5429ccecb0243a255 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 10 Jul 2019 20:41:17 -0300 Subject: [PATCH 3/4] add highpass cmd - remove bypass arg from reverb cmd --- doc/README.md | 13 +++++++++++-- examples/highpass.scri | 3 +++ examples/reverb.scri | 2 +- src/lang.zig | 2 ++ src/runner.zig | 34 ++++++++++++++++++++++++---------- 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 examples/highpass.scri diff --git a/doc/README.md b/doc/README.md index 205d950..73b81b1 100644 --- a/doc/README.md +++ b/doc/README.md @@ -89,11 +89,20 @@ Runs the Higher Quality Pitch Scaler from the SWH plugins. The `mult` parameter is the pitch coefficient, range from 0.5..2, default 1. -## `reverb split index bypass roomLength roomHeight sourceLR sourceFB listLR listFB hpf warmth diffusion` +## `reverb split index roomLength roomHeight sourceLR sourceFB listLR listFB hpf warmth diffusion` Run the Early Reflection Reverb from the Invada Studio plugins. -**TODO** Parameters. +**TODO** Parameter list + +## `highpass split index freq gain noClip` + +Run the High Pass Filter from the Invada Studio plugins. + +Parameters: + - `freq`: Frequency. 20-20000, default 1000 + - `gain`: Gain, 0-12, default 0 + - `noClip`: Soft Clip (assumed boolean), 0-1, default 0 ## TODO `echo split index delay` diff --git a/examples/highpass.scri b/examples/highpass.scri new file mode 100644 index 0000000..3c58799 --- /dev/null +++ b/examples/highpass.scri @@ -0,0 +1,3 @@ +load :0; +highpass 3 1 1000 0 0; +quicksave; diff --git a/examples/reverb.scri b/examples/reverb.scri index 619faf9..9148bf7 100644 --- a/examples/reverb.scri +++ b/examples/reverb.scri @@ -1,3 +1,3 @@ load :0; -reverb 3 1 0 25 30 0 0.8 0 0.2 1000 50 50; +reverb 3 1 25 30 0 0.8 0 0.2 1000 50 50; quicksave; diff --git a/src/lang.zig b/src/lang.zig index 7add67f..20e0b3a 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -21,6 +21,7 @@ pub const CommandType = enum { Chorus, PitchScaler, Reverb, + Highpass, }; pub const Command = struct { @@ -130,6 +131,7 @@ pub const Lang = struct { _ = try self.keywords.put("chorus", .Chorus); _ = try self.keywords.put("pitchscaler", .PitchScaler); _ = try self.keywords.put("reverb", .Reverb); + _ = try self.keywords.put("highpass", .Highpass); } pub fn parse(self: *Lang, data: []const u8) !CommandList { diff --git a/src/runner.zig b/src/runner.zig index 92f450f..029122c 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -204,6 +204,11 @@ pub const Runner = struct { try image.runPlugin("http://invadarecords.com/plugins/lv2/erreverb/mono", pos, params); } + fn highpassCmd(self: *Runner, pos: Position, params: ParamList) !void { + var image = try self.getImage(); + try image.runPlugin("http://invadarecords.com/plugins/lv2/filter/hpf/mono", pos, params); + } + fn runCommand(self: *Runner, cmd: *lang.Command) !void { var params = ParamList.init(self.allocator); defer params.deinit(); @@ -278,20 +283,29 @@ pub const Runner = struct { .Reverb => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "bypass", 2); - try cmd.appendParam(¶ms, "roomLength", 3); - try cmd.appendParam(¶ms, "roomHeight", 4); - try cmd.appendParam(¶ms, "sourceLR", 5); - try cmd.appendParam(¶ms, "sourceFB", 6); - try cmd.appendParam(¶ms, "listLR", 7); - try cmd.appendParam(¶ms, "listFB", 8); - try cmd.appendParam(¶ms, "hpf", 9); - try cmd.appendParam(¶ms, "warmth", 10); - try cmd.appendParam(¶ms, "diffusion", 11); + try cmd.appendParam(¶ms, "roomLength", 2); + try cmd.appendParam(¶ms, "roomHeight", 3); + try cmd.appendParam(¶ms, "sourceLR", 4); + try cmd.appendParam(¶ms, "sourceFB", 5); + try cmd.appendParam(¶ms, "listLR", 6); + try cmd.appendParam(¶ms, "listFB", 7); + try cmd.appendParam(¶ms, "hpf", 8); + try cmd.appendParam(¶ms, "warmth", 9); + try cmd.appendParam(¶ms, "diffusion", 10); try self.reverbCmd(pos, params); }, + .Highpass => blk: { + const pos = try cmd.consumePosition(); + + try cmd.appendParam(¶ms, "freq", 2); + try cmd.appendParam(¶ms, "gain", 3); + try cmd.appendParam(¶ms, "noClip", 4); + + try self.highpassCmd(pos, params); + }, + else => blk: { std.debug.warn("Unsupported command: {}\n", cmd.command); break :blk RunError.UnknownCommand; From 3a8f84a3b23fe6bf8df07ba0b557920c29d15d61 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 10 Jul 2019 20:46:22 -0300 Subject: [PATCH 4/4] add implicit arg index for Command helper funcs --- examples/highpass.scri | 2 +- src/lang.zig | 11 +++++--- src/runner.zig | 58 +++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/examples/highpass.scri b/examples/highpass.scri index 3c58799..dab6def 100644 --- a/examples/highpass.scri +++ b/examples/highpass.scri @@ -1,3 +1,3 @@ load :0; -highpass 3 1 1000 0 0; +highpass 3 1 7800 0 0; quicksave; diff --git a/src/lang.zig b/src/lang.zig index 20e0b3a..c2e475d 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -27,6 +27,7 @@ pub const CommandType = enum { pub const Command = struct { command: CommandType, args: ArgList, + cur_idx: usize = 0, pub fn print(self: *const Command) void { std.debug.warn("cmd:{}\n", self.command); @@ -48,7 +49,8 @@ pub const Command = struct { return try std.fmt.parseInt(usize, arg, 10); } - pub fn consumePosition(self: *const Command) !plugin.Position { + pub fn consumePosition(self: *Command) !plugin.Position { + self.cur_idx = 2; return plugin.Position{ .split = try self.usizeArgAt(0), .index = try self.usizeArgAt(1), @@ -88,12 +90,13 @@ pub const Command = struct { } pub fn appendParam( - self: *const Command, + self: *Command, params: *plugin.ParamList, symbol: []const u8, - idx: usize, ) !void { - var val = try self.floatArgAt(idx); + var val = try self.floatArgAt(self.cur_idx); + self.cur_idx += 1; + try params.append(plugin.Param{ .sym = symbol, .value = val, diff --git a/src/runner.zig b/src/runner.zig index 029122c..3d62267 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -224,22 +224,22 @@ pub const Runner = struct { .Amp => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "gain", 2); + try cmd.appendParam(¶ms, "gain"); try self.ampCmd(pos, params); }, .RFlanger => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "delay_depth_avg", 2); - try cmd.appendParam(¶ms, "law_freq", 3); + try cmd.appendParam(¶ms, "delay_depth_avg"); + try cmd.appendParam(¶ms, "law_freq"); try self.rFlangerCmd(pos, params); }, .Eq => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "lo", 2); - try cmd.appendParam(¶ms, "mid", 3); - try cmd.appendParam(¶ms, "hi", 4); + try cmd.appendParam(¶ms, "lo"); + try cmd.appendParam(¶ms, "mid"); + try cmd.appendParam(¶ms, "hi"); try self.eqCmd(pos, params); }, @@ -247,10 +247,10 @@ pub const Runner = struct { .Phaser => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "lfo_rate", 2); - try cmd.appendParam(¶ms, "lfo_depth", 3); - try cmd.appendParam(¶ms, "fb", 4); - try cmd.appendParam(¶ms, "spread", 5); + try cmd.appendParam(¶ms, "lfo_rate"); + try cmd.appendParam(¶ms, "lfo_depth"); + try cmd.appendParam(¶ms, "fb"); + try cmd.appendParam(¶ms, "spread"); try self.phaserCmd(pos, params); }, @@ -264,34 +264,34 @@ pub const Runner = struct { .Chorus => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "voices", 2); - try cmd.appendParam(¶ms, "delay_base", 3); - try cmd.appendParam(¶ms, "voice_spread", 4); - try cmd.appendParam(¶ms, "detune", 5); - try cmd.appendParam(¶ms, "law_freq", 6); - try cmd.appendParam(¶ms, "attendb", 7); + try cmd.appendParam(¶ms, "voices"); + try cmd.appendParam(¶ms, "delay_base"); + try cmd.appendParam(¶ms, "voice_spread"); + try cmd.appendParam(¶ms, "detune"); + try cmd.appendParam(¶ms, "law_freq"); + try cmd.appendParam(¶ms, "attendb"); try self.chorusCmd(pos, params); }, .PitchScaler => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "mult", 2); + try cmd.appendParam(¶ms, "mult"); try self.pitchScalerCmd(pos, params); }, .Reverb => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "roomLength", 2); - try cmd.appendParam(¶ms, "roomHeight", 3); - try cmd.appendParam(¶ms, "sourceLR", 4); - try cmd.appendParam(¶ms, "sourceFB", 5); - try cmd.appendParam(¶ms, "listLR", 6); - try cmd.appendParam(¶ms, "listFB", 7); - try cmd.appendParam(¶ms, "hpf", 8); - try cmd.appendParam(¶ms, "warmth", 9); - try cmd.appendParam(¶ms, "diffusion", 10); + try cmd.appendParam(¶ms, "roomLength"); + try cmd.appendParam(¶ms, "roomHeight"); + try cmd.appendParam(¶ms, "sourceLR"); + try cmd.appendParam(¶ms, "sourceFB"); + try cmd.appendParam(¶ms, "listLR"); + try cmd.appendParam(¶ms, "listFB"); + try cmd.appendParam(¶ms, "hpf"); + try cmd.appendParam(¶ms, "warmth"); + try cmd.appendParam(¶ms, "diffusion"); try self.reverbCmd(pos, params); }, @@ -299,9 +299,9 @@ pub const Runner = struct { .Highpass => blk: { const pos = try cmd.consumePosition(); - try cmd.appendParam(¶ms, "freq", 2); - try cmd.appendParam(¶ms, "gain", 3); - try cmd.appendParam(¶ms, "noClip", 4); + try cmd.appendParam(¶ms, "freq"); + try cmd.appendParam(¶ms, "gain"); + try cmd.appendParam(¶ms, "noClip"); try self.highpassCmd(pos, params); },