To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / userProgramsTim / enframe.m @ 38:c2204b18f4a2

History | View | Annotate | Download (2.75 KB)

1 38:c2204b18f4a2 rmeddis
function [f,t]=enframe(x,win,inc)
2
%ENFRAME split signal up into (overlapping) frames: one per row. [F,T]=(X,WIN,INC)
3
%
4
%	F = ENFRAME(X,LEN) splits the vector X(:) up into
5
%	frames. Each frame is of length LEN and occupies
6
%	one row of the output matrix. The last few frames of X
7
%	will be ignored if its length is not divisible by LEN.
8
%	It is an error if X is shorter than LEN.
9
%
10
%	F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC
11
%	The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,...
12
%	The number of frames is fix((length(X)-LEN+INC)/INC)
13
%
14
%	F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies
15
%	each frame by WINDOW(:)
16
%
17
%   The second output argument, T, gives the time in samples at the centre
18
%   of each frame. T=i corresponds to the time of sample X(i).
19
%
20
% Example of frame-based processing:
21
%          INC=20       													% set frame increment
22
%          NW=INC*2     													% oversample by a factor of 2 (4 is also often used)
23
%          S=cos((0:NW*7)*6*pi/NW);								% example input signal
24
%          W=sqrt(hamming(NW+1)); W(end)=[];      % sqrt hamming window of period NW
25
%          F=enframe(S,W,INC);               			% split into frames
26
%          ... process frames ...
27
%          X=overlapadd(F,W,INC);           			% reconstitute the time waveform (omit "X=" to plot waveform)
28
29
%	   Copyright (C) Mike Brookes 1997
30
%      Version: $Id: enframe.m,v 1.7 2009/11/01 21:08:21 dmb Exp $
31
%
32
%   VOICEBOX is a MATLAB toolbox for speech processing.
33
%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
34
%
35
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36
%   This program is free software; you can redistribute it and/or modify
37
%   it under the terms of the GNU General Public License as published by
38
%   the Free Software Foundation; either version 2 of the License, or
39
%   (at your option) any later version.
40
%
41
%   This program is distributed in the hope that it will be useful,
42
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
43
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44
%   GNU General Public License for more details.
45
%
46
%   You can obtain a copy of the GNU General Public License from
47
%   http://www.gnu.org/copyleft/gpl.html or by writing to
48
%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
49
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50
51
nx=length(x(:));
52
nwin=length(win);
53
if (nwin == 1)
54
   len = win;
55
else
56
   len = nwin;
57
end
58
if (nargin < 3)
59
   inc = len;
60
end
61
nf = fix((nx-len+inc)/inc);
62
f=zeros(nf,len);
63
indf= inc*(0:(nf-1)).';
64
inds = (1:len);
65
f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:));
66
if (nwin > 1)
67
    w = win(:)';
68
    f = f .* w(ones(nf,1),:);
69
end
70
if nargout>1
71
    t=(1+len)/2+indf;
72
end
73