Chapter 10: Advanced topics

This chapter progresses onward from the foundation of the previous chapters, discussing and describing various advanced topics that combine many of the processing elements that we had met earlier, including aspects of both speech and hearing, as well as progressing beyond hearing into a very new research domain of low-frequency ultrasound.


10.2 Stereo encoding

We can easily demonstrate stereo effects using phase differences at a high sample rate in MATLAB. First we create a tone.

Fs=44100; %sample frequency
Ft =440;
note=tonegen(Ft, Fs, 0.5)

Next we construct signals for two channels, with a slight phase difference between them, leading to stereo placement.

s1 =[[ zeros (1 ,20) , note ];[ note , zeros (1 ,20) ]];
s2=fliplr(s1);

Remember, you need either stereo headphones or a good audio system with stereo separation to make the most of this;

soundsc(s1, Fs); 
soundsc(s2, Fs);

10.2.1 Stereo and noise

r1=0.2*rand(1, Fs*0.5);
r2=0.2*rand(1, Fs*0.5);
%Note use sound not soundsc to save your ears
sound([r1;r1], Fs);
%
%try again
sound([r1;r2], Fs);

10.2.4 More than two channels

The code below is used (and varied) to create the nice wave propagation pictures that are reproduced in the book;

function arr=pt_srce_sim(Lx,Ly,pix,Xp,Yp,W)
%Lx, Ly: horiz. and vert. dimensions, in m. 
%pix: the size of one point to simulate, in m. 
%Xp, Yp: coordinates of the sound source
%W: wavelength of the sound (where W=340/freq)
Nx=floor(Lx/pix);
Ny=floor(Ly/pix); 
arr=zeros(Nx,Ny); 
% define the area
for x=1:Nx
	for y=1:Ny 
		px=x*pix;
		py=y*pix; 
		d=sqrt((px-Xp).^2+(py-Yp).^2); 
		arr(x,y)=cos(2*pi*d/W);
	end 
end

Lx=1.6; 
Ly=1; 
Xp=1; 
Yp=0.5;
W=0.2; % about 1.7 kHz 
pix=1/1000; % 1 mm
arrR=point_source_sim(Lx,Ly,pix,0.45,0,W); 
arrL=point_source_sim(Lx,Ly,pix,1.15,0,W);
%display image
imagesc(arrR+arrL)
colormap('gray') %using greyscale colours

%save to file
imwrite(arrR+arrL,'stereo_source.tiff');

The smiley faces were added to the saved image afterwards, using OpenOffice Draw.