Quantization of audio signal.docx

上传人:b****5 文档编号:11631495 上传时间:2023-03-29 格式:DOCX 页数:13 大小:118.25KB
下载 相关 举报
Quantization of audio signal.docx_第1页
第1页 / 共13页
Quantization of audio signal.docx_第2页
第2页 / 共13页
Quantization of audio signal.docx_第3页
第3页 / 共13页
Quantization of audio signal.docx_第4页
第4页 / 共13页
Quantization of audio signal.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

Quantization of audio signal.docx

《Quantization of audio signal.docx》由会员分享,可在线阅读,更多相关《Quantization of audio signal.docx(13页珍藏版)》请在冰豆网上搜索。

Quantization of audio signal.docx

Quantizationofaudiosignal

Quantizationofaudiosignal

Ximengzhao

Abstract:

ThispaperismainlyfocusingontwobasiccharacteristicsofDSPthataresamplingandquantization.QuantizationrepresentsakeypartintheDSPprocess.Quantizationisalsoessentiallythemappingofananalogvalueintoacorrespondingbinarysequence.Quantizationistheprocessofmappingasetofcontinuousamplitudes(infinitenumberoflevels)intoafinitenumberofpossiblevalues.Whilesamplingrepresentsthetimeofcapturingasignal,quantizationistheamplitudecomponentofsampling.Thesamplesarequantizedbyananalogtodigitalconverterinordertoberepresentedindigitalform.Weloadaudiosignalafterdoingdown-sampledandQuantizethesampledsignalusing8bitand10bit.Afterthat,weproceedtocalculatequantizederrorbyusingthefollowingformulaandapplyamethodcalledVQ(vectorquantization)todealwiththesampledaudiosignal.

Introduction:

Thereiserrorinvolvedwithquantizationduetotheapproximationofthelevelbeingquantized.

Thedifferencebetweenthemisquantizationerror,thedefinedas:

Quantizationerror=Actual-DigitalRepresentation.Wemaythinkofthequantizedsignalasanoisyversionoftheoriginalsignalwithoutquantificationtowhichanoisecomponenthasbeenadded.

Thepurposeofproject:

•TocharacterizethefrequencycontentofanaudiosignalbycalculatingtheFouriertransform.

•Tosimulatesamplingaffectsbydown-samplingtheoriginalbandwidthataratioof1/8.

•DeterminetheMagnitudeandphaseoftheFouriertransformsofthesampledsignal.

•Quantizethesampledsignalusingtwodifferentresolutions:

8bitand10bit.

•ReconstructandanalyzethequantizedsignalfromitsfrequencycontentbycalculatingtheinverseFouriertransform.

Analyzetheerrorsoccurredduringsamplingandquantizationandcomparethetworesolutionsused.

Quantizederror=

•usetrainingalgorithmforvectorquantization

Experimentalprocess:

Figure

(1)showsfourimages,whichareoriginalaudiosignalwaveformattimedomain,frequencydomain,itsrealfrequencyandphase.

Figure

(1)

Figure

(2)showsfourimagesafterdown-sampling

Figure

(2)

Figure(3)showsfourimagesofreconstructingthesampledsignalusing8bit

Figure(3)

Figure(4)showsfourimagesofreconstructingthesampledsignalusing10bit

Figure(4)

Figure(5)showstwoImagesoferroranalysisfor8bitand10bit

Figure(5)

wegettheresult:

•Quantizedby8bit.Thequantizederroris0.00378,whichisapproximatelytothesamplingprecision.(1/2e-8=0.0039)

•Quantizedby10bit.Thequantizederroris9.7599e-004,whichisapproximatelytothesamplingprecision.(1/2e-10=9.7656e-004)

•Byreconstructingthetwosampledsignalsandcomparingtheirvariances,wecanseethatmorebitsweused,moreaccuracyweget.

Here,wegivethedefinitionofVQ,amethodforquantization.Thenumberofscalardatasetstoformavector,andthengivethewholequantizationinthewholevectorspacethatcompressthedatawithoutlosingmuchinformation.Encodedintheimagevectorquantizationistheadvancedmethodthatapplyingintheimageandspeechsignalcodingtechniques.

