changeset 1560:e993c5e1df1a

fix effecteval to drop notes into new-style timeline Ignore-this: 57cae41f60447d55bffc8d59b84bb230
author Drew Perttula <drewp@bigasterisk.com>
date Wed, 24 May 2017 08:27:47 +0000
parents 1ba1d46a70a2
children e05656f00070
files bin/effecteval light9/effect/edit.py
diffstat 2 files changed, 51 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bin/effecteval	Wed May 24 08:26:39 2017 +0000
+++ b/bin/effecteval	Wed May 24 08:27:47 2017 +0000
@@ -11,7 +11,7 @@
 sys.path.append('/usr/lib/python2.7/dist-packages') # For numpy
 from light9 import networking, showconfig
 from light9.effecteval.effect import EffectNode
-from light9.effect.edit import getMusicStatus, songEffectPatch
+from light9.effect.edit import getMusicStatus, songNotePatch
 from light9.effecteval.effectloop import makeEffectLoop
 from light9.greplin_cyclone import StatsForCyclone
 from light9.namespaces import L9
@@ -66,7 +66,7 @@
             
         log.info("adding to %s", song)
 
-        p = yield songEffectPatch(self.settings.graph, dropped, song, event, ctx=song)
+        p = yield songNotePatch(self.settings.graph, dropped, song, event, ctx=song)
         self.settings.graph.patch(p)
         self.settings.graph.suggestPrefixes({'song': URIRef(song + '/')})
         
--- a/light9/effect/edit.py	Wed May 24 08:26:39 2017 +0000
+++ b/light9/effect/edit.py	Wed May 24 08:27:47 2017 +0000
@@ -20,7 +20,7 @@
 @inlineCallbacks
 def songEffectPatch(graph, dropped, song, event, ctx):
     """
-    some uri was 'dropped' in the timeline. event is 'default' or 'start' or 'end'.
+    some uri was 'dropped' in the curvecalc timeline. event is 'default' or 'start' or 'end'.
     """
     with graph.currentState(
             tripleFilter=(dropped, None, None)) as g:
@@ -66,8 +66,55 @@
     for qq in quads:
         print qq
     returnValue(Patch(addQuads=quads))
+
+@inlineCallbacks
+def songNotePatch(graph, dropped, song, event, ctx):
+    """
+    drop into effectsequencer timeline
+
+    ported from timeline.coffee makeNewNote
+    """
+    with graph.currentState(
+            tripleFilter=(dropped, None, None)) as g:
+        droppedTypes = list(g.objects(dropped, RDF.type))
+        droppedLabel = g.label(dropped)
+
+    quads = []
+    fade = 2 if event == 'default' else 0
+
+    print 'droppedTypes', droppedTypes
+    if L9['Effect'] in droppedTypes:
+        musicStatus = yield getMusicStatus()
+        songTime = musicStatus['t']
+        note = graph.sequentialUri(song + '/n')
+        curve = graph.sequentialUri(note + 'c')
+        quads.extend([
+            (song, L9['note'], note, ctx),
+            (note, RDF.type, L9['Note'], ctx),
+            (note, L9['curve'], curve, ctx),
+            (note, L9['effectClass'], dropped, ctx),
+            (note, L9['originTime'], Literal(songTime), ctx),
+            (curve, RDF.type, L9['Curve'], ctx),
+            (curve, L9['attr'], L9['strength'], ctx),
+            ])
+        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
+        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))
+    
     
 def _songHasEffect(graph, song, uri):
     """does this song have an effect of class uri or a sub curve for sub