[c77b15]: blockproc / blockana.m  Maximize  Restore  History

Download this file

93 lines (85 with data), 2.3 kB

 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
91
92
93
function c = blockana(F, f)
%BLOCKANA Blockwise analysis interface
% Usage: c=blockana(F, f)
%
% Input parameters:
% F : Frame object.
% f : Analyzed block.
% Output parameters:
% c : Block coefficients.
%
% `c=blockana(F, f)` calculates coefficients `c` of block `f` using
% frame defined by `F`.
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
if ~isstruct(F)
error('%s: First agument must be a frame definition structure.',upper(mfilename));
end;
% Block length
Lb = size(f,1);
% Next block index start (from a global point of view, starting with zero)
nextSb = block_interface('getPos');
% Block index start (from a global point of view, starting with zero)
Sb = nextSb-Lb;
switch(F.type)
case 'fwt'
J = F.J;
w = F.g;
m = numel(w.h{1}.h);
a = w.a(1);
if Lb<a^J
error('%s: Minimum block length is %i.',upper(mfilename),a^J);
end
rred = (a^J-1)/(a-1)*(m-a);
Sbolen = rred + mod(Sb,a^J);
nextSbolen = rred + mod(nextSb,a^J);
fext = [loadOverlap(Sbolen);f];
c = block_fwt(fext,w,J);
storeOverlap(fext,nextSbolen);
otherwise
% General processing
% Equal block length assumtion
% Slicing window
g = fftshift(firwin('hann',2*Lb));
% Append the previous block
fext = [loadOverlap(Lb);f];
% Save the current block
storeOverlap(fext,Lb);
% Multiply by the slicing window (all channels)
fwin = bsxfun(@times,g,fext);
% Apply transform
c = frana(F,fwin);
end
function overlap = loadOverlap(L)
%LOADOVERLAP Loads overlap
%
%
overlap = block_interface('getAnaOverlap');
% Supply zeros if it is empty
if isempty(overlap)
overlap = zeros(L,size(f,2),block_interface('getClassId'));
end
Lo = size(overlap,1);
if nargin<1
L = Lo;
end
% If required more than stored, do zero padding
if L>Lo
oTmp = zeros(L,size(overlap,2));
oTmp(end-Lo+1:end) = oTmp(end-Lo+1:end)+overlap;
overlap = oTmp;
else
overlap = overlap(end-L+1:end,:);
end
end % LOADOVERLAP
function storeOverlap(fext,L)
%STOREOVERLAP Stores overlap
%
%
if L>size(fext,1)
error('%s: Storing more samples than passed.',upper(mfilename));
end
block_interface('setAnaOverlap',fext(end-L+1:end,:));
end % STOREOVERLAP
end % BLOCKANA

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks