Home > SUpDEq-v5.0.0 > supdeq_win.m

supdeq_win

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

function win = supdeq_win(signalLength, windowLength)

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization

 function win = supdeq_win(signalLength, windowLength)

 This function generates a single- or both-sided hann window which can be
 used for windowing in time domain

 Output:
 win           - Window in time domain

 Input:
 signalLength  - Length of signal to be windowed in samples 
 windowLength  - Values of head and tail window length in samples [a,b].
                 If [a,0] is passed, a single sided (head-)window will be
                 designed with head-length a. If [0,b] is passed, a single 
                 sided (tail-)window will be designed with tail-length b.
                 If only a single value is passed, a head window will be
                 designed.

 Dependencies: -

 (C) 2018 by JMA, Johannes M. Arend
             TH Köln - University of Applied Sciences
             Institute of Communications Engineering
             Department of Acoustics and Audio Signal Processing

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% SUpDEq - Spatial Upsampling by Directional Equalization
0002 %
0003 % function win = supdeq_win(signalLength, windowLength)
0004 %
0005 % This function generates a single- or both-sided hann window which can be
0006 % used for windowing in time domain
0007 %
0008 % Output:
0009 % win           - Window in time domain
0010 %
0011 % Input:
0012 % signalLength  - Length of signal to be windowed in samples
0013 % windowLength  - Values of head and tail window length in samples [a,b].
0014 %                 If [a,0] is passed, a single sided (head-)window will be
0015 %                 designed with head-length a. If [0,b] is passed, a single
0016 %                 sided (tail-)window will be designed with tail-length b.
0017 %                 If only a single value is passed, a head window will be
0018 %                 designed.
0019 %
0020 % Dependencies: -
0021 %
0022 % (C) 2018 by JMA, Johannes M. Arend
0023 %             TH Köln - University of Applied Sciences
0024 %             Institute of Communications Engineering
0025 %             Department of Acoustics and Audio Signal Processing
0026 
0027 function win = supdeq_win(signalLength, windowLength)
0028 
0029 if length(windowLength) < 2
0030     winMode = 'headWin';
0031     headWinLength = windowLength(1);
0032 end
0033 
0034 if length(windowLength) >= 2
0035     if windowLength(1) == 0
0036         winMode = 'tailWin';
0037         tailWinLength = windowLength(2);
0038     elseif windowLength(2) == 0
0039         winMode = 'headWin';
0040         headWinLength = windowLength(1);
0041     else
0042         winMode = 'bothSidedWin';
0043         headWinLength = windowLength(1);
0044         tailWinLength = windowLength(2);
0045     end
0046 end
0047 
0048 %% Design window
0049 if strcmp(winMode,'headWin')
0050    win_head = 0.5*(1 - cos(2*pi*(0:headWinLength*2-1)'/(headWinLength*2-1)));
0051    win = [win_head(1:headWinLength,:);ones(signalLength-headWinLength,1)];
0052 end
0053 
0054 if strcmp(winMode,'tailWin')
0055    win_tail = 0.5*(1 - cos(2*pi*(0:tailWinLength*2-1)'/(tailWinLength*2-1)));
0056    win = [ones(signalLength-tailWinLength,1);win_tail(tailWinLength+1:end,:)];
0057 end
0058 
0059 if strcmp(winMode,'bothSidedWin')
0060     win_head = 0.5*(1 - cos(2*pi*(0:headWinLength*2-1)'/(headWinLength*2-1)));
0061     win_tail = 0.5*(1 - cos(2*pi*(0:tailWinLength*2-1)'/(tailWinLength*2-1)));
0062     win = [win_head(1:headWinLength,:);ones(signalLength-headWinLength-tailWinLength,1);win_tail(tailWinLength+1:end,:)];
0063 end
0064 
0065 end
0066

Generated on Wed 30-Nov-2022 14:15:00 by m2html © 2005