Help required with audio in MATLAB -
I am trying to write a .m file to remove energy facilities from an audio track but I'm having trouble Its implementation: RMS [F, FS, NB] = wavread ('three .wave') for calculation of
% formula; FrameWidth = 441; % 10 mms samples = length (x); NumFrames = (numSamples / 1); Energy (frames) = 0; For frame = 1: numFrames, startSample = (frame -1) * framewidth + 1; EndSample = startSample + frameWidth-1; Calculate frame energy for% I = startSample: end sample energy (frame) = energy (frame) + x (i) ^ 2; Finally closing
I run that file in MATLAB and get the following error:
??? Tried to reach x (2); Index out of bounds because error in numel (x) = 1 ==> 12 energy (frame) = energy (frame) + x (i) ^ 2;
Any help would be greatly appreciated.
using x
instead of f
, Because the actual signal is loaded from your .wav file f
. The variable x
was probably some other scalar in your workspace, which is why the error you were seeing was happening.
Some other improvements / improvements have been made in your code first, as you calculate numFrames
, it needs to be corrected second, energy < / Code> should be started as a vector of zero. Thirdly, you can reduce the loop internally to a line vector operation.
Here's how I will write your code ( Edit: Based on comments, I've updated the code to save some additional variables calculated in the loop ):
[y, fs, nb] = wavread ('three.Ww'); Load the signal into% # variable y framewidth = 441; % # 10 ms numbers sammel = length (y); Y # numFrames =% number of samples in the floor (numSamples / frameWidth); % # Y Number of complete frames in energy = zero (1, numFrames); % # Power to start with = zero (1, numframes); Start the initial index of #% end of the frame sample = zero (1, numframes); Start the end index of the frame for the #% frame: numFrames% # Start the loop over the frame Equal (frame) = (frame -1) * FrameWid + 1; % # Start index at the end of the frame (frame) = frame * framewidth; % # End of index of frame frame index = startSample (frame): end sample (frame); Frame samples of energy (frame) =% sum (y (frame index). # 2); Calculate the #% frame energy end
Comments
Post a Comment