add rflanger command, update readme

This commit is contained in:
Luna 2019-07-10 13:24:03 -03:00
parent 2b2eb51dff
commit 8b189914f7
6 changed files with 54 additions and 6 deletions

View file

@ -3,16 +3,22 @@ scritcher
glitch art "framework", ???????? language??? something? glitch art "framework", ???????? language??? something?
![example of the amp command](https://estrogen.fun/i/57y7kn55.png)
![example of the rflanger command](https://estrogen.fun/i/i2055hdf.png)
# how do? # how do?
currently it can't do much other than running the eg-amp default lv2 plugin. ## build depedencies:
depedencies:
- zig at https://ziglang.org - zig at https://ziglang.org
- libc, lilv and libsndfile - libc, lilv and libsndfile
- an appreciation for glitched anime girls on your hard drive - an appreciation for glitched anime girls on your hard drive
- optional: imagemagick to convert from whatever to bmp - optional: imagemagick to convert from whatever to bmp
## plugin depedencies:
- lv2 default plugins (most specifically the eg-amp plugin)
- the SWH plugins ( https://github.com/swh/lv2 )
```bash ```bash
# build and install # build and install
# assumes lilv headers are at /usr/include/lilv-0, check build.zig if different # assumes lilv headers are at /usr/include/lilv-0, check build.zig if different

View file

@ -32,6 +32,10 @@ be a bmp. feel free to put other files, no warranties are given.)
Run the eg-amp plugin over the given slice of the file. Run the eg-amp plugin over the given slice of the file.
## `rflanger split index delay_depth_avg law_freq`
Runs the Retro Flanger script from the SWH plugins.
## 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.

3
examples/flanger.scri Normal file
View file

@ -0,0 +1,3 @@
load :0;
rflanger 3 1 2.5 1;
quicksave;

View file

@ -1,8 +1,8 @@
load :0; load :0;
amp 5 1 8;
amp 7 4 2;
amp 80 70 10; amp 80 70 10;
amp 80 73 20; amp 80 73 20;
amp 80 75 20; amp 80 75 20;
amp 80 76 20; amp 80 76 20;
amp 7 4 2;
amp 5 1 8;
quicksave; quicksave;

View file

@ -10,6 +10,7 @@ pub const CommandType = enum {
Noop, Noop,
Load, Load,
Amp, Amp,
RFlanger,
Quicksave, Quicksave,
}; };
@ -52,12 +53,15 @@ pub const CommandList = std.ArrayList(*Command);
pub const ArgList = std.ArrayList([]const u8); pub const ArgList = std.ArrayList([]const u8);
pub fn commandToCmdType(command: []const u8) ParseError!CommandType { pub fn commandToCmdType(command: []const u8) ParseError!CommandType {
// TODO make a hashmap for those
if (std.mem.eql(u8, command, "noop")) { if (std.mem.eql(u8, command, "noop")) {
return CommandType.Noop; return CommandType.Noop;
} else if (std.mem.eql(u8, command, "load")) { } else if (std.mem.eql(u8, command, "load")) {
return CommandType.Load; return CommandType.Load;
} else if (std.mem.eql(u8, command, "amp")) { } else if (std.mem.eql(u8, command, "amp")) {
return CommandType.Amp; return CommandType.Amp;
} else if (std.mem.eql(u8, command, "rflanger")) {
return CommandType.RFlanger;
} else if (std.mem.eql(u8, command, "quicksave")) { } else if (std.mem.eql(u8, command, "quicksave")) {
return CommandType.Quicksave; return CommandType.Quicksave;
} else { } else {

View file

@ -154,9 +154,10 @@ pub const Runner = struct {
var image = try self.getImage(); var image = try self.getImage();
var params = plugin.ParamList.init(self.allocator); var params = plugin.ParamList.init(self.allocator);
try params.append(plugin.Param{ .sym = "gain", .value = gain });
defer params.deinit(); defer params.deinit();
try params.append(plugin.Param{ .sym = "gain", .value = gain });
// TODO if we could detect that the next command is a quicksave then // TODO if we could detect that the next command is a quicksave then
// we don't need the temporary file in runPlugin and instead we // we don't need the temporary file in runPlugin and instead we
// dump it all on the output image for it. // dump it all on the output image for it.
@ -167,6 +168,27 @@ pub const Runner = struct {
); );
} }
fn rFlangerCmd(
self: *Runner,
split: usize,
index: usize,
delay_depth_avg: f32,
law_freq: f32,
) !void {
var image = try self.getImage();
var params = plugin.ParamList.init(self.allocator);
defer params.deinit();
try params.append(plugin.Param{ .sym = "delay_depth_avg", .value = delay_depth_avg });
try params.append(plugin.Param{ .sym = "law_freq", .value = law_freq });
try image.runPlugin(
"http://plugin.org.uk/swh-plugins/retroFlange",
plugin.Position{ .split = split, .index = index },
params,
);
}
fn runCommand(self: *Runner, cmd: *lang.Command) !void { fn runCommand(self: *Runner, cmd: *lang.Command) !void {
return switch (cmd.command) { return switch (cmd.command) {
.Noop => {}, .Noop => {},
@ -184,6 +206,15 @@ pub const Runner = struct {
try self.ampCmd(split, index, gain); try self.ampCmd(split, index, gain);
}, },
.RFlanger => blk: {
const split = try cmd.usizeArgAt(0);
const index = try cmd.usizeArgAt(1);
const delay_depth_avg = try cmd.floatArgAt(2);
const law_freq = try cmd.floatArgAt(3);
try self.rFlangerCmd(split, index, delay_depth_avg, law_freq);
},
else => blk: { else => blk: {
std.debug.warn("Unknown command: {}\n", cmd.command); std.debug.warn("Unknown command: {}\n", cmd.command);
break :blk RunError.UnknownCommand; break :blk RunError.UnknownCommand;