-
Notifications
You must be signed in to change notification settings - Fork 419
/
room_complex_wall_materials.py
79 lines (63 loc) · 1.95 KB
/
room_complex_wall_materials.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
"""
This examples demonstrates how to build a 3D room for multi-band simulation
with rich wall materials.
2022 (c) @noahdeetzers, @fakufaku
"""
import matplotlib.pyplot as plt
import numpy as np
import pyroomacoustics as pra
# Define the materials array
ceiling_mat = {
"description": "Example ceiling material",
"coeffs": [0.1, 0.2, 0.1, 0.1, 0.1, 0.05],
"center_freqs": [125, 250, 500, 1000, 2000, 4000],
}
floor_mat = {
"description": "Example floor material",
"coeffs": [0.1, 0.2, 0.1, 0.1, 0.1, 0.05],
"center_freqs": [125, 250, 500, 1000, 2000, 4000],
}
wall_mat = {
"description": "Example wall material",
"coeffs": [0.1, 0.2, 0.1, 0.1, 0.1, 0.05],
"center_freqs": [125, 250, 500, 1000, 2000, 4000],
}
def makeComplexRoom(height):
# this creates a more complex room with 9 non-orthogonal sides
# Creating the array of the 2d room
pol = (
4
* np.array(
[[1, 0], [0, 2], [0, 3], [1, 4], [1.5, 3.8], [2, 4], [3, 3], [3, 2], [2, 0]]
).T
)
# initial acoustic coeffs
m = pra.make_materials(*[(wall_mat,) for i in range(pol.shape[1])])
room = pra.Room.from_corners(
pol,
absorption=None,
fs=8000,
t0=0.0,
max_order=1,
sigma2_awgn=None,
sources=None,
mics=None,
materials=m,
)
# Create the 3D room by extruding the 2D by 3 meters
me = pra.make_materials(floor=(floor_mat,), ceiling=(ceiling_mat,))
room.extrude(height, materials=me)
# Add a source somewhere in the room
room.add_source([3, 3, 0.5])
# Create a linear array beamformer with 4 microphones
# Place an array of two microphones
R = np.array([[3.0, 2.2], [2.25, 2.1], [0.6, 0.55]])
room.add_microphone_array(pra.MicrophoneArray(R, room.fs))
return room
room = makeComplexRoom(5)
room.image_source_model()
fig, ax = room.plot()
ax.set_xlim([0, 12])
ax.set_ylim([0, 12])
ax.set_zlim([0, 12])
plt.show()