%%%%%%%%%%%%%%%%%%% CLOCKS RECONSTRUCTION %%%%%%%%%%%%%%%%%%%%%%%%%%
fs = 4410;
PATH = "optical_signals\clocks.csv"; 
optical_signal = csvread(PATH); %signal captured
%% trim the signal
figure; CreateSpec(optical_signal,fs); title('clocks Raw signal');
csvwrite("clocks_reconstructions\CLOCKS_raw_signal.csv",optical_signal);
audiowrite('clocks_reconstructions\CLOCKS_raw_signal.wav',optical_signal,fs);
%% bandstops
optical_signal = multiple_bandstops(optical_signal,fs);
optical_signal = optical_signal(fs/2:end-fs/2);
figure; CreateSpec(optical_signal,fs); title('clocks Bandstop signal');
csvwrite("clocks_reconstructions\CLOCKS_bandstop_signal.csv",optical_signal);
audiowrite('clocks_reconstructions\CLOCKS_bandstop_signal.wav',optical_signal,fs);
%% normalize
optical_signal = Normalize_signal(optical_signal);
figure; CreateSpec(optical_signal,fs); title('clocks Normalized signal');
csvwrite("clocks_reconstructions\CLOCKS_normalized_signal.csv",optical_signal);
audiowrite('clocks_reconstructions\CLOCKS_normalized_signal.wav',optical_signal,fs);
%% noise reduction
optical_signal = v_specsub(optical_signal,fs);
figure; CreateSpec(optical_signal,fs); title('clocks Noise Reduction signal');
csvwrite("clocks_reconstructions\CLOCKS_noise_reduction_signal.csv",optical_signal);
audiowrite('clocks_reconstructions\CLOCKS_noise_reduction_signal.wav',optical_signal,fs);
%% equalizer from xml file through audacity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% LET IT BE RECONSTRUCTION %%%%%%%%%%%%%%%%%%%%%%%%%%
PATH = "optical_signals\let.csv"; 
optical_signal = csvread(PATH); %signal captured
%% trim the signal
figure; CreateSpec(optical_signal,fs); title('LET IT BE Raw signal');
csvwrite("let_it_be_reconstructions\LET_IT_BE_raw_signal.csv",optical_signal);
audiowrite('let_it_be_reconstructions\LET_IT_BE_raw_signal.wav',optical_signal,fs);
%% bandstops
optical_signal = multiple_bandstops(optical_signal,fs);
optical_signal = optical_signal(fs/2:end-fs/2);
figure; CreateSpec(optical_signal,fs); title('LET IT BE Bandstop signal');
csvwrite("let_it_be_reconstructions\LET_IT_BE_bandstop_signal.csv",optical_signal);
audiowrite('let_it_be_reconstructions\LET_IT_BE_bandstop_signal.wav',optical_signal,fs);
%% normalization
optical_signal = Normalize_signal(optical_signal);
figure; CreateSpec(optical_signal,fs); title('LET IT BE Normalized signal');
csvwrite("let_it_be_reconstructions\LET_IT_BE_normalized_signal.csv",optical_signal);
audiowrite('let_it_be_reconstructions\LET_IT_BE_normalized_signal.wav',optical_signal,fs);
%% noise reduction
optical_signal = v_specsub(optical_signal,fs);
figure; CreateSpec(optical_signal,fs); title('LET IT BE Noise Reduction signal');
csvwrite("let_it_be_reconstructions\LET_IT_BE_noise_reduction_signal.csv",optical_signal);
audiowrite('let_it_be_reconstructions\LET_IT_BE_noise_reduction_signal.wav',optical_signal,fs);
%% equalizer from xml file through audacity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% SENTENCE RECONSTRUCTION %%%%%%%%%%%%%%%%%%%%%%%%%%
PATH = "optical_signals\america.csv"; 
optical_signal = csvread(PATH); %signal captured
%% trim the signal
figure; CreateSpec(optical_signal,fs); title('Raw signal');
csvwrite("sentence_reconstructions\SENTENCE_raw_signal.csv",optical_signal);
audiowrite('sentence_reconstructions\SENTENCE_raw_signal.wav',optical_signal,fs);
%% bandstops
optical_signal = multiple_bandstops(optical_signal,fs);
optical_signal = optical_signal(fs/2:end-fs/2);
figure; CreateSpec(optical_signal,fs); title('Sentence Bandstop signal');
csvwrite("sentence_reconstructions\SENTENCE_bandstop_signal.csv",optical_signal);
audiowrite('sentence_reconstructions\SENTENCE_bandstop_signal.wav',optical_signal,fs);
%% normalize
optical_signal = Normalize_signal(optical_signal);
figure; CreateSpec(optical_signal,fs); title('Sentence Normalized signal');
csvwrite("sentence_reconstructions\SENTENCE_normalized_signal.csv",optical_signal);
audiowrite('sentence_reconstructions\SENTENCE_normalized_signal.wav',optical_signal,fs);
%% noise reduction
optical_signal = v_specsub(optical_signal,fs);
figure; CreateSpec(optical_signal,fs); title('Sentence Noise Reduction signal');
csvwrite("sentence_reconstructions\SENTENCE_noise_reduction_signal.csv",optical_signal);
audiowrite('sentence_reconstructions\SENTENCE_noise_reduction_signal.wav',optical_signal,fs);
%% equalizer from xml file through audacity