ita_sph_window.m 1.78 KB
Newer Older
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
function out = ita_sph_window(B,limits)
%ITA_SPH_WINDOW - Window Sph. Harmonic Coefficients
%  This function ++++ FILL IN INFO HERE +++
%
%  Syntax:
%   audioObjOut = ita_sph_window(audioObjIn, options)
%
%   Options (default):
%           'opt1' (defaultopt1) : description
%           'opt2' (defaultopt1) : description
%           'opt3' (defaultopt1) : description
%
%  Example:
%   audioObjOut = ita_sph_window(audioObjIn)
%
%  See also:
%   ita_toolbox_gui, ita_read, ita_write, ita_generate
%
%   Reference page in Help browser 
%        <a href="matlab:doc ita_sph_window">doc ita_sph_window</a>

% <ITA-Toolbox>
% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. 
% You can find the license for this m-file in the application folder. 
% </ITA-Toolbox>


% Author: Bruno Masiero -- Email: bma@akustik.rwth-aachen.de
% Created:  10-May-2011 


if nargin == 1
    return
elseif nargin == 2
    if length(limits) ~= 2
        error('Please give a vector with lower and upper limit for the window.')
    end
    
    if isa(B,'itaSuper')
        [n,m] = ita_sph_linear2degreeorder(1:B.nChannels);
        flag = 1;
    elseif isscalar(B)
        d = ita_sph_degreeorder2linear(B);
        [n,m] = ita_sph_linear2degreeorder(1:d);
        flag = 0;
    else
        error('First argument must be either an itaSuper or a scalar.');
    end
else
    error('Too many input arguments');
end



A = itaAudio(ones((n(end)+1)*100,1), 100, 'time');
if any(limits > A.trackLength.value)
    limits(limits > A.trackLength.value) = A.trackLength.value;
end
win = ita_time_window(A,limits,'time');
win = interp1(win.timeVector,win.timeData,0:n(end));
win = win(n+1);

if flag
    B.freqData = bsxfun(@times,B.freqData,win);
    out = B;
else
    out = win;
end

%end function
end