[gst-devel] How to simulate a VU meter?

Gruenke, Matt mgruenke at Tycoint.com
Sat Nov 13 05:29:40 CET 2010


Have you seen the list of defined types?

 

 
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/sectio
n-types-definitions.html

 

 

If the type is 'audio/x-raw-int', then look at the (int) depth property.
The maximum abs value should be 2^(depth - (int) signed).  Don't forget
to byteswap, depending on the endianness property.

 

If the type is 'audio/x-raw-float', then it doesn't say, but one would
hope that most things are normalized to [-1.0,1.0] or [-0.5, 0.5].  You
could hope the user has some idea and just expose a property.  I'd
probably start with a reasonable guess, like one of those I just
mentioned, but then maintain a running max, in case the signal is not
normalized.

 

BTW, VU meters often use an exponential decay function.  You could do
something like:

 

    for s in fromstring( buffer, 'int16' ):

        v = alpha * v + (1-apha) * abs( s )

 

And then adjust alpha in the range [0, 1] to taste.

 

 

Matt

 

________________________________

From: Erik Blankinship [mailto:jedierikb at gmail.com] 
Sent: Friday, November 12, 2010 19:11
To: Discussion of the development of GStreamer
Subject: [gst-devel] How to simulate a VU meter?

 

What is the best way to simulate a VU meter [1] with gstreamer?  (
Preferably, I would get value readings as a percent... unless  I make it
go to 11 :-) )

 

I am currently grabbing buffers on their way to a fake sink, and then
using numpy in python extracting an average value out of the buffer:

 

	temp_ay = np.asarray( fromstring( buffer, 'int16'  ) )

	v = 0

	for b in temp_ay:

	  v = v + abs(b)

	avg = v / len(temp_ay)

 

 

Using this approach, I don't know what the upper bound is... I just get
some value which appears to go up and down as I make noise.  

 

This works, but surely there is: (1) a better way; (2) some way to know
what the upper bound is so a percentage can be calculated?

 

Thanks!

 

[1] http://en.wikipedia.org/wiki/VU_meter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20101112/81ea7763/attachment.htm>


More information about the gstreamer-devel mailing list