Trying to add support for Akai APC mini

Hey, I’m new to Zynthian, and am interested in adding some midi controller support for the Akai APC mini mk2 (and next MPD 218 if I can figure this one out). I had seen support for the APC Key25, and thought that this wouldn’t be much of a stretch.

I’ve follwed the instructions on the wiki, found the APC Key25 driver, copied that, tweaked it with the correct button assignments, updated the __init__.py, and deleted the python cache file. I restarted both the zynthian process, as well as rebooting the hardware, but it doesn’t seem to be picking up my changes.

I did run into issues (mostly lack of time) trying to remote debug and see if I could figure out if my changes were being loaded. The wiki talks about a .vscode/launch.json file, but I could find neither the directory, nor file on my Zynthian.

My changes are visible here, and should be pretty straightforward.

Any help or pointers would be appreciated. Thanks!

2 Likes

I have at least partially figured it out. The device is lighting up and the mode switching is working.

For debug, I used the web ui, that gave me enough info to figure out that I hadn’t mapped a couple of important buttons, Record and Play. This controller doesn’t have those, so I just set them outside the range, and that did it.

Still more work to do, but the latest commit in my repo makes this thing do something.

1 Like

Hi @ejf! A warm welcome to the community and kudos for jumping in with such a hefty first development. :smile:

VSCode is not installed nor configured by default on zynthian. If you run vscode from another computer, connected via ssh to zynthian then vscode server is installed on the zynthian but the launch.json file is not created automatically. You can manually create it in /zynthian/zynthian-ui/.vscode/ and then it will be available to use for debug from vscode over ssh for the main UI.

It is great that you are making progress with this and there may be others who will benefit. It would be even better if, when you and/or @oscaracena have time - the code were to be abstracted so that it can be extended to support multiple devices. The work that @oscaracena did with integrating the APC Key25 is excellent and it would be great if we had a superset of functionality that could be mapped to subsests within multiple controllers.

Having different codebase for each controller is bloated and requires increased support effort, e.g. if a bug is found in one then it may need patching in all. If there were one class with all/most of the functionality then subclasses for each hardware device we could more rapidly add more devices.

You have most recently been through the fun/pain of figuring out what changes are required (maybe minor because of the similarity of the devices) so may be in a good position to start this abstraction.

Let us know if you need any assistance. Cheers!

5 Likes

I think you are right. If @ejf reaches a working version, I can diff it with the base, and refactor to extract the common factor, so we can DRY it. :slightly_smiling_face:

3 Likes

I’ll take a pass at abstracting and combining the two files. Python is not my native language, so it might be rough comparitively. The only key differences are the button addresses and device name. The APC mini also does not have Play or Record buttons, so I mapped those to values that I think were outside the range (but that may actually have introduced a bug).

On the VSCode issue, it did not automatically create the .vscode/ directory, so knowing that I can just create it where it needs to be and drop in that launch file is helpful. Thanks @riban ! Overall, the wiki was amazing. I haven’t seen one that detailed in a while, and it really sped things up for me and made this very approachable for someone not familliar with the project.

And of course, thank you to @oscaracena for the awesome work on the keys versions of these things, all I needed to do was a bunch of copy/paste on your work.

2 Likes