add helper to make lv2 command structs
This commit is contained in:
parent
f9c1851734
commit
94c9695110
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,
|
||||
};
|
||||
|
||||
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 {
|
||||
tag: Tag,
|
||||
|
||||
|
@ -112,6 +129,33 @@ pub const NewCommand = struct {
|
|||
|
||||
.amp => Amp,
|
||||
.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"),
|
||||
};
|
||||
}
|
||||
|
@ -149,28 +193,37 @@ pub const NewCommand = struct {
|
|||
base: NewCommand,
|
||||
};
|
||||
|
||||
pub const Amp = struct {
|
||||
pub const base_tag = Tag.amp;
|
||||
pub const command_type = NewCommandType.lv2_command;
|
||||
pub const lv2_url = "http://lv2plug.in/plugins/eg-amp";
|
||||
pub const Amp = LV2Command(
|
||||
.amp,
|
||||
"http://lv2plug.in/plugins/eg-amp",
|
||||
struct {
|
||||
gain: f32
|
||||
},
|
||||
);
|
||||
|
||||
base: NewCommand,
|
||||
split: usize,
|
||||
index: usize,
|
||||
gain: f32
|
||||
};
|
||||
pub const RFlanger = LV2Command(
|
||||
.rflanger,
|
||||
"http://plugin.org.uk/swh-plugins/retroFlange",
|
||||
struct {
|
||||
delay_depth_avg: f32, law_freq: f32
|
||||
},
|
||||
);
|
||||
|
||||
pub const RFlanger = struct {
|
||||
pub const base_tag = Tag.rflanger;
|
||||
pub const command_type = NewCommandType.lv2_command;
|
||||
pub const lv2_url = "http://plugin.org.uk/swh-plugins/retroFlange";
|
||||
pub const Eq = LV2Command(
|
||||
.rflanger,
|
||||
"http://plugin.org.uk/swh-plugins/dj_eq_mono",
|
||||
struct {
|
||||
lo: f32, mid: f32, hi: f32
|
||||
},
|
||||
);
|
||||
|
||||
base: NewCommand,
|
||||
split: usize,
|
||||
index: usize,
|
||||
delay_depth_avg: f32,
|
||||
law_freq: 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 {
|
||||
|
|
|
@ -439,6 +439,35 @@ pub const Runner = struct {
|
|||
try self.quicksaveCmd();
|
||||
},
|
||||
.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 => {
|
||||
std.debug.warn("TODO support {}\n", .{@tagName(cmd.tag)});
|
||||
@panic("TODO support tag");
|
||||
|
@ -465,28 +494,6 @@ pub const Runner = struct {
|
|||
.Quicksave => try self.quicksaveCmd(),
|
||||
.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: {
|
||||
const pos = try cmd.consumePosition();
|
||||
|
||||
|
|
Loading…
Reference in a new issue