How to simulate a VU meter?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to simulate a VU meter?

Erik Blankinship-2
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!


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Gruenke, Matt

Have you seen the list of defined types?

 

    http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-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:[hidden email]]
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!

 


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Stefan Sauer
In reply to this post by Erik Blankinship-2
Am 13.11.2010 02:11, schrieb Erik Blankinship:

> 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.  


Does it have to be a VU Meter, or is the "level" element enough?

Stefan

>
> 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
>
>
>
> ------------------------------------------------------------------------------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Erik Blankinship-2

Does it have to be a VU Meter, or is the "level" element enough?


Level element?  Oh no, I have the creeping sense of having over-engineered.  What is the level element?

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Stefan Sauer
Am 13.11.2010 23:25, schrieb Erik Blankinship:
>
>     Does it have to be a VU Meter, or is the "level" element enough?
>
>
> Level element?  Oh no, I have the creeping sense of having over-engineered.
>  What is the level element?

Its part of gst-plugins-good: gst-inspect level tells you that it is a
"RMS/Peak/Decaying Peak Level messager for audio/raw"

Also gst-plugins-good/tests/examples/level/ has a small example of how to use it.

Stefan

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Marc Leeman
> Its part of gst-plugins-good: gst-inspect level tells you that it is a
> "RMS/Peak/Decaying Peak Level messager for audio/raw"
>
> Also gst-plugins-good/tests/examples/level/ has a small example of how to use it.

We used level to implement something like that. I believe my collegues
had to do some interpretation of the db values for the respective
scales; but AFAIK, level was at the core of it.

--
  greetz, marc
There is no royal road to geometry.
                -- Euclid
crichton 2.6.26 #1 PREEMPT Tue Jul 29 21:17:59 CDT 2008 GNU/Linux

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to simulate a VU meter?

Stefan Sauer
Am 14.11.2010 19:18, schrieb Marc Leeman:
>> Its part of gst-plugins-good: gst-inspect level tells you that it is a
>> "RMS/Peak/Decaying Peak Level messager for audio/raw"
>>
>> Also gst-plugins-good/tests/examples/level/ has a small example of how to use it.
>
> We used level to implement something like that. I believe my collegues
> had to do some interpretation of the db values for the respective
> scales; but AFAIK, level was at the core of it.
>
If there is something that we can improve on the level element, please let us know.

Stefan

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel