annotate aim-mat/tools/@signal/loadwavefile.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
bleeck@3 1 % method of class @signal
bleeck@3 2 %
bleeck@3 3 % INPUT VALUES:
bleeck@3 4 %
bleeck@3 5 % RETURN VALUE:
bleeck@3 6 %
bleeck@3 7 %
bleeck@3 8 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 9 % (c) 2011, University of Southampton
bleeck@3 10 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 11 % download of current version is on the soundsoftware site:
bleeck@3 12 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 13 % documentation and everything is on http://www.acousticscale.org
bleeck@3 14
bleeck@3 15
bleeck@3 16 function [sig1,sig2]=loadwavefile(sig,orgname,timestart,duration)
bleeck@3 17 % usage: [sig1,sig2]=loadwavefile(name,time)
bleeck@3 18 % reads in the wavefile name in the time boundaries
bleeck@3 19 % returns two signals, if signal is stereo
bleeck@3 20
bleeck@3 21 %
bleeck@3 22 % [path,name,ext]=fileparts(name);
bleeck@3 23 % if strcmp(ext,'.wav')
bleeck@3 24 %
bleeck@3 25 % [data,sr,nbits]=wavread(name);
bleeck@3 26 % elseif strcmp(ext,'.aif') || strcmp(ext,'.aiff')
bleeck@3 27 % error('aif import not implemented yet');
bleeck@3 28 % end
bleeck@3 29 %
bleeck@3 30 % sig=signal(data);
bleeck@3 31 % sig=setsr(sig,sr);
bleeck@3 32 % sig=setname(sig,name);
bleeck@3 33 % if nargin > 2
bleeck@3 34 % sig=getpart(sig,timestart,timestart+duration);
bleeck@3 35 % end
bleeck@3 36 %
bleeck@3 37
bleeck@3 38 [name,path,ext]=fileparts(orgname);
bleeck@3 39 if strcmp(lower(ext),'.wav')
bleeck@3 40 try
bleeck@3 41 [data,sr,nbits]=wavread(orgname);
bleeck@3 42 catch
bleeck@3 43 error(sprintf('cant open file %s',orgname))
bleeck@3 44 end
bleeck@3 45 nr_sig=size(data,2);
bleeck@3 46
bleeck@3 47 sig1=signal(data(:,1));
bleeck@3 48 sig1=setsr(sig1,sr);
bleeck@3 49 sig1=setname(sig1,orgname);
bleeck@3 50 if nargin > 2
bleeck@3 51 sig1=getpart(sig1,timestart,timestart+duration);
bleeck@3 52 end
bleeck@3 53 if nr_sig==2
bleeck@3 54 sig2=signal(data(:,2));
bleeck@3 55 sig2=setsr(sig2,sr);
bleeck@3 56 sig2=setname(sig2,orgname);
bleeck@3 57 if nargin > 2
bleeck@3 58 sig2=getpart(sig2,timestart,timestart+duration);
bleeck@3 59 end
bleeck@3 60
bleeck@3 61 end
bleeck@3 62 elseif strcmp(ext,'.aif') || strcmp(ext,'.aiff')
bleeck@3 63 [data,sr]=aifread(orgname);
bleeck@3 64 sig=signal(data);
bleeck@3 65 sig=setsr(sig,sr);
bleeck@3 66 sig=setname(sig,orgname);
bleeck@3 67 if nargin > 2
bleeck@3 68 sig=getpart(sig,timestart,timestart+duration);
bleeck@3 69 end
tomwalters@0 70 end