2019-07-08 15:38:16 +00:00
|
|
|
const std = @import("std");
|
|
|
|
const lang = @import("lang.zig");
|
2019-07-08 17:43:58 +00:00
|
|
|
const images = @import("image.zig");
|
2019-07-09 01:40:52 +00:00
|
|
|
const plugin = @import("plugin.zig");
|
2019-07-13 20:42:46 +00:00
|
|
|
const custom = @import("custom.zig");
|
2019-07-22 22:28:55 +00:00
|
|
|
const magick = @import("magick.zig");
|
2019-07-08 15:38:16 +00:00
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
const Position = plugin.Position;
|
|
|
|
const ParamList = plugin.ParamList;
|
2019-07-13 21:17:44 +00:00
|
|
|
const ParamMap = plugin.ParamMap;
|
2019-07-10 20:15:57 +00:00
|
|
|
|
2019-07-08 17:43:58 +00:00
|
|
|
const Image = images.Image;
|
|
|
|
|
|
|
|
pub const RunError = error{
|
|
|
|
UnknownCommand,
|
|
|
|
NoBMP,
|
2019-07-08 18:40:31 +00:00
|
|
|
ImageRequired,
|
2019-07-08 17:43:58 +00:00
|
|
|
};
|
2019-07-08 15:38:16 +00:00
|
|
|
|
|
|
|
pub const Runner = struct {
|
|
|
|
allocator: *std.mem.Allocator,
|
2019-10-06 18:16:41 +00:00
|
|
|
|
|
|
|
/// The currently opened image in the runner
|
2019-07-08 17:43:58 +00:00
|
|
|
image: ?*Image = null,
|
2019-07-08 15:38:16 +00:00
|
|
|
|
2019-10-06 18:16:41 +00:00
|
|
|
/// If the runner is in REPL mode
|
|
|
|
repl: bool = false,
|
|
|
|
|
|
|
|
pub fn init(allocator: *std.mem.Allocator, repl: bool) Runner {
|
2019-07-09 03:04:01 +00:00
|
|
|
return Runner{
|
|
|
|
.allocator = allocator,
|
2019-10-06 18:16:41 +00:00
|
|
|
.repl = repl,
|
2019-07-09 03:04:01 +00:00
|
|
|
};
|
2019-07-08 15:38:16 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 17:43:58 +00:00
|
|
|
pub fn deinit(self: *Runner) void {
|
|
|
|
if (self.image) |image| {
|
|
|
|
image.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-11 01:00:07 +00:00
|
|
|
pub fn clone(self: *Runner) !Runner {
|
|
|
|
var cloned_image = if (self.image) |image| try image.clone() else null;
|
|
|
|
return Runner{ .allocator = self.allocator, .image = cloned_image };
|
2019-09-11 00:31:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 16:55:54 +00:00
|
|
|
fn resolveArg(self: *Runner, load_path: []const u8) ![]const u8 {
|
|
|
|
if (load_path[0] == ':') {
|
|
|
|
// parse the index from 1 to end
|
2019-10-06 18:16:41 +00:00
|
|
|
var index = try std.fmt.parseInt(usize, load_path[1..], 10);
|
|
|
|
|
|
|
|
// don't care about the 'repl' being prepended when we're in repl
|
|
|
|
if (self.repl) index += 1;
|
|
|
|
|
2019-07-08 16:55:54 +00:00
|
|
|
var args_it = std.process.args();
|
|
|
|
_ = args_it.skip();
|
|
|
|
|
|
|
|
var i: usize = 0;
|
|
|
|
while (i <= index) : (i += 1) {
|
|
|
|
_ = args_it.skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
const arg = try (args_it.next(self.allocator) orelse @panic("expected argument"));
|
|
|
|
|
|
|
|
return arg;
|
|
|
|
} else {
|
|
|
|
return load_path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn resolveArgPath(self: *Runner, path_or_argidx: []const u8) ![]const u8 {
|
|
|
|
const path = try self.resolveArg(path_or_argidx);
|
|
|
|
const resolved_path = try std.fs.path.resolve(
|
|
|
|
self.allocator,
|
2019-12-08 15:14:31 +00:00
|
|
|
&[_][]const u8{path},
|
2019-07-08 16:55:54 +00:00
|
|
|
);
|
2019-07-08 17:43:58 +00:00
|
|
|
|
2019-07-08 16:55:54 +00:00
|
|
|
return resolved_path;
|
|
|
|
}
|
|
|
|
|
2019-07-08 17:43:58 +00:00
|
|
|
fn loadCmd(self: *Runner, path_or_argidx: []const u8) !void {
|
2019-07-08 16:55:54 +00:00
|
|
|
var load_path = try self.resolveArgPath(path_or_argidx);
|
2020-01-15 01:31:20 +00:00
|
|
|
std.debug.warn("\tload path: {}\n", .{load_path});
|
2019-07-08 17:43:58 +00:00
|
|
|
|
|
|
|
// we could use ImageMagick to convert from X to BMP
|
|
|
|
// but i can't find an easy way to do things in memory.
|
|
|
|
|
|
|
|
// the upside is that this allows some pre-processing by the user
|
|
|
|
// before loading the file into scritcher. for example, you can start
|
|
|
|
// krita/gimp and make it export a bmp and while in the program you can
|
|
|
|
// apply filters, etc.
|
2019-11-02 00:43:45 +00:00
|
|
|
if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) {
|
2020-01-15 01:31:20 +00:00
|
|
|
std.debug.warn("Only BMP files are allowed to be loaded.\n", .{});
|
2019-07-08 17:43:58 +00:00
|
|
|
return RunError.NoBMP;
|
|
|
|
}
|
|
|
|
|
2019-07-10 15:00:43 +00:00
|
|
|
// we don't copy load_path into a temporary file because we're already
|
|
|
|
// loading it under the SFM_READ mode, which won't cause any destructive
|
|
|
|
// operations on the file.
|
2019-07-08 17:43:58 +00:00
|
|
|
self.image = try Image.open(self.allocator, load_path);
|
2019-07-08 16:55:54 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 18:40:31 +00:00
|
|
|
fn getImage(self: *Runner) !*Image {
|
|
|
|
if (self.image) |image| {
|
|
|
|
return image;
|
|
|
|
} else {
|
2020-01-15 01:31:20 +00:00
|
|
|
std.debug.warn("image is required!\n", .{});
|
2019-07-08 18:40:31 +00:00
|
|
|
return RunError.ImageRequired;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-11 00:43:23 +00:00
|
|
|
fn makeGlitchedPath(self: *Runner) ![]const u8 {
|
2019-07-08 18:40:31 +00:00
|
|
|
// we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where
|
|
|
|
// N is the maximum non-used integer.
|
|
|
|
var image = try self.getImage();
|
|
|
|
|
|
|
|
const basename = std.fs.path.basename(image.path);
|
|
|
|
const dirname = std.fs.path.dirname(image.path).?;
|
|
|
|
|
2020-03-26 19:35:58 +00:00
|
|
|
var dir = try std.fs.cwd().openDir(dirname, .{ .iterate = true });
|
2019-07-08 18:40:31 +00:00
|
|
|
defer dir.close();
|
|
|
|
|
|
|
|
const period_idx = std.mem.lastIndexOf(u8, basename, ".").?;
|
|
|
|
const extension = basename[period_idx..basename.len];
|
|
|
|
|
|
|
|
// starts_with would be "x_g", we want to find all files in the directory
|
|
|
|
// that start with that name.
|
2020-01-15 01:31:20 +00:00
|
|
|
const starts_with = try std.fmt.allocPrint(self.allocator, "{}_g", .{
|
2019-07-08 18:40:31 +00:00
|
|
|
basename[0..period_idx],
|
2020-01-15 01:31:20 +00:00
|
|
|
});
|
2019-08-13 13:33:08 +00:00
|
|
|
defer self.allocator.free(starts_with);
|
2019-07-08 18:40:31 +00:00
|
|
|
|
|
|
|
var max: usize = 0;
|
|
|
|
|
2019-10-31 22:02:36 +00:00
|
|
|
var it = dir.iterate();
|
|
|
|
|
|
|
|
while (try it.next()) |entry| {
|
2019-07-08 18:40:31 +00:00
|
|
|
switch (entry.kind) {
|
|
|
|
.File => blk: {
|
|
|
|
if (!std.mem.startsWith(u8, entry.name, starts_with)) break :blk {};
|
|
|
|
|
|
|
|
// we want to get the N in x_gN.ext
|
|
|
|
const entry_gidx = std.mem.lastIndexOf(u8, entry.name, "_g").?;
|
|
|
|
|
|
|
|
const entry_pidx_opt = std.mem.lastIndexOf(u8, entry.name, ".");
|
|
|
|
if (entry_pidx_opt == null) break :blk {};
|
|
|
|
|
|
|
|
const entry_pidx = entry_pidx_opt.?;
|
|
|
|
|
|
|
|
// if N isn't a number, we just ignore that file
|
|
|
|
const idx_str = entry.name[entry_gidx + 2 .. entry_pidx];
|
|
|
|
const idx = std.fmt.parseInt(usize, idx_str, 10) catch |err| {
|
|
|
|
break :blk {};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (idx > max) max = idx;
|
|
|
|
},
|
|
|
|
else => {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-15 01:31:20 +00:00
|
|
|
const out_path = try std.fmt.allocPrint(self.allocator, "{}/{}{}{}", .{
|
2019-07-10 02:04:05 +00:00
|
|
|
dirname,
|
|
|
|
starts_with,
|
|
|
|
max + 1,
|
|
|
|
extension,
|
2020-01-15 01:31:20 +00:00
|
|
|
});
|
2019-07-10 02:04:05 +00:00
|
|
|
|
2019-07-11 00:43:23 +00:00
|
|
|
return out_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn quicksaveCmd(self: *Runner) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
const out_path = try self.makeGlitchedPath();
|
2019-07-10 02:04:05 +00:00
|
|
|
try image.saveTo(out_path);
|
2019-07-08 18:40:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 00:43:23 +00:00
|
|
|
fn runQSCmd(self: *Runner, program: []const u8) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
const out_path = try self.makeGlitchedPath();
|
|
|
|
try image.saveTo(out_path);
|
|
|
|
|
|
|
|
var proc = try std.ChildProcess.init(
|
2019-12-08 15:14:31 +00:00
|
|
|
&[_][]const u8{ program, out_path },
|
2019-07-11 00:43:23 +00:00
|
|
|
self.allocator,
|
|
|
|
);
|
|
|
|
defer proc.deinit();
|
|
|
|
|
2020-01-15 01:31:20 +00:00
|
|
|
std.debug.warn("running '{} {}'\n", .{ program, out_path });
|
2019-07-11 00:43:23 +00:00
|
|
|
_ = try proc.spawnAndWait();
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:40:52 +00:00
|
|
|
/// Run the http://lv2plug.in/plugins/eg-amp plugin over the file.
|
2019-07-10 20:15:57 +00:00
|
|
|
fn ampCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
2019-07-09 03:04:01 +00:00
|
|
|
var image = try self.getImage();
|
2019-07-10 20:15:57 +00:00
|
|
|
try image.runPlugin("http://lv2plug.in/plugins/eg-amp", pos, params);
|
2019-07-09 01:40:52 +00:00
|
|
|
}
|
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
fn rFlangerCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
2019-07-10 16:24:03 +00:00
|
|
|
var image = try self.getImage();
|
2019-07-10 20:15:57 +00:00
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/retroFlange", pos, params);
|
2019-07-10 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
fn eqCmd(self: *Runner, position: Position, params: ParamList) !void {
|
2019-07-10 19:06:44 +00:00
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/dj_eq_mono", position, params);
|
|
|
|
}
|
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
fn phaserCmd(self: *Runner, position: Position, params: ParamList) !void {
|
2019-07-10 19:24:43 +00:00
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params);
|
|
|
|
}
|
|
|
|
|
2019-07-10 20:31:18 +00:00
|
|
|
fn mbeqCmd(self: *Runner, position: Position, bands: []const f32) !void {
|
2019-07-10 19:43:30 +00:00
|
|
|
var image = try self.getImage();
|
2019-07-10 20:15:57 +00:00
|
|
|
var params = ParamList.init(self.allocator);
|
2019-07-10 19:43:30 +00:00
|
|
|
defer params.deinit();
|
|
|
|
|
|
|
|
for (bands) |band_value, idx| {
|
2020-01-15 01:31:20 +00:00
|
|
|
var sym = try std.fmt.allocPrint(self.allocator, "band_{}", .{idx + 1});
|
2019-07-10 20:15:57 +00:00
|
|
|
try params.append(plugin.Param{
|
|
|
|
.sym = sym,
|
|
|
|
.value = band_value,
|
|
|
|
});
|
2019-07-10 19:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/mbeq", position, params);
|
|
|
|
}
|
|
|
|
|
2019-07-10 20:31:18 +00:00
|
|
|
fn chorusCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
2019-07-10 19:59:15 +00:00
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/multivoiceChorus", pos, params);
|
|
|
|
}
|
|
|
|
|
2019-07-10 20:31:18 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-07-10 23:19:40 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-07-10 23:41:17 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-07-11 13:20:09 +00:00
|
|
|
fn delayCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/delayorama", pos, params);
|
|
|
|
}
|
|
|
|
|
2019-07-13 19:46:26 +00:00
|
|
|
fn vinylCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/vynil", pos, params);
|
|
|
|
}
|
|
|
|
|
2019-07-13 20:20:14 +00:00
|
|
|
fn revDelayCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/revdelay", pos, params);
|
|
|
|
}
|
|
|
|
|
2019-07-13 21:17:44 +00:00
|
|
|
fn noiseCmd(self: *Runner, pos: Position, map: *ParamMap) !void {
|
2019-07-13 20:42:46 +00:00
|
|
|
var image = try self.getImage();
|
2019-10-22 21:16:15 +00:00
|
|
|
try image.runCustomPlugin(custom.RandomNoise, pos, *ParamMap, map);
|
2019-07-13 20:42:46 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 22:55:57 +00:00
|
|
|
fn wildNoiseCmd(self: *Runner, pos: Position, map: *ParamMap) !void {
|
|
|
|
var image = try self.getImage();
|
2019-10-22 21:16:15 +00:00
|
|
|
try image.runCustomPlugin(custom.WildNoise, pos, *ParamMap, map);
|
2019-07-13 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
2019-07-29 14:51:40 +00:00
|
|
|
fn writeCmd(self: *Runner, pos: Position, map: *ParamMap) !void {
|
|
|
|
var image = try self.getImage();
|
2019-10-22 21:16:15 +00:00
|
|
|
try image.runCustomPlugin(custom.Write, pos, *ParamMap, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn embedCmd(self: *Runner, pos: Position, path: []const u8) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runCustomPlugin(custom.Embed, pos, []const u8, path);
|
2019-07-29 14:51:40 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 01:22:01 +00:00
|
|
|
fn rotateCmd(
|
|
|
|
self: *Runner,
|
|
|
|
deg: f32,
|
|
|
|
bgfill: []const u8,
|
|
|
|
) !void {
|
2019-07-22 22:28:55 +00:00
|
|
|
var image = try self.getImage();
|
2019-07-23 01:22:01 +00:00
|
|
|
var c_bgfill = try std.cstr.addNullByte(self.allocator, bgfill);
|
|
|
|
defer self.allocator.free(c_bgfill);
|
|
|
|
|
|
|
|
try magick.runRotate(image, deg, c_bgfill);
|
2019-07-22 22:28:55 +00:00
|
|
|
}
|
|
|
|
|
2020-01-25 20:47:20 +00:00
|
|
|
fn gateCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://hippie.lt/lv2/gate", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-25 21:52:45 +00:00
|
|
|
fn detuneCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/Detune", pos, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn overdriveCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/Overdrive", pos, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn degradeCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/Degrade", pos, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn repsychoCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/RePsycho", pos, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn talkboxCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/TalkBox", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 01:45:37 +00:00
|
|
|
fn dynCompCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://gareus.org/oss/lv2/darc#mono", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 02:52:22 +00:00
|
|
|
fn foverdriveCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/foverdrive", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 02:32:24 +00:00
|
|
|
fn thruZeroCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://drobilla.net/plugins/mda/ThruZero", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 03:03:15 +00:00
|
|
|
fn gverbCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/gverb", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 03:13:53 +00:00
|
|
|
fn invertCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/inv", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 03:28:59 +00:00
|
|
|
fn tapedelayCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/tapeDelay", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 05:05:43 +00:00
|
|
|
fn moddelayCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/modDelay", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 17:03:01 +00:00
|
|
|
fn multichorusCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://calf.sourceforge.net/plugins/MultiChorus", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-01-26 17:50:50 +00:00
|
|
|
fn saturatorCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://calf.sourceforge.net/plugins/Saturator", pos, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn vintagedelayCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
|
|
var image = try self.getImage();
|
|
|
|
try image.runPlugin("http://calf.sourceforge.net/plugins/VintageDelay", pos, params);
|
|
|
|
}
|
|
|
|
|
2020-05-31 01:56:45 +00:00
|
|
|
fn newRunCommandSingle(
|
|
|
|
self: *@This(),
|
|
|
|
cmd: lang.NewCommand,
|
|
|
|
comptime tag: lang.NewCommand.Tag,
|
|
|
|
) !void {
|
|
|
|
comptime const typ = lang.NewCommand.tagToType(tag);
|
|
|
|
const command = cmd.cast(typ).?;
|
|
|
|
|
|
|
|
std.debug.warn("{}\n", .{command});
|
|
|
|
}
|
|
|
|
|
|
|
|
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void {
|
|
|
|
switch (cmd.tag) {
|
|
|
|
.load => try self.newRunCommandSingle(cmd, .load),
|
|
|
|
else => @panic("TODO"),
|
|
|
|
}
|
|
|
|
}
|
2020-05-31 01:25:43 +00:00
|
|
|
|
2019-07-08 15:38:16 +00:00
|
|
|
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
2019-07-10 20:15:57 +00:00
|
|
|
var params = ParamList.init(self.allocator);
|
2019-07-10 19:59:15 +00:00
|
|
|
defer params.deinit();
|
|
|
|
|
2019-07-13 21:17:44 +00:00
|
|
|
var map = ParamMap.init(self.allocator);
|
|
|
|
defer map.deinit();
|
|
|
|
|
2019-07-08 15:38:16 +00:00
|
|
|
return switch (cmd.command) {
|
|
|
|
.Noop => {},
|
2019-07-08 16:55:54 +00:00
|
|
|
.Load => blk: {
|
2020-05-12 20:26:33 +00:00
|
|
|
var path = cmd.args.items[0];
|
2019-07-08 16:55:54 +00:00
|
|
|
try self.loadCmd(path);
|
2019-10-22 21:16:15 +00:00
|
|
|
|
|
|
|
// TODO is this needed?
|
2019-07-08 16:55:54 +00:00
|
|
|
break :blk;
|
|
|
|
},
|
2019-07-08 18:40:31 +00:00
|
|
|
.Quicksave => try self.quicksaveCmd(),
|
2020-05-12 20:26:33 +00:00
|
|
|
.RunQS => try self.runQSCmd(cmd.args.items[0]),
|
2019-07-09 01:40:52 +00:00
|
|
|
|
2019-07-09 03:04:01 +00:00
|
|
|
.Amp => blk: {
|
2019-07-10 20:15:57 +00:00
|
|
|
const pos = try cmd.consumePosition();
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "gain");
|
2019-07-10 20:15:57 +00:00
|
|
|
try self.ampCmd(pos, params);
|
2019-07-09 03:04:01 +00:00
|
|
|
},
|
2019-07-09 01:40:52 +00:00
|
|
|
|
2019-07-10 16:24:03 +00:00
|
|
|
.RFlanger => blk: {
|
2019-07-10 20:15:57 +00:00
|
|
|
const pos = try cmd.consumePosition();
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "delay_depth_avg");
|
|
|
|
try cmd.appendParam(¶ms, "law_freq");
|
2019-07-10 20:15:57 +00:00
|
|
|
try self.rFlangerCmd(pos, params);
|
2019-07-10 16:24:03 +00:00
|
|
|
},
|
|
|
|
|
2019-07-10 19:06:44 +00:00
|
|
|
.Eq => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "lo");
|
|
|
|
try cmd.appendParam(¶ms, "mid");
|
|
|
|
try cmd.appendParam(¶ms, "hi");
|
2019-07-10 19:06:44 +00:00
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
try self.eqCmd(pos, params);
|
2019-07-10 19:06:44 +00:00
|
|
|
},
|
|
|
|
|
2019-07-10 19:24:43 +00:00
|
|
|
.Phaser => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "lfo_rate");
|
|
|
|
try cmd.appendParam(¶ms, "lfo_depth");
|
|
|
|
try cmd.appendParam(¶ms, "fb");
|
|
|
|
try cmd.appendParam(¶ms, "spread");
|
2019-07-10 19:24:43 +00:00
|
|
|
|
2019-07-10 20:15:57 +00:00
|
|
|
try self.phaserCmd(pos, params);
|
2019-07-10 19:24:43 +00:00
|
|
|
},
|
|
|
|
|
2019-07-10 19:43:30 +00:00
|
|
|
.Mbeq => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
2019-11-10 16:37:59 +00:00
|
|
|
const bands = try cmd.floatArgMany(self.allocator, 2, 15, @as(f32, 0));
|
2019-08-13 13:33:08 +00:00
|
|
|
defer self.allocator.free(bands);
|
|
|
|
|
2019-07-10 19:43:30 +00:00
|
|
|
try self.mbeqCmd(pos, bands);
|
|
|
|
},
|
|
|
|
|
2019-07-10 19:59:15 +00:00
|
|
|
.Chorus => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
2019-07-10 23:46:22 +00:00
|
|
|
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");
|
2019-07-10 19:59:15 +00:00
|
|
|
|
|
|
|
try self.chorusCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-10 20:31:18 +00:00
|
|
|
.PitchScaler => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "mult");
|
2019-07-10 20:31:18 +00:00
|
|
|
try self.pitchScalerCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-10 23:19:40 +00:00
|
|
|
.Reverb => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "roomLength");
|
2019-07-15 17:21:08 +00:00
|
|
|
try cmd.appendParam(¶ms, "roomWidth");
|
2019-07-10 23:46:22 +00:00
|
|
|
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");
|
2019-07-10 23:19:40 +00:00
|
|
|
|
|
|
|
try self.reverbCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-10 23:41:17 +00:00
|
|
|
.Highpass => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
2019-07-10 23:46:22 +00:00
|
|
|
try cmd.appendParam(¶ms, "freq");
|
|
|
|
try cmd.appendParam(¶ms, "gain");
|
|
|
|
try cmd.appendParam(¶ms, "noClip");
|
2019-07-10 23:41:17 +00:00
|
|
|
|
|
|
|
try self.highpassCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-11 13:20:09 +00:00
|
|
|
.Delay => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "seed");
|
|
|
|
try cmd.appendParam(¶ms, "gain");
|
|
|
|
try cmd.appendParam(¶ms, "feedback_pc");
|
|
|
|
try cmd.appendParam(¶ms, "tap_count");
|
|
|
|
try cmd.appendParam(¶ms, "first_delay");
|
|
|
|
try cmd.appendParam(¶ms, "delay_range");
|
|
|
|
try cmd.appendParam(¶ms, "delay_scale");
|
|
|
|
try cmd.appendParam(¶ms, "delay_rand_pc");
|
|
|
|
try cmd.appendParam(¶ms, "gain_scale");
|
|
|
|
try cmd.appendParam(¶ms, "wet");
|
|
|
|
|
|
|
|
try self.delayCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-13 19:46:26 +00:00
|
|
|
.Vinyl => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "year");
|
|
|
|
try cmd.appendParam(¶ms, "rpm");
|
|
|
|
try cmd.appendParam(¶ms, "warp");
|
|
|
|
try cmd.appendParam(¶ms, "click");
|
|
|
|
try cmd.appendParam(¶ms, "wear");
|
|
|
|
|
|
|
|
try self.vinylCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-13 20:20:14 +00:00
|
|
|
.RevDelay => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "delay_time");
|
|
|
|
try cmd.appendParam(¶ms, "dry_level");
|
|
|
|
try cmd.appendParam(¶ms, "wet_level");
|
|
|
|
try cmd.appendParam(¶ms, "feedback");
|
|
|
|
try cmd.appendParam(¶ms, "xfade_samp");
|
|
|
|
|
|
|
|
try self.revDelayCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-13 20:42:46 +00:00
|
|
|
.Noise => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
2019-07-13 21:17:44 +00:00
|
|
|
|
|
|
|
try cmd.appendParamMap(&map, "seed");
|
|
|
|
try cmd.appendParamMap(&map, "fill_bytes");
|
|
|
|
|
|
|
|
try self.noiseCmd(pos, &map);
|
2019-07-13 20:42:46 +00:00
|
|
|
},
|
|
|
|
|
2019-07-13 22:55:57 +00:00
|
|
|
.WildNoise => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
|
|
|
try cmd.appendParamMap(&map, "seed");
|
|
|
|
try cmd.appendParamMap(&map, "fill_bytes");
|
|
|
|
|
|
|
|
try self.wildNoiseCmd(pos, &map);
|
|
|
|
},
|
|
|
|
|
2019-07-29 14:51:40 +00:00
|
|
|
.Write => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParamMap(&map, "data");
|
|
|
|
try self.writeCmd(pos, &map);
|
|
|
|
},
|
|
|
|
|
2019-10-22 21:16:15 +00:00
|
|
|
.Embed => blk: {
|
|
|
|
const pos = try cmd.consumePosition();
|
2020-05-12 20:26:33 +00:00
|
|
|
const path = cmd.args.items[2];
|
2019-10-22 21:16:15 +00:00
|
|
|
try self.embedCmd(pos, path);
|
|
|
|
},
|
|
|
|
|
2019-07-23 01:22:01 +00:00
|
|
|
.Rotate => blk: {
|
|
|
|
const deg = try cmd.floatArgAt(0);
|
|
|
|
const bgfill = try cmd.argAt(1);
|
|
|
|
try self.rotateCmd(deg, bgfill);
|
|
|
|
},
|
2019-07-22 22:28:55 +00:00
|
|
|
|
2020-01-25 20:47:20 +00:00
|
|
|
.Gate => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "switch");
|
|
|
|
try cmd.appendParam(¶ms, "threshold");
|
|
|
|
try cmd.appendParam(¶ms, "attack");
|
|
|
|
try cmd.appendParam(¶ms, "hold");
|
|
|
|
try cmd.appendParam(¶ms, "decay");
|
|
|
|
try cmd.appendParam(¶ms, "gaterange");
|
|
|
|
try self.gateCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-25 21:52:45 +00:00
|
|
|
.Detune => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "detune");
|
|
|
|
try cmd.appendParam(¶ms, "mix");
|
|
|
|
try cmd.appendParam(¶ms, "output");
|
|
|
|
try cmd.appendParam(¶ms, "latency");
|
|
|
|
try self.detuneCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
.Overdrive => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "drive");
|
|
|
|
try cmd.appendParam(¶ms, "muffle");
|
|
|
|
try cmd.appendParam(¶ms, "output");
|
|
|
|
try self.overdriveCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
.Degrade => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "headroom");
|
|
|
|
try cmd.appendParam(¶ms, "quant");
|
|
|
|
try cmd.appendParam(¶ms, "rate");
|
|
|
|
try cmd.appendParam(¶ms, "post_filt");
|
|
|
|
try cmd.appendParam(¶ms, "non_lin");
|
|
|
|
try cmd.appendParam(¶ms, "output");
|
|
|
|
try self.degradeCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
.RePsycho => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "tune");
|
|
|
|
try cmd.appendParam(¶ms, "fine");
|
|
|
|
try cmd.appendParam(¶ms, "decay");
|
|
|
|
try cmd.appendParam(¶ms, "thresh");
|
|
|
|
try cmd.appendParam(¶ms, "hold");
|
|
|
|
try cmd.appendParam(¶ms, "mix");
|
|
|
|
try cmd.appendParam(¶ms, "quality");
|
|
|
|
try self.repsychoCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
.TalkBox => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "wet");
|
|
|
|
try cmd.appendParam(¶ms, "dry");
|
|
|
|
try cmd.appendParam(¶ms, "carrier");
|
|
|
|
try cmd.appendParam(¶ms, "quality");
|
|
|
|
try self.talkboxCmd(pos, params);
|
|
|
|
},
|
2020-01-26 01:45:37 +00:00
|
|
|
|
|
|
|
.DynComp => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "enable");
|
|
|
|
try cmd.appendParam(¶ms, "hold");
|
|
|
|
try cmd.appendParam(¶ms, "inputgain");
|
|
|
|
try cmd.appendParam(¶ms, "threshold");
|
|
|
|
try cmd.appendParam(¶ms, "ratio");
|
|
|
|
try cmd.appendParam(¶ms, "attack");
|
|
|
|
try cmd.appendParam(¶ms, "release");
|
|
|
|
try cmd.appendParam(¶ms, "gain_min");
|
|
|
|
try cmd.appendParam(¶ms, "gain_max");
|
|
|
|
try cmd.appendParam(¶ms, "rms");
|
|
|
|
try self.dynCompCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 02:32:24 +00:00
|
|
|
.ThruZero => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "rate");
|
|
|
|
try cmd.appendParam(¶ms, "mix");
|
|
|
|
try cmd.appendParam(¶ms, "feedback");
|
|
|
|
try cmd.appendParam(¶ms, "depth_mod");
|
|
|
|
try self.thruZeroCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 02:52:22 +00:00
|
|
|
.Foverdrive => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "drive");
|
|
|
|
try self.foverdriveCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 03:03:15 +00:00
|
|
|
.Gverb => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "roomsize");
|
|
|
|
try cmd.appendParam(¶ms, "revtime");
|
|
|
|
try cmd.appendParam(¶ms, "damping");
|
|
|
|
try cmd.appendParam(¶ms, "inputbandwidth");
|
|
|
|
try cmd.appendParam(¶ms, "drylevel");
|
|
|
|
try cmd.appendParam(¶ms, "earlylevel");
|
|
|
|
try cmd.appendParam(¶ms, "taillevel");
|
|
|
|
try self.gverbCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 03:13:53 +00:00
|
|
|
.Invert => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try self.gverbCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 03:28:59 +00:00
|
|
|
.TapeDelay => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "speed");
|
|
|
|
try cmd.appendParam(¶ms, "da_db");
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "t1d");
|
|
|
|
try cmd.appendParam(¶ms, "t1a_db");
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "t2d");
|
|
|
|
try cmd.appendParam(¶ms, "t2a_db");
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "t3d");
|
|
|
|
try cmd.appendParam(¶ms, "t3a_db");
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "t4d");
|
|
|
|
try cmd.appendParam(¶ms, "t4a_db");
|
|
|
|
|
|
|
|
try self.tapedelayCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 05:05:43 +00:00
|
|
|
.ModDelay => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "base");
|
|
|
|
try self.moddelayCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 17:03:01 +00:00
|
|
|
.MultiChorus => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
try cmd.appendParam(¶ms, "min_delay");
|
|
|
|
try cmd.appendParam(¶ms, "mod_depth");
|
|
|
|
try cmd.appendParam(¶ms, "mod_rate");
|
|
|
|
try cmd.appendParam(¶ms, "stereo");
|
|
|
|
try cmd.appendParam(¶ms, "voices");
|
|
|
|
try cmd.appendParam(¶ms, "vphase");
|
|
|
|
try cmd.appendParam(¶ms, "amount");
|
|
|
|
try cmd.appendParam(¶ms, "dry");
|
|
|
|
try cmd.appendParam(¶ms, "freq");
|
|
|
|
try cmd.appendParam(¶ms, "freq2");
|
|
|
|
try cmd.appendParam(¶ms, "q");
|
|
|
|
try cmd.appendParam(¶ms, "overlap");
|
|
|
|
try cmd.appendParam(¶ms, "level_in");
|
|
|
|
try cmd.appendParam(¶ms, "level_out");
|
|
|
|
try cmd.appendParam(¶ms, "lfo");
|
|
|
|
try self.multichorusCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2020-01-26 17:50:50 +00:00
|
|
|
.Saturator => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
|
|
|
|
try cmd.appendParam(¶ms, "bypass");
|
|
|
|
try cmd.appendParam(¶ms, "level_in");
|
|
|
|
try cmd.appendParam(¶ms, "level_out");
|
|
|
|
try cmd.appendParam(¶ms, "mix");
|
|
|
|
try cmd.appendParam(¶ms, "drive");
|
|
|
|
try cmd.appendParam(¶ms, "blend");
|
|
|
|
try cmd.appendParam(¶ms, "lp_pre_freq");
|
|
|
|
try cmd.appendParam(¶ms, "hp_pre_freq");
|
|
|
|
try cmd.appendParam(¶ms, "lp_post_freq");
|
|
|
|
try cmd.appendParam(¶ms, "hp_post_freq");
|
|
|
|
try cmd.appendParam(¶ms, "p_freq");
|
|
|
|
try cmd.appendParam(¶ms, "p_level");
|
|
|
|
try cmd.appendParam(¶ms, "p_q");
|
|
|
|
try cmd.appendParam(¶ms, "pre");
|
|
|
|
try cmd.appendParam(¶ms, "post");
|
|
|
|
try self.saturatorCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
.VintageDelay => {
|
|
|
|
const pos = try cmd.consumePosition();
|
|
|
|
const PARAMS = [_][]const u8{
|
|
|
|
"level_in",
|
|
|
|
"level_out",
|
|
|
|
"subdiv",
|
|
|
|
"time_l",
|
|
|
|
"time_r",
|
|
|
|
"feedback",
|
|
|
|
"amount",
|
|
|
|
"mix_mode",
|
|
|
|
"medium",
|
|
|
|
"dry",
|
|
|
|
"width",
|
|
|
|
"fragmentation",
|
|
|
|
"pbeats",
|
|
|
|
"pfrag",
|
|
|
|
"timing",
|
|
|
|
"bpm",
|
|
|
|
"ms",
|
|
|
|
"hz",
|
|
|
|
"bpm_host",
|
|
|
|
};
|
|
|
|
|
|
|
|
inline for (PARAMS) |param| {
|
|
|
|
try cmd.appendParam(¶ms, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
try self.vintagedelayCmd(pos, params);
|
|
|
|
},
|
|
|
|
|
2019-07-08 15:38:16 +00:00
|
|
|
else => blk: {
|
2020-01-15 01:31:20 +00:00
|
|
|
std.debug.warn("Unsupported command: {}\n", .{cmd.command});
|
2019-07-08 15:38:16 +00:00
|
|
|
break :blk RunError.UnknownCommand;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-07-08 17:43:58 +00:00
|
|
|
/// Run a list of commands.
|
2019-07-08 16:13:03 +00:00
|
|
|
pub fn runCommands(
|
|
|
|
self: *Runner,
|
|
|
|
cmds: lang.CommandList,
|
|
|
|
debug_flag: bool,
|
|
|
|
) !void {
|
2020-05-31 01:25:43 +00:00
|
|
|
for (cmds.items) |cmd| {
|
2020-05-31 01:39:45 +00:00
|
|
|
cmd.print();
|
2020-05-31 01:25:43 +00:00
|
|
|
try self.newRunCommand(cmd);
|
2019-07-08 15:38:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-08-08 19:48:31 +00:00
|
|
|
|
|
|
|
test "running noop" {
|
|
|
|
const allocator = std.heap.direct_allocator;
|
|
|
|
var cmds = lang.CommandList.init(allocator);
|
|
|
|
defer cmds.deinit();
|
|
|
|
|
|
|
|
var cmd_ptr = try allocator.create(lang.Command);
|
|
|
|
cmd_ptr.* = lang.Command{
|
|
|
|
.command = .Noop,
|
|
|
|
.args = lang.ArgList.init(allocator),
|
|
|
|
};
|
|
|
|
try cmds.append(cmd_ptr);
|
|
|
|
|
|
|
|
var runner = Runner.init(allocator);
|
|
|
|
defer runner.deinit();
|
|
|
|
|
|
|
|
try runner.runCommands(cmds, false);
|
|
|
|
}
|