Skip to content

Commit

Permalink
Populate database
Browse files Browse the repository at this point in the history
  • Loading branch information
JensAhrens committed Mar 12, 2020
1 parent dcfe6e3 commit f48ec35
Show file tree
Hide file tree
Showing 34 changed files with 500 additions and 2 deletions.
27 changes: 27 additions & 0 deletions DirPat_loudspeaker_cube/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The data are the measurements of the 4 loudspeaker drivers of the IEM Loudspeaker Cube in the [DirPat database](https://opendata.iem.at/projects/dirpat/). All directivity models are far-field models based on third-octave smoothed magnitude data like in the Common Loudspeaker Format. The details are described in

> J. Ahrens and S. Bilbao, “Interpolation and Range Extrapolation of Sound Source Directivity Based on a Spherical Wave Propagation Model,” in Proc. of IEEE ICASSP, Barcelona, Spain, May 2020
and particularly in

> J. Ahrens and S. Bilbao, “Computation of Spherical Harmonics Based Sound Source Directivity Models from Sparse Measurement Data,” Forum Acusticum, Lyon, France, May 2020.


Example balloon plots:

`irs_DirPat_loudspeaker_cube_1_N6.mat`

![irs_DirPat_loudspeaker_cube_1_N6](irs_DirPat_loudspeaker_cube_1_N6.png "irs_DirPat_loudspeaker_cube_1_N6")

`irs_DirPat_loudspeaker_cube_2_N6.mat`

![irs_DirPat_loudspeaker_cube_2_N6](irs_DirPat_loudspeaker_cube_2_N6.png "irs_DirPat_loudspeaker_cube_2_N6")

`irs_DirPat_loudspeaker_cube_3_N6.mat`

![irs_DirPat_loudspeaker_cube_3_N6](irs_DirPat_loudspeaker_cube_3_N6.png "irs_DirPat_loudspeaker_cube_3_N6")

`irs_DirPat_loudspeaker_cube_4_N6.mat`

![irs_DirPat_loudspeaker_cube_4_N6](irs_DirPat_loudspeaker_cube_4_N6.png "irs_DirPat_loudspeaker_cube_4_N6")
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions DirPat_singing_voice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
The data are the singing voice measurements from the [DirPat database](https://opendata.iem.at/projects/dirpat/), specifically from the files

* `IR_a_long_sweep.mat`

* `IR_a_closed_sweep.mat`

* `IR_a_open_sweep.mat`

* `IR_a_wide_sweep.mat`.

The calibration data in file `cal64.mat` were applied to all datasets. All directivity models are far-field models referenced to the direction straight ahead and computed as described in

> J. Ahrens and S. Bilbao, “Interpolation and Range Extrapolation of Sound Source Directivity Based on a Spherical Wave Propagation Model,” in Proc. of IEEE ICASSP, Barcelona, Spain, May 2020
and

> J. Ahrens and S. Bilbao, “Computation of Spherical Harmonics Based Sound Source Directivity Models from Sparse Measurement Data,” Forum Acusticum, Lyon, France, May 2020.


Example balloon plots:

`irs_DirPat_a_closed_sweep_N9_non-reg.mat`

![irs_DirPat_a_closed_sweep_N9_non-reg](irs_DirPat_a_closed_sweep_N9_non-reg.png "irs_DirPat_a_closed_sweep_N9_non-reg")

`irs_DirPat_a_closed_sweep_N9_reg.mat`

![irs_DirPat_a_closed_sweep_N9_reg](irs_DirPat_a_closed_sweep_N9_reg.png "irs_DirPat_a_closed_sweep_N9_reg")

`irs_DirPat_a_long_sweep_N9_non-reg.mat`

![irs_DirPat_a_long_sweep_N9_non-reg](irs_DirPat_a_long_sweep_N9_non-reg.png "irs_DirPat_a_long_sweep_N9_non-reg")

`irs_DirPat_a_long_sweep_N9_reg.mat`

![irs_DirPat_a_long_sweep_N9_reg](irs_DirPat_a_long_sweep_N9_reg.png "irs_DirPat_a_long_sweep_N9_reg")

`irs_DirPat_a_open_sweep_N9_non-reg.mat`

![irs_DirPat_a_open_sweep_N9_non-reg](irs_DirPat_a_open_sweep_N9_non-reg.png "irs_DirPat_a_open_sweep_N9_non-reg")

`irs_DirPat_a_open_sweep_N9_reg.mat`

![irs_DirPat_a_open_sweep_N9_reg](irs_DirPat_a_open_sweep_N9_reg.png "irs_DirPat_a_open_sweep_N9_reg")

`irs_DirPat_a_wide_sweep_N9_non-reg.mat`

![irs_DirPat_a_wide_sweep_N9_non-reg](irs_DirPat_a_wide_sweep_N9_non-reg.png "irs_DirPat_a_wide_sweep_N9_non-reg")

`irs_DirPat_a_wide_sweep_N9_reg.mat`

![irs_DirPat_a_wide_sweep_N9_reg](irs_DirPat_a_wide_sweep_N9_reg.png "irs_DirPat_a_wide_sweep_N9_reg")

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# sound-source-directivities
Data base of spherical harmonic models of sound source directivities
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.

# Database of spherical harmonic models of sound source directivities

This is a database of complete spherical harmonic models of the directivities of sound sources. The data are provided as impulse responses that represent the directivity of the given source in a given discrete direction. The Matlab script `compute_spherical_harmonics_model.m` demonstrates how a spherical harmonic representation can be computed from the data. We do not provide spherical harmonic coefficients directly because of the multitude of definitions of spherical harmonics and also of the Discrete Fourier transform. We rather ask you to select the combination of definitions you would like to use and compute the spherical harmonic coefficients on demand. You may want to add resampling or zero padding and the like to make the data compatible with your intended application.

As of now, all spherical harmonic models are based on previously published data. Please do not forget to site this repository as well as the original repositories when using the data. References to the original sources are provided with each dataset. All data are limited to the spherical harmonic order `N` that is specified in the corresponding file name. The conversion between raw data and spherical harmonic coefficients is therefore essentially lossless.

All data are far-field models as described in

> J. Ahrens and S. Bilbao, “Interpolation and Range Extrapolation of Sound Source Directivity Based on a Spherical Wave Propagation Model,” in Proc. of IEEE ICASSP, Barcelona, Spain, May 2020
and

> J. Ahrens and S. Bilbao, “Computation of Spherical Harmonics Based Sound Source Directivity Models from Sparse Measurement Data,” Forum Acusticum, Lyon, France, May 2020.
We will extend and update the data continuously.

41 changes: 41 additions & 0 deletions _tools/asslegendre.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function [Lnm] = asslegendre(n, m, arg)
%ASSLEGENDRE Calculates the associated Legendre function of degree n and
% order m
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This work is supplementary material for the book %
% %
% Jens Ahrens, Analytic Methods of Sound Field Synthesis, Springer-Verlag %
% Berlin Heidelberg, 2012, http://dx.doi.org/10.1007/978-3-642-25743-8 %
% %
% It has been downloaded from http://soundfieldsynthesis.org and is %
% licensed under a Creative Commons Attribution-NonCommercial-ShareAlike %
% 3.0 Unported License. Please cite the book appropriately if you use %
% these materials in your own work. %
% %
% (c) 2012 by Jens Ahrens %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if (n < 0)
error('Degree(n) must not be negative.')
end

if (n < abs(m))
% warning('Absolute value of order(m) must be less than or equal to the degree(n).');
Lnm = zeros(size(arg));
return;
end

Lnm = legendre(n, arg);

if (n ~= 0)
Lnm = squeeze(Lnm(abs(m) + 1, :, :));
end

if (m < 0)
Lnm = (-1).^abs(m) .* factorial(n - abs(m)) ./ factorial(n + abs(m)) .* Lnm;
end

Lnm = reshape(Lnm, size(arg));

end
108 changes: 108 additions & 0 deletions _tools/balloon_plot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
function [] = balloon_plot(coefficients, order, fs, sph_definition)
% Creates a ballon plot from spherical harmonics coefficients

% plot 4 different frequencies
f_to_plot = [500 1000 2000 4000]; % in Hz
f_to_plot = f_to_plot(f_to_plot < fs/2); % sort out
bins_to_plot = round(f_to_plot/(fs/2) * size(coefficients, 1));

% update values
f_to_plot = bins_to_plot/size(coefficients, 1) * fs/2;

% remove all unused data
coefficients = coefficients(bins_to_plot, :);

% set up a spatial grid
resolution = 2*order + 2;
alpha_v = linspace(0, 2*pi, 2*resolution); % azimuth
beta_v = linspace(0, pi, resolution+1); % colatitude
[alpha_m, beta_m] = meshgrid(alpha_v, beta_v);

colatitude = beta_m(:).';
azimuth = alpha_m(:).';

% compute the directivity on the spatial grid
D = zeros(size(coefficients, 1), size(azimuth, 2));

for l = 0 : order
for m = -l : l
D = D + coefficients(:, l^2+l+m+1) .* repmat(sphharm(l, m, colatitude, azimuth, sph_definition), [length(bins_to_plot) 1]);
end
end

% prepare data for plotting
alpha_m = reshape(azimuth, resolution+1, []);
beta_m = reshape(colatitude, resolution+1, []);

% --------------------- finally, plot data -------------------------------
figure;
set(gcf, 'Color', [1 1 1]);

subplot(2, 2, 1);
plot_it(abs(reshape(D(1, :), resolution+1, [])), alpha_m, beta_m, f_to_plot(1));

if length(f_to_plot) > 1
subplot(2, 2, 2);
plot_it(abs(reshape(D(2, :), resolution+1, [])), alpha_m, beta_m, f_to_plot(2));
end

if length(f_to_plot) > 2
subplot(2, 2, 3);
plot_it(abs(reshape(D(3, :), resolution+1, [])), alpha_m, beta_m, f_to_plot(3));
end

if length(f_to_plot) > 3
subplot(2, 2, 4);
plot_it(abs(reshape(D(4, :), resolution+1, [])), alpha_m, beta_m, f_to_plot(4));
end

end

function plot_it(data_to_plot, alpha_m, beta_m, f)

view_angle = [135 20];

color1 = [0.9769 0.9839 0.0805];
color2 = [0.2440 0.4358 0.9988];
color3 = [0.2422 0.1504 0.6603];

% avoid a hole in the hull
alpha_m = [alpha_m, alpha_m(:, 1)];
beta_m = [beta_m, beta_m(:, 1)];
data_to_plot = [data_to_plot, data_to_plot(:, 1)];

[Xm, Ym, Zm] = sph2cart(alpha_m, pi/2-beta_m, data_to_plot);

surf(Xm, Ym, Zm);

plot_max = max(abs([Xm(:); Ym(:); Zm(:)]));

% plot coordinate axes
hold on;
line([-1 1] * plot_max * .75, [.0 .0], [ 0 0], 'Marker', '.', 'LineStyle', '-', 'Color', [.5 .5 .5], 'LineWidth', 1 );
line([ 0 0], [-1 1] * plot_max * .75, [ 0 0], 'Marker', '.', 'LineStyle', '-', 'Color', [.5 .5 .5], 'LineWidth', 1 );
line([ 0 0], [ 0 0], [-1 1] * plot_max * .75, 'Marker', '.', 'LineStyle', '-', 'Color', [.5 .5 .5], 'LineWidth', 1 );
hold off;

title(sprintf('f = %d Hz', round(f)));

view(view_angle(1), view_angle(2));

box on;

xlabel( '$x$', 'Interpreter', 'latex' );
ylabel( '$y$', 'Interpreter', 'latex' );
zlabel( '$z$', 'Interpreter', 'latex' );

axis equal
axis([-1 1 -1 1 -1 1] * plot_max);

lighting phong
shading interp

light('Position', [1 0 0], 'Color', color1);
light('Position', [0 1 0], 'Color', color2);
light('Position', [0 0 1], 'Color', color3);
set(gca, 'Projection', 'Perspective', 'FontSize', 7);

end
16 changes: 16 additions & 0 deletions _tools/dft.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function [tfs] = dft(irs, dft_definition)
%DFT Discrete Fourier transform
% Is always performed along the first dimension of irs
% dft_definition: 'matlab' (negative exponent in forward transform) or
% 'williams' (positive exponent in forward transform)

if strcmp(dft_definition, 'matlab')
tfs = fft(irs, [], 1);
elseif strcmp(dft_definition, 'williams')
tfs = ifft(irs) * size(irs, 1);
else
warning('Unknown method.');
end

end

53 changes: 53 additions & 0 deletions _tools/least_squares_sh_fit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function [coefficients] = least_squares_sh_fit(N, data, azimuth, colatitude, sphharm_type, reg_parameter)
% Performs an Nth-order least squares fit of spherical harmonics on data
% that is available in the directions (azimuth, colatitude) for each
% frequency bin separately using the pseudo inverse
%
% data: frequency goes downwards, position to the right
% azimuth, colatitude: row vectors in radians
% sphharm_type: see file sphharm.m for the options
% reg_parameter (optional): regularization parameters according to
% Eq. (XX) in XXX; defaults to 0
%
% coefficients: frequency goes downwards, order to the right (sorted
% according to (n^2+n+m+1)
%
% Author: Jens Ahrens, March 2020

if nargin < 6
reg_parameter = 0;
end

azimuth = azimuth.';
colatitude = colatitude.';
data = data.';

% generate a series of n: (0, 1, 1, 1, 2, 2, 2, 2, 2, 3, ...)
ns = zeros(0, 1);

for n = 0 : N
for m = -n : n
ns = [ns; n];
end
end

% -------- compute basis functions ----------
Y_nm = zeros(size(azimuth, 1), (N+1)^2);

for n = 0 : N
for m = -n : n
Y_nm(:, n^2+n+m+1) = sphharm(n, m, colatitude, azimuth, sphharm_type);
end
end

% ------------- perform the ls fit ---------------
fprintf('Performing LS fit... ');

coefficients = inv(Y_nm' * Y_nm + reg_parameter * diag(1 + ns .* (ns + 1))) * Y_nm' * data;

fprintf('done.\n');

coefficients = coefficients.';

end

Loading

0 comments on commit f48ec35

Please sign in to comment.