Click here to Skip to main content
15,891,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im building an audio editor, i got a progress bar on my recording window and i want that in there u can see when u speak, not basically see what u speak just to see the green thing coming out according to how loud u speak
Im not sure if i made myself clear?
thanks in advance guys
Posted

1 solution

If I understand you correctly...;)
To do such thing you should calculate the instant power. To do that you can take wave buffer and summerize the absolute values of the data. The buffer length you should choose according to the sampling frequency. For example, if the sampling frequency equal to 8000 Hz and you want to update progress bar every 1 second it is necessary to take 8000 points.

Code, using C# may look like that:

public static double getPowEst(short[] data)<br />
{<br />
double powEst = 0;<br />
			<br />
for(int t=0; t<code><
data.Length; t++)
{
powEst += Math.Abs(data[t]);
}

powEst = powEst/data.Length;

return powEst;
}
 
Share this answer
 
Comments
wizardzz 27-Apr-11 17:42pm    
Good answer, but I think he literally wants to use the progress bar as a volume of the input indicator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900