You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-8Lines changed: 2 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Utils to interface with [Ableton's Push 2](https://www.ableton.com/en/push/) fro
5
5
These utils follow Ableton's [Push 2 MIDI and Display Interface Manual](https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc) for comunicating with Push 2. I recommend reading Ableton's manual before using this tool.
6
6
7
7
So far I only implemented some utils to **interface with the display** and some utils for **basic interaction with pads, buttons, encoders and the touchstrip**. More detailed interaction with each of these elements (e.g. changing color palettes, support for led blinking, advanced touchstrip configuration, etc.) has not been implemented. Contributions are welcome :)
8
+
*EDIT*: customization of color palettes is now implemented!
8
9
9
10
I only testd the package in **Python 3** and **macOS**. Some things will not work on Python 2 but it should be easy to port. I don't know how it will work on Windows/Linux. ~~It is possible that MIDI port names (see [push2_python/constants.py](https://github.com/ffont/push2-python/blob/master/push2_python/constants.py#L12-L13)) need to be changed to correctly reach Push2 in Windows/Linux~~. **UPDATE**: MIDI port names should now be cross-platform, but I have not tested them on Linux/Windows.
All pads support RGB colors, and some buttons do as well. However, some buttons only support black and white. Checkout the MIDI mapping diagram in the
155
156
[Push 2 MIDI and Display Interface Manual](https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc#23-midi-mapping) to see which buttons support RGB and which ones only support black and white. In both cases colors are set using the same method, but the list of available colors for black and white buttons is restricted.
156
157
157
-
For a list of avilable RGB colors check the keys of the `RGB_COLORS` dictionary in [push2_python/constants.py](https://github.com/ffont/push2-python/blob/master/push2_python/constants.py). Similarly, black and white available colors are defined in the `BLACK_WHITE_COLORS` dictionary in the same file. You can also list available colors in code like this:
**NOTE**: The Push 2 Interface Manual provides a way to configure custom color palettes which has not yet been implemented in `push2-python`. Also, only a limited number of colors is included here but many more are avilable in the default color palette.
158
+
For a list of avilable RGB colors check the `DEFAULT_COLOR_PALETTE` dictionary in [push2_python/constants.py](https://github.com/ffont/push2-python/blob/master/push2_python/constants.py). First item of each color entry corresponds to the RGB color name while second item corresponds to the BW color name. The color palette can be customized using the `set_color_palette_entry` and `reapply_color_palette` of Push2 object. See the documentation of these methods for more details.
See https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc#262-rgb-led-color-processing
262
+
"""
263
+
264
+
asserttype(color_idx) ==int, 'Parameter "color_idx" must be an integer'
265
+
assert0<=color_idx<=127, 'Parameter "color_idx" must be in range [0..127]'
266
+
267
+
assertrgbisnotNoneorbwisnotNone, 'At least "rgb" or "bw" parameter (or both) should be provided'
268
+
269
+
ifrgbisnotNone:
270
+
assertlen(rgb) ==3, 'Parameter "rgb" should have 3 elements'
271
+
272
+
iftype(color_name) ==str:
273
+
color_names= [color_name, color_name]
274
+
else:
275
+
assertlen(color_name) ==2, 'Parameter "color_name" should have 2 elements'
276
+
color_names=color_name
277
+
278
+
ifnotallow_overwrite:
279
+
assertcolor_names[0] notin [rgb_color_nameforrgb_color_name, _inself.color_palette.values()], 'A color with name "{0}" for RGB palette already exists'.format(color_names[0])
280
+
assertcolor_names[1] notin [bw_color_namefor_, bw_color_nameinself.color_palette.values()], 'A color with name "{0}" for BW palette already exists'.format(color_names[1])
281
+
282
+
defcheck_color_range(c):
283
+
# If color is float, map it to [0..255], also check range is inside [0..255]
284
+
iftype(c) ==float:
285
+
c=int(round(c*255))
286
+
ifc<0:
287
+
c=0
288
+
elifc>255:
289
+
c=255
290
+
returnc
291
+
292
+
ifrgbisnotNone:
293
+
r=check_color_range(rgb[0])
294
+
g=check_color_range(rgb[1])
295
+
b=check_color_range(rgb[2])
296
+
else:
297
+
# If rgb is not provided, w will have been provided, use this number for all components
298
+
r=check_color_range(bw)
299
+
g=r
300
+
b=r
301
+
302
+
ifbwisnotNone:
303
+
w=check_color_range(bw)
304
+
else:
305
+
# If white is not provided, rgb will have been provided, use an average of it ti decide white
306
+
w=check_color_range(int((r+g+b) /3))
307
+
308
+
# Send message to Push to update internal color palette
0 commit comments