% this is a module that will accept the file name of a speech data file, 
% and noise variance (observation), and store the corrupted signal 
% 
% Author: Sanjay Patil Nov 02, 2005. Wednesday. 1146 hours central
%

% ??????????????????????????????????????????????????????????????????
% I do not have an idea how to input a file name as an argument to a .m
% file and then load the data from it
% ??????????????????????????????????????????????????????????????????
%


% this will the command line argument for the signal generation afterwards
%
% function signal_generator_sine(fileName, R)

% if you are having a function all, do not free memory allocated to the 
% variables
%
% initial set-up
%
% clear all;
close all;
clc;

% details of the program
%
disp('The program to corrupt the input signal (eg. speech signal) ');
disp('Input Parameters (two parameters) :');
disp('1. filename 2. Observation noise variance');
disp('Output parameters (one files) :');
disp('1. obsn file (obsn_speech.raw)');

disp(' ');

% % uncomment afterwards
% %
% disp('displaying all the values :');
%
% disp(['the amplitude                  : ', num2str(amplitude)]);
% disp(['the frequency  [Hz]            : ', num2str(freq)]);
% disp(['the Observation noise variance : ', num2str(R)]);
%
%
% disp('displayed all the values :');

% % accepting values from command window
% %
% fileName = input('Enter file name           : ', 's');
% R = input ('Enter noise variance      : ');

% load the file which is to be corrupted by known noise variance
%
load ;
R

%     % % assuming sampling frequency to be 8000
%     % % example values :
%     % amplitude = 1;
%     % R = 0.05;
%     % freq = 100;
%
%     % angle should be given in radians
%     %
%     for i = 1:100
%         x(i)= cos(2 * pi * freq / 8000 * i);
%         z(i)= x(i) + normrnd(0, sqrt(R)); %Adjust the noise variance here
%     end;
%
%     save ('clean_sine.raw', 'x', '-ascii', '-double');
%     save ('obsn_sine.raw', 'z', '-ascii', '-double');
%
%     figure;
%     plot(x, 'b');
%     hold on;
%     plot(z, 'm');
%     title(['Determinstic Signal : ', num2str(amplitude),...
%         ' cos(2*{\pi}*', num2str(freq), '/', num2str(8000), ') + '...
%         , 'noise {\sigma} =', num2str(R)]);
%     legend('clean signal', 'observation signal');
