Re: [Rhythmbox-devel] Python Plugin-LED Cube Visualizations
- From: EmbeddedMicro <justin embeddedmicro com>
- To: rhythmbox-devel gnome org
- Subject: Re: [Rhythmbox-devel] Python Plugin-LED Cube Visualizations
- Date: Sat, 2 May 2009 10:40:45 -0700 (PDT)
I have it working with the cube now! Thanks a lot!
You were right about the magnitude part, but the source part didn't work
quite right.
Here's the working code.
import rb
> import gst
> import serial
> import array
>
> class LEDcube(rb.Plugin):
>
> def activate(self, shell):
> self.max = -60
> self.spectrum = gst.element_factory_make("spectrum")
> self.spectrum.set_property('bands',9)
> self.spectrum.set_property('interval',15000000)
> self.spectrum.set_property('threshold',-50)
>
> player = shell.get_player().props.player
> player.add_filter(self.spectrum)
>
> bus = player.props.bus
> if bus is None:
> self.bus_id = player.connect('notify::bus', self.bus_notify)
> else:
> self.bus_id = player.props.bus.connect('message', self.on_message)
> self.ser = serial.Serial('/dev/ttyS0', 115200, timeout=1)
>
> def deactivate(self, shell):
> player = shell.get_player().props.player
>
> player.remove_filter(self.spectrum)
> player.props.bus.disconnect(self.bus_id)
> self.bus_id = 0
>
> def bus_notify(self, obj, pspec):
> obj.disconnect(self.bus_id)
> self.bus_id = obj.props.bus.connect('message', self.on_message)
>
> def on_message(self, bus, message):
> if message.src == self.spectrum and
> message.structure.has_key('magnitude'):
> magnitudes = message.structure['magnitude']
> self.ser.write("\x35")
> for i in range(0, 9):
> data = array.array('B', [51+int(round(magnitudes[i],0))]).tostring()
> self.ser.write(data)
> self.ser.write(data)
> self.ser.write(data)
All I have to do now is get it synced and make the visualisations better.
Thanks again,
Justin
--
View this message in context: http://www.nabble.com/Python-Plugin-LED-Cube-Visualizations-tp23117783p23348613.html
Sent from the Gnome - Rhythmbox - Dev mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]