Use comptime for fully declarative LV2 and Custom commands #14

Merged
luna merged 69 commits from declarative-commands into master 2020-06-02 21:37:47 +00:00
2 changed files with 197 additions and 233 deletions
Showing only changes of commit 3a7009f9bf - Show all commits

View file

@ -88,23 +88,23 @@ pub const Command = struct {
.rflanger => RFlanger, .rflanger => RFlanger,
.eq => Eq, .eq => Eq,
.phaser => Phaser, .phaser => Phaser,
// .mbeq => Mbeq, .mbeq => Mbeq,
// .chorus => Chorus, .chorus => Chorus,
// .pitchscaler => Pitchscaler, .pitchscaler => Pitchscaler,
// .reverb => Reverb, .reverb => Reverb,
// .highpass => Highpass, .highpass => Highpass,
// .delay => Delay, .delay => Delay,
// .vinyl => Vinyl, .vinyl => Vinyl,
// .revdelay => Revdelay, .revdelay => Revdelay,
// .gate => Gate, .gate => Gate,
// .detune => Detune, .detune => Detune,
// .overdrive => Overdrive, .overdrive => Overdrive,
// .degrade => Degrade, .degrade => Degrade,
// .repsycho => Repsycho, .repsycho => Repsycho,
// .talkbox => Talkbox, .talkbox => Talkbox,
// .dyncomp => Dyncomp, .dyncomp => Dyncomp,
// .thruzero => Thruzero, .thruzero => Thruzero,
// .foverdrive => Foverdrive, .foverdrive => Foverdrive,
// .gverb => Gverb, // .gverb => Gverb,
// .invert => Invert, // .invert => Invert,
// .tapedelay => Tapedelay, // .tapedelay => Tapedelay,
@ -175,12 +175,172 @@ pub const Command = struct {
); );
pub const Phaser = LV2Command( pub const Phaser = LV2Command(
.rflanger, .phaser,
"http://plugin.org.uk/swh-plugins/lfoPhaser", "http://plugin.org.uk/swh-plugins/lfoPhaser",
struct { struct {
lfo_rate: f32, lfo_depth: f32, fb: f32, spread: f32 lfo_rate: f32, lfo_depth: f32, fb: f32, spread: f32
}, },
); );
pub const Mbeq = LV2Command(
.mbeq,
"http://plugin.org.uk/swh-plugins/mbeq",
struct {
band_1: f32,
band_2: f32,
band_3: f32,
band_4: f32,
band_5: f32,
band_6: f32,
band_7: f32,
band_8: f32,
band_9: f32,
band_10: f32,
band_11: f32,
band_12: f32,
band_13: f32,
band_14: f32,
band_15: f32,
},
);
pub const Chorus = LV2Command(
.chorus,
"http://plugin.org.uk/swh-plugins/multivoiceChorus",
struct {
voices: f32,
delay_base: f32,
voice_spread: f32,
detune: f32,
law_freq: f32,
attendb: f32,
},
);
pub const Pitchscaler = LV2Command(
.pitchscaler,
"http://plugin.org.uk/swh-plugins/pitchScaleHQ",
struct { mult: f32 },
);
pub const Reverb = LV2Command(
.reverb,
"http://invadarecords.com/plugins/lv2/erreverb/mono",
struct {
roomLength: f32,
roomWidth: f32,
roomHeight: f32,
sourceLR: f32,
sourceFB: f32,
listLR: f32,
listFB: f32,
hpf: f32,
warmth: f32,
diffusion: f32,
},
);
pub const Highpass = LV2Command(.highpass, "http://invadarecords.com/plugins/lv2/filter/hpf/mono", struct {
freq: f32,
gain: f32,
noClip: f32,
});
pub const Delay = LV2Command(.delay, "http://plugin.org.uk/swh-plugins/delayorama", struct {
seed: f32,
gain: f32,
feedback_pc: f32,
tap_count: f32,
first_delay: f32,
delay_range: f32,
delay_scale: f32,
delay_rand_pc: f32,
gain_scale: f32,
wet: f32,
});
pub const Vinyl = LV2Command(.vinyl, "http://plugin.org.uk/swh-plugins/vynil", struct {
year: f32,
rpm: f32,
warp: f32,
click: f32,
wear: f32,
});
pub const Revdelay = LV2Command(.revdelay, "http://plugin.org.uk/swh-plugins/revdelay", struct {
delay_time: f32,
dry_level: f32,
wet_level: f32,
feedback: f32,
xfade_samp: f32,
});
// pub const Noise= LV2Command(.,,struct{});
pub const Gate = LV2Command(.gate, "http://hippie.lt/lv2/gate", struct {
@"switch": f32,
threshold: f32,
attack: f32,
hold: f32,
decay: f32,
gaterange: f32,
});
pub const Detune = LV2Command(.detune, "http://drobilla.net/plugins/mda/Detune", struct {
@"switch": f32,
threshold: f32,
attack: f32,
hold: f32,
decay: f32,
gaterange: f32,
detune: f32,
mix: f32,
output: f32,
latency: f32,
});
pub const Overdrive = LV2Command(.overdrive, "http://drobilla.net/plugins/mda/Overdrive", struct {
drive: f32,
muffle: f32,
output: f32,
});
pub const Degrade = LV2Command(.degrade, "http://drobilla.net/plugins/mda/Degrade", struct {
headroom: f32,
quant: f32,
rate: f32,
post_filt: f32,
non_lin: f32,
output: f32,
});
pub const Repsycho = LV2Command(.repsycho, "http://drobilla.net/plugins/mda/RePsycho", struct {
tune: f32,
fine: f32,
decay: f32,
thresh: f32,
hold: f32,
mix: f32,
quality: f32,
});
pub const Talkbox = LV2Command(.talkbox, "http://drobilla.net/plugins/mda/TalkBox", struct {
wet: f32,
dry: f32,
carrier: f32,
quality: f32,
});
pub const Dyncomp = LV2Command(.dyncomp, "http://gareus.org/oss/lv2/darc#mono", struct {
enable: f32,
hold: f32,
inputgain: f32,
threshold: f32,
ratio: f32,
attack: f32,
release: f32,
gain_min: f32,
gain_max: f32,
rms: f32,
});
pub const Foverdrive = LV2Command(.foverdrive, "http://plugin.org.uk/swh-plugins/foverdrive", struct {
drive: f32,
});
pub const Thruzero = LV2Command(.thruzero, "http://drobilla.net/plugins/mda/ThruZero", struct {
rate: f32, mix: f32, feedback: f32, depth_mod: f32
});
}; };
pub const CommandList = std.ArrayList(*Command); pub const CommandList = std.ArrayList(*Command);

