%Program 11.1 Audio codec
%input: vector x of input signal
%output: vector out of output signal
%Example usage: out=simplecodec(cos((1:2^(12))*2*pi*256/2^(13)));
%               example signal is 1/2 sec. pure tone of frequency f = 256
function chords(tone,a,b)
Fs=2^(13);                                  % Fs=sampling rate
n=32;                                       % length of window
x = cos((1:2^(12))*2*pi*tone*a/Fs);
x = x+cos((1:2^(12))*2*pi*tone*b/Fs);
newx = audioComp2(x);
len = length(x);
nwx = floor(len/n);                          % number of length n windows in x
x = x(1:n*nwx);                               % cut x to integer number of n windows
xshort = x(n+1: end-n);                       % cut for the original signal
xshort = 0.3*xshort/max(abs(xshort));         % normalize signal to max amplitude = 0.3
x = 0.3*x/max(abs(x));
newx = 0.3*newx/max(abs(newx));

sound(x,Fs)
pause(1)
sound(newx,Fs)

audiowrite('chordin3.wav', x, Fs);
audiowrite('chordout3.wav', newx, Fs);

RMSE = sqrt(mean((xshort(:) - newx(:)).^2))  % Root Mean Squared Error

t=1000:1200;
plot(xshort(t),'k-');hold on;
plot(newx(t),'g-');hold off;
title('Original Chord Audio Versus Compressed Chord Audio')
xlabel('Number Of Data Points (1000 to 1200 in the actual audio matrix)') % x-axis label
legend('Original','Compressed')
Not enough input arguments.

Error in chords (line 9)
x = cos((1:2^(12))*2*pi*tone*a/Fs);