import math TAU = 2 * math.pi class SoundNode: def __init__(self, name, room): self.name = name self.room = room self.air_in = [] self.air_out = [] self.wire_in = [] self.wire_out = [] self.start_location = (0, 0, 0) def location(self, t): # Location of the soundnote (x,y,z) in meters # at time t. return self.start_location def distance_to_node(self, other_node, t): loc = self.location(t) other_loc = other_node.location(t) return (loc[0]-other_loc[0])**2 + (loc[1]-other_loc[1])**2 + (loc[2]-other_loc[2])**2 def frequency_max_rel_amp(self, f, t): return 0 def amp_at_tick(self, f, t): return self.room.max_amp * self.frequency_max_rel_amp(f, t) * math.sin(self.room.sine_multiplier * f * t) def amp_at_tick_by_air(self, f, t, node): dist = self.distance_to_node(node, t) t = t - ((self.room.speed_of_sound*dist)/float(self.room.sample_rate)) return self.room.max_amp * self.frequency_max_rel_amp(f, t) * math.sin(self.room.sine_multiplier * f * t)