Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_opening(hull, opening_limit=135):
"""Return valid simplices with all opening angles within simplex > limit.
"""
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[1, :], v[2, :], vi=v[0, :])
b = utils.angle_between(v[0, :], v[2, :], vi=v[1, :])
c = utils.angle_between(v[0, :], v[1, :], vi=v[2, :])
if np.any(np.r_[a, b, c] > utils.deg2rad(opening_limit)):
print("Found large opening angle in face: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_aperture(hull, aperture_limit=90, listener_position=None):
"""Return valid simplices, where the aperture form the listener is small.
"""
if listener_position is None:
listener_position = hull.listener_position
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[0, :], v[1, :], vi=listener_position)
b = utils.angle_between(v[1, :], v[2, :], vi=listener_position)
c = utils.angle_between(v[0, :], v[2, :], vi=listener_position)
if np.any(np.r_[a, b, c] > utils.deg2rad(aperture_limit)):
print("Face produces critically large aperture: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_normals(hull, normal_limit=85, listener_position=None):
"""Return valid simplices that point towards listener."""
if listener_position is None:
listener_position = hull.listener_position
valid_simplices = []
for face, v_n, c in zip(hull.simplices, hull.face_normals,
hull.centroids):
if hull.is_simplex_valid(face):
if utils.angle_between(c, v_n, vi=listener_position) > \
utils.deg2rad(normal_limit):
print("Face not pointing towards listener: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_opening(hull, opening_limit=135):
"""Return valid simplices with all opening angles within simplex > limit.
"""
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[1, :], v[2, :], vi=v[0, :])
b = utils.angle_between(v[0, :], v[2, :], vi=v[1, :])
c = utils.angle_between(v[0, :], v[1, :], vi=v[2, :])
if np.any(np.r_[a, b, c] > utils.deg2rad(opening_limit)):
print("Found large opening angle in face: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_aperture(hull, aperture_limit=90, listener_position=None):
"""Return valid simplices, where the aperture form the listener is small.
"""
if listener_position is None:
listener_position = hull.listener_position
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[0, :], v[1, :], vi=listener_position)
b = utils.angle_between(v[1, :], v[2, :], vi=listener_position)
c = utils.angle_between(v[0, :], v[2, :], vi=listener_position)
if np.any(np.r_[a, b, c] > utils.deg2rad(aperture_limit)):
print("Face produces critically large aperture: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_aperture(hull, aperture_limit=90, listener_position=None):
"""Return valid simplices, where the aperture form the listener is small.
"""
if listener_position is None:
listener_position = hull.listener_position
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[0, :], v[1, :], vi=listener_position)
b = utils.angle_between(v[1, :], v[2, :], vi=listener_position)
c = utils.angle_between(v[0, :], v[2, :], vi=listener_position)
if np.any(np.r_[a, b, c] > utils.deg2rad(aperture_limit)):
print("Face produces critically large aperture: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
def check_opening(hull, opening_limit=135):
"""Return valid simplices with all opening angles within simplex > limit.
"""
valid_simplices = []
for face in hull.valid_simplices:
# extract vertices face
v = hull.points[face, :]
a = utils.angle_between(v[1, :], v[2, :], vi=v[0, :])
b = utils.angle_between(v[0, :], v[2, :], vi=v[1, :])
c = utils.angle_between(v[0, :], v[1, :], vi=v[2, :])
if np.any(np.r_[a, b, c] > utils.deg2rad(opening_limit)):
print("Found large opening angle in face: " + str(face))
else:
valid_simplices.append(face)
return np.array(valid_simplices)
# virtual t-design loudspeakers
J = len(kernel_hull.points)
# virtual speakers expressed as VBAP phantom sources
G = vbap(src=kernel_hull.points, hull=ambisonics_hull)
# SH tapering coefficients
a_n = sph.max_rE_weights(N_sph)
# sqrt(E) normalization (eq.6)
a_w = np.sqrt(np.sum((2 * (np.arange(N_sph + 1) + 1)) / (4 * np.pi) *
a_n**2))
a_n /= a_w
gains = np.zeros([src_count, ls_count])
for src_idx in range(src_count):
# discretize panning function
d = utils.angle_between(src[src_idx, :], kernel_hull.points)
g_l = sph.bandlimited_dirac(N_sph, d, a_n)
gains[src_idx, :] = np.sqrt(4 * np.pi / J * G.T**2 @ g_l**2)
# remove imaginary loudspeaker
gains = np.delete(gains, ambisonics_hull.imaginary_speaker, axis=1)
return gains