add chorus command
This commit is contained in:
parent
317916a1e0
commit
5fb0f9c066
4 changed files with 58 additions and 1 deletions
15
src/lang.zig
15
src/lang.zig
|
@ -18,6 +18,7 @@ pub const CommandType = enum {
|
|||
Eq,
|
||||
Phaser,
|
||||
Mbeq,
|
||||
Chorus,
|
||||
};
|
||||
|
||||
pub const Command = struct {
|
||||
|
@ -82,6 +83,19 @@ pub const Command = struct {
|
|||
|
||||
return arr.toSliceConst();
|
||||
}
|
||||
|
||||
pub fn appendParam(
|
||||
self: *const Command,
|
||||
params: *plugin.ParamList,
|
||||
symbol: []const u8,
|
||||
idx: usize,
|
||||
) !void {
|
||||
var val = try self.floatArgAt(idx);
|
||||
try params.append(plugin.Param{
|
||||
.sym = symbol,
|
||||
.value = val,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
pub const CommandList = std.ArrayList(*Command);
|
||||
|
@ -111,6 +125,7 @@ pub const Lang = struct {
|
|||
_ = try self.keywords.put("eq", .Eq);
|
||||
_ = try self.keywords.put("mbeq", .Mbeq);
|
||||
_ = try self.keywords.put("phaser", .Phaser);
|
||||
_ = try self.keywords.put("chorus", .Chorus);
|
||||
}
|
||||
|
||||
pub fn parse(self: *Lang, data: []const u8) !CommandList {
|
||||
|
|
|
@ -248,7 +248,19 @@ pub const Runner = struct {
|
|||
try image.runPlugin("http://plugin.org.uk/swh-plugins/mbeq", position, params);
|
||||
}
|
||||
|
||||
fn chorusCmd(
|
||||
self: *Runner,
|
||||
pos: plugin.Position,
|
||||
params: plugin.ParamList,
|
||||
) !void {
|
||||
var image = try self.getImage();
|
||||
try image.runPlugin("http://plugin.org.uk/swh-plugins/multivoiceChorus", pos, params);
|
||||
}
|
||||
|
||||
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
||||
var params = plugin.ParamList.init(self.allocator);
|
||||
defer params.deinit();
|
||||
|
||||
return switch (cmd.command) {
|
||||
.Noop => {},
|
||||
.Load => blk: {
|
||||
|
@ -301,8 +313,21 @@ pub const Runner = struct {
|
|||
try self.mbeqCmd(pos, bands);
|
||||
},
|
||||
|
||||
.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 self.chorusCmd(pos, params);
|
||||
},
|
||||
|
||||
else => blk: {
|
||||
std.debug.warn("Unknown command: {}\n", cmd.command);
|
||||
std.debug.warn("Unsupported command: {}\n", cmd.command);
|
||||
break :blk RunError.UnknownCommand;
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue