-2

The frame rate of a given video is 24fps. For audio sampling rate equal to 44.1Khz and 22050 (Fs/2) samples of audio are present in every second of audio. i.e. for every video frame, 22050/24≈919 audio samples are present.

This is the matlab code I have don till. Is this the way we plot the audio samples I am talking about ??

[y f] = wavread('test.wav');
t = 0:1/f:(length(y)-1)/f;
plot(t, y), grid on;

Should I be using Audio Processing libraries for c++ for this purpose ? I will be using VS 2010.

Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130
  • 2
    You haven't actually stated what you are trying to *achieve* here. What do you mean by "audio levels" ? Peak ? RMS ? Instantaneous ? Short-term ? Long-term ? Do you just want to display the data or do you want to perform additional processing ? – Paul R Dec 26 '12 at 13:11

1 Answers1

0

I wanted to find the all the samples that had value above the mean sample value of the audio file. Here is the code.

function AudioLevels(a, fps)
clc
format long g
[y f nbits] = wavread(a);
len = length(y);
t = 0:1/f:(length(y)-1)/f;
plot(t, abs(y(:,1))), grid on;
meanAudioLevel = sum(abs(y(:,1)))/length(y);
samplesPerFrame = f/fps;
noOfFrames = ceil(double(length(y)/samplesPerFrame));

array1= [;];
%---------------------------------------------------------------------
for i = 1 : 1 : noOfFrames-1;
for j = 1+(samplesPerFrame*(i-1)) : 1 : (samplesPerFrame*i)
    array = [;];
    array = [array ; abs(y(j,1))];
end
if (sum(array) >= meanAudioLevel)
    array1 = [array1 ; sum(array)];
    fprintf (fileIO, '%d\t%f\r\n', i ,sum(array));
end
end
%---------------------------------------------------------------------
for j = length(y) - mod (length(y), samplesPerFrame)+1 : 1 : length(y)
array = [;];
array = [array ; abs(y(j,1))];
end
if (sum(array) >= meanAudioLevel)
    array1 = [array1 ; sum(array)];
end
%---------------------------------------------------------------------
array1
Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130