Changeset - 7eb3676b8fd6
[Not reviewed]
default
0 7 0
Drew Perttula - 8 years ago 2017-05-23 06:58:02
drewp@bigasterisk.com
more of the fixed add-to-song service
Ignore-this: 44b96a929b79ab201a80a6914b117f9d
7 files changed with 42 insertions and 19 deletions:
0 comments (0 inline, 0 general)
bin/effecteval
Show inline comments
 
@@ -53,25 +53,25 @@ class SongEffects(PrettyErrorHandler, cy
 
        self.write('')
 

	
 
    @inlineCallbacks
 
    def post(self):
 
        self.wideOpenCors()
 
        dropped = URIRef(self.get_argument('drop'))
 

	
 
        try:
 
            song = URIRef(self.get_argument('uri'))
 
        except Exception: # which?
 
            song = yield currentSong()
 

	
 
        event = self.get_argument('event') or 'default'
 
        event = self.get_argument('event', default='default')
 
            
 
        log.info("adding to %s", song)
 

	
 
        p = yield songEffectPatch(self.settings.graph, dropped, song, event, ctx=song)
 
        self.settings.graph.patch(p)
 
        
 
class SongEffectsUpdates(cyclone.websocket.WebSocketHandler):
 
    def connectionMade(self, *args, **kwargs):
 
        self.graph = self.settings.graph
 
        self.graph.addHandler(self.updateClient)
 
        
 
    def updateClient(self):
light9/effect/edit.py
Show inline comments
 
@@ -10,24 +10,27 @@ from light9.curvecalc.curve import Curve
 

	
 
def clamp(x, lo, hi):
 
    return max(lo, min(hi, x))
 

	
 

	
 
@inlineCallbacks
 
def getMusicStatus():
 
    returnValue(json.loads((yield cyclone.httpclient.fetch(
 
        networking.musicPlayer.path('time'), timeout=.5)).body))
 

	
 
@inlineCallbacks
 
def songEffectPatch(graph, dropped, song, event, ctx):
 
    """
 
    some uri was 'dropped' in the timeline. event is 'default' or 'start' or 'end'.
 
    """
 
    with graph.currentState(
 
            tripleFilter=(dropped, None, None)) as g:
 
        droppedTypes = list(g.objects(dropped, RDF.type))
 
        droppedLabel = g.label(dropped)
 
        droppedCodes = list(g.objects(dropped, L9['code']))
 

	
 
    quads = []
 
    fade = 2 if event == 'default' else 0
 

	
 
    if _songHasEffect(graph, song, dropped):
 
        # bump the existing curve
 
        pass
light9/rdfdb/currentstategraphapi.py
Show inline comments
 
import logging, traceback, time, itertools
 
from rdflib import ConjunctiveGraph
 
from light9.rdfdb.rdflibpatch import contextsForStatement as rp_contextsForStatement
 
log = logging.getLogger("currentstate")
 

	
 
class ReadOnlyConjunctiveGraph(object):
 
    """similar to rdflib's ReadOnlyGraphAggregate but takes one CJ in, instead
 
    of a bunch of Graphs"""
 
    def __init__(self, graph):
 
        self.graph = graph
 

	
 
    def __getattr__(self, attr):
 
        if attr in ['subjects', 'value', 'objects', 'triples']: # not complete
 
        if attr in ['subjects', 'value', 'objects', 'triples', 'label']: # not complete
 
            return getattr(self.graph, attr)
 
        raise TypeError("can't access %r of read-only graph" % attr)
 

	
 

	
 
class CurrentStateGraphApi(object):
 
    """
 
    mixin for SyncedGraph, separated here because these methods work together
 
    """
 

	
 
    def currentState(self, context=None, tripleFilter=(None, None, None)):
 
        """
 
        a graph you can read without being in an addHandler
light9/rdfdb/syncedgraph.py
Show inline comments
 
@@ -116,24 +116,28 @@ class SyncedGraph(CurrentStateGraphApi, 
 
                       addQuads=p.addQuads,
 
                       perfect=True)
 
        except ValueError as e:
 
            log.error(e)
 
            self.sendFailed(None)
 
            return
 
        log.debug('runDepsOnNewPatch')
 
        self.runDepsOnNewPatch(p)
 
        log.debug('sendPatch')
 
        self._sender.sendPatch(p).addErrback(self.sendFailed)
 
        log.debug('patch is done %s', debugKey)
 

	
 
    def suggestPrefixes(self, prefixes):
 
        song note edit should put song: to the song uri
 
        self.addlPrefixes.update(prefixes)
 

	
 
    def sendFailed(self, result):
 
        """
 
        we asked for a patch to be queued and sent to the master, and
 
        that ultimately failed because of a conflict
 
        """
 
        log.warn("sendFailed")
 
        self.resync()
 
        
 
        #i think we should receive back all the pending patches,
 
        #do a resync here,
 
        #then requeue all the pending patches (minus the failing one?) after that's done.
 

	
light9/subserver/effects.coffee
Show inline comments
 
@@ -24,23 +24,38 @@ class Model
 
    ]
 
  
 

	
 
model = new Model()
 

	
 
model.addToCurrentSong = (e) ->
 
  $.ajax({
 
    type: 'POST'
 
    url: '/effectEval/songEffects'
 
    data: {drop: e.uri}
 
  })
 

	
 
model.addMomentary = (e) ->
 
  $.ajax({
 
    type: 'POST'
 
    url: '/effectEval/songEffects'
 
    data: {drop: e.uri, event: 'start'}
 
  })
 

	
 
model.addMomentaryUp = (e) ->
 
  $.ajax({
 
    type: 'POST'
 
    url: '/effectEval/songEffects'
 
    data: {drop: e.uri, event: 'end'}
 
  })
 
  
 

	
 
reconnectingWebSocket "../effectsUpdates", (msg) ->
 
  model.chases(msg.chases) if msg.chases?
 
  model.classes(msg.classes) if msg.classes?
 

	
 
# this sort of works to stop clicks in <input> from following the
 
# submaster hyperlink, but it may make certain clicks act wrong
 
$(document).on('click', 'a', (ev) ->
 
  return false if ev.target.tagName == 'INPUT'
 
)
 

	
 
ko.applyBindings(model)
 
\ No newline at end of file
light9/subserver/effects.jade
Show inline comments
 
@@ -21,21 +21,22 @@ html
 
        a(data-bind="attr: {href: uri}, text: label")
 
        ul(data-bind="foreach: $parent.subtermExprs($data)")
 
          li: a.resource(data-bind="attr: {href: $root.subtermLink($parent.label, $data)}, text: $data")
 

	
 

	
 
    div(data-bind="foreach: classes")
 
      div.resource.effectClass
 
        h2
 
          | Effect class
 
          | 
 
          a(data-bind="attr: {href: uri}, text: label")
 
          button(data-bind="click: $root.addToCurrentSong") Add to current song
 
          button(data-bind="event: { mousedown: $root.addMomentary, mouseup: $root.addMomentaryUp }") Add momentary
 
        div
 
          code(data-bind="text: code")
 
        
 
    #status
 
      
 
    script(src="/lib/jquery/dist/jquery.min.js")
 
    script(src="/lib/knockout/dist/knockout.js")
 
    script(src="/websocket.js")
 
    script(src="effects.js")
 
\ No newline at end of file
show/dance2017/playlist.n3
Show inline comments
 
@@ -5,31 +5,31 @@
 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 

	
 
show:dance2017 :musicRoot "show/dance2016/music/pad";
 
:spectrogramUrlRoot "/show/dance2016/spectrogram" .
 

	
 
show:dance2017 :playList (
 
  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:song18
 
) .
 

	
 
sh:song1 a :Song; rdfs:label  "01"; :songFilename "01.wav" .
 
sh:song2 a :Song; rdfs:label  "02"; :songFilename "02.wav" .
 
sh:song3 a :Song; rdfs:label  "03"; :songFilename "03.wav" .
 
sh:song4 a :Song; rdfs:label  "04"; :songFilename "04.wav" .
 
sh:song5 a :Song; rdfs:label  "05"; :songFilename "05.wav" .
 
sh:song6 a :Song; rdfs:label  "06"; :songFilename "06.wav" .
 
sh:song7 a :Song; rdfs:label  "07"; :songFilename "07.wav" .
 
sh:song8 a :Song; rdfs:label  "08"; :songFilename "08.wav" .
 
sh:song9 a :Song; rdfs:label  "09"; :songFilename "09.wav" .
 
sh:song10 a :Song; rdfs:label "10"; :songFilename "10.wav" .
 
sh:song11 a :Song; rdfs:label "11"; :songFilename "11.wav" .
 
sh:song12 a :Song; rdfs:label "12"; :songFilename "12.wav" .
 
sh:song13 a :Song; rdfs:label "13"; :songFilename "13.wav" .
 
sh:song14 a :Song; rdfs:label "14"; :songFilename "14.wav" .
 
sh:song15 a :Song; rdfs:label "15"; :songFilename "15.wav" .
 
sh:song16 a :Song; rdfs:label "16"; :songFilename "16.wav" .
 
sh:song17 a :Song; rdfs:label "17"; :songFilename "17.wav" .
 
sh:song1 a :Song; rdfs:label  "01"; :songFilename "01-out.wav" .
 
sh:song2 a :Song; rdfs:label  "02"; :songFilename "02-out.wav" .
 
sh:song3 a :Song; rdfs:label  "03"; :songFilename "03-out.wav" .
 
sh:song4 a :Song; rdfs:label  "04"; :songFilename "04-out.wav" .
 
sh:song5 a :Song; rdfs:label  "05"; :songFilename "05-out.wav" .
 
sh:song6 a :Song; rdfs:label  "06"; :songFilename "06-out.wav" .
 
sh:song7 a :Song; rdfs:label  "07"; :songFilename "07-out.wav" .
 
sh:song8 a :Song; rdfs:label  "08"; :songFilename "08-out.wav" .
 
sh:song9 a :Song; rdfs:label  "09"; :songFilename "09-out.wav" .
 
sh:song10 a :Song; rdfs:label "10"; :songFilename "10-out.wav" .
 
sh:song11 a :Song; rdfs:label "11"; :songFilename "11-out.wav" .
 
sh:song12 a :Song; rdfs:label "12"; :songFilename "12-out.wav" .
 
sh:song13 a :Song; rdfs:label "13"; :songFilename "13-out.wav" .
 
sh:song14 a :Song; rdfs:label "14"; :songFilename "14-out.wav" .
 
sh:song15 a :Song; rdfs:label "15"; :songFilename "15-africaout.wav" .
 
sh:song16 a :Song; rdfs:label "16"; :songFilename "16-out.wav" .
 
sh:song17 a :Song; rdfs:label "17"; :songFilename "17-out.wav" .
 

	
 

	
0 comments (0 inline, 0 general)