Re: Can midish match on CC number and parameters and then change the outgoing CC number?

From: Raphaël Mouneyres <rmouneyres_at_gmail.com>
Date: Wed, 19 Nov 2025 08:57:39 +0100
Hi,
If midish cannot do it natively and you dont want to code, I haveuse
mididings to do such stuff.
It is another tool, python, not fully suported nowadays but works nicely.
(Or this could be an inspiration for the new filter rule)

Cheers.
Raphaël

Le mar. 18 nov. 2025, 23:17, Alexandre Ratchov <alex_at_caoua.org> a écrit :

> On Mon, Nov 17, 2025 at 10:36:23PM +0000, midish _at_ oijn wrote:
> > I have a MIDI Piano keyboard that for reasons only the
> designers/developers
> > of the piano understand.  Some of the piano keyboard controls on the left
> > side of the keyboard are note events presented on one ALSA MIDI port.
> While
> > the keyboard controls on the right side of the keyboard are CC events
> which
> > also share the notes from the piano keyboard which are presented on
> another
> > ALSA MIDI port.  Where the keyboard left side controller note events
> > conflict with the piano note events.
> >
> > I've found that most software like DAWs or Sequencers or Notation either
> > expect the (1) Piano keyboard note events on one ALSA MIDI port only;
> with
> > control events on another ALSA port separate from the note events (Ardour
> > for example).  Or the software expects (2) everything - note events and
> > control events all mixed on only one ALSA MIDI port (Musescore for
> example).
> >
> > Also known only to the Piano keyboard designers/developers is why they
> > decided for many of the piano control buttons to use a single CC number
> and
> > differentiate the buttons by just the parameter values. Example:
> >
> > Button 1
> >     Controller chn  1 1e 01
> >     Controller chn  1 1e 00
> > Button 2
> >     Controller chn  1 1e 03
> >     Controller chn  1 1e 02
> > Button 3
> >     Controller chn  1 1e 05
> >     Controller chn  1 1e 04
> > Knob Rotate Left
> >     Controller chn  1 70 40
> >     Controller chn  1 70 3f
> > Knob Rotate Right
> >     Controller chn  1 70 40
> >     Controller chn  1 70 41
> >
> > What I have been looking for is a MIDI router/filter/transform utility
> that
> > would go between the physical ALSA MIDI ports and the software input MIDI
> > ports and be able to sort out the mess.
> >
> > For scenario (1) above where all controller events are to be routed to
> one
> > ALSA MIDI port; while all piano note events are to be routed to another
> > separate ALSA MIDI port - I've been able to get midish to do exactly that
> > with the following config:
> >
> > dnew 0 "28:1" rw #DAW
> > dnew 1 "28:0" rw #MIDI
> > dnew 2  nil   rw #Keyboard
> > dnew 3  nil   rw #Controllers
> >
> > fnew sort_events
> >  fmap   {any 1}   {any 2} #MIDI to Keyboard
> >  fmap   {any 0}   {any 3} #DAW  to Controllers
> >  fmap   {rpn 1}   {rpn 3} #MIDI to Controllers
> >  fmap  {nrpn 1}  {nrpn 3} #MIDI to Controllers
> >  fmap  {xctl 1}  {xctl 3} #MIDI to Controllers
> >  fmap   {ctl 1}   {ctl 3} #MIDI to Controllers
> >  fmap {ctl 1 1} {ctl 2 1} # Mod to Keyboard
> >
> >
> > For scenario (1) I've now run into a challenge - as to how to match and
> > transform the button controller events so that they become separate CC
> > numbers; ideally with more standard parameters.  However, I think as
> long as
> > the CC numbers are different it should still work with associated
> software.
> >
> > By any chance is there a way in midish to match on CC number and
> parameters
> > and then change the outgoing CC number? and ideally change the
> parameters to
> > be more standard?  Something like:
> > #fmap {ctl 0 30} 2   {ctl 3 31} 127
> > #fmap {ctl 0 30} 1   {ctl 3 31} 0
> > #fmap {ctl 0 30} 3   {ctl 3 32} 127
> > #fmap {ctl 0 30} 2   {ctl 3 32} 0
> > #fmap {ctl 0 30} 5   {ctl 3 33} 127
> > #fmap {ctl 0 30} 4   {ctl 3 33} 0
> >
>
> Hi,
>
> Indeed, very "interesting" design regarding the choice of the events ;-)
>
> midish can't map one controller value to another. The filter matches
> against the first parameter of the the event only (ie the controller
> number).
>
> AFAICS, changing the "evinfo" array (diff below) will force all the
> code to use both parameters (controller number and value).
>
> If you go this way, let me know if this work or you notice any side
> effect.
>
> > For scenario (2) is there a way to transform note events to CC events so
> > that the left side of the keyboard controllers won't conflict with the
> piano
> > keyboard note events when all left-side and right-side controller and
> piano
> > note events are combined together to only one ALSA MIDI port?
> >
> > Something like:
> > #fmap {note 1}  {ctl 3}
> >
>
> This is not possible without changing the code.
>
> There are two options:
>
> - extend "fmap", but this requires many changes as a lot of code
>   assumes notes are mapped to notes. Not easy.
>
> - create a new filter rule dedicated to buttons to handle such cases,
>   maybe it could handle scenario 1 as well.
>
> diff --git a/ev.c b/ev.c
> index eb43aa7..f7626a0 100644
> --- a/ev.c
> +++ b/ev.c
> _at__at_ -63,7 +63,7 @@ struct evinfo evinfo[EV_NUMCMD] =
>         },
>         { "xctl", "xctl",
>           EV_HAS_DEV | EV_HAS_CH,
> -         2, 1,
> +         2, 2,
>           0, EV_MAXCOARSE, 0, EV_MAXFINE,
>           NULL
>         },
> _at__at_ -93,7 +93,7 @@ struct evinfo evinfo[EV_NUMCMD] =
>         },
>         { "ctl", "ctl",
>           EV_HAS_DEV | EV_HAS_CH,
> -         2, 1,
> +         2, 2,
>           0, EV_MAXCOARSE, 0, EV_MAXCOARSE,
>           NULL
>         },
>
>
Received on Wed Nov 19 2025 - 08:57:39 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 19 2025 - 11:51:46 CET