add rflanger command, update readme

This commit is contained in:
Luna 2019-07-10 13:24:03 -03:00
parent 2b2eb51dff
commit 8b189914f7
6 changed files with 54 additions and 6 deletions

View file

@ -10,6 +10,7 @@ pub const CommandType = enum {
Noop,
Load,
Amp,
RFlanger,
Quicksave,
};
@ -52,12 +53,15 @@ pub const CommandList = std.ArrayList(*Command);
pub const ArgList = std.ArrayList([]const u8);
pub fn commandToCmdType(command: []const u8) ParseError!CommandType {
// TODO make a hashmap for those
if (std.mem.eql(u8, command, "noop")) {
return CommandType.Noop;
} else if (std.mem.eql(u8, command, "load")) {
return CommandType.Load;
} else if (std.mem.eql(u8, command, "amp")) {
return CommandType.Amp;
} else if (std.mem.eql(u8, command, "rflanger")) {
return CommandType.RFlanger;
} else if (std.mem.eql(u8, command, "quicksave")) {
return CommandType.Quicksave;
} else {

View file

@ -154,9 +154,10 @@ pub const Runner = struct {
var image = try self.getImage();
var params = plugin.ParamList.init(self.allocator);
try params.append(plugin.Param{ .sym = "gain", .value = gain });
defer params.deinit();
try params.append(plugin.Param{ .sym = "gain", .value = gain });
// TODO if we could detect that the next command is a quicksave then
// we don't need the temporary file in runPlugin and instead we
// dump it all on the output image for it.
@ -167,6 +168,27 @@ pub const Runner = struct {
);
}
fn rFlangerCmd(
self: *Runner,
split: usize,
index: usize,
delay_depth_avg: f32,
law_freq: f32,
) !void {
var image = try self.getImage();
var params = plugin.ParamList.init(self.allocator);
defer params.deinit();
try params.append(plugin.Param{ .sym = "delay_depth_avg", .value = delay_depth_avg });
try params.append(plugin.Param{ .sym = "law_freq", .value = law_freq });
try image.runPlugin(
"http://plugin.org.uk/swh-plugins/retroFlange",
plugin.Position{ .split = split, .index = index },
params,
);
}
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
return switch (cmd.command) {
.Noop => {},
@ -184,6 +206,15 @@ pub const Runner = struct {
try self.ampCmd(split, index, gain);
},
.RFlanger => blk: {
const split = try cmd.usizeArgAt(0);
const index = try cmd.usizeArgAt(1);
const delay_depth_avg = try cmd.floatArgAt(2);
const law_freq = try cmd.floatArgAt(3);
try self.rFlangerCmd(split, index, delay_depth_avg, law_freq);
},
else => blk: {
std.debug.warn("Unknown command: {}\n", cmd.command);
break :blk RunError.UnknownCommand;