% Experiment with cell phone calling sounds
%
% Samuli Siltanen Nov 2015

% Read in the file
[Y, FS]=audioread('phone1234567890.m4a');

% Pick out one channel
Y = Y(:,1);

% Pick out the sounds of numbers
beep1 = Y(150001:180000);
N    = length(beep1);
beep2 = Y(390000+[1:N]);
beep3 = Y(550000+[1:N]);
beep4 = Y(690000+[1:N]);
beep5 = Y(830000+[1:N]);
beep6 = Y(965000+[1:N]);
beep7 = Y(1110000+[1:N]);
beep8 = Y(1240000+[1:N]);
beep9 = Y(1370000+[1:N]);
beep0 = Y(1510000+[1:N]);

% Listen to the sounds
%sound(Y,FS)
sound(beep1,FS)
pause(1)
sound(beep2,FS)
pause(1)
sound(beep3,FS)
pause(1)
sound(beep4,FS)
pause(1)
sound(beep5,FS)
pause(1)
sound(beep6,FS)
pause(1)
sound(beep7,FS)
pause(1)
sound(beep8,FS)
pause(1)
sound(beep9,FS)
pause(1)
sound(beep0,FS)

% Fourier transform a couple of the signals
Fbeep1 = fft(beep1);
Fbeep2 = fft(beep2);

% Show the signals
figure(1)
clf
subplot(1,2,1)
plot([1:N],beep2,'b')
hold on
plot([1:N],beep1,'r')
xlim([1 N])
axis square
subplot(1,2,2)
plot([1:N],abs(fftshift(Fbeep1)),'r')
hold on
plot([1:N],abs(fftshift(Fbeep2)),'b')
axis square
% Let's restrict our plot
xlim([.45*N .55*N])