Theprincipleoftrainingalgorithmforvectorquantizationis:

•Pickasamplepointatrandom

•Movethenearestquantizationvectorcentroidtowardsthissamplepoint,byasmallfractionofthedistance

•Eachvectoriscomparedwithacollectionofrepresentativecodevectors

•Usingaminimumdistortionruletochoosebestcodevector

Thefollowingtwoimagesshowthattherelationshipbetweenerrorandbothdimensionsizeandcodebooksize:

Fromtheabovetwoimages,wecanseethattheimageontheleftreflectstherelationshipbetweenerrorandcodebooksize.Ontheotherhand,theimageontherightreflectstherelationshipbetweenerroranddimensionsize.Tosumup,withcodebooksizeincreasedanddimensionsizefixed,theerrordecreases.Onthecontrary,withdimensionsizeincreasesandcodebooksizefixed,theerroralsoturnstohigher.

Wecanseemoreclearlyfromthefollowingimage,whichreflectsdifferentdimensionsizesinoneCoordinatesystemwithcodebooksizeincreasesandanalyzetheerror.

Thehorizontalordinateofthisimageiscodebooksizeandtheverticalordinateofthisimageiserror.Threedifferentcolorlinesshowsthedimensionsize,whichis4,8,16.

Conclusion:

1:

Intheprocessofquantization,byreconstructingthetwosampledsignalsandcomparingtheirvariances,wecanseethatmorebitsweused,moreaccuracyweget.

2:

Intheprocessofvectorquantization,wedrawtheconclusionthatwithcodebooksizeincreasedanddimensionsizefixed,theerrordecreases.Onthecontrary,withdimensionsizeincreasesandcodebooksizefixed,theerroralsoturnstohigher.

References:

[1]:

Dr.BrainVijay”quantizationdspslide”.

[2]:

AlanV.OppenheimRonaldW.Schafer”Discrete-TimeSignalProcessing”ThirdEdition,chapter4.8.

[3]:

[4]:

http:

//en.wikipedia.org/wiki/Vector_quantization

 

MatlabCode:

%Project2

clear

loadwav

wavplay(wav,fs);

%%

%originalsignalanalysis

figure

(1)

L=length(wav);

subplot(221)%waveformtimedomain

plot((1:

L)/L,wav);

xlabel('time(s)')

ylabel('Amplitude(v)')

gridon

axis([0,1,-0.1,0.15])

subplot(222)%frequencydomain

yf=fft(wav);

plot(yf);

xlabel('Realpart')

ylabel('Imaginarypart')

gridon

subplot(223)%realfrequency

MagY=abs(yf);

%MagY=20*log10(MagY/max(MagY));

AngY=angle(yf);

plot((1:

L)/L*fs,MagY)

xlabel('Frequency(Hz)')

ylabel('Amplitude')

gridon

axis([0,L,040])

subplot(224)%phase

plot(AngY);

xlabel('Samples')

ylabel('Phase')

gridon

%%

%downsamplinganalysis

downS=8;

wav1=wav(1:

downS:

L,:

);

L1=length(wav1);

yf1=fft(wav1);

MagY1=abs(yf1);

angY1=angle(yf1);%MagY=20*log10(MagY/max(MagY));

figure

(2)

subplot(221)

plot((1:

L1)/L1,wav1);

xlabel('Time(s)')

ylabel('Amplitude(V)')

gridon

subplot(222)%frequencydomain

plot(yf1);

xlabel('Realpart')

ylabel('Imaginarypart')

gridon

subplot(223)%realfrequency

plot((1:

L1)/L1*fs,MagY1)

xlabel('Frequency(Hz)')

ylabel('Amplitude')

gridon

axis([0,L,05])

subplot(224)%phase

plot(angY1);

xlabel('Samples')

ylabel('Phase')

gridon

%%

%quantization

na1=10;%quantizeresolution8bits

na2=8;

wav8=quant(wav1,na2);

wav10=quant(wav1,na1);

yf8=fft(wav8);

yf10=fft(wav10);

MagY8=abs(yf8);

Ang8=angle(yf8);

MagY10=abs(yf10);

