clear all
clear sound;
%x=cos((1:T*Fs)*2*pi*64*f/Fs);         % test signal
%x=x+cos((1:4096)*2*pi*64*5/Fs);
%T = 0.5, f = 64,
rmse1 = zeros(1,10);
rmse2 = zeros(1,10);
for k = 1:10

    rmsenum1 = 0;
    rmsenum2 = 0;

    [x,Fs] =audioread('23 Lost... Broken Shards.wav'); %singal for frequencies of f*m
    x = x(1:length(x),1);

        %sound(x,frequency,n)
    x2 = simplecodec5nowindow(x,k); %no windowing
    x3 = simplecodec5window(x,k); %windowing
    x1 = x(33:length(x2)+32); %trimmed down signal

    error1 = (x1 - x2).^2; %difference squred
    error2 = (x1 - x3).^2;

    for i = 1:length(x2)
        rmsenum1 = rmsenum1+error1(i); %numeric rmse
        rmsenum2 = rmsenum2+error2(i);
    end
    rmse1(k) = sqrt(rmsenum1/length(x2)); %rmse for each frequency
    rmse2(k) = sqrt(rmsenum2/length(x2));
    k
end

audiowrite('Lostnowidnow.wav',x2,44100)
audiowrite('Lostwindow.wav',x3,44100)
rmse1
rmse2
