rmeddis@35
|
1 function f=enframe(x,win,inc)
|
rmeddis@35
|
2 %ENFRAME split signal up into (overlapping) frames: one per row. F=(X,WIN,INC)
|
rmeddis@35
|
3 %
|
rmeddis@35
|
4 % F = ENFRAME(X,LEN) splits the vector X(:) up into
|
rmeddis@35
|
5 % frames. Each frame is of length LEN and occupies
|
rmeddis@35
|
6 % one row of the output matrix. The last few frames of X
|
rmeddis@35
|
7 % will be ignored if its length is not divisible by LEN.
|
rmeddis@35
|
8 % It is an error if X is shorter than LEN.
|
rmeddis@35
|
9 %
|
rmeddis@35
|
10 % F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC
|
rmeddis@35
|
11 % The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,...
|
rmeddis@35
|
12 % The number of frames is fix((length(X)-LEN+INC)/INC)
|
rmeddis@35
|
13 %
|
rmeddis@35
|
14 % F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies
|
rmeddis@35
|
15 % each frame by WINDOW(:)
|
rmeddis@35
|
16
|
rmeddis@35
|
17 % Copyright (C) Mike Brookes 1997
|
rmeddis@35
|
18 % Version: $Id: enframe.m,v 1.4 2006/06/22 19:07:50 dmb Exp $
|
rmeddis@35
|
19 %
|
rmeddis@35
|
20 % VOICEBOX is a MATLAB toolbox for speech processing.
|
rmeddis@35
|
21 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
|
rmeddis@35
|
22 %
|
rmeddis@35
|
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
rmeddis@35
|
24 % This program is free software; you can redistribute it and/or modify
|
rmeddis@35
|
25 % it under the terms of the GNU General Public License as published by
|
rmeddis@35
|
26 % the Free Software Foundation; either version 2 of the License, or
|
rmeddis@35
|
27 % (at your option) any later version.
|
rmeddis@35
|
28 %
|
rmeddis@35
|
29 % This program is distributed in the hope that it will be useful,
|
rmeddis@35
|
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
rmeddis@35
|
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
rmeddis@35
|
32 % GNU General Public License for more details.
|
rmeddis@35
|
33 %
|
rmeddis@35
|
34 % You can obtain a copy of the GNU General Public License from
|
rmeddis@35
|
35 % http://www.gnu.org/copyleft/gpl.html or by writing to
|
rmeddis@35
|
36 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
|
rmeddis@35
|
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
rmeddis@35
|
38
|
rmeddis@35
|
39 nx=length(x(:));
|
rmeddis@35
|
40 nwin=length(win);
|
rmeddis@35
|
41 if (nwin == 1)
|
rmeddis@35
|
42 len = win;
|
rmeddis@35
|
43 else
|
rmeddis@35
|
44 len = nwin;
|
rmeddis@35
|
45 end
|
rmeddis@35
|
46 if (nargin < 3)
|
rmeddis@35
|
47 inc = len;
|
rmeddis@35
|
48 end
|
rmeddis@35
|
49 nf = fix((nx-len+inc)/inc);
|
rmeddis@35
|
50 f=zeros(nf,len);
|
rmeddis@35
|
51 indf= inc*(0:(nf-1)).';
|
rmeddis@35
|
52 inds = (1:len);
|
rmeddis@35
|
53 f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:));
|
rmeddis@35
|
54 if (nwin > 1)
|
rmeddis@35
|
55 w = win(:)';
|
rmeddis@35
|
56 f = f .* w(ones(nf,1),:);
|
rmeddis@35
|
57 end
|
rmeddis@35
|
58
|
rmeddis@35
|
59
|