spaudiopy
spaudiopy copied to clipboard
Speed-up VBAP and VBIP decoders?
Hi Chris, I was using your VBAP decoder, which came in quite handy for something I wanted to do. Thanks for coding! I was wondering if there could be a simple but potentially significant speedup appart from threading. At the moment you are cycling trhough all faces until you find a face with all non-zero weights:
if (jobs_count == 1) or (src_count < 10):
for src_idx in range(src_count):
for face_idx, ls_base in enumerate(inverted_vbase):
# projecting src onto loudspeakers
projection = np.dot(ls_base, src[src_idx, :])
# normalization
projection /= np.linalg.norm(projection, ord=norm)
if np.all(projection > -10e-6):
assert (np.count_nonzero(projection) <= 3)
# print(f"Source {src_idx}: Gains {projection}")
gains[src_idx, valid_simplices[face_idx]] = projection
break # found valid gains
Would it make sense to first compute the distance between each source to run the face loop in a sorted manner? I assume this way, the triangle with all non-zero weights should usually be the first of the list (if it exists) and the loop would break earlier.
Probably not so relevant for common speaker setups, but I was using it for HRTF interpolation, with lots of thousands of sources.