Use comptime for fully declarative LV2 and Custom commands #14
2 changed files with 101 additions and 41 deletions
91
src/lang.zig
91
src/lang.zig
|
@ -57,6 +57,23 @@ pub const NewCommandType = enum {
|
||||||
lv2_command,
|
lv2_command,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn LV2Command(
|
||||||
|
comptime tag: NewCommand.Tag,
|
||||||
|
comptime lv2_url: []const u8,
|
||||||
|
comptime LV2Parameters: type,
|
||||||
|
) type {
|
||||||
|
return struct {
|
||||||
|
pub const base_tag = tag;
|
||||||
|
pub const command_type = NewCommandType.lv2_command;
|
||||||
|
pub const lv2_url = lv2_url;
|
||||||
|
|
||||||
|
base: NewCommand,
|
||||||
|
split: usize,
|
||||||
|
index: usize,
|
||||||
|
parameters: LV2Parameters,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub const NewCommand = struct {
|
pub const NewCommand = struct {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
|
|
||||||
|
@ -112,6 +129,33 @@ pub const NewCommand = struct {
|
||||||
|
|
||||||
.amp => Amp,
|
.amp => Amp,
|
||||||
.rflanger => RFlanger,
|
.rflanger => RFlanger,
|
||||||
|
.eq => Eq,
|
||||||
|
.phaser => Phaser,
|
||||||
|
// .mbeq => Mbeq,
|
||||||
|
// .chorus => Chorus,
|
||||||
|
// .pitchscaler => Pitchscaler,
|
||||||
|
// .reverb => Reverb,
|
||||||
|
// .highpass => Highpass,
|
||||||
|
// .delay => Delay,
|
||||||
|
// .vinyl => Vinyl,
|
||||||
|
// .revdelay => Revdelay,
|
||||||
|
// .gate => Gate,
|
||||||
|
// .detune => Detune,
|
||||||
|
// .overdrive => Overdrive,
|
||||||
|
// .degrade => Degrade,
|
||||||
|
// .repsycho => Repsycho,
|
||||||
|
// .talkbox => Talkbox,
|
||||||
|
// .dyncomp => Dyncomp,
|
||||||
|
// .thruzero => Thruzero,
|
||||||
|
// .foverdrive => Foverdrive,
|
||||||
|
// .gverb => Gverb,
|
||||||
|
// .invert => Invert,
|
||||||
|
// .tapedelay => Tapedelay,
|
||||||
|
// .moddelay => Moddelay,
|
||||||
|
// .multichorus => Multichorus,
|
||||||
|
// .saturator => Saturator,
|
||||||
|
// .vintagedelay => Vintagedelay,
|
||||||
|
|
||||||
else => @panic("TODO"),
|
else => @panic("TODO"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -149,28 +193,37 @@ pub const NewCommand = struct {
|
||||||
base: NewCommand,
|
base: NewCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Amp = struct {
|
pub const Amp = LV2Command(
|
||||||
pub const base_tag = Tag.amp;
|
.amp,
|
||||||
pub const command_type = NewCommandType.lv2_command;
|
"http://lv2plug.in/plugins/eg-amp",
|
||||||
pub const lv2_url = "http://lv2plug.in/plugins/eg-amp";
|
struct {
|
||||||
|
|
||||||
base: NewCommand,
|
|
||||||
split: usize,
|
|
||||||
index: usize,
|
|
||||||
gain: f32
|
gain: f32
|
||||||
};
|
},
|
||||||
|
);
|
||||||
|
|
||||||
pub const RFlanger = struct {
|
pub const RFlanger = LV2Command(
|
||||||
pub const base_tag = Tag.rflanger;
|
.rflanger,
|
||||||
pub const command_type = NewCommandType.lv2_command;
|
"http://plugin.org.uk/swh-plugins/retroFlange",
|
||||||
pub const lv2_url = "http://plugin.org.uk/swh-plugins/retroFlange";
|
struct {
|
||||||
|
delay_depth_avg: f32, law_freq: f32
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
base: NewCommand,
|
pub const Eq = LV2Command(
|
||||||
split: usize,
|
.rflanger,
|
||||||
index: usize,
|
"http://plugin.org.uk/swh-plugins/dj_eq_mono",
|
||||||
delay_depth_avg: f32,
|
struct {
|
||||||
law_freq: f32,
|
lo: f32, mid: f32, hi: f32
|
||||||
};
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
pub const Phaser = LV2Command(
|
||||||
|
.rflanger,
|
||||||
|
"http://plugin.org.uk/swh-plugins/lfoPhaser",
|
||||||
|
struct {
|
||||||
|
lfo_rate: f32, lfo_depth: f32, fb: f32, spread: f32
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Command = struct {
|
pub const Command = struct {
|
||||||
|
|
|
@ -439,6 +439,35 @@ pub const Runner = struct {
|
||||||
try self.quicksaveCmd();
|
try self.quicksaveCmd();
|
||||||
},
|
},
|
||||||
.amp => try self.newRunCommandSingle(cmd, .amp),
|
.amp => try self.newRunCommandSingle(cmd, .amp),
|
||||||
|
|
||||||
|
.rflanger => try self.newRunCommandSingle(cmd, .rflanger),
|
||||||
|
.eq => try self.newRunCommandSingle(cmd, .eq),
|
||||||
|
.phaser => try self.newRunCommandSingle(cmd, .phaser),
|
||||||
|
// .mbeq => try self.newRunCommandSingle(cmd, .mbeq),
|
||||||
|
// .chorus => try self.newRunCommandSingle(cmd, .chorus),
|
||||||
|
// .pitchscaler => try self.newRunCommandSingle(cmd, .pitchscaler),
|
||||||
|
// .reverb => try self.newRunCommandSingle(cmd, .reverb),
|
||||||
|
// .highpass => try self.newRunCommandSingle(cmd, .highpass),
|
||||||
|
// .delay => try self.newRunCommandSingle(cmd, .delay),
|
||||||
|
// .vinyl => try self.newRunCommandSingle(cmd, .vinyl),
|
||||||
|
// .revdelay => try self.newRunCommandSingle(cmd, .revdelay),
|
||||||
|
// .gate => try self.newRunCommandSingle(cmd, .gate),
|
||||||
|
// .detune => try self.newRunCommandSingle(cmd, .detune),
|
||||||
|
// .overdrive => try self.newRunCommandSingle(cmd, .overdrive),
|
||||||
|
// .degrade => try self.newRunCommandSingle(cmd, .degrade),
|
||||||
|
// .repsycho => try self.newRunCommandSingle(cmd, .repsycho),
|
||||||
|
// .talkbox => try self.newRunCommandSingle(cmd, .talkbox),
|
||||||
|
// .dyncomp => try self.newRunCommandSingle(cmd, .dyncomp),
|
||||||
|
// .thruzero => try self.newRunCommandSingle(cmd, .thruzero),
|
||||||
|
// .foverdrive => try self.newRunCommandSingle(cmd, .foverdrive),
|
||||||
|
// .gverb => try self.newRunCommandSingle(cmd, .gverb),
|
||||||
|
// .invert => try self.newRunCommandSingle(cmd, .invert),
|
||||||
|
// .tapedelay => try self.newRunCommandSingle(cmd, .tapedelay),
|
||||||
|
// .moddelay => try self.newRunCommandSingle(cmd, .moddelay),
|
||||||
|
// .multichorus => try self.newRunCommandSingle(cmd, .multichorus),
|
||||||
|
// .saturator => try self.newRunCommandSingle(cmd, .saturator),
|
||||||
|
// .vintagedelay => try self.newRunCommandSingle(cmd, .vintagedelay),
|
||||||
|
|
||||||
else => {
|
else => {
|
||||||
std.debug.warn("TODO support {}\n", .{@tagName(cmd.tag)});
|
std.debug.warn("TODO support {}\n", .{@tagName(cmd.tag)});
|
||||||
@panic("TODO support tag");
|
@panic("TODO support tag");
|
||||||
|
@ -465,28 +494,6 @@ pub const Runner = struct {
|
||||||
.Quicksave => try self.quicksaveCmd(),
|
.Quicksave => try self.quicksaveCmd(),
|
||||||
.RunQS => try self.runQSCmd(cmd.args.items[0]),
|
.RunQS => try self.runQSCmd(cmd.args.items[0]),
|
||||||
|
|
||||||
.Amp => blk: {
|
|
||||||
const pos = try cmd.consumePosition();
|
|
||||||
try cmd.appendParam(¶ms, "gain");
|
|
||||||
try self.ampCmd(pos, params);
|
|
||||||
},
|
|
||||||
|
|
||||||
.RFlanger => blk: {
|
|
||||||
const pos = try cmd.consumePosition();
|
|
||||||
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");
|
|
||||||
try cmd.appendParam(¶ms, "mid");
|
|
||||||
try cmd.appendParam(¶ms, "hi");
|
|
||||||
|
|
||||||
try self.eqCmd(pos, params);
|
|
||||||
},
|
|
||||||
|
|
||||||
.Phaser => blk: {
|
.Phaser => blk: {
|
||||||
const pos = try cmd.consumePosition();
|
const pos = try cmd.consumePosition();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue