# MIDI learning toggle (on/off) parameters doesn't work

**URL:** <https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636>\
**Category:** Using Zynthian\
**Tags:** issue, vangelis\
**Created:** [December 3, 2024, 7:33pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636 "2024-12-03T19:33:41Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 3, 2024, 7:33pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/1 "2024-12-03T19:33:41Z")

</div>

Using the midi CC learning function of Zynthian, I set a lv2 parameter to be controlled by an external device. The lv2 parameter shows the correct midi channel and CC number of the external device on the zynthian screen.

But the lv2 parameter could only be controlled by the external device if CC number is \<= 64.  
If I choose a CC number higher than 64, the parameter could not be controlled by the external device.

Is this a bug or by purpose?

I’m on a just updated vangelis system, sending single CC’s to zynthian via CLI from a connected linux terminal.

Is this enough information? Branches are:  
zyncoder: [vangelis (66fa477)](https://github.com/zynthian/zyncoder/commit/66fa4771e4fd46404a02d19fa5672af97284c59e)  
zynthian-ui: [vangelis (1a44522)](https://github.com/zynthian/zynthian-ui/commit/1a4452272071f721232def156b05d4f78368e2f2)  
zynthian-sys: [vangelis (210c2db)](https://github.com/zynthian/zynthian-sys/commit/210c2dbc9fc0816c1677a95bb58c2def281b4cc5)  
zynthian-data: [vangelis (305b301)](https://github.com/zynthian/zynthian-data/commit/305b30199e4baa508a7b2efa761b82934afd6277)  
zynthian-webconf: [vangelis (e240038)](https://github.com/zynthian/zynthian-webconf/commit/e240038f9e8f76d1cd0e33253441a9f46569d1c8)

Regards

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 4, 2024, 2:14pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/2 "2024-12-04T14:14:47Z")

</div>

I made a screenshot video from what I observed and copied it together with the midi log from zynthian.  
Regards  
[CCexternal-bug.zip](https://discourse.zynthian.org/uploads/short-url/hNHF7Gym2yXDFASvaOmod4mkVTu.zip) (1.1 MB)

---

<div class="post-metadata">

**Author:** ![tunagenes](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/tunagenes/32/7279_2.png) [@tunagenes](https://discourse.zynthian.org/u/tunagenes)\
**Post date:** [December 4, 2024, 2:42pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/3 "2024-12-04T14:42:37Z")

</div>

IMHO this is a clear enough bug that it would make sense to report it via the big button at the bottom of webconf main screen. If @jofemodo or @riban don’t fix it first!

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 4, 2024, 3:19pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/4 "2024-12-04T15:19:34Z")

</div>

Bug report sent!

> <https://github.com/zynthian/zynthian-issue-tracking/issues/1292>
>
> \# Describe the issue
> Using the midi CC learning function of Zynthian, I set a l…v2 parameter to be controlled by an external device. The lv2 parameter shows the correct midi channel and CC number of the external device on the zynthian screen.
> 
> But the lv2 parameter could only be controlled by the external device if CC number is \<= 64.
> If I choose a CC number higher than 64, the parameter could not be controlled by the external device.
> Funny enough, with a continuous change on some CC channels (\>64) it is working, but not if I use a value change from 0 to 127.
> 
> \# To Reproduce
> \## Steps to reproduce the behavior:
> 1. Use external midi device with toggle button / or on/off connected to zynthian
> 2. Midi learn an on/off parameter with the external device (midi channel and number are visible now)
> 3. Toggle on/off button on external device
> 4. midi log shows values (0 -\> 127 -\> 0 -\> 127 -\> 0 ....)
> 5. no change of lv2 parameter
> \## Expected behaviour
> Any CC channel on any midi channel to work after midi learning
> \## Actual behaviour
> See attached video.
> \[CCexternal-bug.zip\](https://github.com/user-attachments/files/18010385/CCexternal-bug.zip)
> 
> \# Configuration
> \## Hardware
> \`\`\`
> Raspberry Pi 5 Model B Rev 1.0
> Audio: V5 ADAC
> Display: MIPI DSI 800x480 (inverted)
> Wiring: V5
> I2C: MCP23017@0x20, MCP23017@0x21
> Profile: v5
> \`\`\`
> \## System
> \`\`\`
> Debian GNU/Linux 12 (bookworm)
> Build Date: 2024-10-02
> Memory: 14% (1181M/8052M)
> SD Card: 50% (14G/29G)
> Temperature: 39.5ºC
> Overclock: None
> \`\`\`
> \## MIDI & UI
> \`\`\`
> Tuning: 440 Hz
> Master Channel: Off
> Preload Presets: On
> ZS3 (SubSnapShots): On
> Power Save: 0 minutes
> Audio Levels on Snapshots: On
> \`\`\`
> \## Software
> \`\`\`
> zyncoder: vangelis (36691b3) 
> zynthian-ui: vangelis (01b3393)
> zynthian-sys: vangelis (0176796)
> zynthian-data: vangelis (305b301)
> zynthian-webconf: vangelis (6d07476)
> \`\`\`

Regards

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [December 5, 2024, 10:07am UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/5 "2024-12-05T10:07:55Z")

</div>

Sorry, I can’t reproduce!  
Did you miss some detail about your setup or config?

Regards

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [December 5, 2024, 10:53am UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/6 "2024-12-05T10:53:27Z")

</div>

The report is for CC numbers below 64. @jofemodo tested with CC 71. I confirm that CC 11 does not work.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [December 5, 2024, 12:12pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/7 "2024-12-05T12:12:34Z")

</div>

The report specifies \>=64.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [December 5, 2024, 12:21pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/8 "2024-12-05T12:21:39Z")

</div>

Anyway, it works for me for any CC number from 1 to 120. I can’t reproduce.  
Is the controller using some relative mode?

Regards,

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 5, 2024, 1:32pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/9 "2024-12-05T13:32:19Z")

</div>

@jofemodo, no it doesn’t use relative mode, as in the video you can see switching from 0 to 127 and back. And I can reproduce it. IIRC there was a difference between continuously changing the CC value or changing it by a big step like I did (0-\>127).  
Can you give me a hint where in the software this mapping is made (from external device to lv2 param)?  
Is it possible that there is some automation behind the mapping process (for example recognising relative mode or anything similar), that refuses to use a jump from 0 to 127?  
I would really like to help finding the error, only thing I can tell is, that before switching from stable to vangelis it was working correctly.  
Regards

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 5, 2024, 1:35pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/10 "2024-12-05T13:35:33Z")

</div>

Regarding your video, I used the second learning mode, to be independent from the midi channel (with the yellow ?? #?? question marks while learning), when I am out of the actual chain.  
Regards

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 5, 2024, 1:41pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/11 "2024-12-05T13:41:37Z")

</div>

And another thing: the error occurs if I use a toggle button on the external device, toggling between 0 and 127, hence to switch on and of a lv2 parameter.  
Continuous changing of CC values seems to work, then the to be toggled parameter changes state if the sent CC value \>=64 (as expected). But toggling CC106 on (127) and off (0) does not work.  
Regards

---

<div class="post-metadata">

**Author:** ![fussl](https://discourse.zynthian.org/letter_avatar_proxy/v4/letter/f/d07c76/32.png) [@fussl](https://discourse.zynthian.org/u/fussl)\
**Post date:** [December 5, 2024, 2:38pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/12 "2024-12-05T14:38:50Z")

</div>

Strange. Tested here with different controllers, everything works as expected, be it absolute, relative, toggle, MPE, normal frame speeds or high speed USB.  
Zynthian Software is:

```auto
zyncoder: [vangelis (36691b3) 
zynthian-ui: [vangelis (088958c)
zynthian-sys: [vangelis (050c76d)
zynthian-data: [vangelis (305b301)
zynthian-webconf: [vangelis (d811ea6)

```

Wich is the newest Vangelis at time of writing.  
Could it be the absolute/relative-autodetect interfering here? If so, it may be really a good idea to give an option to define the format at time of learning or some setting matrix in the Midi menus.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [December 5, 2024, 3:49pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/13 "2024-12-05T15:49:29Z")

</div>

If the issue is just with CC toggle buttons, i would bet it’s an issue with the relative mode autodetection algorithm.

Please, after learning push the button several times until it starts to work. Probably it will do at some point (10-12 pushes or so).

Regards

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [December 5, 2024, 4:18pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/14 "2024-12-05T16:18:00Z")

</div>

I just pushed a patch that should fix the issue when learning a toggle parameter (on/off) with a CC push button.

Apart from this, i would like to highlight there is a “MIDI learning” menu when bold-pushing the zynthian controller (knob). This menu have some interesting options that you should be aware of.

This is for a toggle controller (on/off):

 ![zui_controller_options_toggle](https://discourse.zynthian.org/uploads/default/original/2X/2/29686cf173f3e5c9eaed2ceb5aca8e3831adaab4.png)

and this for a continuous one:

 ![zui_controller_options_continous](https://discourse.zynthian.org/uploads/default/original/2X/2/251fca52a7410efd92cfcbff78ab29c42efc4370.png)

Regards,

---

<div class="post-metadata">

**Author:** ![gitnob](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/gitnob/32/11827_2.png) [@gitnob](https://discourse.zynthian.org/u/gitnob)\
**Post date:** [December 5, 2024, 8:32pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/15 "2024-12-05T20:32:43Z")

</div>

It’s working now, just tested it. Thanks @jofemodo .

I saw your code adjustment. It has been a problem with the automagic midi learning function in zynthian.  
This means, that if the lv2 is not a toggle param, but I want to switch to full amount (=127) with the CC value changing from 0 → 127, I have to be aware during learning, because I am triggering the relative mode during midi learning.  
My question then is - and this should be written in the user manual - when exactly does this algorithm recognize a CC value as relative CC message during learning?  
Regards

---

<div class="post-metadata">

**Author:** ![Joe](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/joe/32/13784_2.png) [@Joe](https://discourse.zynthian.org/u/Joe)\
**Post date:** [December 8, 2024, 6:42pm UTC](https://discourse.zynthian.org/t/midi-learning-toggle-on-off-parameters-doesnt-work/10636/16 "2024-12-08T18:42:07Z")

</div>

Thank you for fixing this! I thought there was something wrong with my midi pedal. Working for me now as well.
