diff --git a/light9/ascoltami/player.py b/light9/ascoltami/player.py
--- a/light9/ascoltami/player.py
+++ b/light9/ascoltami/player.py
@@ -71,14 +71,14 @@ class Player(object):
t * gst.SECOND)
self.playStartTime = time.time()
- def setSong(self, songUri, play=True):
+ def setSong(self, songLoc, play=True):
"""
uri like file:///my/proj/light9/show/dance2010/music/07.wav
"""
- log.info("set song to %r" % songUri)
+ log.info("set song to %r" % songLoc)
self.pipeline.set_state(gst.STATE_READY)
- self.preload(songUri)
- self.pipeline.set_property("uri", songUri)
+ self.preload(songLoc)
+ self.pipeline.set_property("uri", songLoc)
# todo: don't have any error report yet if the uri can't be read
if play:
self.pipeline.set_state(gst.STATE_PLAYING)
@@ -88,7 +88,7 @@ class Player(object):
"""Returns the URI of the current song."""
return self.playbin.get_property("uri")
- def preload(self, songUri):
+ def preload(self, songPath):
"""
to avoid disk seek stutters, which happened sometimes (in 2007) with the
non-gst version of this program, we read the whole file to get
@@ -96,10 +96,9 @@ class Player(object):
i don't care that it's blocking.
"""
- assert songUri.startswith('file://')
- p = songUri[len('file://'):]
- log.info("preloading %s", p)
- open(p).read()
+ log.info("preloading %s", songPath)
+ assert songPath.startswith("file://"), songPath
+ open(songPath[len("file://"):]).read()
def currentTime(self):
try:
diff --git a/light9/ascoltami/webapp.py b/light9/ascoltami/webapp.py
--- a/light9/ascoltami/webapp.py
+++ b/light9/ascoltami/webapp.py
@@ -1,23 +1,21 @@
import web, jsonlib, socket
from twisted.python.util import sibpath
from light9.namespaces import L9
-from light9.showconfig import getSongsFromShow
+from light9.showconfig import getSongsFromShow, songOnDisk
from rdflib import URIRef
from web.contrib.template import render_genshi
render = render_genshi([sibpath(__file__, ".")])
app = None
+
+_songUris = {} # locationUri : song
def songLocation(graph, songUri):
- loc = graph.value(songUri, L9['showPath'])
- if loc is None:
- raise ValueError("no showPath for %r" % songUri)
+ loc = URIRef("file://%s" % songOnDisk(songUri))
+ _songUris[loc] = songUri
return loc
def songUri(graph, locationUri):
- try:
- return graph.subjects(L9['showPath'], locationUri).next()
- except StopIteration:
- raise ValueError("no song has :showPath of %r" % locationUri)
+ return _songUris[locationUri]
class root(object):
def GET(self):
diff --git a/light9/showconfig.py b/light9/showconfig.py
--- a/light9/showconfig.py
+++ b/light9/showconfig.py
@@ -63,34 +63,18 @@ def findMpdHome():
raise ValueError("can't find music_directory in any mpd config file")
-def songInMpd(song):
- """
- get the mpd path (with correct encoding) from the song URI
-
- mpd only works off its own musicroot, which for me is
- /my/music. song is a file in musicDir; this function returns a
- version starting with the mpd path, but minus the mpd root itself.
- the mpc ~/.mpdconf
-
- changed root to /home/drewp/projects/light9/show/dance2005 for now
- """
-
- assert isinstance(song, URIRef), "songInMpd now takes URIRefs"
-
- mpdPath = getGraph().value(song, L9['showPath'])
- if mpdPath is None:
- raise ValueError("no mpd path found for subject=%r" % song)
- return mpdPath.encode('ascii')
-
def songOnDisk(song):
"""given a song URI, where's the on-disk file that mpd would read?"""
graph = getGraph()
- showPath = graph.value(song, L9['showPath'])
- if not showPath:
- raise ValueError("no mpd path found for subject=%r" % song)
- if showPath.startswith("file://"):
- showPath = showPath[7:]
- return showPath
+ root = graph.value(showUri(), L9['musicRoot'])
+ if not root:
+ raise ValueError("%s has no :musicRoot" % showUri())
+
+ name = graph.value(song, L9['songFilename'])
+ if not name:
+ raise ValueError("Song %r has no :songFilename" % song)
+
+ return path.join(root, name)
def songFilenameFromURI(uri):
"""
diff --git a/show/dance2011/config.n3 b/show/dance2011/config.n3
--- a/show/dance2011/config.n3
+++ b/show/dance2011/config.n3
@@ -23,29 +23,30 @@ sh:netHome
:dmxServer ;
:keyboardComposer .
-
:Song is rdf:type of sh:song1, sh:song2, sh:song3, sh:song4,
sh:song5, sh:song6, sh:song7, sh:song8, sh:song9, sh:song10,
sh:song11, sh:song12, sh:song13, sh:song14, sh:song15, sh:song16,
sh:song17 .
-sh:song1 rdfs:label "1 opening"; :showPath .
-sh:song2 rdfs:label "2 "; :showPath .
-sh:song3 rdfs:label "3 kung fu"; :showPath .
-sh:song4 rdfs:label "4 "; :showPath .
-sh:song5 rdfs:label "5 ballgame"; :showPath .
-sh:song6 rdfs:label "6 marching"; :showPath .
-sh:song7 rdfs:label "7 cirque"; :showPath .
-sh:song8 rdfs:label "8 racecar"; :showPath .
-sh:song9 rdfs:label "9 " ; :showPath .
-sh:song10 rdfs:label "10" ; :showPath .
-sh:song11 rdfs:label "11 ball"; :showPath .
-sh:song12 rdfs:label "12 "; :showPath .
-sh:song13 rdfs:label "13 "; :showPath .
-sh:song14 rdfs:label "14 "; :showPath .
-sh:song15 rdfs:label "15 "; :showPath .
-sh:song16 rdfs:label "16 "; :showPath .
-sh:song17 rdfs:label "17 rocky"; :showPath .
+show:dance2011 :musicRoot "/my/music/projects/sharlyn2011/final/norm/pad" .
+
+sh:song1 rdfs:label "1 opening"; :songFilename "01-opening.wav" .
+sh:song2 rdfs:label "2 "; :songFilename "02-mix.wav" .
+sh:song3 rdfs:label "3 kung fu"; :songFilename "03-mix.wav" .
+sh:song4 rdfs:label "4 "; :songFilename "04.wav" .
+sh:song5 rdfs:label "5 ballgame"; :songFilename "05-ballgame.wav" .
+sh:song6 rdfs:label "6 marching"; :songFilename "06-marching.wav" .
+sh:song7 rdfs:label "7 cirque"; :songFilename "07-cirque-mix.wav" .
+sh:song8 rdfs:label "8 racecar"; :songFilename "08-racecar-mix.wav" .
+sh:song9 rdfs:label "9 " ; :songFilename "09-mix.wav" .
+sh:song10 rdfs:label "10" ; :songFilename "10-mix.wav" .
+sh:song11 rdfs:label "11 ball"; :songFilename "11-ball-cut2.wav" .
+sh:song12 rdfs:label "12 "; :songFilename "12-mix.wav" .
+sh:song13 rdfs:label "13 "; :songFilename "13-mix.wav" .
+sh:song14 rdfs:label "14 "; :songFilename "14-conv.wav" .
+sh:song15 rdfs:label "15 "; :songFilename "15-mix.wav" .
+sh:song16 rdfs:label "16 "; :songFilename "16-mix.wav" .
+sh:song17 rdfs:label "17 rocky"; :songFilename "17-rocky.wav" .
sub:red :color "#ff0000"; :group group:strip; :order 0 .
sub:orange :color "#f65d00"; :group group:strip; :order 1 .