Godtone (talk | contribs)
m →My Python 3 code: trivial dependency fix
Godtone (talk | contribs)
Line 1,279: Line 1,279:
== Novation Launchpad Pro MK3 isomorphic keyboard code ==
== Novation Launchpad Pro MK3 isomorphic keyboard code ==
This code is licensed under the AGPLv3 (https://www.gnu.org/licenses/agpl-3.0.html), a version of the [[wikipedia:Affero General Public License|AGPL]] corresponding to the [[wikipedia:GNU General Public License#Version 3|GPLv3]].
This code is licensed under the AGPLv3 (https://www.gnu.org/licenses/agpl-3.0.html), a version of the [[wikipedia:Affero General Public License|AGPL]] corresponding to the [[wikipedia:GNU General Public License#Version 3|GPLv3]].
'''It should be compatible with any Launchpad that has programmer mode; it has been confirmed to work for the Launchpad X so will likely also work for a Launchpad Mini MK3.'''


NOTE: I discovered it was possible to use custom colour palettes after I'd spent a lot of time making these rainbows using the rather limited and uneven set of factory colours. I haven't tested using this yet, but for those who want to take that route to achieve a more even rainbow, here is the link: https://fw.mat1jaczyyy.com/
NOTE: I discovered it was possible to use custom colour palettes after I'd spent a lot of time making these rainbows using the rather limited and uneven set of factory colours. I haven't tested using this yet, but for those who want to take that route to achieve a more even rainbow, here is the link: https://fw.mat1jaczyyy.com/
Line 1,285: Line 1,287:


IMPORTANT: for the Python 3 code to work, it requires the launchpad to be plugged in with updated firmware and be in programmer mode! Also requires loopMIDI on Windows.
IMPORTANT: for the Python 3 code to work, it requires the launchpad to be plugged in with updated firmware and be in programmer mode! Also requires loopMIDI on Windows.
=== Installation issues/troubleshooting strategies/recommendations: ===
The most potentially difficult part is that depending on what OS you are using, how you have Python installed, what version, etc. there can be complications so that running <code>pip install rtmidi</code> in a terminal does not work. I list potential issues below, so please read carefully for something applicable to your case if it isn't going smoothly.
0. Technically not an issue with rtmidi, but an easy one to solve: you forgot to update the firmware of your launchpad to be up-to-date via the official site: https://components.novationmusic.com/
1. The easiest issue is if you have a version of Python 2 installed (regardless of whether you have Python 3 installed), then sometimes <code>pip</code> and <code>python</code> refer to Python 2, so use <code>pip3</code> and <code>python3</code> instead wherever applicable. Alternatively, if you don't need Python 2, uninstalling it may help.
2. If you installed Python 3 but it doesn't work on command line, maybe you haven't used an official installer, as that usually shouldn't be an issue, or if you did use an official installer, you may not have marked the checkbox that makes it change PATH environment variables for you automatically, in which case adding the location of the Python 3 (and potentially pip) executables should fix it.
3. <code>rtmidi</code> seems to install but there's issues when trying to use it; installing <code>python-rtmidi</code> may help in such a case. That's why I have "pip install mido && pip install python-rtmidi" witha note about the loopMIDI requirement on Windows as the default/simplest installation recommendation present at the beginning of the code where I <code>import mido</code>.
4. If you are getting a long error where towards the end there is <code>error: Microsoft Visual C++ 14.0 or greater is required.</code> (which might happen if you are using an older version of Windows) then try <code>pip install --only-binary :all: rtmidi</code> which will save you a huge amount of trouble if it works. Versions apparently should be available for almost every relevant version of Python 3, so if it isn't, try a different version of Python 3 if you know how. If your system doesn't use Python 3 and you installed it, it should definitely be safe to uninstall the current version.
4.1. I haven't seen this issue, but possibly if <code>pip install --only-binary :all: rtmidi</code> seems to work but then brings an error when trying to use the code, try <code>pip install --only-binary :all: python-rtmidi</code> in case it helps.
5. If you are on Windows, make sure you have [https://www.tobias-erichsen.de/software/loopmidi.html loopMIDI] installed and running with the default port name! (The default name should work; the code searches for a name starting with "loop".)
'''Mix and match these solutions as you find them potentially relevant to your situation, and hopefully you should be able to get it working.'''
Feel free to send me a friend request to ask me for help on Discord (<code>@osmiumic</code>).
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
# this code is licensed under the AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
# this code is licensed under the AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
import math
import math
import mido # pip install mido && pip install python-rtmidi; requires loopMIDI on Windows (using the default name should work; the code searches for a name starting with "loop")
import mido # pip install mido && pip install python-rtmidi; requires loopMIDI on Windows (using the default name should work; the code searches for a name starting with "loop")
# IMPORTANT: if installation of the dependencies of this code isn't working, try: pip install --only-binary :all: rtmidi


def lpselect(of):
def lpselect(of):