5-2 Volume (?喲?)

[english][all]

(請注意:中文版本並未隨英文版本同步更新!)

「音量」代表聲音的強度,又稱為「力度」、「強度」(Intensity)或「能量」(Energy),可由一個音框內的訊號震幅大小來類比,基本上兩種方式來計算:

  1. 每個音框的絕對值的總和:
    volume = Si=1n |si|
    其中 si 是一個音框中的第 i 個取樣點,而 n 則是每個音框的點數。這種方法的計算較簡單,只需要整數運算,適合用於低階平台(如微電腦等)。
  2. 每個音框的平方值的總和,再取以 10 為底對數值,再乘以10:
    volume = 10*log10(Si=1n si2)
    這種方法得到的值是以分貝(Decibels)為單位,是一個相對強度的值,比較符合人耳對於大小聲音的感覺。以下網頁有對分貝的詳細說明:
    http://www.phys.unsw.edu.au/~jw/dB.html (local copy)

音量具有下列特性:

以下顯示如何以兩種方法來計算音量:

Example 1: volume01.mwaveFile='sunday.wav'; frameSize=256; overlap=128; au=myAudioRead(waveFile); y=au.signal; fs=au.fs; fprintf('Length of %s is %g sec.\n', waveFile, length(y)/fs); frameMat=enframe(y, frameSize, overlap); frameNum=size(frameMat, 2); % Compute volume using method 1 volume1=zeros(frameNum, 1); for i=1:frameNum frame=frameMat(:,i); frame=frame-median(frame); % zero-justified volume1(i)=sum(abs(frame)); % method 1 end % Compute volume using method 2 volume2=zeros(frameNum, 1); for i=1:frameNum frame=frameMat(:,i); frame=frame-mean(frame); % zero-justified volume2(i)=10*log10(sum(frame.^2)+realmin); % method 2 end sampleTime=(1:length(y))/fs; frameTime=((0:frameNum-1)*(frameSize-overlap)+0.5*frameSize)/fs; subplot(3,1,1); plot(sampleTime, y); ylabel(waveFile); subplot(3,1,2); plot(frameTime, volume1, '.-'); ylabel('Volume (Abs. sum)'); subplot(3,1,3); plot(frameTime, volume2, '.-'); ylabel('Volume (Decibels)'); xlabel('Time (sec)');Length of sunday.wav is 0.98225 sec.

Since we need to compute the volume in many different applications, so we have created a function "frame2volume" (in SAP toolbox) which can compute the volume from a given frame. So we can use the function to simply the previous example:

Example 2: volume02.mwaveFile='sunday.wav'; frameSize=256; overlap=128; au=myAudioRead(waveFile); y=au.signal; fs=au.fs; fprintf('Length of %s is %g sec.\n', waveFile, length(y)/fs); frameMat=enframe(y, frameSize, overlap); frameNum=size(frameMat, 2); opt=frame2volume('defaultOpt'); opt.method='absSum'; volume1=frame2volume(frameMat, opt); opt.method='decibel'; volume2=frame2volume(frameMat, opt); sampleTime=(1:length(y))/fs; frameTime=frame2sampleIndex(1:frameNum, frameSize, overlap)/fs; subplot(3,1,1); plot(sampleTime, y); ylabel(waveFile); subplot(3,1,2); plot(frameTime, volume1, '.-'); ylabel('Volume (Abs. sum)'); subplot(3,1,3); plot(frameTime, volume2, '.-'); ylabel('Volume (Decibels)'); xlabel('Time (sec)');Length of sunday.wav is 0.98225 sec.

To go one step further, we can use the function "wave2volume" (in SAP toolbox) which computes volume from a given wave file:

Example 3: volume03.mwaveFile='sunday.wav'; au=myAudioRead(waveFile); opt=wave2volume('defaultOpt'); opt.frameSize=256; opt.overlap=128; time=(1:length(au.signal))/au.fs; subplot(3,1,1); plot(time, au.signal); xlabel('Time (sec)'); ylabel('Amplitude'); title(waveFile); subplot(3,1,2); opt1=opt; opt1.frame2volumeOpt.method='absSum'; vollume1=wave2volume(au, opt1, 1); ylabel(opt1.frame2volumeOpt.method); subplot(3,1,3); opt2=opt; opt2.frame2volumeOpt.method='decibel'; volume2=wave2volume(au, opt2, 1); ylabel(opt2.frame2volumeOpt.method);

基本上我們使用音量來表示聲音的強弱,但是前述兩種計算音量的方法,只是用數學的公式來逼近人耳的感覺,和人耳的感覺有時候會有相當大的落差,為了區分,我們使用「主觀音量」來表示人耳所聽到的音量大小。例如,人耳對於同樣振福但不同頻率的聲音,所產生的主觀音量就會非常不一樣。若把以人耳為測試主體的「等主觀音量曲線」(Curves of Equal Loudness)畫出來,就可以得到下面這一張圖:

Fletcher-Munson curves of equal loudness
Curves of equal loudness determined experimentally by Fletcher, H. and Munson, W.A. (1933) J.Acoust.Soc.Am. 6:59.

上面這一張圖,也代表人耳對於不同頻率的聲音的靈敏程度,這也就是人耳的頻率響應(Frequency Response)。如果你要測試你自己的耳朵的頻率響應,可以到這個網頁「Equal Loudness Tester」試試看:

http://www.phys.unsw.edu.au/~jw/hearing.html (local copy)

主觀音量除了和頻率有關外,也和音訊的內容(音色或是基本週期的波形)有關,例如,我們可以盡量使用相同的主觀音量來錄下幾個發音比較單純的母音(ㄚ、ㄧ、ㄨ、ㄝ、ㄛ、ㄜ、ㄩ),然後再用音量公式來算它們的音量,就應該可以看出來音量公式和發音嘴型的關係。

Example 4: volume04.mwaveFile='aeiou.wav'; au=myAudioRead(waveFile); opt=wave2volume('defaultOpt'); opt.frameSize=512; opt.overlap=0; time=(1:length(au.signal))/au.fs; subplot(3,1,1); plot(time, au.signal); xlabel('Time (sec)'); ylabel('Amplitude'); title(waveFile); subplot(3,1,2); opt1=opt; opt1.frame2volumeOpt.method='absSum'; vollume1=wave2volume(au, opt1, 1); ylabel(opt1.frame2volumeOpt.method); subplot(3,1,3); opt2=opt; opt2.frame2volumeOpt.method='decibel'; volume2=wave2volume(au, opt2, 1); ylabel(opt2.frame2volumeOpt.method);

主觀音量容易受到頻率和音色的影響,因此我們在進行語音或歌聲合成時,常常根據聲音的頻率和內容來對音訊的振福進行校正,以免造成主觀音量忽大忽小的情況。


Audio Signal Processing and Recognition (音訊處理與辨識)