Compare commits
No commits in common. "046e43a68c5d3b83ec3803ee293927a1aefedc4b" and "7dae50b030fef9b08473c9253855d54056cbd4bf" have entirely different histories.
046e43a68c
...
7dae50b030
8 changed files with 44 additions and 78 deletions
|
@ -245,16 +245,3 @@ other presets:
|
||||||
- dry: 0..1, default 0
|
- dry: 0..1, default 0
|
||||||
- carrier: 0..1, default 0
|
- carrier: 0..1, default 0
|
||||||
- quality: 0..1, default 1
|
- quality: 0..1, default 1
|
||||||
|
|
||||||
## `dyncomp split index enable hold inputgain threshold ratio attack release gain_min gain_max rms`
|
|
||||||
|
|
||||||
- enable (bool): 0..1, default 1
|
|
||||||
- hold (bool): 0..1, default 0
|
|
||||||
- inputgain (dB): -10..30, default 0
|
|
||||||
- threshold (dB): -50..-10, default -30
|
|
||||||
- ratio (???): 0..1, default 0
|
|
||||||
- attack (seconds): 0.001..0.1, default 0.01
|
|
||||||
- release (seconds): 0.03..3.0, default 0.3
|
|
||||||
- gain\_min (dB): -20..40
|
|
||||||
- gain\_max (dB): -20..40
|
|
||||||
- rms (signal level, dB): -80..10
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
load :0;
|
load :0;
|
||||||
degrade 8 1 0.8 0.5 0.65 0.9 0.58 0.5;
|
degrade 5 1 0.8 0.5 0.65 0.9 0.58 0.5;
|
||||||
degrade 8 2 0.1 1 0.65 0.5 0.5 0.4;
|
degrade 5 2 0.1 1 0.65 0.5 0.5 0.4;
|
||||||
degrade 8 3 0.1 1 0.65 0.9 0.58 0.5;
|
degrade 5 3 0.1 1 0.65 0.9 0.58 0.5;
|
||||||
degrade 8 4 0 1 1 0 0 1;
|
|
||||||
degrade 8 5 0 1 1 0 0 0;
|
|
||||||
degrade 8 6 0 0 0 0 0 0;
|
|
||||||
quicksave;
|
quicksave;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
load :0;
|
|
||||||
dyncomp 3 1 1 0 0 -30 0 0.01 0.3 0 0 0;
|
|
||||||
quicksave;
|
|
|
@ -370,25 +370,18 @@ pub const Image = struct {
|
||||||
var i: usize = seek_pos.start;
|
var i: usize = seek_pos.start;
|
||||||
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end });
|
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end });
|
||||||
|
|
||||||
var inbuf = &rctx.buffers.in;
|
var inbuf = rctx.buffers.in;
|
||||||
var outbuf = &rctx.buffers.out;
|
var outbuf = rctx.buffers.out;
|
||||||
|
|
||||||
while (i <= seek_pos.end) : (i += 1) {
|
while (i <= seek_pos.end) : (i += 1) {
|
||||||
inbuf[0] = 0;
|
const read_bytes = c.sf_readf_float(self.sndfile, inbuf.ptr, 1);
|
||||||
inbuf[1] = 0;
|
|
||||||
|
|
||||||
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
|
|
||||||
if (read_bytes == 0) {
|
if (read_bytes == 0) {
|
||||||
std.debug.warn("WARN! reached EOF at idx={}\n", .{i});
|
std.debug.warn("WARN! reached EOF at idx={}\n", .{i});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trick plugins into having correct stereo signal from
|
|
||||||
// my mono input
|
|
||||||
inbuf[1] = inbuf[0];
|
|
||||||
|
|
||||||
lv2.lilv_instance_run(rctx.instance, 1);
|
lv2.lilv_instance_run(rctx.instance, 1);
|
||||||
try swrite(out_file, outbuf, 1);
|
try swrite(out_file, outbuf.ptr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sseek(self.sndfile, seek_pos.end);
|
sseek(self.sndfile, seek_pos.end);
|
||||||
|
@ -446,7 +439,9 @@ pub const Image = struct {
|
||||||
var out_fmt = mkSfInfo();
|
var out_fmt = mkSfInfo();
|
||||||
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
|
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
|
||||||
|
|
||||||
var bufs = plugins.RunBuffers{};
|
var bufs = try plugins.RunBuffers.init(self.allocator);
|
||||||
|
defer bufs.deinit();
|
||||||
|
|
||||||
const seek_pos = self.getSeekPos(position);
|
const seek_pos = self.getSeekPos(position);
|
||||||
|
|
||||||
// make sure we start from 0
|
// make sure we start from 0
|
||||||
|
@ -470,18 +465,18 @@ pub const Image = struct {
|
||||||
var i: usize = seek_pos.start;
|
var i: usize = seek_pos.start;
|
||||||
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end });
|
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end });
|
||||||
|
|
||||||
var inbuf = &bufs.in;
|
var inbuf = bufs.in;
|
||||||
var outbuf = &bufs.out;
|
var outbuf = bufs.out;
|
||||||
|
|
||||||
while (i <= seek_pos.end) : (i += 1) {
|
while (i <= seek_pos.end) : (i += 1) {
|
||||||
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
|
const read_bytes = c.sf_readf_float(self.sndfile, bufs.in.ptr, 1);
|
||||||
if (read_bytes == 0) {
|
if (read_bytes == 0) {
|
||||||
std.debug.warn("WARN! reached EOF at idx={}\n", .{i});
|
std.debug.warn("WARN! reached EOF at idx={}\n", .{i});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.run(&bufs);
|
plugin.run(&bufs);
|
||||||
try swrite(out_file, outbuf, 1);
|
try swrite(out_file, bufs.out.ptr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sseek(self.sndfile, seek_pos.end);
|
sseek(self.sndfile, seek_pos.end);
|
||||||
|
|
|
@ -32,7 +32,6 @@ pub const CommandType = enum {
|
||||||
Degrade,
|
Degrade,
|
||||||
RePsycho,
|
RePsycho,
|
||||||
TalkBox,
|
TalkBox,
|
||||||
DynComp,
|
|
||||||
|
|
||||||
Noise,
|
Noise,
|
||||||
WildNoise,
|
WildNoise,
|
||||||
|
@ -203,7 +202,6 @@ pub const Lang = struct {
|
||||||
_ = try self.keywords.put("embed", .Embed);
|
_ = try self.keywords.put("embed", .Embed);
|
||||||
_ = try self.keywords.put("degrade", .Degrade);
|
_ = try self.keywords.put("degrade", .Degrade);
|
||||||
_ = try self.keywords.put("repsycho", .RePsycho);
|
_ = try self.keywords.put("repsycho", .RePsycho);
|
||||||
_ = try self.keywords.put("dyncomp", .RePsycho);
|
|
||||||
|
|
||||||
// even more custom
|
// even more custom
|
||||||
_ = try self.keywords.put("rotate", .Rotate);
|
_ = try self.keywords.put("rotate", .Rotate);
|
||||||
|
|
|
@ -61,11 +61,29 @@ pub const Context = struct {
|
||||||
|
|
||||||
/// Specific run context for non-plugins.
|
/// Specific run context for non-plugins.
|
||||||
pub const RunBuffers = struct {
|
pub const RunBuffers = struct {
|
||||||
// we use [2]f32 to account for stereo plugins, however
|
allocator: *std.mem.Allocator,
|
||||||
// we only use in_buf[0] and out_buf[0], and don't use the
|
|
||||||
// (supposedly) right side of neither input or output.
|
in: []f32,
|
||||||
in: [2]f32 = [_]f32{0} ** 2,
|
out: []f32,
|
||||||
out: [2]f32 = [_]f32{0} ** 2,
|
|
||||||
|
pub fn init(allocator: *std.mem.Allocator) !RunBuffers {
|
||||||
|
// we allocate []f32 with size 2 to account for stereo plugins, however
|
||||||
|
// we only use &in_buf[0] and &out_buf[0], and don't use the
|
||||||
|
// (supposedly) right side of neither input or output.
|
||||||
|
var in_buf = try allocator.alloc(f32, 2);
|
||||||
|
std.mem.secureZero(f32, in_buf);
|
||||||
|
|
||||||
|
return RunBuffers{
|
||||||
|
.allocator = allocator,
|
||||||
|
.in = in_buf,
|
||||||
|
.out = try allocator.alloc(f32, 2),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *RunBuffers) void {
|
||||||
|
self.allocator.free(self.in);
|
||||||
|
self.allocator.free(self.out);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents the specific run context of plugin instantation.
|
/// Represents the specific run context of plugin instantation.
|
||||||
|
@ -85,19 +103,23 @@ pub const RunContext = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
return RunContext{
|
return RunContext{
|
||||||
.buffers = RunBuffers{},
|
.buffers = try RunBuffers.init(allocator),
|
||||||
.instance = instance.?,
|
.instance = instance.?,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *RunContext) void {
|
pub fn deinit(self: *RunContext) void {
|
||||||
c.lilv_instance_free(self.instance);
|
c.lilv_instance_free(self.instance);
|
||||||
|
self.buffers.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn connectPorts(self: *RunContext, ports: []lv2.Port) void {
|
pub fn connectPorts(self: *RunContext, ports: []lv2.Port) void {
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
var o: usize = 0;
|
var o: usize = 0;
|
||||||
|
|
||||||
|
var in_buf = self.buffers.in;
|
||||||
|
var out_buf = self.buffers.out;
|
||||||
|
|
||||||
for (ports) |_, p_idx| {
|
for (ports) |_, p_idx| {
|
||||||
var p = @intCast(u32, p_idx);
|
var p = @intCast(u32, p_idx);
|
||||||
var port: *lv2.Port = &ports[p_idx];
|
var port: *lv2.Port = &ports[p_idx];
|
||||||
|
@ -106,18 +128,10 @@ pub const RunContext = struct {
|
||||||
.Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value),
|
.Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value),
|
||||||
.Audio => blk: {
|
.Audio => blk: {
|
||||||
if (port.is_input) {
|
if (port.is_input) {
|
||||||
lv2.lilv_instance_connect_port(
|
lv2.lilv_instance_connect_port(self.instance, p, &in_buf[i]);
|
||||||
self.instance,
|
|
||||||
p,
|
|
||||||
&self.buffers.in[i],
|
|
||||||
);
|
|
||||||
i += 1;
|
i += 1;
|
||||||
} else {
|
} else {
|
||||||
lv2.lilv_instance_connect_port(
|
lv2.lilv_instance_connect_port(self.instance, p, &out_buf[o]);
|
||||||
self.instance,
|
|
||||||
p,
|
|
||||||
&self.buffers.out[o],
|
|
||||||
);
|
|
||||||
o += 1;
|
o += 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,7 +26,6 @@ pub fn printList(list: langs.CommandList, stream: var) !void {
|
||||||
.Degrade => "Degrade",
|
.Degrade => "Degrade",
|
||||||
.RePsycho => "repsycho",
|
.RePsycho => "repsycho",
|
||||||
.TalkBox => "talkbox",
|
.TalkBox => "talkbox",
|
||||||
.DynComp => "dyncomp",
|
|
||||||
|
|
||||||
.Noise => "noise",
|
.Noise => "noise",
|
||||||
.WildNoise => "wildnoise",
|
.WildNoise => "wildnoise",
|
||||||
|
|
|
@ -324,11 +324,6 @@ pub const Runner = struct {
|
||||||
try image.runPlugin("http://drobilla.net/plugins/mda/TalkBox", pos, params);
|
try image.runPlugin("http://drobilla.net/plugins/mda/TalkBox", pos, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dynCompCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
|
||||||
var image = try self.getImage();
|
|
||||||
try image.runPlugin("http://gareus.org/oss/lv2/darc#mono", pos, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
||||||
var params = ParamList.init(self.allocator);
|
var params = ParamList.init(self.allocator);
|
||||||
defer params.deinit();
|
defer params.deinit();
|
||||||
|
@ -571,22 +566,6 @@ pub const Runner = struct {
|
||||||
try cmd.appendParam(¶ms, "quality");
|
try cmd.appendParam(¶ms, "quality");
|
||||||
try self.talkboxCmd(pos, params);
|
try self.talkboxCmd(pos, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
.DynComp => {
|
|
||||||
const pos = try cmd.consumePosition();
|
|
||||||
try cmd.appendParam(¶ms, "enable");
|
|
||||||
try cmd.appendParam(¶ms, "hold");
|
|
||||||
try cmd.appendParam(¶ms, "inputgain");
|
|
||||||
try cmd.appendParam(¶ms, "threshold");
|
|
||||||
try cmd.appendParam(¶ms, "ratio");
|
|
||||||
try cmd.appendParam(¶ms, "attack");
|
|
||||||
try cmd.appendParam(¶ms, "release");
|
|
||||||
try cmd.appendParam(¶ms, "gain_min");
|
|
||||||
try cmd.appendParam(¶ms, "gain_max");
|
|
||||||
try cmd.appendParam(¶ms, "rms");
|
|
||||||
try self.dynCompCmd(pos, params);
|
|
||||||
},
|
|
||||||
|
|
||||||
else => blk: {
|
else => blk: {
|
||||||
std.debug.warn("Unsupported command: {}\n", .{cmd.command});
|
std.debug.warn("Unsupported command: {}\n", .{cmd.command});
|
||||||
break :blk RunError.UnknownCommand;
|
break :blk RunError.UnknownCommand;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue