Changeset - c677bf37a1b4
[Not reviewed]
default
0 3 0
Drew Perttula - 11 years ago 2014-06-15 15:47:15
drewp@bigasterisk.com
effect list has button to add to current song
Ignore-this: 336da00ee802890c5b75af5b0d2ab255
3 files changed with 40 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/effecteval
Show inline comments
 
@@ -36,13 +36,17 @@ class EffectEdit(PrettyErrorHandler, cyc
 
        
 
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 newEnvelopeCurve(graph, ctx, uri, label):
 
    """this does its own patch to the graph"""
 
    
 
    musicStatus = json.loads((yield cyclone.httpclient.fetch(
 
        networking.musicPlayer.path('time'), timeout=.5)).body)
 
    musicStatus = yield getMusicStatus()
 
    songTime=musicStatus['t']
 
    songDuration=musicStatus['duration']
 
    
 
@@ -69,12 +73,37 @@ def newEffect(graph, song, ctx):
 
    
 
def musicCurveForSong(uri):
 
    return URIRef(uri + 'music')
 

	
 
@inlineCallbacks
 
def currentSong():
 
    s = (yield getMusicStatus())['song']
 
    if s is None:
 
        raise ValueError("no current song")
 
    returnValue(URIRef(s))
 
    
 
class SongEffects(PrettyErrorHandler, cyclone.web.RequestHandler):
 
    def wideOpenCors(self):
 
        self.set_header('Access-Control-Allow-Origin', '*')
 
        self.set_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTIONS')
 
        self.set_header('Access-Control-Max-Age', '1000')
 
        self.set_header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With')
 
    
 
    def options(self):
 
        self.wideOpenCors()
 
        self.write('')
 

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

	
 
        try:
 
            song = URIRef(self.get_argument('uri'))
 
        except Exception: # which?
 
            song = yield currentSong()
 
            
 
        log.info("adding to %s", song)
 

	
 
        ctx = song
 
        graph = self.settings.graph
 
        
light9/subserver/effects.coffee
Show inline comments
 
@@ -26,6 +26,13 @@ class Model
 

	
 
model = new Model()
 

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

	
 
reconnectingWebSocket "ws://localhost:8052/effectsUpdates", (msg) ->
 
  model.chases(msg.chases) if msg.chases?
 
  model.classes(msg.classes) if msg.classes?
light9/subserver/effects.jade
Show inline comments
 
@@ -26,6 +26,7 @@ html
 
          | Effect class
 
          | 
 
          a(data-bind="attr: {href: uri}, text: label")
 
          button(data-bind="click: $root.addToCurrentSong") Add to current song
 
        div
 
          code(data-bind="text: code")
 
        
0 comments (0 inline, 0 general)