Using the Akai APC mini to control Sonic Pi

Hi!

I have an Akai APC mini controller that I use with Sonic Pi and over the weekend I spent some time polishing the utility functions I use, in order to share them, in case someone finds them useful. I guess it would be possible to make it more generic to support more controllers, but since it’s the only device I have access to, and all I know about MIDI is what I learnt to write this, I thought I’d better start with something completely coupled to this model, and then maybe extend it in the future.

Usual disclaimer, It Works On My Computer [1], etc. Any feedback is welcome, and I hope it helps someone. Also, thanks to everyone that ever wrote anything about the MIDI topic on this website, I have probably read your post over the last weeks and it sure helped me :heart:

Happy coding!

[1] And as you can read in the docs, not perfectly :sweat_smile:

1 Like

Thanks for sharing! And congratulations :+1:
I will try asap
Again bravo !

That’d be very kind! I’ve tested it in a grand total of 1 computer so I’m afraid of having some tiny detail completely coupled to it (e.g. the name of the generated MIDI events). Knowing what can change in other computers would be very helpful. Please feel free to file issues in the repo if something is broken in your setup.

hello,

may i suggest you to add an example file we can load, something like start.rb with the minimal code to get some sounds quicky and show us the main features.
Actually i own an AKAI Professional APC Key 25. Do you think it will work ?
Thanks

@nlb - have you seen David’s Fiddle’s YouTube video/blog post about his APC key 25 Sonic Pi script?
(A few years old now, but should hopefully not be broken! It wouldn’t be too hard to get it working again regardless)

yes @ethancrawford i have seen this project and i have started mine but always " work in progress" until death frees me :slight_smile:

1 Like

Great idea with the example, I’ll do that asap.

I think it wouldn’t be difficult to modify the code so that it supports more controllers, but I don’t think it would work “as is”. In the way I see it, the initialize_akai method could accept a parameter to select a model, which would configure a number of things that need to be slightly different:

  • The name of the MIDI events (this is trivial but needs to be done)
  • How many controls of each type there is, and which note number do they use. For example, the mini has a grid of 8x8 buttons which use the notes 0-63 (while the key 25, from what I see in pics, has only half of those, and I don’t know which notes they use), 9 faders (the key 25 has 8), etc. This is simple stuff but needs to be in the code that calculates midi note → button/fader/light and the other way around
  • The functionality to “free play” needs to work differently (probably enough to be a different function): on one hand, it doesn’t make sense to assign notes to keys like I do for the mini, because a piano key already has a corresponding note. And on the other, currently velocity information is ignored because the mini doesn’t have it (a button is either pressed or not). It would make sense to use that information with the key 25

So, to summarize, most of the code could be reused, but not exactly as it is, and I don’t have any other device so it’s kind of tricky for me to implement it :roll_eyes: If you happen to modify my script to make it work with your device, I would be very happy to get your changes and work on a single version that works with both models.

Cheers!

hum i can help testing but ruby is a foreign language to me :frowning:
i have read a little your code and not sure i can understand all this stuff :slight_smile:

a grid of 5 rows and 8 colums : notes 0-39 and some other differences…

i guess you talk about the midi port Name ?
Indeed it will be better if they were stored into variables :slight_smile:

Good luck

Yes I meant the midi port. Showing off that I know close to nothing about midi :sweat_smile:

Thinking about it, I think that information should be enough to give it a try. I’ll probably have some time next weekend. May I ask you to check your device for the following?:

  • Midi port name
  • Range in Midi notes covered by the faders
  • Range in Midi notes covered by the keyboard + do they send different velocity depending on how hard you press? + do they send note_off when released?

That would be super helpful!