Changeset - d8202a0a7fd5
[Not reviewed]
default
0 7 0
Drew Perttula - 13 years ago 2012-06-13 04:27:48
drewp@bigasterisk.com
fix up musicpad and wavecurve. ascoltami2 can now use relative paths in the config
Ignore-this: eb95f50f54f14275f1f031ccb7fbb97f
7 files changed with 14 insertions and 16 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -259,14 +259,14 @@ def main():
 
        showconfig.songFilenameFromURI(song)),
 
                  skipMusic=opts.skip_music)
 

	
 
    subtermPath = graphPathForSubterms(song)
 
    try:
 
        graph.parse(subtermPath, format='n3')
 
    except urllib2.URLError, e:
 
        if e.reason.errno != 2:
 
    except IOError, e:
 
        if e.errno != 2:
 
            raise
 
        log.info("%s not found, starting with empty graph" % subtermPath)
 
    
 
    log.debug("startup: output %s", time.time() - startTime)
 
    out = Output(subterms, music)
 

	
bin/listsongs
Show inline comments
 
#!/usr/bin/python
 
#!bin/python
 

	
 
"""for completion, print the available song uris on stdout
 

	
 
in .zshrc:
 

	
 
function _songs { local expl;  _description files expl 'songs';  compadd "$expl[@]" - `${LIGHT9_SHOW}/../../bin/listsongs` }
bin/musicPad
Show inline comments
 
#!/usr/bin/python
 
#!bin/python
 
"""
 
rewrite all the songs with silence at the start and end
 
"""
 
import sys, wave, logging, os
 
sys.path.append(".")
 
from light9 import showconfig
 
@@ -11,15 +11,12 @@ logging.basicConfig(level=logging.INFO)
 
log = logging.getLogger()
 

	
 
introPad = 4
 
postPad = 9 # 5 + autostop + 4
 

	
 
playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri())
 
# instead of taking a show uri like it should, i just convert every
 
# path i find in the graph (hoping that you only loaded statements for
 
# the current show)
 
for p in playlist.allSongPaths():
 
    log.info("read %s", p)
 
    inputWave = wave.open(p, 'r')
 

	
 
    outputDir = os.path.join(os.path.dirname(p), "pad")
 
    try:
bin/wavecurve
Show inline comments
 
#!/usr/bin/env python
 
#!bin/python
 
import optparse
 
import run_local
 
from light9.wavepoints import simp
 

	
 
def createCurve(inpath, outpath, t):
 
    print "reading %s, writing %s" % (inpath, outpath)
 
@@ -28,13 +28,13 @@ if options.all:
 
    from rdflib import RDF
 
    from light9.ascoltami.playlist import Playlist
 
    graph = showconfig.getGraph()
 

	
 
    playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri())
 
    for song in playlist.allSongs():
 
        inpath = playlist.songPath(song)
 
        inpath = showconfig.songOnDisk(song)
 
        for curveName, t in [('music', .01),
 
                             ('smooth_music', .07)]:
 
            outpath = showconfig.curvesDir() + "/%s-%s" % (
 
                showconfig.songFilenameFromURI(song), curveName)
 
            createCurve(inpath, outpath, t)
 
else:
light9/ascoltami/player.py
Show inline comments
 
@@ -29,13 +29,13 @@ class Player(object):
 
        gobject.timeout_add(50, self.watchTime)
 

	
 
        bus = self.pipeline.get_bus()
 
        bus.add_signal_watch()
 

	
 
        def on_any(bus, msg):
 
            print bus, msg, msg.type
 
            #print bus, msg, msg.type
 
            if msg.type == gst.MESSAGE_EOS:
 
                if self.onEOS is not None:
 
                    self.onEOS(self.getSong())
 
        bus.connect('message', on_any)
 

	
 
        def onStreamStatus(bus, message):
light9/ascoltami/playlist.py
Show inline comments
 
from light9.showconfig import getSongsFromShow
 
from light9.showconfig import getSongsFromShow, songOnDisk
 
from light9.namespaces import L9
 

	
 
class NoSuchSong(ValueError):
 
    """Raised when a song is requested that doesn't exist (e.g. one
 
    after the last song in the playlist)."""
 

	
 
@@ -22,27 +22,28 @@ class Playlist(object):
 
            nextSong = self.songs[currentIndex + 1]
 
        except IndexError:
 
            raise NoSuchSong("%r is the last item in the playlist." % \
 
                             currentSong)
 

	
 
        return nextSong
 

	
 
    def allSongs(self):
 
        """Returns a list of all song URIs in order."""
 
        return self.songs
 
    
 
    def allSongPaths(self):
 
        """Returns a list of the filesystem paths to all songs in order."""
 
        paths = []
 
        for song in self.songs:
 
            paths.append(self.songPath(song))
 
            paths.append(songOnDisk(song))
 
        return paths
 
    
 
    def songPath(self, uri):
 
        """filesystem path to a song"""
 
        p = self.graph.value(uri, L9['showPath'])
 
        assert p.startswith("file://"), p
 
        return p[len("file://"):]
 
        raise NotImplementedError("see showconfig.songOnDisk")
 
        # maybe that function should be moved to this method
 

	
 
    @classmethod
 
    def fromShow(playlistClass, graph, show):
 
        playlistUri = graph.value(show, L9['playList'])
 
        if not playlistUri:
 
            raise ValueError("%r has no l9:playList" % show)
light9/showconfig.py
Show inline comments
 
@@ -71,13 +71,13 @@ def songOnDisk(song):
 
        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)
 
    return path.abspath(path.join(root, name))
 

	
 
def songFilenameFromURI(uri):
 
    """
 
    'http://light9.bigasterisk.com/show/dance2007/song8' -> 'song8'
 

	
 
    everything that uses this should be deprecated for real URIs
0 comments (0 inline, 0 general)