Compare commits

...

3 commits

Author SHA1 Message Date
223fb6628c change mono plugin check to a 3+ channel plugin check
i'm not sure if there's anyone with more than two ears who is biological
2019-07-13 16:48:53 -03:00
8d3cd47665 add vinyl cmd 2019-07-13 16:46:26 -03:00
f07c989407 allow for stereo input (unused, though) 2019-07-13 16:40:08 -03:00
6 changed files with 48 additions and 5 deletions

View file

@ -104,7 +104,7 @@ Parameters:
- `gain`: Gain, 0..12, default 0 - `gain`: Gain, 0..12, default 0
- `noClip`: Soft Clip (assumed boolean), 0..1, default 0 - `noClip`: Soft Clip (assumed boolean), 0..1, default 0
## `delay seed gain` ## `delay seed gain feedback_pc tap_count first_delay delay_range delay_scale delay_rand_pc gain_scale wet`
Parameters: Parameters:
- `seed`: Random seed, 0..1000, default 0 - `seed`: Random seed, 0..1000, default 0
@ -118,10 +118,25 @@ Parameters:
- `gain_scale`: Amplitude change, 0.2..5, default 1 - `gain_scale`: Amplitude change, 0.2..5, default 1
- `wet`: Dry/wet mix, 0..1, default 1 - `wet`: Dry/wet mix, 0..1, default 1
## TODO `vinyl split index year warp click wear`
VyNil effect from SWH.
Parameters:
- `year`: Year (int), 1900..1990, default 1990
- `rpm`: RPM (int), 33..78, default 33
- `warp`: Surface Warping, 0..1, default 0
- `click`: Crackle, 0..1, default 0
- `wear`: Wear, 0..1, default 0
## TODO `echo split index delay` ## TODO `echo split index delay`
Run an echo filter on the given loaded file. Run an echo filter on the given loaded file.
## TODO `noise split index seed`
Inject white noise on the image.
## `quicksave` ## `quicksave`
Save the file on the same directory of the file specified by `load`, but Save the file on the same directory of the file specified by `load`, but

3
examples/vinyl.scri Normal file
View file

@ -0,0 +1,3 @@
load :0;
vinyl 3 1 1990 33 0 0 0;
quicksave;

View file

@ -212,12 +212,12 @@ pub const Image = struct {
var ports = try lv2.setupPorts(&ctx); var ports = try lv2.setupPorts(&ctx);
if (ctx.n_audio_in != 1) { if (ctx.n_audio_in > 2) {
std.debug.warn("plugin <{}> does not accept mono input.\n", plugin_uri); std.debug.warn("plugin <{}> accepts more than two channels.\n", plugin_uri);
return ImageError.InvalidPlugin; return ImageError.InvalidPlugin;
} }
// TODO check n_audio_out // TODO check n_audio_out > 2
// now, for each param for the plugin, we find its port, and set // now, for each param for the plugin, we find its port, and set
// the value for the port there. // the value for the port there.

View file

@ -24,6 +24,7 @@ pub const CommandType = enum {
Reverb, Reverb,
Highpass, Highpass,
Delay, Delay,
Vinyl,
}; };
pub const Command = struct { pub const Command = struct {
@ -139,6 +140,7 @@ pub const Lang = struct {
_ = try self.keywords.put("reverb", .Reverb); _ = try self.keywords.put("reverb", .Reverb);
_ = try self.keywords.put("highpass", .Highpass); _ = try self.keywords.put("highpass", .Highpass);
_ = try self.keywords.put("delay", .Delay); _ = try self.keywords.put("delay", .Delay);
_ = try self.keywords.put("vinyl", .Vinyl);
} }
pub fn parse(self: *Lang, data: []const u8) !CommandList { pub fn parse(self: *Lang, data: []const u8) !CommandList {

View file

@ -72,8 +72,14 @@ pub const RunContext = struct {
return ImageError.InstantiateFail; return ImageError.InstantiateFail;
} }
// 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 RunContext{ return RunContext{
.in_buf = try allocator.alloc(f32, 1), .in_buf = in_buf,
.out_buf = try allocator.alloc(f32, 2), .out_buf = try allocator.alloc(f32, 2),
.instance = instance.?, .instance = instance.?,
}; };

View file

@ -235,6 +235,11 @@ pub const Runner = struct {
try image.runPlugin("http://plugin.org.uk/swh-plugins/delayorama", pos, params); try image.runPlugin("http://plugin.org.uk/swh-plugins/delayorama", pos, params);
} }
fn vinylCmd(self: *Runner, pos: Position, params: ParamList) !void {
var image = try self.getImage();
try image.runPlugin("http://plugin.org.uk/swh-plugins/vynil", 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();
@ -350,6 +355,18 @@ pub const Runner = struct {
try self.delayCmd(pos, params); 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);
},
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;