Skip to content

Commit

Permalink
Updated the configuration to use substructs like conf.wfs
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jul 3, 2013
1 parent 9f48a3e commit c856254
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 102 deletions.
6 changes: 3 additions & 3 deletions SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset_3d.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
%% ===== Variables ======================================================
conf.array = 'spherical';
conf.usetapwin = 0;
conf.usehpre = 1;
conf.wfs.usehpre = 1;
conf.usefracdelay = 0;
conf.xref = [0 0 0];
x0 = zeros(length(irs.source_position),8);
Expand All @@ -81,8 +81,8 @@
x0(1,7) = x0(2,7);
x0(:,8) = weights_for_points_on_a_sphere_rectangle(irs.apparent_azimuth,...
irs.apparent_elevation,irs.distance)';
conf.hprefhigh = aliasing_frequency(x0,conf);
conf.hpreflow = 1;
conf.wfs.hprefhigh = aliasing_frequency(x0,conf);
conf.wfs.hpreflow = 1;
%% ===== Computation =====================================================
% get virtual secondary source positions
% x0_all = secondary_source_positions(L,conf);
Expand Down
4 changes: 2 additions & 2 deletions SFS_binaural_synthesis/wfs_preequalization3d.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@


%% ===== Configuration ==================================================
usehpre = conf.usehpre;
usehpre = conf.wfs.usehpre;


%% ===== Computation =====================================================
Expand All @@ -74,4 +74,4 @@
% Apply the filter
for ii = 1:size(ir,2)
ir(:,ii) = conv(hpre,ir(1:end-length(hpre)+1,ii));
end
end
179 changes: 96 additions & 83 deletions SFS_config_example.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,49 +77,81 @@
%


% ===== Misc ====================================
%% ===== Misc ============================================================
conf.tmpdir = '/tmp/sfs';
% Debugging level. We are supporting 3 levels:
% 0 - normal mode
% 1 - debug modus, showing interim results and plots
conf.debug = 0;


% ===== Audio ===================================
%% ===== Audio ===========================================================
% Audio and signal processing settings
%
% Samplingrate
conf.fs = 44100; % Hz
conf.fs = 44100; % / Hz
% Speed of sound
conf.c = 343; % m/s
conf.c = 343; % / m/s
% use fractional delays for delay lines
conf.usefracdelay = 0;
conf.usefracdelay = false; % boolean
conf.fracdelay_method = 'resample';
% Bandpass filter for time domain driving functions
% FIXME: check where the bandpass should be applied exactly. At the moment
% it is applied in the wave_field_imp.m function
conf.usebandpass = 1;
conf.bandpassflow = 10;
conf.bandpassfhigh = 20000;
conf.usebandpass = true; % boolean
conf.bandpassflow = 10; % / Hz
conf.bandpassfhigh = 20000; % / Hz


% ===== Simulations =============================
% xyresolution for wavefield simulations
conf.xysamples = 300; % samples
% Phase of omega of wavefield (change this value to create monochromatic wave
% fields with different phases for a movie)
conf.phase = 0; % rad
%% ===== SFS =============================================================
% Common sound field synthesis settings
%
% === Dimensionality ===
% Dimensionality of the secondary sources and the sound field synthesis driving
% functions:
% '2D' - line sources as secondary sources, arranged in a circle, line, ...
% '2.5D' - point sources as secondary sources, arranged in a circle, line, ...
% '3D' - point sources as secondary sources, arranged in a sphere, plane, ...
conf.dimension = '2.5D';
%
% === Driving functions ===
% Implementation of driving functions. For the default ones use 'default'. These
% functions are described in the PDF documentation, in the doc folder of the
% SFS-Toolbox. For possible other flags have a look into the driving functions.
% Most users can safely use the 'default' flag here.
conf.driving_functions = 'default';
%
% === 2.5D ===
% The amplitude will be correct at the point xref for 2.5D
% synthesis.
% This point is also used to scale the wave field to 1 at this point.
conf.xref = [0 0 0]; % / m
%
% === Tapering ===
% The truncation of the loudspeaker array leads to diffraction of the
% synthesized wave field. It has been shown that the truncation can be discribed
% by cylindrical waves originating from the edges of the array
% [Young,Sommerfeld,Rubinovitch]. Therefore a good method to reduce artifacts
% due to the diffraction edge waves is to fade out the amplitude of the driving
% function at the edges of the array. This method is called tapering and
% implemented using a Hanning window.
% Use tapering window
conf.usetapwin = true; % boolean
% Size of the tapering window
conf.tapwinlen = 0.3; % / percent of array length, 0..1


