-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_1.py
More file actions
67 lines (51 loc) · 1.71 KB
/
example_1.py
File metadata and controls
67 lines (51 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# reverb simulation example
import reverbsimulator as rs
import time
# set to true to animate the bounces
do_anim = False
# create the scene
scene = rs.Scene()
# this is the main wall, a square
scene.add_obj(rs.Material(
rs.Polygon((3.0, 3.0), (-3.0, 3.0), (-3.0, -3.0), (3.0, -3.0)),
rs.ImpulseResponse.RC_lowpass(14500),
tag="MainWall"
))
# this is the middle pillar (which is a circle)
scene.add_obj(rs.Material(
rs.Circle((0.0, 0.0), 2.0),
rs.ImpulseResponse.RC_highpass(400),
#rs.ImpulseResponse.response_filter(lambda hz: hz / 22050.0, num_pts=100),
tag="CenterPillar"
))
# a speaker in the bottom left
scene.add_obj(rs.Speaker(
rs.Circle((-3.0, -3.0), 0.5),
tag="MainSpeaker"
))
# the main microphone position
scene.add_obj(rs.Mic(
(2.5, 2.5),
tag="MainMic"
))
anim = None
if do_anim:
anim = rs.viz.Animator()
# make it a bit smaller, TODO: add scene bounding rect
anim.scale *= 0.75
anim.draw_scene(scene)
st = time.time()
# change the threads argument to speed it up!
result_IR = rs.normalize(scene.create_IR(mic_tag="MainMic", Nsamples=500, max_bounces=250, anim=anim, threads=1).flattened())
print ("gen took %f s" % (time.time() - st))
st = time.time()
rs.write_wav("impulse_example_1.wav", result_IR)
print ("output took %f s" % (time.time() - st))
# uncomment this line to graph the impulse response
#rs.viz.graph_samples(result_IR)
# uncomment this line to see the frequency response
#rs.viz.graph_FFT(result_IR)
# you can also use this on just IRs without running a simulation
#rs.graph_FFT(rs.ImpulseResponse.response_filter(lambda hz: 1.0 * hz / 22050.0, num_pts=512))
#rs.graph_FFT(rs.ImpulseResponse.RC_highpass(12000.0, 1000))