forked from sfstoolbox/sfs-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wfs_preequalization.m
90 lines (83 loc) · 4.01 KB
/
wfs_preequalization.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function ir = wfs_preequalization(ir,conf)
%WFS_PREEQUALIZATION applies a pre-equalization filter for WFS
%
% Usage: ir = wfs_preequalization(ir,[conf])
%
% Input parameters:
% ir - IR to which the pre-equalization filter should be applied
% conf - optional configuration struct (see SFS_config)
%
% Output parameters:
% ir - IR with applied pre-equalization
%
% WFS_PREEQUALIZATION(ir,conf) applies the pre-equalization filter for
% Wave Field Synthesis to the given impulse response.
%
% see also: wfs_fir_prefilter, wfs_iir_prefilter, ir_wfs
%*****************************************************************************
% Copyright (c) 2010-2013 Quality & Usability Lab, together with *
% Assessment of IP-based Applications *
% Deutsche Telekom Laboratories, TU Berlin *
% Ernst-Reuter-Platz 7, 10587 Berlin, Germany *
% *
% Copyright (c) 2013 Institut fuer Nachrichtentechnik *
% Universitaet Rostock *
% Richard-Wagner-Strasse 31, 18119 Rostock *
% *
% This file is part of the Sound Field Synthesis-Toolbox (SFS). *
% *
% The SFS is free software: you can redistribute it and/or modify it under *
% the terms of the GNU General Public License as published by the Free *
% Software Foundation, either version 3 of the License, or (at your option) *
% any later version. *
% *
% The SFS is distributed in the hope that it will be useful, but WITHOUT ANY *
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
% FOR A PARTICULAR PURPOSE. *
% See the GNU General Public License for more details. *
% *
% You should have received a copy of the GNU General Public License along *
% with this program. If not, see <http:https://www.gnu.org/licenses/>. *
% *
% The SFS is a toolbox for Matlab/Octave to simulate and investigate sound *
% field synthesis methods like wave field synthesis or higher order *
% ambisonics. *
% *
% http:https://dev.qu.tu-berlin.de/projects/sfs-toolbox [email protected] *
%*****************************************************************************
%% ===== Checking of input parameters ====================================
nargmin = 1;
nargmax = 2;
narginchk(nargmin,nargmax);
isargmatrix(ir);
if nargin<nargmax
conf = SFS_config;
else
isargstruct(conf);
end
%% ===== Configuration ==================================================
usehpre = conf.wfs.usehpre;
hpretype = conf.wfs.hpretype;
%% ===== Computation =====================================================
% Check if we should procide
if ~usehpre
return;
end
% Get the filter
if strcmp('FIR',hpretype)
% get FIR filter
hpre = wfs_fir_prefilter(conf);
% apply filter
for ii = 1:size(ir,2)
ir_tmp(:,ii) = conv(hpre,ir(:,ii));
end
elseif strcmp('IIR',hpretype)
% get IIR filter
hpre = wfs_iir_prefilter(conf);
% apply filter
ir_tmp = filter(hpre.b,hpre.a,ir);
else
error('%s: %s is an unknown filter type.',upper(mfilename),hpretype);
end
% Fix length of ir to be conf.N
ir = ir_tmp(1:size(ir,1),:);