Purpose of fswapin

From: Hydro Flask <hydroflask_at_yqxmail.com>
Date: Sun, 25 Apr 2021 12:39:24 -0700
Hello,

I stumbled across midish while needing a quick and dirty way to split my 
MIDI keyboard into two channels live. I found it linked from this site: 
https://askubuntu.com/questions/675470/how-to-do-advanced-midi-keyboard-routing

Since then I've been using it for increasingly more tasks and it's been 
delightful. I usually go to Python for these types of tasks but when it 
comes to routing MIDI events in real-time, I like the idea that the main 
loop is native code.

Anyway, my question concerns fswapin. What is the purpose of this 
function? I did not understand the blurb in the documentation:

     Similar to fchgin but swap ``evspec1'' and ``evspec2'' in the source 
events set of each rule.

So I dug into the source and found the essential difference between 
fswapin and fchgin here:

     /* in filt_chgin() */
     if (evspec_in(&s->es, from)) {
         evspec_map(&s->es, from, to, &newspec);
     } else if (swap && evspec_in(&s->es, to)) {
         evspec_map(&s->es, to, from, &newspec);
     } else {
         newspec = s->es;
     }

What it seems like on cursory glance is that it's intending to be like 
fchgin except it interprets the arguments in reverse order. On its own 
that doesn't seem like justification enough to add a new function. 
Indeed it doesn't just do that, it first checks that the source evspec 
of the filter rules is contained in the "from" evspec of the function, 
just like fchgin, and then maps in that direction.

So I understand what it's doing but now my question is why would one 
need that? Thank you.

Hydro Flask
Received on Sun Apr 25 2021 - 21:39:24 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 26 2021 - 01:34:08 CEST