add implicit arg index for Command helper funcs
This commit is contained in:
parent
c743681515
commit
3a8f84a3b2
3 changed files with 37 additions and 34 deletions
|
@ -1,3 +1,3 @@
|
|||
load :0;
|
||||
highpass 3 1 1000 0 0;
|
||||
highpass 3 1 7800 0 0;
|
||||
quicksave;
|
||||
|
|
11
src/lang.zig
11
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,
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue