--- Saving session to: ECE481_02-May-2002.txt --- Processed startup.m --- ; ; ; ; ; ; ; spatial2(90) spatial2(90) spatial2(0) spatial2(180) spatial2(90) spatial2(180) spatial2(0) spatial2(45) spatial2(180) spatial2(45) spatial2(135) spatial2(180) spatial2(0) exit function spatial2(theta) % Spatialization #2 [x fs bits]=wavread('s6'); %theta=10; itd=630e-6*cos(theta*(pi/180)); N=round(itd*fs); yr=x'; yl=shift(x',N); sound([yr' yl'],fs) function y=shift(x,n) % SHIFT Shift (rotate) the elements of vector x by an amount n % SHIFT(x,n) returns the shifted (rotated) version of 'x'. 'n' specifies % the amount of the shift, and should be an integer. % % Positive 'n' shifts the elements to the right, and negative 'n' % shifts to the left. 'n' may be larger than the number of elements in % the vector because the actual shift amount is 'n' modulo length of 'x'. nx=length(x); b=nx-mod(n,nx); y=[x(b+1:nx) x(1:b)]; return % Spatialization #1 fs=40e3; dur=3; tt=0:1/fs:dur-1/fs; x=sawtooth(2*pi*440*tt); theta=[linspace(45,135,length(tt)/2) linspace(135,45,length(tt)/2)] ; Gl=cos( (theta-135)*(pi/180) ); Gr=cos( (theta-45)*(pi/180) ); yl=Gl.*x; yr=Gr.*x; sound([yr' yl'],fs)