speed of sound fix
This commit is contained in:
parent
1b96f75fec
commit
9560346cdd
3 changed files with 5 additions and 5 deletions
|
|
@ -12,9 +12,9 @@ class Room:
|
|||
|
||||
def __init__(self):
|
||||
|
||||
self.speed_of_sound = 330 #m/s
|
||||
self.dissipation_quotient = 0.9993
|
||||
self.sample_rate = 44100
|
||||
self.speed_of_sound = 343 / float(self.sample_rate) #m/tick
|
||||
self.set_bit_depth(24)
|
||||
|
||||
self.lowest_freq = 430
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class SoundNode:
|
|||
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))
|
||||
t = t - int(dist / self.room.speed_of_sound)
|
||||
|
||||
return self.room.max_amp * self.frequency_max_rel_amp(f, t) * math.sin(self.room.sine_multiplier * f * t)
|
||||
|
||||
6
test.py
6
test.py
|
|
@ -4,7 +4,7 @@ import math
|
|||
|
||||
R = Room()
|
||||
R.left_sink.start_location = (-1, 0, 0)
|
||||
R.right_sink.start_location = (1, 0, 0)
|
||||
R.right_sink.start_location = (2, 0, 0)
|
||||
|
||||
class SineNode(SoundNode):
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ class SineNode(SoundNode):
|
|||
|
||||
sn = SineNode(440, R)
|
||||
|
||||
R.link_wire(sn, R.left_sink)
|
||||
R.link_wire(sn, R.right_sink)
|
||||
R.link_air(sn, R.left_sink)
|
||||
R.link_air(sn, R.right_sink)
|
||||
|
||||
R.record('test5.wav', 0, 6)
|
||||
Loading…
Add table
Reference in a new issue