View file

@ -190,58 +190,6 @@ pub const Runner = struct {
_ = try proc.spawnAndWait(); _ = try proc.spawnAndWait();
} }
/// Run the http://lv2plug.in/plugins/eg-amp plugin over the file.
fn ampCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://lv2plug.in/plugins/eg-amp", pos, params);
}
fn rFlangerCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/retroFlange", pos, params);
}
fn eqCmd(self: *Runner, position: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/dj_eq_mono", position, params);
}
fn phaserCmd(self: *Runner, position: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params);
}
fn mbeqCmd(self: *Runner, position: Position, bands: []const f32) !void {
var image = try self.getImage();
var params = ParamList.init(self.allocator);
defer params.deinit();
for (bands) |band_value, idx| {
var sym = try std.fmt.allocPrint(self.allocator, "band_{}", .{idx + 1});
try params.append(plugin.Param{
.sym = sym,
.value = band_value,
});
}
try image.runPlugin("http://plugin.org.uk/swh-plugins/mbeq", position, params);
}
fn chorusCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/multivoiceChorus", pos, params);
}
fn pitchScalerCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/pitchScaleHQ", pos, params);
}
fn reverbCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://invadarecords.com/plugins/lv2/erreverb/mono", pos, params);
}
fn highpassCmd(self: *Runner, pos: Position, params: ParamList) !void { fn highpassCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage(); var image = try self.getImage();
try image.runPlugin("http://invadarecords.com/plugins/lv2/filter/hpf/mono", pos, params); try image.runPlugin("http://invadarecords.com/plugins/lv2/filter/hpf/mono", pos, params);
@ -432,23 +380,23 @@ pub const Runner = struct {
.rflanger => try self.newRunCommandSingle(cmd, .rflanger), .rflanger => try self.newRunCommandSingle(cmd, .rflanger),
.eq => try self.newRunCommandSingle(cmd, .eq), .eq => try self.newRunCommandSingle(cmd, .eq),
.phaser => try self.newRunCommandSingle(cmd, .phaser), .phaser => try self.newRunCommandSingle(cmd, .phaser),
// .mbeq => try self.newRunCommandSingle(cmd, .mbeq), .mbeq => try self.newRunCommandSingle(cmd, .mbeq),
// .chorus => try self.newRunCommandSingle(cmd, .chorus), .chorus => try self.newRunCommandSingle(cmd, .chorus),
// .pitchscaler => try self.newRunCommandSingle(cmd, .pitchscaler), .pitchscaler => try self.newRunCommandSingle(cmd, .pitchscaler),
// .reverb => try self.newRunCommandSingle(cmd, .reverb), .reverb => try self.newRunCommandSingle(cmd, .reverb),
// .highpass => try self.newRunCommandSingle(cmd, .highpass), .highpass => try self.newRunCommandSingle(cmd, .highpass),
// .delay => try self.newRunCommandSingle(cmd, .delay), .delay => try self.newRunCommandSingle(cmd, .delay),
// .vinyl => try self.newRunCommandSingle(cmd, .vinyl), .vinyl => try self.newRunCommandSingle(cmd, .vinyl),
// .revdelay => try self.newRunCommandSingle(cmd, .revdelay), .revdelay => try self.newRunCommandSingle(cmd, .revdelay),
// .gate => try self.newRunCommandSingle(cmd, .gate), .gate => try self.newRunCommandSingle(cmd, .gate),
// .detune => try self.newRunCommandSingle(cmd, .detune), .detune => try self.newRunCommandSingle(cmd, .detune),
// .overdrive => try self.newRunCommandSingle(cmd, .overdrive), .overdrive => try self.newRunCommandSingle(cmd, .overdrive),
// .degrade => try self.newRunCommandSingle(cmd, .degrade), .degrade => try self.newRunCommandSingle(cmd, .degrade),
// .repsycho => try self.newRunCommandSingle(cmd, .repsycho), .repsycho => try self.newRunCommandSingle(cmd, .repsycho),
// .talkbox => try self.newRunCommandSingle(cmd, .talkbox), .talkbox => try self.newRunCommandSingle(cmd, .talkbox),
// .dyncomp => try self.newRunCommandSingle(cmd, .dyncomp), .dyncomp => try self.newRunCommandSingle(cmd, .dyncomp),
// .thruzero => try self.newRunCommandSingle(cmd, .thruzero), .thruzero => try self.newRunCommandSingle(cmd, .thruzero),
// .foverdrive => try self.newRunCommandSingle(cmd, .foverdrive), .foverdrive => try self.newRunCommandSingle(cmd, .foverdrive),
// .gverb => try self.newRunCommandSingle(cmd, .gverb), // .gverb => try self.newRunCommandSingle(cmd, .gverb),
// .invert => try self.newRunCommandSingle(cmd, .invert), // .invert => try self.newRunCommandSingle(cmd, .invert),
// .tapedelay => try self.newRunCommandSingle(cmd, .tapedelay), // .tapedelay => try self.newRunCommandSingle(cmd, .tapedelay),
@ -483,112 +431,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]),
.Phaser => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "lfo_rate");
try cmd.appendParam(&params, "lfo_depth");
try cmd.appendParam(&params, "fb");
try cmd.appendParam(&params, "spread");
try self.phaserCmd(pos, params);
},
.Mbeq => blk: {
const pos = try cmd.consumePosition();
const bands = try cmd.floatArgMany(self.allocator, 2, 15, @as(f32, 0));
defer self.allocator.free(bands);
try self.mbeqCmd(pos, bands);
},
.Chorus => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "voices");
try cmd.appendParam(&params, "delay_base");
try cmd.appendParam(&params, "voice_spread");
try cmd.appendParam(&params, "detune");
try cmd.appendParam(&params, "law_freq");
try cmd.appendParam(&params, "attendb");
try self.chorusCmd(pos, params);
},
.PitchScaler => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "mult");
try self.pitchScalerCmd(pos, params);
},
.Reverb => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "roomLength");
try cmd.appendParam(&params, "roomWidth");
try cmd.appendParam(&params, "roomHeight");
try cmd.appendParam(&params, "sourceLR");
try cmd.appendParam(&params, "sourceFB");
try cmd.appendParam(&params, "listLR");
try cmd.appendParam(&params, "listFB");
try cmd.appendParam(&params, "hpf");
try cmd.appendParam(&params, "warmth");
try cmd.appendParam(&params, "diffusion");
try self.reverbCmd(pos, params);
},
.Highpass => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "freq");
try cmd.appendParam(&params, "gain");
try cmd.appendParam(&params, "noClip");
try self.highpassCmd(pos, params);
},
.Delay => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "seed");
try cmd.appendParam(&params, "gain");
try cmd.appendParam(&params, "feedback_pc");
try cmd.appendParam(&params, "tap_count");
try cmd.appendParam(&params, "first_delay");
try cmd.appendParam(&params, "delay_range");
try cmd.appendParam(&params, "delay_scale");
try cmd.appendParam(&params, "delay_rand_pc");
try cmd.appendParam(&params, "gain_scale");
try cmd.appendParam(&params, "wet");
try self.delayCmd(pos, params);
},
.Vinyl => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "year");
try cmd.appendParam(&params, "rpm");
try cmd.appendParam(&params, "warp");
try cmd.appendParam(&params, "click");
try cmd.appendParam(&params, "wear");
try self.vinylCmd(pos, params);
},
.RevDelay => blk: {
const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "delay_time");
try cmd.appendParam(&params, "dry_level");
try cmd.appendParam(&params, "wet_level");
try cmd.appendParam(&params, "feedback");
try cmd.appendParam(&params, "xfade_samp");
try self.revDelayCmd(pos, params);
},
.Noise => blk: { .Noise => blk: {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
@ -627,76 +469,38 @@ pub const Runner = struct {
.Gate => { .Gate => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "switch");
try cmd.appendParam(&params, "threshold");
try cmd.appendParam(&params, "attack");
try cmd.appendParam(&params, "hold");
try cmd.appendParam(&params, "decay");
try cmd.appendParam(&params, "gaterange");
try self.gateCmd(pos, params); try self.gateCmd(pos, params);
}, },
.Detune => { .Detune => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "detune");
try cmd.appendParam(&params, "mix");
try cmd.appendParam(&params, "output");
try cmd.appendParam(&params, "latency");
try self.detuneCmd(pos, params); try self.detuneCmd(pos, params);
}, },
.Overdrive => { .Overdrive => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "drive");
try cmd.appendParam(&params, "muffle");
try cmd.appendParam(&params, "output");
try self.overdriveCmd(pos, params); try self.overdriveCmd(pos, params);
}, },
.Degrade => { .Degrade => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "headroom");
try cmd.appendParam(&params, "quant");
try cmd.appendParam(&params, "rate");
try cmd.appendParam(&params, "post_filt");
try cmd.appendParam(&params, "non_lin");
try cmd.appendParam(&params, "output");
try self.degradeCmd(pos, params); try self.degradeCmd(pos, params);
}, },
.RePsycho => { .RePsycho => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "tune");
try cmd.appendParam(&params, "fine");
try cmd.appendParam(&params, "decay");
try cmd.appendParam(&params, "thresh");
try cmd.appendParam(&params, "hold");
try cmd.appendParam(&params, "mix");
try cmd.appendParam(&params, "quality");
try self.repsychoCmd(pos, params); try self.repsychoCmd(pos, params);
}, },
.TalkBox => { .TalkBox => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "wet");
try cmd.appendParam(&params, "dry");
try cmd.appendParam(&params, "carrier");
try cmd.appendParam(&params, "quality");
try self.talkboxCmd(pos, params); try self.talkboxCmd(pos, params);
}, },
.DynComp => { .DynComp => {
const pos = try cmd.consumePosition(); const pos = try cmd.consumePosition();
try cmd.appendParam(&params, "enable");
try cmd.appendParam(&params, "hold");
try cmd.appendParam(&params, "inputgain");
try cmd.appendParam(&params, "threshold");
try cmd.appendParam(&params, "ratio");
try cmd.appendParam(&params, "attack");
try cmd.appendParam(&params, "release");
try cmd.appendParam(&params, "gain_min");
try cmd.appendParam(&params, "gain_max");
try cmd.appendParam(&params, "rms");
try self.dynCompCmd(pos, params); try self.dynCompCmd(pos, params);
}, },