| Home | Trees | Indices | Help |
|---|
|
|
1 #Embedded file name: /Users/versonator/Hudson/live/Projects/AppLive/Resources/MIDI Remote Scripts/_Framework/TrackEQComponent.py
2 import Live
3 from ControlSurfaceComponent import ControlSurfaceComponent
4 from EncoderElement import EncoderElement
5 from _Generic.Devices import get_parameter_by_name
6 EQ_DEVICES = {'Eq8': {'Gains': [ '%i Gain A' % (index + 1) for index in range(8) ]},
7 'FilterEQ3': {'Gains': ['GainLo', 'GainMid', 'GainHi'],
8 'Cuts': ['LowOn', 'MidOn', 'HighOn']}}
9
11 """ Class representing a track's EQ, it attaches to the last EQ device in the track """
12
14 ControlSurfaceComponent.__init__(self)
15 self._track = None
16 self._device = None
17 self._gain_controls = None
18 self._cut_buttons = None
19
21 if self._gain_controls != None:
22 for control in self._gain_controls:
23 control.release_parameter()
24
25 self._gain_controls = None
26 if self._cut_buttons != None:
27 for button in self._cut_buttons:
28 button.remove_value_listener(self._cut_value)
29
30 self._cut_buttons = None
31 if self._track != None:
32 self._track.remove_devices_listener(self._on_devices_changed)
33 self._track = None
34 self._device = None
35 if self._device != None:
36 device_dict = EQ_DEVICES[self._device.class_name]
37 if 'Cuts' in device_dict.keys():
38 cut_names = device_dict['Cuts']
39 for cut_name in cut_names:
40 parameter = get_parameter_by_name(self._device, cut_name)
41 if parameter != None and parameter.value_has_listener(self._on_cut_changed):
42 parameter.remove_value_listener(self._on_cut_changed)
43
45 self.update()
46
48 if not (track == None or isinstance(track, Live.Track.Track)):
49 raise AssertionError
50 if self._track != None:
51 self._track.remove_devices_listener(self._on_devices_changed)
52 if self._gain_controls != None and self._device != None:
53 for control in self._gain_controls:
54 control.release_parameter()
55
56 self._track = track
57 self._track != None and self._track.add_devices_listener(self._on_devices_changed)
58 self._on_devices_changed()
59
73
75 raise controls != None or AssertionError
76 raise isinstance(controls, tuple) or AssertionError
77 if self._device != None and self._gain_controls != None:
78 for control in self._gain_controls:
79 control.release_parameter()
80
81 for control in controls:
82 raise control != None or AssertionError
83 raise isinstance(control, EncoderElement) or AssertionError
84
85 self._gain_controls = controls
86 self.update()
87
89 if self.is_enabled() and self._device != None:
90 device_dict = EQ_DEVICES[self._device.class_name]
91 if self._gain_controls != None:
92 gain_names = device_dict['Gains']
93 for index in range(len(self._gain_controls)):
94 self._gain_controls[index].release_parameter()
95 if len(gain_names) > index:
96 parameter = get_parameter_by_name(self._device, gain_names[index])
97 if parameter != None:
98 self._gain_controls[index].connect_to(parameter)
99
100 if self._cut_buttons != None and 'Cuts' in device_dict.keys():
101 cut_names = device_dict['Cuts']
102 for index in range(len(self._cut_buttons)):
103 self._cut_buttons[index].turn_off()
104 if len(cut_names) > index:
105 parameter = get_parameter_by_name(self._device, cut_names[index])
106 if parameter != None:
107 if parameter.value == 0.0:
108 self._cut_buttons[index].turn_on()
109 if not parameter.value_has_listener(self._on_cut_changed):
110 parameter.add_value_listener(self._on_cut_changed)
111
112 else:
113 if self._cut_buttons != None:
114 for button in self._cut_buttons:
115 if button != None:
116 button.turn_off()
117
118 if self._gain_controls != None:
119 for control in self._gain_controls:
120 control.release_parameter()
121
123 if not sender in self._cut_buttons:
124 raise AssertionError
125 if not value in range(128):
126 raise AssertionError
127 if self.is_enabled() and self._device != None:
128 if not sender.is_momentary() or value is not 0:
129 device_dict = EQ_DEVICES[self._device.class_name]
130 if 'Cuts' in device_dict.keys():
131 cut_names = device_dict['Cuts']
132 index = list(self._cut_buttons).index(sender)
133 parameter = index in range(len(cut_names)) and get_parameter_by_name(self._device, cut_names[index])
134 parameter.value = parameter != None and parameter.is_enabled and float(int(parameter.value + 1) % 2)
135
137 if self._device != None:
138 device_dict = EQ_DEVICES[self._device.class_name]
139 if 'Cuts' in device_dict.keys():
140 cut_names = device_dict['Cuts']
141 for cut_name in cut_names:
142 parameter = get_parameter_by_name(self._device, cut_name)
143 if parameter != None and parameter.value_has_listener(self._on_cut_changed):
144 parameter.remove_value_listener(self._on_cut_changed)
145
146 self._device = None
147 if self._track != None:
148 for index in range(len(self._track.devices)):
149 device = self._track.devices[-1 * (index + 1)]
150 if device.class_name in EQ_DEVICES.keys():
151 self._device = device
152 break
153
154 self.update()
155
157 if not self._device != None:
158 raise AssertionError
159 raise 'Cuts' in EQ_DEVICES[self._device.class_name].keys() or AssertionError
160 cut_names = self.is_enabled() and self._cut_buttons != None and EQ_DEVICES[self._device.class_name]['Cuts']
161 for index in range(len(self._cut_buttons)):
162 self._cut_buttons[index].turn_off()
163 if len(cut_names) > index:
164 parameter = get_parameter_by_name(self._device, cut_names[index])
165 if parameter != None and parameter.value == 0.0:
166 self._cut_buttons[index].turn_on()
167
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Wed Mar 6 18:53:32 2013 | http://epydoc.sourceforge.net |