daniele@166
|
1 function obj = buffer(obj,wLength,overlap,window,method)
|
daniele@166
|
2
|
daniele@166
|
3 %% Check inputs & Defaults
|
daniele@166
|
4 error(nargchk(2, 5, nargin, 'struct'));
|
daniele@166
|
5
|
daniele@166
|
6 if ~exist('overlap','var') || isempty(overlap), overlap = 0; end
|
daniele@166
|
7 if ~exist('method','var') || isempty(method), method = 'standard'; end
|
daniele@166
|
8
|
daniele@166
|
9 %% Buffer audio
|
daniele@166
|
10 switch lower(method)
|
daniele@166
|
11 case 'standard'
|
daniele@166
|
12 if ~exist('window','var') || isempty(window), window = @rectwin; end
|
daniele@166
|
13 validWindows = {'hanning','hamming','triang','rectwin'};
|
daniele@166
|
14 if ~sum(strcmpi(validWindows,func2str(window)));
|
daniele@166
|
15 error('The window chosen is not valid because it cannot be inverted!');
|
daniele@166
|
16 end
|
daniele@166
|
17 obj.S = diag(window(wLength))*buffer(obj.s,wLength,overlap,'nodelay');
|
daniele@166
|
18 case 'lot'
|
daniele@166
|
19 if ~exist('window','var') || isempty(window), window = 'sin2'; end
|
daniele@166
|
20 s_lot = lot(obj.s,wLength,'id',overlap,window);
|
daniele@166
|
21 obj.S = buffer(s_lot,wLength);
|
daniele@166
|
22 otherwise
|
daniele@166
|
23 error('Please specify a valid buffer method');
|
daniele@166
|
24 end
|
daniele@166
|
25
|
daniele@166
|
26 obj.bufferOperator = struct('wLength',wLength,'overlap',...
|
daniele@166
|
27 overlap,'window',window,'method',method);
|