pyroomacoustics icon indicating copy to clipboard operation
pyroomacoustics copied to clipboard

libroom does not return image-sources in correct order (ordering = 'order')

Open hrosseel opened this issue 4 years ago • 2 comments

Hello,

First of all, thanks for this amazing library. I've recently noticed that image-sources are not returned in the correct ordering when the ordering is set to 'order' using libroom. However, when setting use_libroom to false, the library outputs the correct order of image-sources.

Can be reproduced using the following code (only tested this in 2D rooms):

import numpy as np
import matplotlib.pyplot as plt
import pyroomacoustics as pra

max_order = 3
room = pra.ShoeBox([9, 7.5], fs=16000, max_order=max_order)
room.add_source([2.5, 3.73])
R = np.array([[6.3], [4.87]])
room.add_microphone_array(pra.MicrophoneArray(R, fs=room.fs))

color_dict = ['g', 'r', 'c', 'm', 'y', 'k']
colors = np.array(['b'])
imgs = 1
for order in range(max_order + 1):
    prev_imgs = imgs
    imgs = imgs + 4 * order
    for i in range(prev_imgs, imgs, 1):
        colors = np.append(colors, color_dict[order])

fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=True)

room.image_source_model()
ax1.scatter(room.sources[0].images[0], room.sources[0].images[1], c=colors)
ax1.title.set_text('w/ libroom')
room.image_source_model(use_libroom=False)
ax2.scatter(room.sources[0].images[0], room.sources[0].images[1], c=colors)
ax2.title.set_text('w/o libroom')

plt.show()

hrosseel avatar May 18 '20 15:05 hrosseel

Sorry for the late reply! Thanks for pointing out this inconsistency! I have not been playing with this feature for some time, so consistency might have been lost. I'll be taking a look as soon as I can.

fakufaku avatar May 31 '20 13:05 fakufaku

A small update on this problem: it appears my example (see above) is now broken. The function room.image_source_model() does not take parameter use_libroom anymore. However, the return order of image-sources is still broken.

hrosseel avatar Nov 21 '20 19:11 hrosseel