tomwalters@0: % tool tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % bleeck@3: % 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: function ret=SBReadAiff(aifffile,echo) tomwalters@0: % usage SBReadAiff(aifffile,echo) tomwalters@0: % tomwalters@0: % returns all info in a struct tomwalters@0: % if echo =0, than no screen output is created tomwalters@0: if nargin<2 tomwalters@0: echo=1; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: aiffstruct=getAIFFinfo(aifffile); tomwalters@0: if echo tomwalters@0: fprintf('read %d frames with %d channels...',aiffstruct.numWindowFrames,aiffstruct.numChannels);end tomwalters@0: tomwalters@0: ende=0; tomwalters@0: n=0; tomwalters@0: nap=zeros(aiffstruct.numChannels,aiffstruct.frameLength,aiffstruct.numWindowFrames); tomwalters@0: tomwalters@0: if aiffstruct.littleEndian tomwalters@0: fid=fopen(aifffile,'r','l'); tomwalters@0: else tomwalters@0: fid=fopen(aifffile,'r','b'); tomwalters@0: end tomwalters@0: tomwalters@0: while ~ende tomwalters@0: von=n*30+1; tomwalters@0: bis=(n+1)*30; tomwalters@0: n=n+1; tomwalters@0: if bis>aiffstruct.numWindowFrames tomwalters@0: bis=aiffstruct.numWindowFrames; tomwalters@0: ende=1; tomwalters@0: end tomwalters@0: tomwalters@0: status = fseek(fid, aiffstruct.soundPosition, 'bof'); tomwalters@0: tnap = ReadWinFrame2(fid, von:bis, aiffstruct.numWindowFrames,... tomwalters@0: aiffstruct.numChannels,aiffstruct.frameLength, aiffstruct.wordSize,echo); tomwalters@0: tomwalters@0: if bis>=aiffstruct.numWindowFrames; tomwalters@0: ende=1; tomwalters@0: end tomwalters@0: tomwalters@0: if echo tomwalters@0: fprintf('\n'); end tomwalters@0: tomwalters@0: tnap = tnap .* aiffstruct.scale; tomwalters@0: tomwalters@0: % tnap = myReadAIFF(aifffile,von:bis); tomwalters@0: nap(:,:,von:bis)=tnap; tomwalters@0: end tomwalters@0: tomwalters@0: [nr_channels,nr_points,nr_frames]=size(nap); tomwalters@0: tomwalters@0: high=-inf;low=inf; tomwalters@0: sumhigh=-inf; tomwalters@0: frehigh=-inf; tomwalters@0: % do some controlling of the values tomwalters@0: for i=1:nr_frames tomwalters@0: vals=nap(:,:,i); tomwalters@0: fr=frame(vals,aiffstruct); % construct the frame tomwalters@0: ret(i)=fr; tomwalters@0: tomwalters@0: % find the maximum and the minimum values of each frame. this is useful for scaling tomwalters@0: ma=getmaximumvalue(fr); tomwalters@0: high=max([high ma]); tomwalters@0: mi=getminimumvalue(fr); tomwalters@0: low=min([low mi]); tomwalters@0: tomwalters@0: tomwalters@0: maxs=max(getsum(fr)); tomwalters@0: sumhigh=max([maxs sumhigh]); tomwalters@0: tomwalters@0: maxf=max(getfrequencysum(fr)); tomwalters@0: frehigh=max([maxf frehigh]); tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: % sr=getsr(ret(1)); tomwalters@0: tomwalters@0: for i=1:nr_frames tomwalters@0: ret(i)=setallmaxvalue(ret(i),high); tomwalters@0: ret(i)=setallminvalue(ret(i),low); tomwalters@0: ret(i)=setnrframestotal(ret(i),nr_frames); tomwalters@0: ret(i)=setscalesumme(ret(i),sumhigh); tomwalters@0: ret(i)=setscalefrequency(ret(i),frehigh); tomwalters@0: ret(i)=setcurrentframenumber(ret(i),i); tomwalters@0: frame_duration=aiffstruct.frameLength/aiffstruct.sampleRate; tomwalters@0: ret(i)=setcurrentframestarttime(ret(i),(i-1)*frame_duration); tomwalters@0: end