Ang10=angle(yf10);

figure(3)

subplot(221)

plot((1:

L1)/L1,wav8);

xlabel('Time(s)')

ylabel('Amplitude(V)')

gridon

subplot(222)%frequencydomain

plot(yf8);

xlabel('Realpart')

ylabel('Imaginarypart')

gridon

subplot(223)%realfrequency

plot((1:

L1)/L1*fs,MagY8)

xlabel('Frequency(Hz)')

ylabel('Amplitude')

gridon

axis([0,L,05])

subplot(224)%phase

plot(Ang8);

xlabel('Samples')

ylabel('Phase')

gridon

%%

figure(4)

subplot(221)

plot((1:

L1)/L1,wav10);

xlabel('Time(s)')

ylabel('Amplitude(V)')

gridon

subplot(222)%frequencydomain

plot(yf10);

xlabel('Realpart')

ylabel('Imaginarypart')

gridon

subplot(223)%realfrequency

plot((1:

L1)/L1*fs,MagY10)

xlabel('Frequency(Hz)')

ylabel('Amplitude')

gridon

axis([0,L,05])

subplot(224)%phase

plot(Ang10);

xlabel('Samples')

ylabel('Phase')

gridon

%%

%erroranalysis

yf8=[yf8;zeros((downS-1)*length(yf8),1)];%upsampling

yf10=[yf10;zeros((downS-1)*length(yf10),1)];

wav8=ifft(yf8);

wav10=ifft(yf10);

error8=(real(wav8)-wav).^2;

er8=sum(error8)

error10=(real(wav10)-wav).^2;

er10=sum(error10)

figure(5)

subplot(211)

plot(1:

L,error8)

xlabel('Samples')

ylabel('Meansquareerror')

title('Quantizedby8bit')

subplot(212)

plot(1:

L,error10)

xlabel('Samples')

ylabel('Meansquareerror')

title('Quantizedby10bit')

%%

function[disdistortion]=VQ(dimension,codebook_size)

loadwav

Y=wav;

a_seq=downsample(Y(:

1)',8);

%dimension=2^ii

a_seq=[a_seqzeros(1,ceil(length(a_seq)/dimension)*dimension-length(a_seq))];

%codebook_size=2^4;

%codebook_size=2^ii;

tolerance=10^(-8);

m=round(length(a_seq)/dimension);

if(m*dimension-length(a_seq)<0)

error('')

end

initial=a_seq(1:

dimension*codebook_size);

initialcodebook=(reshape(initial,dimension,codebook_size))';

updated_codebook=initialcodebook;

newdistortion=0;

distortion=0;

fori=1:

m;

a_seq_block=a_seq((i-1)*dimension+1:

i*dimension);

training_matrix(i,:

)=a_seq_block;

distortion_block=[];

forj=1:

codebook_size;

distort=sum((a_seq_block-updated_codebook(j,:

)).^2);

distortion_block=[distortion_blockdistort];

end

[distortion_min,ind]=min(distortion_block);

newdistortion=newdistortion+distortion_min;

index(i)=ind;

end

forl=1:

codebook_size;

partition=(index==l);

ifsum(partition)>0

updated_codebook(l,:

)=partition*training_matrix/sum(partition);

end

end

newdistortion=newdistortion/m;

while(abs(distortion-newdistortion)/newdistortion>tolerance)

distortion=newdistortion;

newdistortion=0;

fori=1:

m;

a_seq_block=a_seq((i-1)*dimension+1:

i*dimension);

training_matrix(i,:

)=a_seq_block;

distortion_block=[];

forj=1:

codebook_size;

distort=sum((a_seq_block-updated_codebook(j,:

)).^2);

distortion_block=[distortion_blockdistort];

end

[distortion_min,ind]=min(distortion_block);

newdistortion=newdistortion+distortion_min;

index(i)=ind;

end

forl=1:

codebook_size;

partition=(index==l);

ifsum(partition)>0

updated_codebook(l,:

)=partition*training_matrix/sum(partition);

end

end

newdistortion=newdistortion/m;

end

codebook=updated_codebook;

disdistortion=newdistortion/dimension;

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 工学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1