Changeset - c81f86f3d65a
[Not reviewed]
default
0 3 0
Drew Perttula - 6 years ago 2019-06-02 11:37:14
drewp@bigasterisk.com
effecteval is mostly obsolete, but now it can at least show a list of effects used in a song (which seq can too)
Ignore-this: c24e4c1c3ccd839e79b1b2fb19ee996a
3 files changed with 20 insertions and 13 deletions:
0 comments (0 inline, 0 general)
bin/effecteval
Show inline comments
 
#!bin/python
 

	
 
from run_local import log
 
from twisted.internet import reactor
 
from twisted.internet.defer import inlineCallbacks, returnValue
 
import cyclone.web, cyclone.websocket, cyclone.httpclient
 
import sys, optparse, logging, json, itertools
 
from rdflib import URIRef, Literal
 

	
 
sys.path.append('/usr/lib/pymodules/python2.7/')  # for numpy, on rpi
 
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, songNotePatch
 
from light9.effecteval.effectloop import makeEffectLoop
 
from greplin.scales.cyclonehandler import StatsHandler
 
from light9.namespaces import L9
 
from rdfdb.patch import Patch
 
from rdfdb.syncedgraph import SyncedGraph
 
from greplin import scales
 

	
 
from cycloneerr import PrettyErrorHandler
 
from light9.coffee import StaticCoffee
 
@@ -94,29 +92,38 @@ class SongEffects(PrettyErrorHandler, cy
 
class SongEffectsUpdates(cyclone.websocket.WebSocketHandler):
 

	
 
    def connectionMade(self, *args, **kwargs):
 
        self.graph = self.settings.graph
 
        self.graph.addHandler(self.updateClient)
 

	
 
    def updateClient(self):
 
        # todo: abort if client is gone
 
        playlist = self.graph.value(showconfig.showUri(), L9['playList'])
 
        songs = list(self.graph.items(playlist))
 
        out = []
 
        for s in songs:
 
            out.append({'uri': s, 'label': self.graph.label(s)})
 
            out[-1]['effects'] = [{
 
                'uri': uri,
 
                'label': self.graph.label(uri)
 
            } for uri in sorted(self.graph.objects(s, L9['effect']))]
 
            out.append({'uri': s, 'label': self.graph.label(s), 'effects': []})
 
            seen = set()
 
            for n in self.graph.objects(s, L9['note']):
 
                for uri in self.graph.objects(n, L9['effectClass']):
 
                    if uri in seen:
 
                        continue
 
                    seen.add(uri)
 
                    out[-1]['effects'].append({
 
                        'uri': uri,
 
                        'label': self.graph.label(uri)
 
                    })
 
            out[-1]['effects'].sort(key=lambda e: e['uri'])
 
                    
 
                    
 
        self.sendMessage({'songs': out})
 

	
 

	
 
class EffectUpdates(cyclone.websocket.WebSocketHandler):
 
    """
 
    stays alive for the life of the effect page
 
    """
 

	
 
    def connectionMade(self, *args, **kwargs):
 
        log.info("websocket opened")
 
        self.uri = URIRef(self.get_argument('uri'))
 
        self.sendMessage({'hello': repr(self)})
light9/effecteval/effect-components.html
Show inline comments
 
@@ -7,27 +7,28 @@
 
    <template is="dom-repeat" items="{{songs}}" as="song">
 
      <li>
 
        <a class="song"
 
           href="{{song.uri}}"
 
           on-click="focusSong">Song <span>{{song.label}}</span></a>
 
        <ul>
 
          <template is="dom-repeat" items="{{song.effects}}" as="effect">
 
            <li>
 
              <l9-effect uri="{{effect.uri}}"
 
                         label="{{effect.label}}"></l9-effect>
 
            </li>
 
          </template>
 
          <li>
 
            <effect-drop-target song-uri="{{song.uri}}"></effect-drop-target>
 
          </li>
 
       <!--    <li>
 
          <effect-drop-target song-uri="{{song.uri}}"></effect-drop-target>
 
      </li>
 
      -->
 
        </ul>
 
      </li>
 
    </template>
 
  </template>
 
</dom-module>
 
<script>
 
 Polymer({
 
   is: "song-effect-list",
 
   properties: {
 
     songs: Object
 
   },
 
   ready: function() {
 
@@ -43,25 +44,25 @@
 
     }.bind(this));
 
   },
 
   focusSong: function(ev) {
 
     ev.preventDefault()
 
     window.location.search = '?' + $.param({song: ev.model.song.uri});
 
   }
 
 });
 
</script>
 

	
 
<dom-module id="l9-effect">
 
  <template>
 
    <a class="effect" href="{{href}}">{{label}}</a>
 
    <button on-click="deleteEffect">Delete</button>
 
    
 
  </template>
 
</dom-module>
 
<script>
 
 Polymer({
 
   is: "l9-effect",
 
   properties: {
 
     uri: String,
 
     label: String,
 
     href: {
 
       type: String,
 
       computed: 'computeHref(uri)'
 
     }
light9/effecteval/index.html
Show inline comments
 
<!doctype html>
 
<html>
 
  <head>
 
    <title>effecteval</title>
 
    <meta charset="utf-8" />
 
    <link rel="stylesheet" href="/style.css">
 
    <link rel="import" href="effect-components.html">
 
  </head>
 
  <body>
 
    <div id="status">starting...</div>
 
    <div><a href="stats">/stats</a></div>
 
    <h1>Effect instances</h1>
 
    <h1>Effect instances <a href="stats/">[stats]</a></h1>
 
    <div><a href=".">View all songs</a></div>
 
    <!-- subscribe to a query of all effects and their songs -->
 
    <song-effect-list></song-effect-list>
 
  </body>
 
</html>
0 comments (0 inline, 0 general)