First attempt at ctrldev for Akai LPD8

Hi all,

I’m trying to get my first ctrldev driver going.
I have an Akai LPD8 and I want to use the pots as a replacement for the encoders.

This part works fine.

But, as soon as the driver is loaded, no MIDI messages get through to the chain itself, so the pads no longer produce any sound.
In fact, even with a completely empty midi_event function this happens. I tried to end the function with return True and with super().midi_event(ev) but nothing works.
I think I’m missing something basic.

(The __init__ function sends a sysex to color the pads.)

My code:

EDIT: Code replaced. This is the working version

# Zynthian specific modules
from zyncoder.zyncore import lib_zyncore
from zyngine.ctrldev.zynthian_ctrldev_base import zynthian_ctrldev_zynmixer

# --------------------------------------------------------------------------
# AKAI LPD8 potmeters as encoder
# --------------------------------------------------------------------------

class zynthian_ctrldev_akai_lpd8_mk2(zynthian_ctrldev_zynmixer):

        dev_ids = ["LPD8 mk2 IN 1"]

        # Make sure the midi events reach the chains
        unroute_from_chains = False
        #unroute_from_chains = 0b0000001000000000  # Unroute channel 10

        # Function to initialise class
        # Sets RGB colors for the pads
        def __init__(self, state_manager, idev_in, idev_out):
                super().__init__(state_manager, idev_in, idev_out)
                if self.idev_out is not None:
                        msg = bytes.fromhex(f"F0 47 7F 4C 06 00 30 7F 7F 00 00 00 00 7F 7F 00 3F 00 00 7F 7F 7F 7F 00 00 00 00 7F 7F 00 00 00 00 3F 3F 7F 7F 00 00 00 00 7F 7F 3F 3F 00 00 7F 7F 7F 7F 00 00 00 3F F7")
                        lib_zyncore.dev_send_midi_event(self.idev_out, msg, len(msg))

        def midi_event(self, ev):
                evtype = (ev[0] >> 4) & 0x0F
                channel = ev[0] & 0x0F
                ccnum = ev[1] & 0x7F
                ccval = ev[2] & 0x7F

                if evtype == 0xB:

                        if ccnum == 70:
                                self.state_manager.send_cuia("ZYNPOT_ABS", params=[0, ccval / 127])

                        elif ccnum == 71:
                                self.state_manager.send_cuia("ZYNPOT_ABS", params=[1, ccval / 127])

                        elif ccnum == 72:
                                self.state_manager.send_cuia("ZYNPOT_ABS", params=[2, ccval / 127])

                        elif ccnum == 73:
                                self.state_manager.send_cuia("ZYNPOT_ABS", params=[3, ccval / 127])

# ------------------------------------------------------------------------------

Kind regards,
Hans.

Hello Hans

I am myself working on a ctrl driver for Novation LaunchPAD MK3 and I had similar problems

(great)Thanks to @riban .

I think you need to use a threading system for you pots emulation , otherwise no other task can perform

You can check my post called Autorepeat CUIA in a ctrl driver (work in progress) - #19 by riban

Hope it can help

Regards

Alain

Hello Alain,

I don’t think I need threading here.

The problem lies in not propagating the MIDI event when it is not handled.

If you would need threading in this situation, that would be bad driver design and @jofemodo and @riban don’t do bad design :grin:

Kind regards,
Hans.

Hi @HansR !

By default, drivers unroute the device from chains. You can route all channels by adding this to your class:

unroute_from_chains = False

Or do it selectively, by MIDI channel, using a mask:

unroute_from_chains = 0b0000001000000000 # Unroute channel 10

Regards,

1 Like

Thanks @jofemodo, it works great now, even including poly aftertouch.

I’m glad my blind trust in you is justified :grinning_face:

Kind regards,
Hans.

2 Likes

Glad for you .@HansR

I did not notice that you used CUIA :ZYNPOT_ABS that ,I suppose is able to understand a changing CCval (it will be very useful to build a driver for my Arturia Keystep 37)

For my LP MK3 driver I use CUIA :ZYNPOT and needed the thread system as explained by @riban

to avoid blocking other process.

Learning … Learning :man_student:

1 Like

Hi @AL1-1956

Yes, as the name suggests, it sets an absolute value. CUIA:ZYNPOT increases or decreases the value of the pot with the number (positive or negative) you specify. ZYNPOT_ABS sets the pot to the value specified.

I don’t know if this works for your use case (I don’t use sequencers) but for engine settings it works great, the white dot indicates the current setting of the potmeter, you move it to the higher part of the indicator to “pick it up” and then you set the value you desire. Works brilliantly!

I do try but @jofemodo keeps telling me off.

Did I do that? I forgot it was deployed.

Apparently, please leave it in, it’s brilliant!

2 Likes

Hello @HansR

By adapting your code I have build a (very basic) driver for Arturia KeyStep 37

So I can control parameters of synths (ADSR , Cutoff , Res …) as long as the 4 parameters

I want to control are in the same page of 4 and it works great :winking_face_with_tongue:

To use the keyboard of the KS37 I had to authorize routing from chains

The CCs I am using are 80 81 82 83 (Bank 4)

so I hope there will not be side effects.

Regards

Alain

You can add favourite controllers that appear on pages at the top of the chain list which can allow you to have whichever four controller you want on the same page, even from different processors!

Hi @AL1-1956 ,

CC 80-83 are defined as “General Purpose Controllers”, although they are often described as on/off switches (I think Roland started that).

I used CC 70-73 because that was the default for my Akai (quick and dirty to see if it worked), but I’m going to move them to 22-25, these are documented as “Undefined”.

This sounds interesting, but I don’t understand it. Can you give an example?

This is a cool feature, you access it by boldpushing the encoder that is “paired” with the controller you want to favour, theres a checkbox, i think it is called something else than “Favourite Something”
Then if yoy scroll up through the pages of controllers all the way to the top, your favourite controller will be on the very first page of controllers, and you can add more
I’m away from Z so can not send screendump

EDIT; i’m on vangelis if it makes a difference

Thanks @core.east, this is very cool indeed!

When you bold press an encoder, a Control options screen opens (the same one where you can also unlearn midi). The top line is Chain Controller. If you check that a new settings item is opened called CHAIN and the checked controllers are added there.

This is in Oram Stable.

1 Like

The right name is “Chain Controllers”.
I chose this name because it’s list of controllers you can choose for each chain and they are displayed at top. You can see this as your “favorite controllers for each chain”.

Also, they have special meaning in some ctrldev drivers, like the Akai APC40, that uses the “Chain Controllers” for the strip top encoders when “user” mode is selected.

Regards

1 Like