如何计算音频帧的能量(fe)?

时间:2019-07-18 09:50:35

标签: java audio steganography

我想计算音频文件的能量,就我而言,我使用的是mp3扩展名文件,以及在日记中得到的公式

Formula energy of frame (fe) 信息如下: 文件:audio.length() 镜框宽度:441 N:帧数(其中文件长度/帧宽) i:在样本索引前加上

但是有些信息我不知道含义

这是matlab的源代码示例

[y, fs, nb] = wavread ('Audio.mp3'); % # Load the signal into variable y
frameWidth = 441; % # 10 msec
numSamples = length (y); % # Number of samples in y
numFrames = floor (numSamples / frameWidth); % # Number of full frames in y
energy = zeros (1, numFrames); % # Initialize energy

for frame = 1: numFrames% # Loop over frames
startSample = (frame-1) * frameWidth + 1; % # Starting index of frame
endSample = startSample + frameWidth-1; % # Ending index of frame
energy (frame) = sum (y (startSample: endSample). ^ 2); % # Calculate frame energy
 end

我已经用Java实现了,结果正在运行

numSamples = dataSet.size();//AudioSamples.lenght
float framewitdh = 441; 
double numFrame = floor(numSamples/framewitdh);
double energy = pow(1,numFrame);
double frames =1/numFrame;//1/N
double startSamples= (frames-1)*framewitdh+1;//i=(j-1).N+1
double endSamples =startSamples+framewitdh-1;
value =numSamples*Math.pow(startSamples/endSamples, 2);//X^2(i)
System.out.println("\nPower Of Energy\t:"+value);

the result is :
Number Frame    :32607
numframe        :73.0
Energy          :1.0
Frames          :0.0136986301369863
Start Samples   :-433.958904109589
End Samples     :6.041095890410986
Energy Of Frame :1.6825833706062135E8

我想问一下我使用的公式是否正确,程序是否正确?

0 个答案:

没有答案