54 lines
No EOL
1.2 KiB
Zig
54 lines
No EOL
1.2 KiB
Zig
const std = @import("std");
|
|
const print = std.debug.print;
|
|
const SoundNode = @import("soundnode.zig").SoundNode;
|
|
|
|
pub const Activity = struct {
|
|
|
|
start_tick: u32,
|
|
end_tick: u32,
|
|
opcode: u16,
|
|
soundnode: *SoundNode,
|
|
operands: [10]f16 = std.mem.zeroes([10]f16),
|
|
|
|
pub fn do(self: *Activity) !void {
|
|
switch (self.opcode) {
|
|
0 => { try self.reset(); },
|
|
1 => { try self.setfreq(); },
|
|
2 => { try self.relay(); },
|
|
else => {},
|
|
}
|
|
}
|
|
|
|
pub fn reset(self: *Activity) !void {
|
|
try self.soundnode.freqamp.reset();
|
|
}
|
|
|
|
pub fn setfreq(self: *Activity) !void {
|
|
try self.soundnode.freqamp.setfreq(self.operands[0], self.operands[1]);
|
|
}
|
|
|
|
pub fn relay(self: *Activity) !void {
|
|
|
|
try self.soundnode.freqamp.reset();
|
|
|
|
for (self.soundnode.wire_in.items, 0..) |wired_sn, i| {
|
|
|
|
const current_index: u32 = self.soundnode.freqamp.current_index();
|
|
if (current_index == 0) {
|
|
print("relaying {s} to {s}\n", .{wired_sn.name, self.soundnode.name});
|
|
}
|
|
|
|
const clist = wired_sn.freqamp.freqamps[current_index];
|
|
|
|
for (clist.lst.items) |freqamp| {
|
|
try self.soundnode.freqamp.addfreq(freqamp.freq, freqamp.r_amp);
|
|
}
|
|
|
|
_ = i;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}; |