%% ===== Wave Field Simulations ==========================================
% Simulations of monochromatic or time domain wave field
%
% xyz-resolution for wavefield simulations, this value is applied along every
% desired dimension, expect if only one point is desired
conf.xysamples = 300; % / samples
% Phase of omega of wave field (change this value to create monochromatic wave
% fields with different phases, for example this can be useful to create a movie)
conf.phase = 0; % / rad
% normalize the simulated wave field?
conf.usenormalisation = 1;
conf.usenormalisation = true; % boolean


% ===== Secondary Sources =======================
Expand All @@ -141,49 +173,10 @@
conf.secondary_sources.grid = 'equally_spaced_points';


% ===== Binaural reproduction ===================
%
% === Headphone compensation ===
% Headphone compensation
conf.usehcomp = true; % boolean
% Headphone compensation file for left and right ear.
conf.hcomplfile = ...
'~/data/ir_databases/headphone_compensations/TU_FABIAN_AKGK601_hcompl.wav';
conf.hcomprfile = ...
'~/data/ir_databases/headphone_compensations/TU_FABIAN_AKGK601_hcompr.wav';
%% ===== WFS =============================================================
% Settings for wave field synthesis
%
% === HRIR/BRIR ===
% Target length of BRIR impulse responses (2^14 may be enough for your
% purposes, but for a large distance between source and listener, this will
% be not enough to contain the desired time delay. But don't worry, SFS
% checks for you if conf.N is large enough)
conf.N = 2^15; % samples
% To use a dynamic binaural simulation together with the SoundScape Renderer
% (SSR) and a headtracker, brs sets can be created. If these sets should be
% used in BRS mode of the SSR, the angles have to be:
% conf.brsangles = 0:1:359;
% If the brs set should be used as IRs for the SSR, the angles have to be:
% conf.brsangles = 360:-1:1;
conf.brsangles = 0:1:359; % degree
%
% === Auralisation ===
% These files are used for the auralization of impulse responses by the
% auralize_ir() function.
% NOTE: you have to provide them by yourself!
conf.speechfile = '';
conf.cellofile = '';
conf.castanetsfile = '';
conf.noisefile = '';
conf.pinknoisefile = '';


% ===== WFS =====================================
% The amplitude will be correct at the point xref for 2.5D
% synthesis.
% Thi point is also used to scale the wave field to 1 at this point.
conf.xref = [0 0 0]; % m, m, m
%
% ===== Pre-Equalization =====
% === Pre-Equalization ===
% WFS can be implemented very efficiently using a delay-line with different
% amplitudes and convolving the whole signal once with the so called
% pre-equalization filter [References]. If we have aliasing in our system we
Expand All @@ -192,44 +185,64 @@
% frequency (which means the frequency response over the aliasing frequency is
% allready "correct") [Reference]
% Use WFS preequalization-filter
conf.usehpre = false; % boolean
conf.wfs.usehpre = false; % boolean
% Lower frequency limit of preequalization filter (~ frequency when
% subwoofer is active)
conf.hpreflow = 50; % Hz
conf.wfs.hpreflow = 50; % / Hz
% Upper frequency limit of preequalization filter (~ aliasing frequency of
% system)
conf.hprefhigh = 1200; % Hz
%
% ===== Tapering =====
% The truncation of the loudspeaker array leads to diffraction of the
% synthesized wave field. It has been shown that the truncation can be discribed
% by cylindrical waves originating from the edges of the array
% [Young,Sommerfeld,Rubinovitch]. Therefore a good method to reduce artifacts
% due to the diffraction edge waves is to fade out the amplitude of the driving
% function at the edges of the array. This method is called tapering and
% implemented using a Hanning window.
% Use tapering window
conf.usetapwin = true; % boolean
% Size of the tapering window
conf.tapwinlen = 0.3; % percent of array length 0..1
%
% === Virtual Sources ===
% Pre-delay for causality for focused sources
% Note: for a non focused point source this will be set automaticly to 0
% from brs_wfs_25d!
conf.t0 = -3*1024/conf.fs; % s
conf.wfs.hprefhigh = 1200; % / Hz


