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: ReadWinFrame.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: tomwalters@0: % Created: tomwalters@0: % Updated: tomwalters@0: % Copyright: (c) 2000, University of Essex tomwalters@0: % tomwalters@0: %%%%%%%%%%%%%%%%%%%%%%%%%%% tomwalters@0: tomwalters@0: function frame=ReadWinFrame(fid, numChannels, frameLen, wordSize, littleEndian) tomwalters@0: tomwalters@0: switch wordSize tomwalters@0: case 1 tomwalters@0: frame = fread(fid, [numChannels, frameLen], 'char'); tomwalters@0: case 2 tomwalters@0: for i = 1:frameLen tomwalters@0: for j = 1:numChannels tomwalters@0: data = Read16Bits(fid, littleEndian); tomwalters@0: if (data >= 32768) tomwalters@0: frame(j, i) = data - 65536; tomwalters@0: else tomwalters@0: frame(j, i) = data; tomwalters@0: end tomwalters@0: end; tomwalters@0: end; tomwalters@0: case 4 tomwalters@0: for i = 1:frameLen tomwalters@0: for j = 1:numChannels tomwalters@0: data = Read32Bits(fid, littleEndian); tomwalters@0: if (data >= 2147483648) tomwalters@0: frame(j, i) = data - 4294967296; tomwalters@0: else tomwalters@0: frame(j, i) = data; tomwalters@0: end tomwalters@0: end; tomwalters@0: end; tomwalters@0: tomwalters@0: end tomwalters@0: