72 lines
1.6 KiB
Zig
72 lines
1.6 KiB
Zig
const std = @import("std");
|
|
const print = std.debug.print;
|
|
const math = std.math;
|
|
|
|
const Endian = std.builtin.Endian;
|
|
const ArrayList = std.ArrayList;
|
|
const AutoHashMap = std.AutoHashMap;
|
|
const Allocator = std.mem.Allocator;
|
|
|
|
const pnt = @import("point.zig");
|
|
const Pnt = pnt.Pnt;
|
|
const Activity = @import("activity.zig").Activity;
|
|
const SoundSettings = @import("settings.zig").SoundSettings;
|
|
const FreqAmpBuffer = @import("freqamp.zig").FreqAmpBuffer;
|
|
|
|
const utility = @import("utility.zig");
|
|
const prnt = utility.prnt;
|
|
|
|
|
|
pub const SoundNode = struct {
|
|
|
|
allocator: Allocator,
|
|
|
|
name: []const u8 = "soundnode",
|
|
location: Pnt = Pnt{.x = 0, .y = 0, .z = 0},
|
|
|
|
air_in: ArrayList(*SoundNode),
|
|
wire_in: ArrayList(*SoundNode),
|
|
activities: ArrayList(*Activity),
|
|
|
|
fab: FreqAmpBuffer,
|
|
|
|
pub fn init(allocator: Allocator, name: []const u8) !SoundNode {
|
|
|
|
const air_in = ArrayList(*SoundNode).init(allocator);
|
|
const wire_in = ArrayList(*SoundNode).init(allocator);
|
|
const activities = ArrayList(*Activity).init(allocator);
|
|
const fab = try FreqAmpBuffer.init(allocator);
|
|
|
|
return .{
|
|
.allocator = allocator,
|
|
.name = name,
|
|
.air_in = air_in,
|
|
.wire_in = wire_in,
|
|
.activities = activities,
|
|
.fab = fab,
|
|
};
|
|
|
|
}
|
|
|
|
pub fn deinit(self: *SoundNode) void {
|
|
|
|
self.air_in.deinit();
|
|
self.wire_in.deinit();
|
|
self.activities.deinit();
|
|
self.fab.deinit();
|
|
|
|
}
|
|
|
|
pub fn current_tick(self: *SoundNode) u32 {
|
|
|
|
return self.fab.current_tick;
|
|
|
|
}
|
|
|
|
pub fn distance(self: *SoundNode, other: *SoundNode) f32 {
|
|
|
|
return pnt.distanceBetweenPoints(self.location, other.location);
|
|
|
|
}
|
|
|
|
};
|