% ===== SDM =====================================
%% ===== SDM =============================================================
% Use the evanescent part of the driving function for SDM
conf.withev = true; % boolean
conf.sdm.withev = true; % boolean


% ===== HOA =====================================
%% ===== HOA =============================================================
% TODO


% ===== Plotting ================================
%% ===== Binaural reproduction ===========================================
% Settings regarding all the stuff with impulse responses from the SFS_ir and
% SFS_binaural_synthesis folders
%
% Target length of BRIR impulse responses (2^14 may be enough for your
% purposes, but for a large distance between source and listener, this will
% be not enough to contain the desired time delay. But don't worry, SFS
% checks for you if conf.N is large enough)
conf.ir.N = 2^15; % samples
%
% === Headphone compensation ===
% Headphone compensation
conf.ir.usehcomp = true; % boolean
% Headphone compensation file for left and right ear.
conf.ir.hcomplfile = ...
'~/data/ir_databases/headphone_compensations/TU_FABIAN_AKGK601_hcompl.wav';
conf.ir.hcomprfile = ...
'~/data/ir_databases/headphone_compensations/TU_FABIAN_AKGK601_hcompr.wav';
%
% === BRS (binaural room scanning) ===
% To use a dynamic binaural simulation together with the SoundScape Renderer
% (SSR) and a headtracker, brs sets can be created. If these sets should be
% used in BRS mode of the SSR, the angles have to be:
% conf.brsangles = 0:1:359;
% If the brs set should be used as IRs for the SSR, the angles have to be:
% conf.brsangles = 360:-1:1;
conf.ir.brsangles = 0:1:359; % / degree
%
% === Auralisation ===
% These files are used for the auralization of impulse responses by the
% auralize_ir() function.
% NOTE: you have to provide them by yourself!
conf.ir.speechfile = '';
conf.ir.cellofile = '';
conf.ir.castanetsfile = '';
conf.ir.noisefile = '';
conf.ir.pinknoisefile = '';


%% ===== Plotting ========================================================
% Plot the results (wave fields etc.) directly
conf.plot.useplot = false; % boolean
% Plot mode (uses the GraphDefaults function). Avaiable modes are:
Expand Down
7 changes: 4 additions & 3 deletions SFS_general/wfs_prefilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
% hpre - pre-equalization filter
%
% WFS_PREFILTER(conf) calculates a sqrt(j k) pre-equalization filter for
% Wave Field Synthesis (from conf.hpreflow to conf.hprefhigh, see SFS_config).
% Wave Field Synthesis (from conf.wfs.hpreflow to conf.wfs.hprefhigh,
% see SFS_config).
%
% see also: wfs_preequalization, SFS_config, brs_wfs_25d

Expand Down Expand Up @@ -61,9 +62,9 @@

%% ===== Configuration ==================================================
fs = conf.fs; % Sampling rate
flow = conf.hpreflow; % Lower frequency limit of preequalization
flow = conf.wfs.hpreflow; % Lower frequency limit of preequalization
% filter (= frequency when subwoofer is active)
fhigh = conf.hprefhigh; % Upper frequency limit of preequalization
fhigh = conf.wfs.hprefhigh; % Upper frequency limit of preequalization
% filter (= aliasing frequency of system)


