add mbeq command
This commit is contained in:
parent
6bc54f8e46
commit
317916a1e0
4 changed files with 59 additions and 0 deletions
|
@ -60,6 +60,15 @@ Parameters:
|
||||||
- `fb`: Feedback, -1..1, default 0
|
- `fb`: Feedback, -1..1, default 0
|
||||||
- `spread`: Spread (octaves), 0..2, default 1
|
- `spread`: Spread (octaves), 0..2, default 1
|
||||||
|
|
||||||
|
## `mbeq split index band_1 band_2 band_3 band_4 band_5 band_6 band_7 band_8 band_9 band_10 band_11 band_12 band_13 band_14 band_15`
|
||||||
|
|
||||||
|
In respective order, the band arugments represent the:
|
||||||
|
50Hz, 100Hz, 156Hz, 220Hz, 311Hz, 440Hz, 622Hz, 880Hz 1250Hz, 1750Hz, 2500Hz,
|
||||||
|
3500Hz, 5000Hz, 10000Hz and 20000Hz frequencies.
|
||||||
|
|
||||||
|
All of them represent the band's gain in dB. The range is -70 to +30dB,
|
||||||
|
default is 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.
|
||||||
|
|
3
examples/mbeq.scri
Normal file
3
examples/mbeq.scri
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
load :0;
|
||||||
|
mbeq 3 1 1 4 0.2 2.1;
|
||||||
|
quicksave;
|
24
src/lang.zig
24
src/lang.zig
|
@ -17,6 +17,7 @@ pub const CommandType = enum {
|
||||||
RFlanger,
|
RFlanger,
|
||||||
Eq,
|
Eq,
|
||||||
Phaser,
|
Phaser,
|
||||||
|
Mbeq,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Command = struct {
|
pub const Command = struct {
|
||||||
|
@ -59,6 +60,28 @@ pub const Command = struct {
|
||||||
var arg = try self.argAt(idx);
|
var arg = try self.argAt(idx);
|
||||||
return try std.fmt.parseFloat(f32, arg);
|
return try std.fmt.parseFloat(f32, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn floatArgMany(
|
||||||
|
self: *const Command,
|
||||||
|
allocator: *std.mem.Allocator,
|
||||||
|
start_index: usize,
|
||||||
|
elements: usize,
|
||||||
|
default: f32,
|
||||||
|
) ![]const f32 {
|
||||||
|
var i: usize = start_index;
|
||||||
|
var arr = std.ArrayList(f32).init(allocator);
|
||||||
|
|
||||||
|
while (i < elements) : (i += 1) {
|
||||||
|
var value: f32 = self.floatArgAt(i) catch |err| blk: {
|
||||||
|
std.debug.warn("\tdoing default on arg {}\n", i);
|
||||||
|
break :blk default;
|
||||||
|
};
|
||||||
|
|
||||||
|
try arr.append(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr.toSliceConst();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CommandList = std.ArrayList(*Command);
|
pub const CommandList = std.ArrayList(*Command);
|
||||||
|
@ -86,6 +109,7 @@ pub const Lang = struct {
|
||||||
_ = try self.keywords.put("amp", .Amp);
|
_ = try self.keywords.put("amp", .Amp);
|
||||||
_ = try self.keywords.put("rflanger", .RFlanger);
|
_ = try self.keywords.put("rflanger", .RFlanger);
|
||||||
_ = try self.keywords.put("eq", .Eq);
|
_ = try self.keywords.put("eq", .Eq);
|
||||||
|
_ = try self.keywords.put("mbeq", .Mbeq);
|
||||||
_ = try self.keywords.put("phaser", .Phaser);
|
_ = try self.keywords.put("phaser", .Phaser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,23 @@ pub const Runner = struct {
|
||||||
try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params);
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/lfoPhaser", position, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mbeqCmd(
|
||||||
|
self: *Runner,
|
||||||
|
position: plugin.Position,
|
||||||
|
bands: []const f32,
|
||||||
|
) !void {
|
||||||
|
var image = try self.getImage();
|
||||||
|
var params = plugin.ParamList.init(self.allocator);
|
||||||
|
defer params.deinit();
|
||||||
|
|
||||||
|
for (bands) |band_value, idx| {
|
||||||
|
var sym = try std.fmt.allocPrint(self.allocator, "band_{}", idx + 1);
|
||||||
|
try appendParam(¶ms, sym, band_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
try image.runPlugin("http://plugin.org.uk/swh-plugins/mbeq", position, 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 => {},
|
||||||
|
@ -278,6 +295,12 @@ pub const Runner = struct {
|
||||||
try self.phaserCmd(pos, lfo_rate, lfo_depth, fb, spread);
|
try self.phaserCmd(pos, lfo_rate, lfo_depth, fb, spread);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.Mbeq => blk: {
|
||||||
|
const pos = try cmd.consumePosition();
|
||||||
|
const bands = try cmd.floatArgMany(self.allocator, 2, 15, f32(0));
|
||||||
|
try self.mbeqCmd(pos, bands);
|
||||||
|
},
|
||||||
|
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue