Changeset - 13e3cbe9071a
[Not reviewed]
default
0 4 0
Drew Perttula - 8 years ago 2017-05-25 06:12:55
drewp@bigasterisk.com
momentary-add button support
Ignore-this: 6269d0492f1b5ec4e112b3b932708b04
4 files changed with 57 insertions and 18 deletions:
0 comments (0 inline, 0 general)
bin/effecteval
Show inline comments
 
@@ -64,11 +64,17 @@ class SongEffects(PrettyErrorHandler, cy
 

	
 
        event = self.get_argument('event', default='default')
 
            
 
        note = self.get_argument('note', default=None)
 
        if note is not None:
 
            note = URIRef(note)
 

	
 
        log.info("adding to %s", song)
 

	
 
        p = yield songNotePatch(self.settings.graph, dropped, song, event, ctx=song)
 
        note, p = yield songNotePatch(self.settings.graph, dropped, song, event, ctx=song, note=note)
 
        
 
        self.settings.graph.patch(p)
 
        self.settings.graph.suggestPrefixes({'song': URIRef(song + '/')})
 
        self.write(json.dumps({'note': note}))
 
        
 
class SongEffectsUpdates(cyclone.websocket.WebSocketHandler):
 
    def connectionMade(self, *args, **kwargs):
light9/effect/edit.py
Show inline comments
 
@@ -68,7 +68,7 @@ def songEffectPatch(graph, dropped, song
 
    returnValue(Patch(addQuads=quads))
 

	
 
@inlineCallbacks
 
def songNotePatch(graph, dropped, song, event, ctx):
 
def songNotePatch(graph, dropped, song, event, ctx, note=None):
 
    """
 
    drop into effectsequencer timeline
 

	
 
@@ -79,11 +79,43 @@ def songNotePatch(graph, dropped, song, 
 
        droppedTypes = list(g.objects(dropped, RDF.type))
 

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

	
 
    if note:
 
        musicStatus = yield getMusicStatus()
 
        songTime = musicStatus['t']
 
        _finishCurve(graph, note, quads, ctx, songTime)
 
    else:
 
    if L9['Effect'] in droppedTypes:
 
        musicStatus = yield getMusicStatus()
 
        songTime = musicStatus['t']
 
            note = _makeNote(graph, song, note, quads, ctx, dropped, songTime, event, fade)
 
        else:
 
            raise NotImplementedError
 

	
 
    returnValue((note, Patch(addQuads=quads)))
 

	
 

	
 
def _point(ctx, uri, t, v):
 
    return [
 
        (uri, L9['time'], Literal(round(t, 3)), ctx),
 
        (uri, L9['value'], Literal(round(v, 3)), ctx)
 
        ]
 
    
 
def _finishCurve(graph, note, quads, ctx, songTime):
 
    with graph.currentState() as g:
 
        origin = g.value(note, L9['originTime']).toPython()
 
        curve = g.value(note, L9['curve'])
 

	
 
    pt2 = graph.sequentialUri(curve + 'p')
 
    pt3 = graph.sequentialUri(curve + 'p')
 
    quads.extend(
 
        [(curve, L9['point'], pt2, ctx)] + _point(ctx, pt2, songTime - origin, 1) +
 
        [(curve, L9['point'], pt3, ctx)] + _point(ctx, pt3, songTime - origin + .5, 0)
 
        )
 
    
 

	
 
def _makeNote(graph, song, note, quads, ctx, dropped, songTime, event, fade):
 
        note = graph.sequentialUri(song + '/n')
 
        curve = graph.sequentialUri(note + 'c')
 
        quads.extend([
 
@@ -98,21 +130,15 @@ def songNotePatch(graph, dropped, song, 
 
        if event == 'default':
 
            coords = [(0 - fade, 0), (0, 1), (20, 1), (20 + fade, 0)]
 
        elif event == 'start':
 
            coords = [(0 - fade, 0), (0, 1), (20, 1), (20 + fade, 0)]
 
        elif event == 'end':
 
            raise
 
        coords = [(0 - fade, 0), (0, 1), ]
 
    elif event == 'end': # probably unused- goes to _finishCurve instead
 
        coords = [(20, 1), (20 + fade, 0)]
 
        else:
 
            raise NotImplementedError(event)
 
        for t,v in coords:
 
            pt = graph.sequentialUri(curve + 'p')
 
            quads.extend([
 
                (curve, L9['point'], pt, ctx),
 
                (pt, L9['time'], Literal(t), ctx),
 
                (pt, L9['value'], Literal(v), ctx),
 
                ])
 
    
 
    returnValue(Patch(addQuads=quads))
 
    
 
        quads.extend([(curve, L9['point'], pt, ctx)] + _point(ctx, pt, t, v))
 
    return note
 
    
 
def _songHasEffect(graph, song, uri):
 
    """does this song have an effect of class uri or a sub curve for sub
light9/subserver/effects.coffee
Show inline comments
 
@@ -33,18 +33,23 @@ model.addToCurrentSong = (e) ->
 
    data: {drop: e.uri}
 
  })
 

	
 
lastMomentaryNote = null
 

	
 
model.addMomentary = (e) ->
 
  $.ajax({
 
    type: 'POST'
 
    url: '/effectEval/songEffects'
 
    data: {drop: e.uri, event: 'start'}
 
    success: (data) ->
 
      lastMomentaryNote = JSON.parse(data)['note']
 

	
 
  })
 

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

	
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -463,8 +463,10 @@ Polymer
 
    screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight]) for pt in @worldPts)
 
    @dia.setNote(@uri, screenPts, effect)
 

	
 
    leftX = Math.max(2, screenPts[1].e(1) + 5)
 
    rightX = screenPts[2].e(1) - 5
 
    leftX = Math.max(2, screenPts[Math.min(1, screenPts.length - 1)].e(1) + 5)
 
    rightX = screenPts[Math.min(2, screenPts.length - 1)].e(1) - 5
 
    if screenPts.length < 3
 
      rightX = leftX + 120
 
    w = 114
 
    h = 80
 
    @inlineRect = {
 
@@ -475,7 +477,7 @@ Polymer
 
      display: if rightX - leftX > w then 'block' else 'none'
 
      }
 

	
 
    if screenPts[3].e(1) - screenPts[0].e(1) < 100
 
    if screenPts[screenPts.length - 1].e(1) - screenPts[0].e(1) < 100
 
      @clearAdjusters()
 
      # also kill their connectors
 
      return
0 comments (0 inline, 0 general)