Mercurial > code > home > repos > light9
annotate bin/keyboardcomposer @ 1517:3bb58b74c9c1
timeline: add cache of floats between graph updates for smoother redraws
Ignore-this: dbdc4782855087f4ec12f1d24d440484
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 12 Apr 2017 06:04:18 +0000 |
parents | 0e746743dd0f |
children | eccbc249fee7 |
rev | line source |
---|---|
721 | 1 #!bin/python |
214 | 2 |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
3 from __future__ import division, nested_scopes |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
4 from run_local import log |
1390 | 5 import cgi, time, logging |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
6 from optparse import OptionParser |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
7 import webcolors, colorsys |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
8 from louie import dispatcher |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
9 from twisted.internet import reactor, tksupport |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
10 from twisted.web import resource |
1390 | 11 from rdflib import URIRef, Literal |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
12 import Tix as tk |
214 | 13 |
14 from light9.Fadable import Fadable | |
260
7f9d0f04bb2d
KeyboardComposer is now a SubClient
David McClosky <dmcc@bigasterisk.com>
parents:
253
diff
changeset
|
15 from light9.subclient import SubClient |
1390 | 16 from light9 import showconfig, networking, prof |
17 from light9.uihelpers import toplevelat | |
1441
bc753db699f7
KC show all effects; no more :live node
drewp@bigasterisk.com
parents:
1429
diff
changeset
|
18 from light9.namespaces import L9, RDF |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
19 from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
20 from light9.rdfdb import clientsession |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
21 from light9.rdfdb.syncedgraph import SyncedGraph |
1453
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
22 from light9.effect.sequencer import CodeWatcher |
1427 | 23 import light9.effect.effecteval |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
24 |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
25 from bcf2000 import BCF2000 |
0 | 26 |
27 nudge_keys = { | |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
28 'up' : list('qwertyui'), |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
29 'down' : list('asdfghjk') |
0 | 30 } |
31 | |
366 | 32 class DummySliders: |
33 def valueOut(self, name, value): | |
34 pass | |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
35 def close(self): |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
36 pass |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
37 def reopen(self): |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
38 pass |
366 | 39 |
1390 | 40 class SubScale(tk.Scale, Fadable): |
0 | 41 def __init__(self, master, *args, **kw): |
1390 | 42 self.scale_var = kw.get('variable') or tk.DoubleVar() |
0 | 43 kw.update({'variable' : self.scale_var, |
136 | 44 'from' : 1, 'to' : 0, 'showvalue' : 0, |
146 | 45 'sliderlength' : 15, 'res' : 0.01, |
46 'width' : 40, 'troughcolor' : 'black', 'bg' : 'grey40', | |
47 'highlightthickness' : 1, 'bd' : 1, | |
48 'highlightcolor' : 'red', 'highlightbackground' : 'black', | |
49 'activebackground' : 'red'}) | |
1390 | 50 tk.Scale.__init__(self, master, *args, **kw) |
136 | 51 Fadable.__init__(self, var=self.scale_var, wheel_step=0.05) |
146 | 52 self.draw_indicator_colors() |
53 def draw_indicator_colors(self): | |
54 if self.scale_var.get() == 0: | |
55 self['troughcolor'] = 'black' | |
56 else: | |
57 self['troughcolor'] = 'blue' | |
0 | 58 |
1390 | 59 class SubmasterBox(tk.Frame): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
60 """ |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
61 this object owns the level of the submaster (the rdf graph is the |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
62 real authority) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
63 """ |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
64 def __init__(self, master, graph, sub, session, col, row): |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
65 self.graph = graph |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
66 self.sub = sub |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
67 self.session = session |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
68 self.col, self.row = col, row |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
69 bg = self.graph.value(sub, L9.color, default='#000000') |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
70 rgb = webcolors.hex_to_rgb(bg) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
71 hsv = colorsys.rgb_to_hsv(*[x/255 for x in rgb]) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
72 darkBg = webcolors.rgb_to_hex(tuple([x * 255 for x in colorsys.hsv_to_rgb( |
1171 | 73 hsv[0], hsv[1], .2)])) |
1390 | 74 tk.Frame.__init__(self, master, bd=1, relief='raised', bg=bg) |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
75 self.name = self.graph.label(sub) |
1390 | 76 self.slider_var = tk.DoubleVar() |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
77 self.pauseTrace = False |
0 | 78 self.scale = SubScale(self, variable=self.slider_var, width=20) |
821 | 79 |
1390 | 80 self.namelabel = tk.Label(self, font="Arial 7", bg=darkBg, |
459 | 81 fg='white', pady=0) |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
82 self.graph.addHandler(self.updateName) |
821 | 83 |
1390 | 84 self.namelabel.pack(side=tk.TOP) |
85 levellabel = tk.Label(self, textvariable=self.slider_var, font="Arial 6", | |
459 | 86 bg='black', fg='white', pady=0) |
1390 | 87 levellabel.pack(side=tk.TOP) |
88 self.scale.pack(side=tk.BOTTOM, expand=1, fill=tk.BOTH) | |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
89 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
90 for w in [self, self.namelabel, levellabel]: |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
91 dragSourceRegister(w, 'copy', 'text/uri-list', sub) |
734
d230824728aa
drag submasters out of keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
733
diff
changeset
|
92 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
93 self._slider_var_trace = self.slider_var.trace('w', self.slider_changed) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
94 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
95 self.graph.addHandler(self.updateLevelFromGraph) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
96 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
97 # initial position |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
98 # stil need? dispatcher.send("send_to_hw", sub=sub.uri, hwCol=col + 1) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
99 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
100 def cleanup(self): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
101 self.slider_var.trace_vdelete('w', self._slider_var_trace) |
821 | 102 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
103 def slider_changed(self, *args): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
104 self.scale.draw_indicator_colors() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
105 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
106 if self.pauseTrace: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
107 return |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
108 self.updateGraphWithLevel(self.sub, self.slider_var.get()) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
109 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
110 # needs fixing: plan is to use dispatcher or a method call to tell a hardware-mapping object who changed, and then it can make io if that's a current hw slider |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
111 dispatcher.send("send_to_hw", sub=self.sub, hwCol=self.col + 1, |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
112 boxRow=self.row) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
113 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
114 def updateGraphWithLevel(self, uri, level): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
115 """in our per-session graph, we maintain SubSetting objects like this: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
116 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
117 ?session :subSetting [a :SubSetting; :sub ?s; :level ?l] |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
118 """ |
814
1ae8e6b287e3
improvements to file watching. outline of how resync will work
drewp@bigasterisk.com
parents:
810
diff
changeset
|
119 # move to syncedgraph patchMapping |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
120 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
121 self.graph.patchMapping(context=self.session, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
122 subject=self.session, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
123 predicate=L9['subSetting'], |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
124 nodeClass=L9['SubSetting'], |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
125 keyPred=L9['sub'], newKey=uri, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
126 valuePred=L9['level'], newValue=Literal(level)) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
127 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
128 def updateLevelFromGraph(self): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
129 """read rdf level, write it to subbox.slider_var""" |
814
1ae8e6b287e3
improvements to file watching. outline of how resync will work
drewp@bigasterisk.com
parents:
810
diff
changeset
|
130 # move this to syncedgraph readMapping |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
131 graph = self.graph |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
132 |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
133 for setting in graph.objects(self.session, L9['subSetting']): |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
134 if graph.value(setting, L9['sub']) == self.sub: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
135 self.pauseTrace = True # don't bounce this update back to server |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
136 try: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
137 self.slider_var.set(graph.value(setting, L9['level'])) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
138 finally: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
139 self.pauseTrace = False |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
140 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
141 def updateName(self): |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
142 def shortUri(u): |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
143 return '.../' + u.split('/')[-1] |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
144 self.namelabel.config(text=self.graph.label(self.sub) or shortUri(self.sub)) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
145 |
1390 | 146 class KeyboardComposer(tk.Frame, SubClient): |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
147 def __init__(self, root, graph, session, |
394
0c33ea7d523d
keyboardcomposer: sliders default to true
David McClosky <dmcc@bigasterisk.com>
parents:
393
diff
changeset
|
148 hw_sliders=True): |
1390 | 149 tk.Frame.__init__(self, root, bg='black') |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
150 SubClient.__init__(self) |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
151 self.graph = graph |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
152 self.session = session |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
153 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
154 self.subbox = {} # sub uri : SubmasterBox |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
155 self.slider_table = {} # coords : SubmasterBox |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
156 self.rows = [] # this holds Tk Frames for each row |
821 | 157 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
158 self.current_row = 0 # should come from session graph |
0 | 159 |
390
5d2b119443f2
keyboardcomposer: fix (one) refresh bug
David McClosky <dmcc@bigasterisk.com>
parents:
389
diff
changeset
|
160 self.use_hw_sliders = hw_sliders |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
161 self.connect_to_hw(hw_sliders) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
162 |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
163 self.make_key_hints() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
164 self.make_buttons() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
165 |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
166 self.graph.addHandler(self.redraw_sliders) |
1453
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
167 |
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
168 self.codeWatcher = CodeWatcher( |
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
169 onChange=lambda: self.graph.addHandler(self.redraw_sliders)) |
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
170 |
6906cacaa218
KC and SEQ share inotify code to reload effect code
drewp@bigasterisk.com
parents:
1441
diff
changeset
|
171 self.send_levels_loop(delay=.05) |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
172 self.graph.addHandler(self.rowFromGraph) |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
173 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
174 def make_buttons(self): |
1390 | 175 self.buttonframe = tk.Frame(self, bg='black') |
176 self.buttonframe.pack(side=tk.BOTTOM) | |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
177 |
1390 | 178 self.sliders_status_var = tk.IntVar() |
390
5d2b119443f2
keyboardcomposer: fix (one) refresh bug
David McClosky <dmcc@bigasterisk.com>
parents:
389
diff
changeset
|
179 self.sliders_status_var.set(self.use_hw_sliders) |
1390 | 180 self.sliders_checkbutton = tk.Checkbutton(self.buttonframe, |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
181 text="Sliders", variable=self.sliders_status_var, |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
182 command=lambda: self.toggle_slider_connectedness(), |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
183 bg='black', fg='white') |
1390 | 184 self.sliders_checkbutton.pack(side=tk.LEFT) |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
185 |
1390 | 186 self.alltozerobutton = tk.Button(self.buttonframe, text="All to Zero", |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
187 command=self.alltozero, bg='black', fg='white') |
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
188 self.alltozerobutton.pack(side='left') |
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
189 |
1390 | 190 self.save_stage_button = tk.Button(self.buttonframe, text="Save", |
821 | 191 command=lambda: self.save_current_stage(self.sub_name.get()), |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
192 bg='black', fg='white') |
1390 | 193 self.save_stage_button.pack(side=tk.LEFT) |
194 self.sub_name = tk.Entry(self.buttonframe, bg='black', fg='white') | |
195 self.sub_name.pack(side=tk.LEFT) | |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
196 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
197 def redraw_sliders(self): |
1265
50f8a1a7d5cd
KC don't rebuild your tree so many times
drewp@bigasterisk.com
parents:
1264
diff
changeset
|
198 self.draw_sliders() |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
199 if len(self.rows): |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
200 self.change_row(self.current_row) |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
201 self.rows[self.current_row].focus() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
202 |
136 | 203 self.stop_frequent_update_time = 0 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
204 |
520 | 205 def draw_sliders(self): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
206 for r in self.rows: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
207 r.destroy() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
208 self.rows = [] |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
209 for b in self.subbox.values(): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
210 b.cleanup() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
211 self.subbox.clear() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
212 self.slider_table.clear() |
821 | 213 |
520 | 214 self.tk_focusFollowsMouse() |
215 | |
216 rowcount = -1 | |
217 col = 0 | |
218 last_group = None | |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
219 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
220 withgroups = [] |
1441
bc753db699f7
KC show all effects; no more :live node
drewp@bigasterisk.com
parents:
1429
diff
changeset
|
221 for effect in self.graph.subjects(RDF.type, L9['Effect']): |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
222 withgroups.append(( |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
223 self.graph.value(effect, L9['group']), |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
224 self.graph.value(effect, L9['order']), |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
225 self.graph.label(effect), |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
226 effect)) |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
227 withgroups.sort() |
821 | 228 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
229 log.info("withgroups %s", withgroups) |
520 | 230 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
231 self.effectEval = {} |
1427 | 232 reload(light9.effect.effecteval) |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
233 for group, order, sortLabel, effect in withgroups: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
234 if col == 0 or group != last_group: |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
235 row = self.make_row(group) |
520 | 236 rowcount += 1 |
237 col = 0 | |
238 | |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
239 subbox = SubmasterBox(row, self.graph, effect, self.session, col, rowcount) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
240 subbox.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1) |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
241 self.subbox[effect] = self.slider_table[(rowcount, col)] = subbox |
520 | 242 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
243 self.setup_key_nudgers(subbox.scale) |
520 | 244 |
1479
b2921b59d60c
a compileGraph optimization and some failed ones
drewp@bigasterisk.com
parents:
1453
diff
changeset
|
245 sharedEffectOutputs = {} |
b2921b59d60c
a compileGraph optimization and some failed ones
drewp@bigasterisk.com
parents:
1453
diff
changeset
|
246 self.effectEval[effect] = light9.effect.effecteval.EffectEval(self.graph, effect, sharedEffectOutputs) |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
247 |
520 | 248 col = (col + 1) % 8 |
249 last_group = group | |
821 | 250 |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
251 def toggle_slider_connectedness(self): |
392
53ec93018ee7
keyboardcomposer: remember whether to use hw sliders
David McClosky <dmcc@bigasterisk.com>
parents:
390
diff
changeset
|
252 self.use_hw_sliders = not self.use_hw_sliders |
53ec93018ee7
keyboardcomposer: remember whether to use hw sliders
David McClosky <dmcc@bigasterisk.com>
parents:
390
diff
changeset
|
253 if self.use_hw_sliders: |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
254 self.sliders.reopen() |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
255 else: |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
256 self.sliders.close() |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
257 self.change_row(self.current_row) |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
258 self.rows[self.current_row].focus() |
520 | 259 |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
260 def connect_to_hw(self, hw_sliders): |
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
261 if hw_sliders: |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
262 try: |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
263 self.sliders = Sliders(self) |
1146 | 264 log.info("connected to sliders") |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
265 except IOError: |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
266 log.info("no hardware sliders") |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
267 self.sliders = DummySliders() |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
268 self.use_hw_sliders = False |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
269 dispatcher.connect(self.send_to_hw, 'send_to_hw') |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
270 else: |
366 | 271 self.sliders = DummySliders() |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
272 |
0 | 273 def make_key_hints(self): |
1390 | 274 keyhintrow = tk.Frame(self) |
0 | 275 |
276 col = 0 | |
277 for upkey, downkey in zip(nudge_keys['up'], | |
278 nudge_keys['down']): | |
279 # what a hack! | |
280 downkey = downkey.replace('semicolon', ';') | |
136 | 281 upkey, downkey = (upkey.upper(), downkey.upper()) |
0 | 282 |
283 # another what a hack! | |
1390 | 284 keylabel = tk.Label(keyhintrow, text='%s\n%s' % (upkey, downkey), |
146 | 285 width=1, font=('Arial', 10), bg='red', fg='white', anchor='c') |
1390 | 286 keylabel.pack(side=tk.LEFT, expand=1, fill=tk.X) |
0 | 287 col += 1 |
288 | |
1390 | 289 keyhintrow.pack(fill=tk.X, expand=0) |
0 | 290 self.keyhints = keyhintrow |
520 | 291 |
0 | 292 def setup_key_nudgers(self, tkobject): |
293 for d, keys in nudge_keys.items(): | |
294 for key in keys: | |
295 # lowercase makes full=0 | |
296 keysym = "<KeyPress-%s>" % key | |
297 tkobject.bind(keysym, \ | |
298 lambda evt, num=keys.index(key), d=d: \ | |
299 self.got_nudger(num, d)) | |
300 | |
301 # uppercase makes full=1 | |
302 keysym = "<KeyPress-%s>" % key.upper() | |
303 keysym = keysym.replace('SEMICOLON', 'colon') | |
304 tkobject.bind(keysym, \ | |
305 lambda evt, num=keys.index(key), d=d: \ | |
306 self.got_nudger(num, d, full=1)) | |
307 | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
308 # Row changing: |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
309 # Page dn, C-n, and ] do down |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
310 # Page up, C-p, and ' do up |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
311 for key in '<Prior> <Next> <Control-n> <Control-p> ' \ |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
312 '<Key-bracketright> <Key-apostrophe>'.split(): |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
313 tkobject.bind(key, self.change_row_cb) |
0 | 314 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
315 def change_row_cb(self, event): |
0 | 316 diff = 1 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
317 if event.keysym in ('Prior', 'p', 'bracketright'): |
0 | 318 diff = -1 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
319 self.change_row(self.current_row + diff) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
320 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
321 def rowFromGraph(self): |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
322 self.change_row(int(self.graph.value(self.session, L9['currentRow'], default=0)), fromGraph=True) |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
323 |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
324 def change_row(self, row, fromGraph=False): |
0 | 325 old_row = self.current_row |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
326 self.current_row = row |
0 | 327 self.current_row = max(0, self.current_row) |
328 self.current_row = min(len(self.rows) - 1, self.current_row) | |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
329 try: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
330 row = self.rows[self.current_row] |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
331 except IndexError: |
810 | 332 # if we're mid-load, this row might still appear soon. If |
333 # we changed interactively, the user is out of bounds and | |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
334 # needs to be brought back in |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
335 if fromGraph: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
336 return |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
337 raise |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
338 |
0 | 339 self.unhighlight_row(old_row) |
340 self.highlight_row(self.current_row) | |
341 self.keyhints.pack_configure(before=row) | |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
342 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
343 if not fromGraph: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
344 self.graph.patchObject(self.session, self.session, L9['currentRow'], |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
345 Literal(self.current_row)) |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
346 |
393
e43dcabbf9ba
keyboardcomposer: fix hw slider off by one bug
David McClosky <dmcc@bigasterisk.com>
parents:
392
diff
changeset
|
347 for col in range(1, 9): |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
348 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
349 subbox = self.slider_table[(self.current_row, col - 1)] |
474
c4807e96ee90
KC was sending values that didn't match bcf2000 api
drewp@bigasterisk.com
parents:
459
diff
changeset
|
350 self.sliders.valueOut("button-upper%d" % col, True) |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
351 except KeyError: |
376
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
352 # unfilled bottom row has holes (plus rows with incomplete |
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
353 # groups |
474
c4807e96ee90
KC was sending values that didn't match bcf2000 api
drewp@bigasterisk.com
parents:
459
diff
changeset
|
354 self.sliders.valueOut("button-upper%d" % col, False) |
385
e6f5ffb6a1b4
keyboardcomposer: zero hw sliders not used by row
David McClosky <dmcc@bigasterisk.com>
parents:
384
diff
changeset
|
355 self.sliders.valueOut("slider%d" % col, 0) |
376
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
356 continue |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
357 self.send_to_hw(sub=subbox.sub, hwCol=col, |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
358 boxRow=self.current_row) |
821 | 359 |
0 | 360 def got_nudger(self, number, direction, full=0): |
395
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
361 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
362 subbox = self.slider_table[(self.current_row, number)] |
395
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
363 except KeyError: |
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
364 return |
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
365 |
0 | 366 if direction == 'up': |
367 if full: | |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
368 subbox.scale.fade(1) |
0 | 369 else: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
370 subbox.scale.increase() |
0 | 371 else: |
372 if full: | |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
373 subbox.scale.fade(0) |
0 | 374 else: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
375 subbox.scale.decrease() |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
376 |
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
377 def hw_slider_moved(self, col, value): |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
378 value = int(value * 100) / 100 |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
379 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
380 subbox = self.slider_table[(self.current_row, col)] |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
381 except KeyError: |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
382 return # no slider assigned at that column |
1003
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
383 |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
384 if hasattr(self, 'pendingHwSet'): |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
385 import twisted.internet.error |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
386 try: |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
387 self.pendingHwSet.cancel() |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
388 except twisted.internet.error.AlreadyCalled: |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
389 pass |
b9aec3be2b8c
hw sliders send events in a way that piles up and we get big delays. this is a simple throttle that stops the pileup but interactivity is still bumpy
drewp@bigasterisk.com
parents:
956
diff
changeset
|
390 self.pendingHwSet = reactor.callLater(.01, subbox.slider_var.set, value) |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
391 |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
392 def send_to_hw(self, sub, hwCol, boxRow): |
366 | 393 if isinstance(self.sliders, DummySliders): |
394 return | |
821 | 395 |
1390 | 396 assert isinstance(sub, URIRef), repr(sub) |
955
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
397 |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
398 if boxRow != self.current_row: |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
399 return |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
400 |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
401 try: |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
402 level = self.get_levels()[sub] |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
403 except KeyError: |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
404 log.warn("%r not in %r", sub, self.get_levels()) |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
405 raise |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
406 v = round(127 * level) |
c0f7fc86f89b
fix up hardware sliders in KC. big mess now
drewp@bigasterisk.com
parents:
948
diff
changeset
|
407 chan = "slider%s" % hwCol |
821 | 408 |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
409 # workaround for some rounding issue, where we receive one |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
410 # value and then decide to send back a value that's one step |
368
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
411 # lower. -5 is a fallback for having no last value. hopefully |
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
412 # we won't really see it |
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
413 if abs(v - self.sliders.lastValue.get(chan, -5)) <= 1: |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
414 return |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
415 self.sliders.valueOut(chan, v) |
821 | 416 |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
417 def make_row(self, group): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
418 """group is a URI or None""" |
1390 | 419 row = tk.Frame(self, bd=2, bg='black') |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
420 row.subGroup = group |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
421 def onDrop(ev): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
422 self.change_group(sub=URIRef(ev.data), row=row) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
423 return "link" |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
424 |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
425 dropTargetRegister(row, onDrop=onDrop, typeList=['*'], |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
426 hoverStyle=dict(background="#555500")) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
427 |
1390 | 428 row.pack(expand=1, fill=tk.BOTH) |
0 | 429 self.setup_key_nudgers(row) |
430 self.rows.append(row) | |
431 return row | |
432 | |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
433 def change_group(self, sub, row): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
434 """update this sub's group, and maybe other sub groups as needed, so |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
435 this sub displays in this row""" |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
436 group = row.subGroup |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
437 self.graph.patchObject( |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
438 context=self.session, |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
439 subject=sub, predicate=L9['group'], newObject=group) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
440 |
0 | 441 def highlight_row(self, row): |
442 row = self.rows[row] | |
443 row['bg'] = 'red' | |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
444 |
0 | 445 def unhighlight_row(self, row): |
446 row = self.rows[row] | |
146 | 447 row['bg'] = 'black' |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
448 |
0 | 449 def get_levels(self): |
821 | 450 return dict([(uri, box.slider_var.get()) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
451 for uri, box in self.subbox.items()]) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
452 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
453 def get_output_settings(self): |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
454 outputSettings = [] |
956
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
455 for setting in graph.objects(self.session, L9['subSetting']): |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
456 effect = graph.value(setting, L9['sub']) |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
457 strength = graph.value(setting, L9['level']) |
1429
01dd3928b635
KC can now fade in effects, which can be read from the graph
Drew Perttula <drewp@bigasterisk.com>
parents:
1427
diff
changeset
|
458 if strength: |
1499
0e746743dd0f
effects should also get noteTime for doing one-shot stuff
drewp@bigasterisk.com
parents:
1479
diff
changeset
|
459 now = time.time() |
1429
01dd3928b635
KC can now fade in effects, which can be read from the graph
Drew Perttula <drewp@bigasterisk.com>
parents:
1427
diff
changeset
|
460 outputSettings.extend( |
01dd3928b635
KC can now fade in effects, which can be read from the graph
Drew Perttula <drewp@bigasterisk.com>
parents:
1427
diff
changeset
|
461 self.effectEval[effect].outputFromEffect( |
1499
0e746743dd0f
effects should also get noteTime for doing one-shot stuff
drewp@bigasterisk.com
parents:
1479
diff
changeset
|
462 [(L9['strength'], strength)], |
0e746743dd0f
effects should also get noteTime for doing one-shot stuff
drewp@bigasterisk.com
parents:
1479
diff
changeset
|
463 songTime=now, |
0e746743dd0f
effects should also get noteTime for doing one-shot stuff
drewp@bigasterisk.com
parents:
1479
diff
changeset
|
464 # should be counting from when you bumped up from 0 |
0e746743dd0f
effects should also get noteTime for doing one-shot stuff
drewp@bigasterisk.com
parents:
1479
diff
changeset
|
465 noteTime=now)) |
956
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
466 |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
467 return outputSettings |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
468 |
146 | 469 def save_current_stage(self, subname): |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1390
diff
changeset
|
470 raise NotImplementedError |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
471 log.info("saving current levels as %s", subname) |
956
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
472 with self.graph.currentState() as current: |
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
473 sub = self.get_levels_as_sub(graph=current) |
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
474 |
901884392e24
KC wasn't sending dmx whenever anything changed, only on a periodic keepalive timer
drewp@bigasterisk.com
parents:
955
diff
changeset
|
475 log.debug("new sub for reference: %r", sub) |
947 | 476 |
477 newUri = showconfig.showUri() + "/sub/%s" % subname | |
478 ps = PersistentSubmaster(self.graph, newUri) | |
479 ps.changeName(subname) | |
480 for chanName, v in sub.get_levels().items(): | |
481 chan = get_channel_uri(str(chanName)) | |
482 ps.editLevel(chan, v) | |
483 | |
484 self.sub_name.delete(0, tk.END) | |
485 | |
136 | 486 def send_frequent_updates(self): |
487 """called when we get a fade -- send events as quickly as possible""" | |
488 if time.time() <= self.stop_frequent_update_time: | |
489 self.send_levels() | |
490 self.after(10, self.send_frequent_updates) | |
146 | 491 |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
492 def alltozero(self): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
493 for uri, subbox in self.subbox.items(): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
494 if subbox.scale.scale_var.get() != 0: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
495 subbox.scale.fade(value=0.0, length=0) |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
496 |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
497 # move to web lib |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
498 def postArgGetter(request): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
499 """return a function that takes arg names and returns string |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
500 values. Supports args encoded in the url or in postdata. No |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
501 support for repeated args.""" |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
502 # this is something nevow normally does for me |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
503 request.content.seek(0) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
504 fields = cgi.FieldStorage(request.content, request.received_headers, |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
505 environ={'REQUEST_METHOD': 'POST'}) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
506 def getArg(n): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
507 try: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
508 return request.args[n][0] |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
509 except KeyError: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
510 return fields[n].value |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
511 return getArg |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
512 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
513 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
514 class LevelServerHttp(resource.Resource): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
515 isLeaf = True |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
516 def __init__(self,name_to_subbox): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
517 self.name_to_subbox = name_to_subbox |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
518 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
519 def render_POST(self, request): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
520 arg = postArgGetter(request) |
821 | 521 |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
522 if request.path == '/fadesub': |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
523 # fadesub?subname=scoop&level=0&secs=.2 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
524 self.name_to_subbox[arg('subname')].scale.fade( |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
525 float(arg('level')), |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
526 float(arg('secs'))) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
527 return "set %s to %s" % (arg('subname'), arg('level')) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
528 else: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
529 raise NotImplementedError(repr(request)) |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
530 |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
531 class Sliders(BCF2000): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
532 def __init__(self, kc): |
1266
1b6583740f76
prefer the later midi device. i don't what the other one is
drewp@bigasterisk.com
parents:
1265
diff
changeset
|
533 devices = ['/dev/snd/midiC3D0', '/dev/snd/midiC2D0', '/dev/snd/midiC1D0'] |
676
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
534 for dev in devices: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
535 try: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
536 BCF2000.__init__(self, dev=dev) |
1390 | 537 except IOError: |
676
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
538 if dev is devices[-1]: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
539 raise |
724
27fdbe9a8118
fix sliders device search
Drew Perttula <drewp@bigasterisk.com>
parents:
721
diff
changeset
|
540 else: |
27fdbe9a8118
fix sliders device search
Drew Perttula <drewp@bigasterisk.com>
parents:
721
diff
changeset
|
541 break |
676
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
542 |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
543 self.kc = kc |
1169 | 544 log.info('found sliders on %s', dev) |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
545 def valueIn(self, name, value): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
546 kc = self.kc |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
547 if name.startswith("slider"): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
548 kc.hw_slider_moved(int(name[6:]) - 1, value / 127) |
382
75213189881e
keyboardcomposer: ignore button-upper presses
David McClosky <dmcc@bigasterisk.com>
parents:
379
diff
changeset
|
549 elif name.startswith("button-upper"): |
75213189881e
keyboardcomposer: ignore button-upper presses
David McClosky <dmcc@bigasterisk.com>
parents:
379
diff
changeset
|
550 kc.change_row(kc.current_row) |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
551 elif name.startswith("button-lower"): |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
552 col = int(name[12:]) - 1 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
553 self.valueOut(name, 0) |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
554 try: |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
555 tkslider = kc.slider_table[(kc.current_row, col)] |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
556 except KeyError: |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
557 return |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
558 |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
559 slider_var = tkslider.slider_var |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
560 if slider_var.get() == 1: |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
561 slider_var.set(0) |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
562 else: |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
563 slider_var.set(1) |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
564 elif name.startswith("button-corner"): |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
565 button_num = int(name[13:]) - 1 |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
566 if button_num == 1: |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
567 diff = -1 |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
568 elif button_num == 3: |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
569 diff = 1 |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
570 else: |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
571 return |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
572 |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
573 kc.change_row(kc.current_row + diff) |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
574 self.valueOut(name, 0) |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
575 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
576 def launch(opts, root, graph, session): |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
577 tl = toplevelat("Keyboard Composer - %s" % opts.session, |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
578 existingtoplevel=root, graph=graph, session=session) |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
579 |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
580 kc = KeyboardComposer(tl, graph, session, |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
581 hw_sliders=not opts.no_sliders) |
1390 | 582 kc.pack(fill=tk.BOTH, expand=1) |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
583 |
948 | 584 for helpline in ["Bindings: B3 mute"]: |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
585 tk.Label(root,text=helpline, font="Helvetica -12 italic", |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
586 anchor='w').pack(side='top',fill='x') |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
587 |
0 | 588 if __name__ == "__main__": |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
589 parser = OptionParser() |
394
0c33ea7d523d
keyboardcomposer: sliders default to true
David McClosky <dmcc@bigasterisk.com>
parents:
393
diff
changeset
|
590 parser.add_option('--no-sliders', action='store_true', |
430 | 591 help="don't attach to hardware sliders") |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
592 clientsession.add_option(parser) |
570
5037fa2c9983
fix how KC reads its graphs. switch to logging lib and add -v flag
drewp@bigasterisk.com
parents:
559
diff
changeset
|
593 parser.add_option('-v', action='store_true', help="log info level") |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
594 opts, args = parser.parse_args() |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
595 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
596 log.setLevel(logging.INFO if opts.v else logging.WARN) |
570
5037fa2c9983
fix how KC reads its graphs. switch to logging lib and add -v flag
drewp@bigasterisk.com
parents:
559
diff
changeset
|
597 |
1114
a38955ba6f40
rdfdb port is now in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
1003
diff
changeset
|
598 graph = SyncedGraph(networking.rdfdb.url, "keyboardcomposer") |
0 | 599 |
821 | 600 # i think this also needs delayed start (like subcomposer has), to have a valid graph |
601 # before setting any stuff from the ui | |
602 | |
1390 | 603 root = tk.Tk() |
734
d230824728aa
drag submasters out of keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
733
diff
changeset
|
604 initTkdnd(root.tk, 'tkdnd/trunk/') |
810 | 605 |
815
d7f1f868eb6c
toplevel window pos is saved in the graph. Patch conflicts no longer break as hard, but they don't exactly reset themselves right yet eiher
drewp@bigasterisk.com
parents:
814
diff
changeset
|
606 session = clientsession.getUri('keyboardcomposer', opts) |
d7f1f868eb6c
toplevel window pos is saved in the graph. Patch conflicts no longer break as hard, but they don't exactly reset themselves right yet eiher
drewp@bigasterisk.com
parents:
814
diff
changeset
|
607 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
608 graph.initiallySynced.addCallback( |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
609 lambda _: launch(opts, root, graph, session)) |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
610 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
611 root.protocol('WM_DELETE_WINDOW', reactor.stop) |
821 | 612 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
613 tksupport.install(root,ms=10) |
1169 | 614 prof.run(reactor.run, profile=None) |