clear all
[s, fs] = wavread('tada.wav');
t = 0.1 * s; % down 20 dB
r = s .^ 2; % form the square of every sample
u = s(1:10000); % pick a range; 1 is first; end is last
v = s(1:2:10000); % pick a range, steps of 2
w = s(end:-1:1); % in reverse
len = length(s);
% linear envelope 0 --> 1
z = (1:len)'/len; % apostrophe: transpose
% -60 dB in a logarithmic fashion
y = 10.^(-3*z);
% fade out
x = s .* y;
%soundsc(x, fs)

s1 = wavread('taaa.wav');
s2 = wavread('taahaa.wav');
% hard switching
r = [s1(1:end/2); s2(end/2:end)];
% soundsc(r, fs)
% fade (destructive interference?)
len1 = length(s1);
len2 = length(s2);
startFade = 20000;
endFade = 21000;
shift = -200;
fade = (1:endFade-startFade+1)'/(endFade-startFade+1);
r = [s1(1:startFade-1); (1-fade).*s1(startFade:endFade)+fade.*s2(startFade-shift:endFade-shift); s2(endFade+1-shift:end)];
soundsc(r, fs)
% plot((1:len1),s1,(1:len2),s2)