% lab 6 ex3 Oversampling
% Oversampling and noise shaping

k=2^7;
OSR = 0;
sim('lab6a')

% Sanity check, power = -3db @ 0.5 Hz
quant = quantOut3a;
sigspectrum(quantOut3a);
spec = sigspectrum(quantOut3a);
SNR = max(spec)/(sum(spec)-max(spec))
SNRdB = 10*log10(SNR)

OSR = 5;
sim('lab6a')
quantOS = quantOut3a;
specOS = sigspectrum(quantOut3a);
sigspectrum(quant, quantOS, 'linf')

SNROS = max(specOS)/(sum(specOS)-max(specOS))
SNROSdB = 10*log10(SNROS)

specOSIdealFiltered = specOS(1:513);
SNROS = max(specOSIdealFiltered)/(sum(specOSIdealFiltered)-max(specOSIdealFiltered))
SNROSdB = 10*log10(SNROS)