Expand Down
4 changes: 2 additions & 2 deletions SFS_general/wfs_prefilter3d.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

%% ===== Configuration ==================================================
fs = conf.fs; % Sampling rate
flow = conf.hpreflow; % Lower frequency limit of preequalization
flow = conf.wfs.hpreflow; % Lower frequency limit of preequalization
% filter (= frequency when subwoofer is active)
fhigh = conf.hprefhigh; % Upper frequency limit of preequalization
fhigh = conf.wfs.hprefhigh; % Upper frequency limit of preequalization
% filter (= aliasing frequency of system)

%% ===== Variables ======================================================
Expand Down
2 changes: 1 addition & 1 deletion SFS_monochromatic/driving_function_mono_sdm_25d_kx.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
xref = conf.xref;
X0 = conf.X0;
c = conf.c;
withev = conf.withev;
withev = conf.sdm.withev;


%% ===== Variables =======================================================
Expand Down
2 changes: 1 addition & 1 deletion SFS_monochromatic/wave_field_mono_sdm_25d_kx.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
% NOTE: if dLS <= dx, than we have a continous loudspeaker
dx = conf.dx0;
% Method to calculate driving function (only for non-aliased part)
withev = conf.withev; % with evanescent waves
withev = conf.sdm.withev; % with evanescent waves
% Reference position for the amplitude (correct reproduction of amplitude
% at y = yref).
xref = conf.xref;
Expand Down
2 changes: 1 addition & 1 deletion SFS_time_domain/driving_function_imp_wfs.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
c = conf.c;
xref = conf.xref;
fs = conf.fs;
usehpre = conf.usehpre;
usehpre = conf.wfs.usehpre;
N = conf.N;


Expand Down
2 changes: 1 addition & 1 deletion SFS_time_domain/wfs_preequalization.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@


%% ===== Configuration ==================================================
usehpre = conf.usehpre;
usehpre = conf.wfs.usehpre;


%% ===== Computation =====================================================
Expand Down
6 changes: 3 additions & 3 deletions examples/frequency_response.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
src = 'ps';
xs = [0 2.5];
conf.xref = [0 0];
conf.usehpre = 1;
conf.wfs.usehpre = 1;
conf.usehcomp = 0;
% get dirac impulses as impulse responses
irs = dummy_irs;
% 1. loudspeaker spacing = 0.16m
conf.dx0 = 0.16;
conf.hprefhigh = conf.c/(2*dx0);
conf.wfs.hprefhigh = conf.c/(2*dx0);
ir = ir_wfs_25d(X,phi,xs,src,L,irs,conf);
[a,p,f] = easyfft(ir(:,1),conf);
figure; semilogx(f,db(a));
% 2. loudspeaker spacing = 0.32m
conf.dx0 = 0.32;
conf.hprefhigh = conf.c/(2*dx0);
conf.wfs.hprefhigh = conf.c/(2*dx0);
ir = ir_wfs_25d(X,phi,xs,src,L,irs,conf);
[a,p,f] = easyfft(ir(:,1),conf);
figure; semilogx(f,db(a));
Expand Down
4 changes: 2 additions & 2 deletions examples/test_wavefield_3d_wfs.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
conf.secondary_sources.grid = 'equally_spaced_points';
conf.secondary_sources.size = 2*r;
conf.usetapwin = 0; % do not use tapering window, it's not needed in the 3D case
conf.usehpre = 1; % use preequalization filter
conf.hprefhigh = 12000;
conf.wfs.usehpre = 1; % use preequalization filter
conf.wfs.hprefhigh = 12000;
conf.debug = 1; % debug=1 allows to plot results of different evaluation steps
conf.xref = [0 0 0]; % ps/fs: 'listener position' ; pw: place where the wavefield is scaled to one
% properties of desired wavefield
Expand Down

0 comments on commit c856254

Please sign in to comment.