FFT, hertz and stream metadata

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

FFT, hertz and stream metadata

Stefano Parmesan
Hello everybody,

I am new of gstreamer, so please forgive me if I say something wrong.

I need your help about performing some actions with gstreamer, I tried
reading tutorials and documentation but I didn't find the solution to a few
points, and I hoped you could help me figuring out some things.

I'm using gstreamer 0.10.35 on Mac OS, and developing a simple user
interface with python, QT and numpy (python-gstreamer, gobject, pyqt4).

I currently have two pipelines, one playing a simple note, using audiotestsrc,
and the other playing an mp3. I'm trying to visualize the spectrum of the
input signal (chosen by the user), so I connected to the "handoff" signal
of an identity element, and I'm playing around with the raw buffer received.
I have to draw the chart with frequencies in Hertz, and for doing so I'm 
using the FFT function of numpy. Numpy however returns unitless 
frequencies, so I need to know the stream bitrate, or the time duration 
of the raw buffer, to convert such frequencies in Hertz. Moreover, I need
to reconstruct the original buffer, so I need to know the stream sample
width in order to pack the raw bytes.

This said, here my questions:
- how do I know the bitrate, or the milliseconds corresponding to the input
buffer received by an identity element with its handoff event? I tried using
the pipeline clock, but it doesn't seem to fit my needs;
- how do I know the actual sample width of the stream? I tried using 
"audiosrc.get_pad("src").get_caps().get_structure(0)" but it gives me what 
I guess are the accepted formats of the pad? I need the actual sample 
width of the playing pipeline.

Thank you in advance for your time,
Best

--
Dott. Stefano Parmesan
PhD Student ~ University of Trento
<ahref Foundation - Trento - Italy
Tel: 0461-235794 ext. 5544


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: FFT, hertz and stream metadata

Tim-Philipp Müller-2
On Tue, 2012-05-29 at 09:09 +0200, Stefano Parmesan wrote:

Hi Stefano,

> I currently have two pipelines, one playing a simple note, using
> audiotestsrc, and the other playing an mp3. I'm trying to visualize
> the
> spectrum of the input signal (chosen by the user), so I connected to
> the "handoff" signal of an identity element, and I'm playing around
> with the raw buffer received. (..) I need to know the stream bitrate,
> or the time duration of the raw buffer, to convert such frequencies in
> Hertz. Moreover, I need to reconstruct the original buffer, so I need
> to know the stream sample width in order to pack the raw bytes.
>
> This said, here my questions:
> - how do I know the bitrate, or the milliseconds corresponding to the
> input
> buffer received by an identity element with its handoff event? I tried
> using
> the pipeline clock, but it doesn't seem to fit my needs;
> - how do I know the actual sample width of the stream? I tried using
> "audiosrc.get_pad("src").get_caps().get_structure(0)" but it gives
> me what
> I guess are the accepted formats of the pad? I need the actual sample
> width of the playing pipeline.

You should check the caps on the buffer itself. At least the very first
buffer should have caps set on it. Those caps should have a "rate"
field, and a "width" and "depth" field.

If you query audiosrc's caps, _get_negotiated_caps() might return the
caps actually used.

Cheers
 -Tim


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

FFT, hertz and stream metadata

Stefano Parmesan
In reply to this post by Stefano Parmesan
Hi Tim,

> You should check the caps on the buffer itself. At least the very first
> buffer should have caps set on it. Those caps should have a "rate"
> field, and a "width" and "depth" field.
>
> If you query audiosrc's caps, _get_negotiated_caps() might return the
> caps actually used.
>
> Cheers
>  -Tim

Thank you, that worked neatly. I didn't expect the buffer to have data
attached to it, but it actually makes perfectly sense.

Thanks, again!
Best

--
Dott. Stefano Parmesan
PhD Student ~ University of Trento
<ahref Foundation - Trento - Italy
Tel: 0461-235794 ext. 5544
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel