rmeddis@35: function f=enframe(x,win,inc) rmeddis@35: %ENFRAME split signal up into (overlapping) frames: one per row. F=(X,WIN,INC) rmeddis@35: % rmeddis@35: % F = ENFRAME(X,LEN) splits the vector X(:) up into rmeddis@35: % frames. Each frame is of length LEN and occupies rmeddis@35: % one row of the output matrix. The last few frames of X rmeddis@35: % will be ignored if its length is not divisible by LEN. rmeddis@35: % It is an error if X is shorter than LEN. rmeddis@35: % rmeddis@35: % F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC rmeddis@35: % The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,... rmeddis@35: % The number of frames is fix((length(X)-LEN+INC)/INC) rmeddis@35: % rmeddis@35: % F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies rmeddis@35: % each frame by WINDOW(:) rmeddis@35: rmeddis@35: % Copyright (C) Mike Brookes 1997 rmeddis@35: % Version: $Id: enframe.m,v 1.4 2006/06/22 19:07:50 dmb Exp $ rmeddis@35: % rmeddis@35: % VOICEBOX is a MATLAB toolbox for speech processing. rmeddis@35: % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html rmeddis@35: % rmeddis@35: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% rmeddis@35: % This program is free software; you can redistribute it and/or modify rmeddis@35: % it under the terms of the GNU General Public License as published by rmeddis@35: % the Free Software Foundation; either version 2 of the License, or rmeddis@35: % (at your option) any later version. rmeddis@35: % rmeddis@35: % This program is distributed in the hope that it will be useful, rmeddis@35: % but WITHOUT ANY WARRANTY; without even the implied warranty of rmeddis@35: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the rmeddis@35: % GNU General Public License for more details. rmeddis@35: % rmeddis@35: % You can obtain a copy of the GNU General Public License from rmeddis@35: % http://www.gnu.org/copyleft/gpl.html or by writing to rmeddis@35: % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. rmeddis@35: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% rmeddis@35: rmeddis@35: nx=length(x(:)); rmeddis@35: nwin=length(win); rmeddis@35: if (nwin == 1) rmeddis@35: len = win; rmeddis@35: else rmeddis@35: len = nwin; rmeddis@35: end rmeddis@35: if (nargin < 3) rmeddis@35: inc = len; rmeddis@35: end rmeddis@35: nf = fix((nx-len+inc)/inc); rmeddis@35: f=zeros(nf,len); rmeddis@35: indf= inc*(0:(nf-1)).'; rmeddis@35: inds = (1:len); rmeddis@35: f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:)); rmeddis@35: if (nwin > 1) rmeddis@35: w = win(:)'; rmeddis@35: f = f .* w(ones(nf,1),:); rmeddis@35: end rmeddis@35: rmeddis@35: