const std = @import("std"); const print = std.debug.print; const math = std.math; const utility = @import("utility.zig"); pub const SoundSettings = struct { const default_sample_rate: u16 = 44100; const default_bit_depth: u8 = 24; sample_rate: u16 = default_sample_rate, speed_of_sound: f32 = 343.0 / @as(f32, default_sample_rate), bit_depth: u8 = default_bit_depth, max_amp: i64 = math.pow(i64, 2, default_bit_depth-1) - 1, max_amp_multiplier: f64 = @as(f64, @floatFromInt(math.pow(i64, 2, default_bit_depth-1) - 1)), min_amp: i64 = - math.pow(i64, 2, default_bit_depth-1), sample_width: u8 = @intFromFloat(@as(f32, default_bit_depth) / 8.0), sine_multiplier: f64 = utility.tau / default_sample_rate, pub fn printSettings(self: *const SoundSettings) void { print("Sample rate : {d}\n", .{self.sample_rate}); print("Bit depth : {d}\n", .{self.bit_depth}); print("Max amp : {d}\n", .{self.max_amp}); print("Min amp : {d}\n", .{self.min_amp}); print("Sample width: {d}\n", .{self.sample_width}); print("Sine mult : {d}\n", .{self.sine_multiplier}); } };