diff bin/curvecalc @ 964:ced2c5e5fb31

curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!) Ignore-this: 3a5349b015605c3a8d640d30ea255000
author drewp@bigasterisk.com
date Sat, 15 Jun 2013 08:21:33 +0000
parents fa78048a3240
children 16c771461cde
line wrap: on
line diff
--- a/bin/curvecalc	Sat Jun 15 08:21:16 2013 +0000
+++ b/bin/curvecalc	Sat Jun 15 08:21:33 2013 +0000
@@ -78,6 +78,25 @@
             songChoice(graph.value(session, L9['currentSong']))
         graph.addHandler(setSong)
         # next here, watch songChoice and patch the graph
+        def songToGraph(newSong):
+            graph.patchObject(context=session, subject=session,
+                              predicate=L9['currentSong'], newObject=newSong)
+        songChoice.subscribe(songToGraph)
+        def current_player_song(song):
+            # (this is run on every frame)
+            ps = wtree.get_object("playerSong")
+            if URIRef(ps.get_uri()) != song:
+                print "update playerSong"
+                def setLabel():
+                    ps.set_label(graph.label(song))
+                graph.addHandler(setLabel)
+                ps.set_uri(song)
+            if song != songChoice():
+                if wtree.get_object("followPlayerSongChoice").get_active():
+                    songChoice(song)
+                
+        self.current_player_song = current_player_song
+        dispatcher.connect(current_player_song, "current_player_song")
         
         ec = EditChoice(graph, songChoice, label="Editing song:")
         wtree.get_object("currentSongEditChoice").add(ec)