% ----------------------------------------
% Matlab code to generate audio SNR examples
% Needs the file 09a07Na.wav
% ECE230X D-term 2007
% D. Richard Brown 23-Mar-2007
% ----------------------------------------

% Sample voice file
[x,fs]=wavread('09a07Na.wav');
L=length(x);

% Normalize the voice file to have unit power and make it a column
x=x(:)/std(x);

s = input('Desired SNR(dB) (hit enter to quit): ');
while ~isempty(s),
    noise=10^(-s/20)*randn(L,1);
    soundsc(x+noise,fs);
    s = input('Desired SNR(dB) (hit enter to quit): ');
end
