Re: [LAD] python, gtk, gstreamer

From: Patrick Shirkey <pshirkey@email-addr-hidden>
Date: Thu Feb 28 2013 - 05:09:21 EET

On Thu, February 28, 2013 1:37 pm, drew Roberts wrote:
> On Wednesday 27 February 2013 18:51:34 Patrick Shirkey wrote:
>> On Thu, February 28, 2013 8:14 am, drew Roberts wrote:
>> > Ignorant here. Trying to scrounge around and make something work for a
>> > demo
>> > purpose.
>> >
>> > In python I am trying to build this pipeline:
>> >
>> > pipeline_txt = (
>> > 'jackaudiosrc ! '
>> > 'level name=level interval=1000000000 !'
>> > 'jackaudiosink')
>> >
>> > pipeline = gst.parse_launch(pipeline_txt)
>> >
>> > I have been trying that a number of ways.
>> >
>> > So, I basically watch the bus for level info.
>> >
>> > In a subroutine, I can print the peak info to the terminal.
>> >
>> > I can't seem to figure out how to pass this info back to the rest of
>> the
>> > program so that I can hook it up to a graphical meter.
>>
>> Add a call to the callback for the meter to set the meter value from the
>> subroutine?
>>
>> > Cna anyone point me to some simple code doing something like this?
>> Give
>> > me some clues that might help someone who seems to be being very dense
>> > for days
>> > now?
>>
>> Sounds like you just need to connect the meter to the subroutine but
>> it's
>> a bit had to say without a bit more code to demonstrate how you are
>> setting up the meter.
>>
>> A few questions...
>>
>> Is the meter a class of it's own or just a widget in a draw routine?
>>
>> Do you have a "set_meter_value" type of function or are you just calling
>> directly to the meter widget's value?
>>
>> What UI toolkit is the meter using?
>
> Right now, I have not even tried to make a meter, I just want to get the
> peak
> value out of the subroutine and print it from outside. I can print it from
> the inside but can't even figure out how to get it out.
>
> One sample I started working with (there are others but this is one) can
> be
> found here:
>
> http://stackoverflow.com/questions/9344888/getting-max-amplitude-for-an-audio-file-per-second
>
> In the def show_peak(bus, message):
>
> there is:
>
> peaks.append(message.structure['peak'][0])
>
> but this is more of a "batch" type setup rather than an interactive one.
>
> So let's say I do something like this instead:
>
> #peaks.append(message.structure['peak'][0])
> zpeak = message.structure['peak'][0]
> #print "message.structure: "
> print zpeak
> return zpeak
>
> along with making a jack source and sink instead of a file source and fake
> sink.
>
> I can get the peaks printed in there via the print zpeak.
>
> But I am going around in circles (actually, circles is too clean a shape)
> in
> my head trying to figure out how to get that info out as it comes in.
>
> Once I ge that, then I have to figure out how to hook it up to a meter
> widget.
>
> One possibility I have looked at basing this on is this:
>
> http://zetcode.com/gui/pygtk/customwidget/
>

A custom gtk/cairo widget is pretty easy to update. You have a draw method
in the widget class and call widget_queue_redraw(widget) when you want to
refresh the widget.

You can set the widget's data before the call to widget_queue_redraw()

With the peak data you can use a timer or loop to update a callback that
sets the meter widget's data then calls the redraw command.

--
Patrick Shirkey
Boost Hardware Ltd
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Thu Feb 28 08:15:04 2013

This archive was generated by hypermail 2.1.8 : Thu Feb 28 2013 - 08:15:04 EET