annotate aim-mat/tools/ReadWinFrame2.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % support file for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 4 % (c) 2011, University of Southampton
bleeck@3 5 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 6 % download of current version is on the soundsoftware site:
bleeck@3 7 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 8 % documentation and everything is on http://www.acousticscale.org
bleeck@3 9
tomwalters@0 10
tomwalters@0 11 %%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 12 %
tomwalters@0 13 % File: ReadWinFrame2.m
tomwalters@0 14 % Purpose: Reads a window from from an AIFF file.
tomwalters@0 15 % Comments:
tomwalters@0 16 % Author: L. P. O'Mard
tomwalters@0 17 % Revised by: M.Tsuzaki (ATR SLT)
tomwalters@0 18 % Created:
tomwalters@0 19 % Updated: 31,Oct.,2001
tomwalters@0 20 % Copyright: (c) 2000, University of Essex
tomwalters@0 21 % changed by Stefan Bleeck to produce stars
tomwalters@0 22 %%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 23 % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $
tomwalters@0 24 % $Revision: 585 $
tomwalters@0 25 function signal=ReadWinFrame2(fid, frameId, numWindowFrames, numChannels, frameLen, wordSize,echo)
tomwalters@0 26 if nargin < 7
tomwalters@0 27 echo=1
tomwalters@0 28 end
tomwalters@0 29 p_bias = ftell(fid);
tomwalters@0 30 if numWindowFrames == 1
tomwalters@0 31 top = frameId(1);
tomwalters@0 32 if length(frameId) > 1
tomwalters@0 33 bot = frameId(end);
tomwalters@0 34 else
tomwalters@0 35 bot = frameLen;
tomwalters@0 36 end
tomwalters@0 37 else
tomwalters@0 38 frameId=frameId(find(frameId>=1 & frameId<=numWindowFrames));
tomwalters@0 39 end
tomwalters@0 40 if isempty(frameId)
tomwalters@0 41 warning(sprintf('FrameID should be in the range of [1 %d]',numWindowFrames));
tomwalters@0 42 signal = [];
tomwalters@0 43 return
tomwalters@0 44 end
tomwalters@0 45 switch wordSize
tomwalters@0 46 case 1
tomwalters@0 47 if numWindowFrames == 1
tomwalters@0 48 fseek(fid,top-1,'cof');
tomwalters@0 49 nn = bot - top + 1;
tomwalters@0 50 signal = fread(fid, [numChannels, nn], 'char');
tomwalters@0 51 else
tomwalters@0 52 for kk=1:length(frameId)
tomwalters@0 53 fseek(fid,p_bais+(frameId(kk)-1)*numChannels*frameLen,'bof');
tomwalters@0 54 signal(:,:,kk)=fread(fid,[numChannels, frameLen],'char');
tomwalters@0 55 end
tomwalters@0 56 end
tomwalters@0 57 case 2
tomwalters@0 58 if numWindowFrames == 1
tomwalters@0 59 fseek(fid,2*(top-1),'cof');
tomwalters@0 60 nn = bot - top + 1;
tomwalters@0 61 signal = fread(fid,[numChannels, nn], 'short');
tomwalters@0 62 else
tomwalters@0 63 for kk=1:length(frameId)
tomwalters@0 64 if echo fprintf('*'); end
tomwalters@0 65
tomwalters@0 66 fseek(fid,p_bias+2*(frameId(kk)-1)*numChannels*frameLen,'bof');
tomwalters@0 67 signal(:,:,kk)=fread(fid,[numChannels, frameLen],'short');
tomwalters@0 68 % signal(:,:,kk)=fread(fid,[numChannels, frameLen],'int');
tomwalters@0 69 end
tomwalters@0 70 end
tomwalters@0 71 case 4
tomwalters@0 72 if numWindowFrames == 1
tomwalters@0 73 fseek(fid,4*(top-1),'cof');
tomwalters@0 74 nn = bot - top + 1;
tomwalters@0 75 % signal = fread(fid,[numChannels, nn], 'float32');
tomwalters@0 76 signal = fread(fid,[numChannels, nn], 'uint32');
tomwalters@0 77 else
tomwalters@0 78 for kk=1:length(frameId)
tomwalters@0 79 fseek(fid,p_bias+4*(frameId(kk)-1)*numChannels*frameLen,'bof');
tomwalters@0 80 % signal(:,:,kk)=fread(fid,[numChannels, frameLen],'float32');
tomwalters@0 81 signal(:,:,kk)=fread(fid,[numChannels, frameLen],'uint32');
tomwalters@0 82 end
tomwalters@0 83 end
tomwalters@0 84
tomwalters@0 85 end