Mercurial > code > home > repos > light9
comparison bin/keyboardcomposer @ 362:fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Fri, 15 Jun 2007 06:04:55 +0000 |
parents | bd8a89743226 |
children | 430014be95ce |
comparison
equal
deleted
inserted
replaced
361:ff914126f3ea | 362:fc87327e29c4 |
---|---|
60 | 60 |
61 def launch_subcomposer(self, *args): | 61 def launch_subcomposer(self, *args): |
62 subprocess.Popen(["bin/subcomposer", self.name]) | 62 subprocess.Popen(["bin/subcomposer", self.name]) |
63 | 63 |
64 class KeyboardComposer(Frame, SubClient): | 64 class KeyboardComposer(Frame, SubClient): |
65 def __init__(self, root, submasters, current_sub_levels=None): | 65 def __init__(self, root, submasters, current_sub_levels=None, |
66 hw_sliders=False): | |
66 Frame.__init__(self, root, bg='black') | 67 Frame.__init__(self, root, bg='black') |
67 SubClient.__init__(self) | 68 SubClient.__init__(self) |
68 self.submasters = submasters | 69 self.submasters = submasters |
69 self.name_to_subtk = {} | 70 self.name_to_subtk = {} |
70 self.current_sub_levels = {} | 71 self.current_sub_levels = {} |
75 self.current_sub_levels = \ | 76 self.current_sub_levels = \ |
76 pickle.load(file('.keyboardcomposer.savedlevels')) | 77 pickle.load(file('.keyboardcomposer.savedlevels')) |
77 except IOError: | 78 except IOError: |
78 pass | 79 pass |
79 | 80 |
81 self.connect_to_hw(hw_sliders) | |
80 self.draw_ui() | 82 self.draw_ui() |
81 self.send_levels_loop() | 83 self.send_levels_loop() |
84 | |
82 def draw_ui(self): | 85 def draw_ui(self): |
83 self.rows = [] # this holds Tk Frames for each row | 86 self.rows = [] # this holds Tk Frames for each row |
84 self.slider_vars = {} # this holds subname:sub Tk vars | 87 self.slider_vars = {} # this holds subname:sub Tk vars |
85 self.slider_table = {} # this holds coords:sub Tk vars | 88 self.slider_table = {} # this holds coords:sub Tk vars |
86 self.name_to_subtk.clear() # subname : SubmasterTk instance | 89 self.name_to_subtk.clear() # subname : SubmasterTk instance |
87 self.current_row = 0 | 90 self.current_row = 0 |
88 | 91 |
89 self.connect_to_hw() | |
90 self.make_key_hints() | 92 self.make_key_hints() |
91 self.draw_sliders() | 93 self.draw_sliders() |
92 self.highlight_row(self.current_row) | 94 self.highlight_row(self.current_row) |
93 self.rows[self.current_row].focus() | 95 self.rows[self.current_row].focus() |
94 | 96 |
106 self.save_stage_button.pack(side=LEFT) | 108 self.save_stage_button.pack(side=LEFT) |
107 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') | 109 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') |
108 self.sub_name.pack(side=LEFT) | 110 self.sub_name.pack(side=LEFT) |
109 self.stop_frequent_update_time = 0 | 111 self.stop_frequent_update_time = 0 |
110 | 112 |
111 def connect_to_hw(self): | 113 def connect_to_hw(self, hw_sliders): |
112 try: | 114 if hw_sliders: |
113 self.sliders = Sliders(self.hw_slider_moved) | 115 self.sliders = Sliders(self.hw_slider_moved) |
114 except IOError: | 116 else: |
115 class dummy: | 117 class dummy: |
116 def valueOut(self, name, value): | 118 def valueOut(self, name, value): |
117 pass | 119 pass |
118 self.sliders = dummy() | 120 self.sliders = dummy() |
119 print "no hw sliders found" | |
120 | 121 |
121 def make_key_hints(self): | 122 def make_key_hints(self): |
122 keyhintrow = Frame(self) | 123 keyhintrow = Frame(self) |
123 | 124 |
124 col = 0 | 125 col = 0 |
323 | 324 |
324 if __name__ == "__main__": | 325 if __name__ == "__main__": |
325 parser = OptionParser() | 326 parser = OptionParser() |
326 parser.add_option('--nonpersistent', action="store_true", | 327 parser.add_option('--nonpersistent', action="store_true", |
327 help="don't load or save levels") | 328 help="don't load or save levels") |
329 parser.add_option('--sliders', action='store_true', | |
330 help="attach to hardware sliders") | |
328 opts, args = parser.parse_args() | 331 opts, args = parser.parse_args() |
329 | 332 |
330 s = Submasters() | 333 s = Submasters() |
331 | 334 |
332 root = Tk() | 335 root = Tk() |
333 tl = toplevelat("Keyboard Composer", existingtoplevel=root) | 336 tl = toplevelat("Keyboard Composer", existingtoplevel=root) |
334 | 337 |
335 startLevels = None | 338 startLevels = None |
336 if opts.nonpersistent: | 339 if opts.nonpersistent: |
337 startLevels = {} | 340 startLevels = {} |
338 kc = KeyboardComposer(tl, s, startLevels) | 341 kc = KeyboardComposer(tl, s, startLevels, hw_sliders=opts.sliders) |
339 kc.pack(fill=BOTH, expand=1) | 342 kc.pack(fill=BOTH, expand=1) |
340 | 343 |
341 for helpline in ["Bindings: B3 mute; C-l edit levels in subcomposer"]: | 344 for helpline in ["Bindings: B3 mute; C-l edit levels in subcomposer"]: |
342 tk.Label(root,text=helpline, font="Helvetica -12 italic", | 345 tk.Label(root,text=helpline, font="Helvetica -12 italic", |
343 anchor='w').pack(side='top',fill='x') | 346 anchor='w').pack(side='top',fill='x') |