--- Saving session to:
    ECE481_26-Mar-2002.txt
--- Processed startup.m ---
; ; ; ; ; ; ; 
am3(0)
Original sound...

f1 =

     1

Press a key to continue...
AM sound

f2 =

     2

am3(150)
Original sound...

f1 =

     1

Press a key to continue...
AM sound

f2 =

     2

am3(11025/4)
Original sound...

f1 =

     1

Press a key to continue...
AM sound

f2 =

     2

am3(11025/4)
Original sound...

f1 =

     1

Press a key to continue...
AM sound

f2 =

     2

edit ssb1
ssb1(0)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

ssb1(40)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

ssb1(440)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

ssb1(-220)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

fschange('c:\personal\class\2001-02\spring\ece481\matlab\ssb1.m');
clear ssb1
ssb1(-220)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

ssb1(440)
Original sound...

f1 =

     1

Press a key to continue...
SSB-AM sound

f2 =

     2

type am1

function am1(fo,fm)
% AM modulation demo #1


% Parameters
%fo=880;	% Signal frequency (Hz)
%fm=2;	% Modulation frequency (Hz)
dur=1;	% Duration (s)
fs=10e3;	% Sampling frequency


% Make a time vector
tt=0:1/fs:dur;

% Make the signal
x=sin(2*pi*fo*tt);
%x=sawtooth(2*pi*fo*tt);

% Make the modulation signal
e=cos(2*pi*fm*tt);

% Make the AM signal
y=e.*x;

% Determine screen size
ssize = get(0,'ScreenSize');
swidth = ssize(3);
sheight = ssize(4);

% Need two figures to fit across top of screen; determine width of each figure
fwidth = swidth/2;

% Play the original
disp('Original sound...');
f1=figure(1)
pos=[sheight-(fwidth+20),fwidth,fwidth];
set(f1,'Position',[0 pos],'MenuBar','none')
[b,f,t]=specgram(x,[],fs);
imagesc(t,f/1000,abs(b))
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('Input Sound')
sound(x,fs)

disp('Press a key to continue...');
pause

% Play the modified sound
disp('AM sound')
f2=figure(2)
set(f2,'Position',[swidth/2 pos],'MenuBar','none')
[b,f,t]=specgram(y,[],fs);
imagesc(t,f/1000,abs(b))
bigtitle('l');
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('AM Sound')
sound(y,fs)
type am2

function am2(fo,fm)
% AM modulation demo #2


% Parameters
%fo=880;	% Signal frequency (Hz)
%fm=2;	% Modulation frequency (Hz)
dur=1;	% Duration (s)
fs=10e3;	% Sampling frequency


% Make a time vector
tt=0:1/fs:dur;

% Make the signal
x=blp(3,fo,fo,dur,fs);

% Make the modulation signal
e=cos(2*pi*fm*tt);

% Make the AM signal
y=e.*x;

% Determine screen size
ssize = get(0,'ScreenSize');
swidth = ssize(3);
sheight = ssize(4);

% Need two figures to fit across top of screen; determine width of each figure
fwidth = swidth/2;
% Play the original
disp('Original sound...');
f1=figure(1)
pos=[sheight-(fwidth+20),fwidth,fwidth];
set(f1,'Position',[0 pos],'MenuBar','none')
[b,f,t]=specgram(x,[],fs);
imagesc(t,f/1000,abs(b))
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('Input Sound')
sound(x,fs)

disp('Press a key to continue...');
pause

% Play the modified sound
disp('AM sound')
f2=figure(2)
set(f2,'Position',[swidth/2 pos],'MenuBar','none')
[b,f,t]=specgram(y,[],fs);
imagesc(t,f/1000,abs(b))
bigtitle('l');
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('AM Sound')
sound(y,fs)
type am3

function am3(fm)
% AM modulation demo #3

% Load the soundfile
[x,fs,bits]=wavread('missedit');
%[x,fs,bits]=wavread('synthsolo');
%[x,fs,bits]=wavread('\ed\sounds\whistle');  %Roland XP-10 sound 079

% Make a time vector
tt=(0:length(x)-1)/fs;

% Modulate the signal
y=x.*cos(2*pi*fm*tt)';

% Determine screen size
ssize = get(0,'ScreenSize');
swidth = ssize(3);
sheight = ssize(4);

% Need two figures to fit across top of screen; determine width of each figure
fwidth = swidth/2;
% Play the original
disp('Original sound...');
f1=figure(1)
pos=[sheight-(fwidth+20),fwidth,fwidth];
set(f1,'Position',[0 pos],'MenuBar','none')
[b,f,t]=specgram(x,[],fs);
imagesc(t,f/1000,abs(b))
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('Input Sound')
sound(x,fs)

disp('Press a key to continue...');
pause

% Play the modified sound
disp('AM sound')
f2=figure(2)
set(f2,'Position',[swidth/2 pos],'MenuBar','none')
[b,f,t]=specgram(y,[],fs);
imagesc(t,f/1000,abs(b))
bigtitle('l');
axis('xy')
xlabel('time (s)')
ylabel('frequency (kHz)')
bigtitle('AM Sound')
sound(y,fs)
type ssb1

function ssb1(fc)
% EC481: SSB AM (S2001-02)
% see p. 243 of Stremler

% Fetch a sound clip
[x fs bits]=wavread('mkmydy.wav');
%[x fs bits]=wavread('flute.wav');
%[x fs bits]=wavread('s6.wav');
%[x fs bits]=wavread('missedit.wav');
x=x';

% Filter the sound clip to prevent aliasing
[b,a] = butter(10,[0.05 0.8]);
x=filter(b,a,x);

% Make sine and cosine carrier signals
tt=(0:length(x)-1)/fs;
%fc = 300;
c=cos(2*pi*fc*tt);
s=sin(2*pi*fc*tt);

% Phase shifted version of input (use Hilbert transform)
xh=imag(hilbert(x));

% Filter-based method using "Hilbert transformer"
% (output is delayed 15 time units... appears to be 1/2 the
%  length of the FIR filter, which is 30 below)
B=REMEZ(30,[.1 .9],[1 1],'Hilbert');
xhalt=filter(B,1,x);
xhalt=shift(xhalt,-15);
%xh=xhalt;

% Create the output
y = x.*c - xh.*s;

% Determine screen size
ssize = get(0,'ScreenSize');
swidth = ssize(3);
sheight = ssize(4);

% Need two figures to fit across top of screen; determine width of each figure
fwidth = swidth/2;

% Play the original
disp('Original sound...');
f1=figure(1)
pos=[sheight-(fwidth+20),fwidth,fwidth];
set(f1,'Position',[0 pos],'MenuBar','none')
calspec(x,1024,fs)
bigtitle('Input Sound')
sound(x,fs)

disp('Press a key to continue...');
pause

% Play the modified sound
disp('SSB-AM sound')
f2=figure(2)
set(f2,'Position',[swidth/2 pos],'MenuBar','none')
calspec(y,1024,fs)
bigtitle('SSB-AM Sound')
sound(y,fs)
exit