Question: code given % % Quantization _ SQNR - Histogram of Sounds % Evaluate the SQNR and sound volume distributions clear; close all; clc; isOctave =
code given QuantizationSQNR Histogram of Sounds
Evaluate the SQNR and sound volume distributions
clear; close all; clc;
isOctave existOCTAVEVERSION', 'builtin' ~; if using Octave
if isOctave Fsize ; else Fsize ; end;
nbits ; mu ;
nbins ;
yfs audioreadRockGuitarwav';
yfs audioreadhomecgrecoMusicBachBachPreludeinEwav';
ymax maxabsy:;
ymax maxabsy:;
Scale signal
y: y:ymax;
y: y:ymax;
Signal power
ndat lengthy:;
py sumy:ndat;
pydB powdbpy;
py sumy:ndat;
pydB powdbpy;
Histograms for each channel
if isOctave
nh histy:nbins;
nsum sumn;
n nnsum;
nh histy:nbins;
nsum sumn;
n nnsum;
else
h histogramy:nbins;
h histogramy:nbins;
nh histy:nbins; Not tested in Matlab
nsum sumn;
n nnsum;
nh histy:nbins;
nsum sumn;
n nnsum;
end
Display Histograms
figureposition
subplot; barhn;grid;
xlabelSignal Magnitude';ylabelCount Frequency';
titleChannel PavgnumstrpydB dB;
setgca'Fontsize',Fsize
subplot;barhn;grid;
xlabelSignal Magnitude';ylabelCount Frequency';
titleChannel PavgnumstrpydB dB;
setgca'Fontsize',Fsize
QuantizationSQNR
SQNRuni logpynbits;
SQNRcomp loglogmunbits;
Instantaneous Power Histogram
ycomb y: y:;
nhpow histycombnbins;
nsum sumn;
n nnsum;
figureposition
subplot;barhpown;grid;
xlabelInstantaneous Signal Power W;ylabelCount Frequency';
titleAverage Instantaneous Power Channels and ;
setgca'Fontsize',Fsize
hpowdB powdbhpow;
subplot;barhpowdBn;grid;
xlabelInstantaneous Signal Power dB;ylabelCount Frequency';
titleAverage Instantaneous Power Channels and ;
setgca'Fontsize',Fsize
SQNR
sqnr nbits loghpow;
figure
barsqnrn;grid;
xl xlim;
xval xl xl xl;
xlabelSQNR dB;ylabelCount Frequency';
titleInstantaneous SQNR uniform;
textxvalSQNRuniformnumstrSQNRuni'Fontsize',Fsize;
textxvalSQNRcompressednumstrSQNRcomp'Fontsize',Fsize;
textxvalnbits intstrnbitsmu intstrmu'Fontsize',Fsize;
setgca'Fontsize',Fsize
mu Law Compression
vmaxabsy:;
xdmuzeroslengthy:; set up storage for decimated signal
xdmu:compandy:muvmucompressor;
xdmu:compandy:muvmucompressor;
nhhistxdmu:nbins;
nsum sumn;
n nnsum;
nhhistxdmu:nbins;
nsum sumn;
n nnsum;
figureposition
subplot;barhn;grid;
xlabelCompressed Signal Magnitude'
ylabelCount Frequency'
titlemu Law Distribution. Channel mu intstrmu
setgca'Fontsize',Fsize
subplot;barhn;grid;
xlabelCompressed Signal Magnitude'
ylabelCount Frequency'
titlemu Law Distribution, Channel mu intstrmu
setgca'Fontsize',Fsize
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
