tomwalters@0: % support file for 'aim-mat' tomwalters@0: % tomwalters@0: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: %%%%%%%%%%%%%%%%%%%%%%%%%%% tomwalters@0: % tomwalters@0: % File: ReadWinFrame2.m tomwalters@0: % Purpose: Reads a window from from an AIFF file. tomwalters@0: % Comments: tomwalters@0: % Author: L. P. O'Mard tomwalters@0: % Revised by: M.Tsuzaki (ATR SLT) tomwalters@0: % Created: tomwalters@0: % Updated: 31,Oct.,2001 tomwalters@0: % Copyright: (c) 2000, University of Essex tomwalters@0: % changed by Stefan Bleeck to produce stars tomwalters@0: %%%%%%%%%%%%%%%%%%%%%%%%%%% tomwalters@0: % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $ tomwalters@0: % $Revision: 585 $ tomwalters@0: function signal=ReadWinFrame2(fid, frameId, numWindowFrames, numChannels, frameLen, wordSize,echo) tomwalters@0: if nargin < 7 tomwalters@0: echo=1 tomwalters@0: end tomwalters@0: p_bias = ftell(fid); tomwalters@0: if numWindowFrames == 1 tomwalters@0: top = frameId(1); tomwalters@0: if length(frameId) > 1 tomwalters@0: bot = frameId(end); tomwalters@0: else tomwalters@0: bot = frameLen; tomwalters@0: end tomwalters@0: else tomwalters@0: frameId=frameId(find(frameId>=1 & frameId<=numWindowFrames)); tomwalters@0: end tomwalters@0: if isempty(frameId) tomwalters@0: warning(sprintf('FrameID should be in the range of [1 %d]',numWindowFrames)); tomwalters@0: signal = []; tomwalters@0: return tomwalters@0: end tomwalters@0: switch wordSize tomwalters@0: case 1 tomwalters@0: if numWindowFrames == 1 tomwalters@0: fseek(fid,top-1,'cof'); tomwalters@0: nn = bot - top + 1; tomwalters@0: signal = fread(fid, [numChannels, nn], 'char'); tomwalters@0: else tomwalters@0: for kk=1:length(frameId) tomwalters@0: fseek(fid,p_bais+(frameId(kk)-1)*numChannels*frameLen,'bof'); tomwalters@0: signal(:,:,kk)=fread(fid,[numChannels, frameLen],'char'); tomwalters@0: end tomwalters@0: end tomwalters@0: case 2 tomwalters@0: if numWindowFrames == 1 tomwalters@0: fseek(fid,2*(top-1),'cof'); tomwalters@0: nn = bot - top + 1; tomwalters@0: signal = fread(fid,[numChannels, nn], 'short'); tomwalters@0: else tomwalters@0: for kk=1:length(frameId) tomwalters@0: if echo fprintf('*'); end tomwalters@0: tomwalters@0: fseek(fid,p_bias+2*(frameId(kk)-1)*numChannels*frameLen,'bof'); tomwalters@0: signal(:,:,kk)=fread(fid,[numChannels, frameLen],'short'); tomwalters@0: % signal(:,:,kk)=fread(fid,[numChannels, frameLen],'int'); tomwalters@0: end tomwalters@0: end tomwalters@0: case 4 tomwalters@0: if numWindowFrames == 1 tomwalters@0: fseek(fid,4*(top-1),'cof'); tomwalters@0: nn = bot - top + 1; tomwalters@0: % signal = fread(fid,[numChannels, nn], 'float32'); tomwalters@0: signal = fread(fid,[numChannels, nn], 'uint32'); tomwalters@0: else tomwalters@0: for kk=1:length(frameId) tomwalters@0: fseek(fid,p_bias+4*(frameId(kk)-1)*numChannels*frameLen,'bof'); tomwalters@0: % signal(:,:,kk)=fread(fid,[numChannels, frameLen],'float32'); tomwalters@0: signal(:,:,kk)=fread(fid,[numChannels, frameLen],'uint32'); tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: end