diff --git a/pyroomacoustics/__init__.py b/pyroomacoustics/__init__.py index dcc9125c..843141dc 100644 --- a/pyroomacoustics/__init__.py +++ b/pyroomacoustics/__init__.py @@ -120,7 +120,7 @@ import warnings -from . import adaptive, bss, datasets, denoise, doa, experimental +from . import adaptive, bss, datasets, denoise, doa, experimental, random from . import libroom as libroom from . import phase, transform from .acoustics import * diff --git a/pyroomacoustics/directivities/analytic.py b/pyroomacoustics/directivities/analytic.py index 897e3c8b..5fd5ba19 100644 --- a/pyroomacoustics/directivities/analytic.py +++ b/pyroomacoustics/directivities/analytic.py @@ -416,7 +416,7 @@ def _pattern(self, x): return cardioid_func( x.T, direction=self._loc, - coef=self._coeff, + p=self._coeff, gain=1.0, normalize=False, magnitude=True, diff --git a/pyroomacoustics/doa/__init__.py b/pyroomacoustics/doa/__init__.py index 057d52c6..5ccc533a 100644 --- a/pyroomacoustics/doa/__init__.py +++ b/pyroomacoustics/doa/__init__.py @@ -118,6 +118,7 @@ from .tops import * from .utils import * from .waves import * +from .histogram import SphericalHistogram # Create this dictionary as a shortcut to different algorithms algorithms = { diff --git a/pyroomacoustics/doa/grid.py b/pyroomacoustics/doa/grid.py index c0c4ed85..36b1cec4 100644 --- a/pyroomacoustics/doa/grid.py +++ b/pyroomacoustics/doa/grid.py @@ -209,7 +209,7 @@ def __init__( # If no list was provided, samples points on the sphere # as uniformly as possible - self.x, self.y, self.z = fibonacci_spherical_sampling(n_points) + self.x[:], self.y[:], self.z[:] = fibonacci_spherical_sampling(n_points) # Create convenient arrays # to access both in cartesian and spherical coordinates @@ -389,10 +389,7 @@ def plot( def plot_old(self, plot_points=False, mark_peaks=0): """Plot the points on the sphere with their values""" - from scipy import rand - try: - import matplotlib.colors as colors import matplotlib.pyplot as plt # from mpl_toolkits.mplot3d import Axes3D diff --git a/pyroomacoustics/doa/histogram.py b/pyroomacoustics/doa/histogram.py index f606748e..84e97750 100644 --- a/pyroomacoustics/doa/histogram.py +++ b/pyroomacoustics/doa/histogram.py @@ -38,11 +38,15 @@ def __init__(self, n_bins, dim=3, enable_peak_finding=False): if self.n_dim == 3: self._grid = GridSphere( - n_points=self.n_bins, enable_peak_finding=enable_peak_finding + n_points=self.n_bins, precompute_neighbors=enable_peak_finding ) else: raise NotImplementedError("Only 3D histogram has been implemented") + import pdb + + pdb.set_trace() + # we need to know the area of each bin self._voronoi = SphericalVoronoi(self._grid.cartesian.T) self._areas = self._voronoi.calculate_areas() @@ -51,7 +55,7 @@ def __init__(self, n_bins, dim=3, enable_peak_finding=False): self._kd_tree = cKDTree(self._grid.cartesian.T) # the counter variables for every bin - self._bins = np.zeros(self.n_bins, dtype=np.int) + self._bins = np.zeros(self.n_bins, dtype=int) # the total number of points in the histogram self._total_count = 0 diff --git a/pyroomacoustics/random/tests/test_rejection.py b/pyroomacoustics/random/tests/test_rejection.py index 211dbc46..6166f4b4 100644 --- a/pyroomacoustics/random/tests/test_rejection.py +++ b/pyroomacoustics/random/tests/test_rejection.py @@ -20,14 +20,13 @@ for loc, scale in zip([[1, 1, 1]], [10, 1, 0.1]): print(loc, scale) - sampler = CardioidFamilySampler( - loc=loc, coeff=pra.DirectivityPattern.FIGURE_EIGHT.value - ) + # Figure-of-eight + sampler = CardioidFamilySampler(loc=loc, p=0) points = sampler(size=10000).T # shape (n_dim, n_points) # Create a spherical histogram - hist = pra.SphericalHistogram(n_bins=500) + hist = pra.doa.SphericalHistogram(n_bins=500) hist.push(points) hist.plot()