Re: Not recording controllers -> diff to test & review

From: Alexandre Ratchov <alex_at_caoua.org>
Date: Tue Dec 11 2012 - 23:07:10 CET
On Tue, Dec 11, 2012 at 12:52:39PM +0100, Julien Claassen wrote:
> Hello Alexandre!
>   OK, I've tested the patch. It seems, that all controllers accept
> 38, 99 and 100 are working. That's loads better for a performance.
>   When I've got my additional MIDI cables, I'll really give the
> other synth a good seeing to. That should be tomorrow or thursday,
> depending on postal services. :-)

excellent!

here's a rather large diff to add two functions: "diev" and
"doev", to control whether midish interprets bank select, NRPN/RPN
and data entry controllers (input and output respectively). They
take a list of events in the {xpc nrpn rpn} set, indicating which
of compound events are supported by the device.

ex, this will leave all controllers to the nordlead

dnew 0 "midi/2" rw
diev 0 {}
doev 0 {}

Let me know if this works.

BTW, I'm interested in any regression this could cause on other
setups as well :)

-- Alexandre

Index: Makefile.in
===================================================================
RCS file: /var/anoncvs/midish/midish/Makefile.in,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile.in
--- Makefile.in	3 Jul 2012 08:51:40 -0000	1.21
+++ Makefile.in	11 Dec 2012 21:46:57 -0000
@@ -96,7 +96,7 @@ mdep_sndio.o:	mdep_sndio.c dbg.h cons.h 
 metro.o:	metro.c dbg.h mux.h metro.h ev.h defs.h timo.h song.h \
 		name.h str.h track.h frame.h state.h filt.h sysex.h
 mididev.o:	mididev.c dbg.h defs.h mididev.h pool.h cons.h str.h \
-		ev.h sysex.h mux.h timo.h
+		ev.h sysex.h mux.h timo.h conv.h
 mixout.o:	mixout.c dbg.h ev.h defs.h filt.h pool.h mux.h timo.h \
 		state.h
 mux.o:		mux.c dbg.h ev.h defs.h cons.h mux.h mididev.h sysex.h \
Index: builtin.c
===================================================================
RCS file: /var/anoncvs/midish/midish/builtin.c,v
retrieving revision 1.88
diff -u -p -r1.88 builtin.c
--- builtin.c	9 Dec 2012 18:06:20 -0000	1.88
+++ builtin.c	11 Dec 2012 21:46:57 -0000
@@ -3054,7 +3054,9 @@ blt_dclkrate(struct exec *o, struct data
 unsigned
 blt_dinfo(struct exec *o, struct data **r)
 {
+	struct mididev *dev;
 	long unit;
+	int i, more;
 
 	if (!exec_lookuplong(o, "devnum", &unit)) {
 		return 0;
@@ -3063,6 +3065,7 @@ blt_dinfo(struct exec *o, struct data **
 		cons_errs(o->procname, "bad device number");
 		return 0;
 	}
+	dev = mididev_byunit[unit];
 	textout_putstr(tout, "{\n");
 	textout_shiftright(tout);
 
@@ -3071,22 +3074,69 @@ blt_dinfo(struct exec *o, struct data **
 	textout_putlong(tout, unit);
 	textout_putstr(tout, "\n");
 
-	if (mididev_mtcsrc == mididev_byunit[unit]) {
+	if (mididev_mtcsrc == dev) {
 		textout_indent(tout);
 		textout_putstr(tout, "mtcrx\t\t\t# master MTC source\n");
 	}
-	if (mididev_byunit[unit]->sendmmc) {
+	if (dev->sendmmc) {
 		textout_indent(tout);
 		textout_putstr(tout, "mmctx\t\t\t# sends MMC messages\n");
 	}
-	if (mididev_clksrc == mididev_byunit[unit]) {
+	if (mididev_clksrc == dev) {
 		textout_indent(tout);
 		textout_putstr(tout, "clkrx\t\t\t# master clock source\n");
 	}
-	if (mididev_byunit[unit]->sendclk) {
+	if (dev->sendclk) {
 		textout_indent(tout);
 		textout_putstr(tout, "clktx\t\t\t# sends clock ticks\n");
 	}
+	textout_indent(tout);
+	textout_putstr(tout, "ixctl {");
+	for (i = 0, more = 0; i < 32; i++) {
+		if (dev->ixctlset & (1 << i)) {
+			if (more)
+				textout_putstr(tout, " ");
+			textout_putlong(tout, i);
+			more = 1;
+		}
+	}
+	textout_putstr(tout, "}\n");
+
+	textout_indent(tout);
+	textout_putstr(tout, "oxctl {");
+	for (i = 0, more = 0; i < 32; i++) {
+		if (dev->oxctlset & (1 << i)) {
+			if (more)
+				textout_putstr(tout, " ");
+			textout_putlong(tout, i);
+			more = 1;
+		}
+	}
+	textout_putstr(tout, "}\n");
+
+	textout_indent(tout);
+	textout_putstr(tout, "iev {");
+	for (i = 0, more = 0; i < EV_NUMCMD; i++) {
+		if (dev->ievset & (1 << i)) {
+			if (more)
+				textout_putstr(tout, " ");
+			textout_putstr(tout, evinfo[i].ev);
+			more = 1;
+		}
+	}
+	textout_putstr(tout, "}\n");
+
+	textout_indent(tout);
+	textout_putstr(tout, "oev {");
+	for (i = 0, more = 0; i < EV_NUMCMD; i++) {
+		if (dev->oevset & (1 << i)) {
+			if (more)
+				textout_putstr(tout, " ");
+			textout_putstr(tout, evinfo[i].ev);
+			more = 1;
+		}
+	}
+	textout_putstr(tout, "}\n");
 
 	textout_indent(tout);
 	textout_putstr(tout, "clkrate ");
@@ -3145,5 +3195,55 @@ blt_doxctl(struct exec *o, struct data *
 		return 0;
 	}
 	mididev_byunit[unit]->oxctlset = ctlset;
+	return 1;
+}
+
+unsigned
+blt_diev(struct exec *o, struct data **r)
+{
+	long unit;
+	struct data *list;
+	unsigned flags;
+
+	if (!song_try_mode(usong, 0)) {
+		return 0;
+	}
+	if (!exec_lookuplong(o, "devnum", &unit) ||
+	    !exec_lookuplist(o, "flags", &list)) {
+		return 0;
+	}
+	if (unit < 0 || unit >= DEFAULT_MAXNDEVS || !mididev_byunit[unit]) {
+		cons_errs(o->procname, "bad device number");
+		return 0;
+	}
+	if (!data_list2xev(list, &flags)) {
+		return 0;
+	}
+	mididev_byunit[unit]->ievset = flags;
+	return 1;
+}
+
+unsigned
+blt_doev(struct exec *o, struct data **r)
+{
+	long unit;
+	struct data *list;
+	unsigned flags;
+
+	if (!song_try_mode(usong, 0)) {
+		return 0;
+	}
+	if (!exec_lookuplong(o, "devnum", &unit) ||
+	    !exec_lookuplist(o, "flags", &list)) {
+		return 0;
+	}
+	if (unit < 0 || unit >= DEFAULT_MAXNDEVS || !mididev_byunit[unit]) {
+		cons_errs(o->procname, "bad device number");
+		return 0;
+	}
+	if (!data_list2xev(list, &flags)) {
+		return 0;
+	}
+	mididev_byunit[unit]->oevset = flags;
 	return 1;
 }
Index: builtin.h
===================================================================
RCS file: /var/anoncvs/midish/midish/builtin.h,v
retrieving revision 1.32
diff -u -p -r1.32 builtin.h
--- builtin.h	9 Dec 2012 18:06:20 -0000	1.32
+++ builtin.h	11 Dec 2012 21:46:57 -0000
@@ -159,5 +159,7 @@ unsigned blt_dclkrate(struct exec *, str
 unsigned blt_dinfo(struct exec *, struct data **);
 unsigned blt_dixctl(struct exec *, struct data **);
 unsigned blt_doxctl(struct exec *, struct data **);
+unsigned blt_diev(struct exec *, struct data **);
+unsigned blt_doev(struct exec *, struct data **);
 
 #endif /* MIDISH_BUILTIN_H */
Index: conv.c
===================================================================
RCS file: /var/anoncvs/midish/midish/conv.c,v
retrieving revision 1.10
diff -u -p -r1.10 conv.c
--- conv.c	11 Dec 2012 07:36:09 -0000	1.10
+++ conv.c	11 Dec 2012 21:46:57 -0000
@@ -130,7 +130,7 @@ conv_getctx(struct statelist *slist, str
  * filled and 1 is returned.
  */
 unsigned
-conv_packev(struct statelist *l, unsigned xctlset,
+conv_packev(struct statelist *l, unsigned xctlset, unsigned flags,
 	    struct ev *ev, struct ev *rev)
 {
 	unsigned num, val;
@@ -140,85 +140,99 @@ conv_packev(struct statelist *l, unsigne
 		rev->dev = ev->dev;
 		rev->ch = ev->ch;
 		rev->pc_prog = ev->pc_prog;
-		rev->pc_bank = conv_getctx(l, ev, BANK_HI, BANK_LO);
+		rev->pc_bank = (flags & CONV_XPC) ?
+		    conv_getctx(l, ev, BANK_HI, BANK_LO) : 0;
 		return 1;
 	} else if (ev->cmd == EV_CTL) {
 		switch (ev->ctl_num) {
 		case BANK_HI:
+			if (!(flags & CONV_XPC))
+				break;
 			conv_rmctl(l, ev, BANK_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case RPN_HI:
+			if (!(flags & CONV_XPC))
+				break;
 			conv_rmctl(l, ev, NRPN_LO);
 			conv_rmctl(l, ev, RPN_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case NRPN_HI:
+			if (!(flags & CONV_NRPN))
+				break;
 			conv_rmctl(l, ev, RPN_LO);
 			conv_rmctl(l, ev, NRPN_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case DATAENT_HI:
+			if (!(flags & (CONV_RPN | CONV_NRPN)))
+				break;
 			conv_rmctl(l, ev, DATAENT_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case BANK_LO:
+			if (!(flags & CONV_XPC))
+				break;
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case NRPN_LO:
+			if (!(flags & CONV_NRPN))
+				break;
 			conv_rmctl(l, ev, RPN_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case RPN_LO:
+			if (!(flags & CONV_RPN))
+				break;
 			conv_rmctl(l, ev, NRPN_LO);
 			conv_setctl(l, ev);
-			break;
+			return 0;
 		case DATAENT_LO:
+			if (!(flags & (CONV_RPN | CONV_NRPN)))
+				break;
 			num = conv_getctx(l, ev, NRPN_HI, NRPN_LO);
 			if (num != EV_UNDEF) {
 				rev->cmd = EV_NRPN;
 			} else {
-				num = conv_getctx(l, ev, RPN_HI, NRPN_LO);
-				if (num == EV_UNDEF) {
-					break;
-				}
+				num = conv_getctx(l, ev,
+				    RPN_HI, NRPN_LO);
+				if (num == EV_UNDEF)
+					return 0;
 				rev->cmd = EV_RPN;
 			}
 			val = conv_getctl(l, ev, DATAENT_HI);
-			if (val == EV_UNDEF) {
-				break;
-			}
+			if (val == EV_UNDEF)
+				return 0;
 			rev->dev = ev->dev;
 			rev->ch = ev->ch;
 			rev->ctl_num = num;
 			rev->ctl_val = ev->ctl_val + (val << 7);
 			return 1;
-		default:
-			if (ev->ctl_num < 32) {
-				if (EVCTL_ISFINE(xctlset, ev->ctl_num)) {
-					conv_setctl(l, ev);
-					break;
-				}
-			} else if (ev->ctl_num < 64) {
-				num = ev->ctl_num - 32;
-				if (EVCTL_ISFINE(xctlset, num)) {
-					val = conv_getctl(l, ev, num);
-					if (val == EV_UNDEF)
-						break;
-					rev->ctl_num = num;
-					rev->ctl_val = ev->ctl_val + (val << 7);
-					goto done;
-				}
+		}
+		if (ev->ctl_num < 32) {
+			if (EVCTL_ISFINE(xctlset, ev->ctl_num)) {
+				conv_setctl(l, ev);
+				return 0;
+			}
+		} else if (ev->ctl_num < 64) {
+			num = ev->ctl_num - 32;
+			if (EVCTL_ISFINE(xctlset, num)) {
+				val = conv_getctl(l, ev, num);
+				if (val == EV_UNDEF)
+					return 0;
+				rev->ctl_num = num;
+				rev->ctl_val = ev->ctl_val + (val << 7);
+				goto done;
 			}
-			rev->ctl_num = ev->ctl_num;
-			rev->ctl_val = ev->ctl_val << 7;
-		done:
-			rev->cmd = EV_XCTL;
-			rev->dev = ev->dev;
-			rev->ch = ev->ch;
-			return 1;
 		}
-		return 0;
+		rev->ctl_num = ev->ctl_num;
+		rev->ctl_val = ev->ctl_val << 7;
+	done:
+		rev->cmd = EV_XCTL;
+		rev->dev = ev->dev;
+		rev->ch = ev->ch;
+		return 1;
 	} else {
 		*rev = *ev;
 		return 1;
@@ -231,13 +245,35 @@ conv_packev(struct statelist *l, unsigne
  * the array.
  */
 unsigned
-conv_unpackev(struct statelist *slist, unsigned xctlset,
+conv_unpackev(struct statelist *slist, unsigned xctlset, unsigned flags,
 	      struct ev *ev, struct ev *rev)
 {
 	unsigned val, hi;
 	unsigned nev = 0;
 
 	if (ev->cmd == EV_XCTL) {
+		switch (ev->ctl_num) {
+		case BANK_HI:
+		case BANK_LO:
+			if (flags & CONV_XPC)
+				return 0;
+			break;
+		case NRPN_HI:
+		case NRPN_LO:
+			if (flags & CONV_NRPN)
+				return 0;
+			break;
+		case RPN_HI:
+		case RPN_LO:
+			if (flags & CONV_RPN)
+				return 0;
+			break;
+		case DATAENT_HI:
+		case DATAENT_LO:
+			if (flags & (CONV_NRPN | CONV_RPN))
+				return 0;
+			break;
+		}
 		if (ev->ctl_num < 32 && EVCTL_ISFINE(xctlset, ev->ctl_num)) {
 			hi = ev->ctl_val >> 7;
 			val = conv_getctl(slist, ev, ev->ctl_num);
@@ -268,24 +304,26 @@ conv_unpackev(struct statelist *slist, u
 			return 1;
 		}
 	} else if (ev->cmd == EV_XPC) {
-		val = conv_getctx(slist, ev, BANK_HI, BANK_LO);
-		if (val != ev->pc_bank && ev->pc_bank != EV_UNDEF) {
-			rev->cmd = EV_CTL;
-			rev->dev = ev->dev;
-			rev->ch = ev->ch;
-			rev->ctl_num = BANK_HI;
-			rev->ctl_val = ev->pc_bank >> 7;
-			conv_setctl(slist, rev);
-			rev++;
-			nev++;
-			rev->cmd = EV_CTL;
-			rev->dev = ev->dev;
-			rev->ch = ev->ch;
-			rev->ctl_num = BANK_LO;
-			rev->ctl_val = ev->pc_bank & 0x7f;
-			conv_setctl(slist, rev);
-			rev++;
-			nev++;
+		if (flags & CONV_XPC) {
+			val = conv_getctx(slist, ev, BANK_HI, BANK_LO);
+			if (val != ev->pc_bank && ev->pc_bank != EV_UNDEF) {
+				rev->cmd = EV_CTL;
+				rev->dev = ev->dev;
+				rev->ch = ev->ch;
+				rev->ctl_num = BANK_HI;
+				rev->ctl_val = ev->pc_bank >> 7;
+				conv_setctl(slist, rev);
+				rev++;
+				nev++;
+				rev->cmd = EV_CTL;
+				rev->dev = ev->dev;
+				rev->ch = ev->ch;
+				rev->ctl_num = BANK_LO;
+				rev->ctl_val = ev->pc_bank & 0x7f;
+				conv_setctl(slist, rev);
+				rev++;
+				nev++;
+			}
 		}
 		rev->cmd = EV_PC;
 		rev->dev = ev->dev;
@@ -295,6 +333,8 @@ conv_unpackev(struct statelist *slist, u
 		nev++;
 		return nev;
 	} else if (ev->cmd == EV_NRPN) {
+		if (!(flags & CONV_NRPN))
+			return 0;
 		val = conv_getctx(slist, ev, NRPN_HI, NRPN_LO);
 		if (val != ev->rpn_num) {
 			conv_rmctl(slist, ev, RPN_HI);
@@ -333,6 +373,8 @@ conv_unpackev(struct statelist *slist, u
 		nev++;
 		return nev;
 	} else if (ev->cmd == EV_RPN) {
+		if (!(flags & CONV_RPN))
+			return 0;
 		val = conv_getctx(slist, ev, RPN_HI, RPN_LO);
 		if (val != ev->rpn_num) {
 			conv_rmctl(slist, ev, NRPN_HI);
Index: conv.h
===================================================================
RCS file: /var/anoncvs/midish/midish/conv.h,v
retrieving revision 1.6
diff -u -p -r1.6 conv.h
--- conv.h	30 Jun 2011 12:30:31 -0000	1.6
+++ conv.h	11 Dec 2012 21:46:57 -0000
@@ -17,14 +17,23 @@
 #ifndef MIDISH_CONV_H
 #define MIDISH_CONV_H
 
+#include "ev.h"
+
 #define CONV_NUMREV 4
 
+/*
+ * constants to define a set of packed events
+ */
+#define CONV_XPC	(1 << EV_XPC)
+#define CONV_NRPN	(1 << EV_NRPN)
+#define CONV_RPN	(1 << EV_RPN)
+
 struct ev;
 struct statelist;
 
-unsigned conv_packev(struct statelist *, unsigned,
+unsigned conv_packev(struct statelist *, unsigned, unsigned,
     struct ev *, struct ev *);
-unsigned conv_unpackev(struct statelist *, unsigned,
+unsigned conv_unpackev(struct statelist *, unsigned, unsigned,
     struct ev *, struct ev *);
 
 #endif /* MIDISH_CONV_H */
Index: manual.html
===================================================================
RCS file: /var/anoncvs/midish/midish/manual.html,v
retrieving revision 1.193
diff -u -p -r1.193 manual.html
--- manual.html	7 Nov 2012 08:32:29 -0000	1.193
+++ manual.html	11 Dec 2012 21:46:58 -0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <!--
 
-Copyright (c) 2003-2011 Alexandre Ratchov &lt;alex@caoua.org&gt;
+Copyright (c) 2003-2012 Alexandre Ratchov &lt;alex@caoua.org&gt;
 
 Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above
@@ -2576,6 +2576,11 @@ add version 
 <li>
 in verbose mode, add message for playback completion
 
+<li>
+add diev
+and doev functions to control whether
+midish interprets bank select, NRPN/RPN and data entry controllers.
+
 </ul>
 
 <h2><a name="attributes">16 Project attributes</a></h2>
@@ -2631,6 +2636,20 @@ received with 14-bit precision.
 <td>list of continuous controllers that will be transmitted
 with 14-bit precision
 
+<tr>
+
+<td>iev
+
+<td>list of compound event types the device transmits;
+it's a subset of ``xpc'', ``nrpn'', ``rpn''.
+
+<tr>
+
+<td>oev
+
+<td>list of compound event types the device accepts;
+it's a subset of ``xpc'', ``nrpn'', ``rpn''.
+
 </table>
 
 <h3><a name="section_16_2">16.2 Channel attributes</a></h3>
@@ -4183,6 +4202,40 @@ let this list empty.
 <dd>
 Setup the list of controllers that will be transmitted
 as 14-bit numbers (both coarse and fine MIDI controller messages).
+
+<dt><a name="func_diev">diev devnum list</a>
+
+<dd>
+Configure the device to process as a single event the following
+patterns of input MIDI messages.
+
+<ul>
+
+<li>
+``xpc'' - group bank select controllers (0 and 32) with program
+changes into a signle ``xpc'' event.
+
+<li>
+``nrpn'' - group NRPN controllers (98 and 99) with data entry
+controllers (6 and 38) into a single ``nrpn'' event.
+
+<li>
+``rpn'' - same as ``nrpn'', but for RPN controllers (100 and 101).
+
+</ul>
+
+By default all of the above are enabled, which allows banks, NRPNs
+and RPNs to be handled by midish the standard way.
+
+It makes sense to disable grouping of above messages on rare hardware
+that maps above-mentioned controller numbers (0, 6, 32, 38, 98, 99,
+100, 101) to other parameters than bank number and NRPN/RPN.
+
+<dt><a name="func_doev">doev devnum list</a>
+
+<dd>
+Same as diev but for output MIDI
+messages.
 
 </dl>
 
Index: mididev.c
===================================================================
RCS file: /var/anoncvs/midish/midish/mididev.c,v
retrieving revision 1.45
diff -u -p -r1.45 mididev.c
--- mididev.c	18 Dec 2011 09:16:13 -0000	1.45
+++ mididev.c	11 Dec 2012 21:46:58 -0000
@@ -53,6 +53,7 @@
 #include "sysex.h"
 #include "mux.h"
 #include "timo.h"
+#include "conv.h"
 
 #define MIDI_SYSEXSTART	0xf0
 #define MIDI_QFRAME	0xf1
@@ -237,6 +238,8 @@ mididev_init(struct mididev *o, struct d
 	o->mode = mode;
 	o->ixctlset = 0;	/* all input controllers are 7bit */
 	o->oxctlset = 0;
+	o->ievset = CONV_XPC | CONV_NRPN | CONV_RPN;
+	o->oevset = CONV_XPC | CONV_NRPN | CONV_RPN;
 	o->eof = 1;
 
 	/*
Index: mididev.h
===================================================================
RCS file: /var/anoncvs/midish/midish/mididev.h,v
retrieving revision 1.32
diff -u -p -r1.32 mididev.h
--- mididev.h	30 Jun 2011 12:30:32 -0000	1.32
+++ mididev.h	11 Dec 2012 21:46:58 -0000
@@ -113,6 +113,7 @@ struct mididev {
 	unsigned isensto, osensto;	/* active sensing timeouts */
 	unsigned mode;			/* read, write */
 	unsigned ixctlset, oxctlset;	/* bitmap of 14bit controllers */
+	unsigned ievset, oevset;	/* bitmap of CONV_{XPC,NRPN,RPN} */
 	unsigned eof;			/* i/o error pending */
 	unsigned runst;			/* use running status for output */
 	unsigned sync;			/* flush buffer after each message */
Index: mux.c
===================================================================
RCS file: /var/anoncvs/midish/midish/mux.c,v
retrieving revision 1.62
diff -u -p -r1.62 mux.c
--- mux.c	30 Jun 2011 12:30:32 -0000	1.62
+++ mux.c	11 Dec 2012 21:46:58 -0000
@@ -315,7 +315,8 @@ mux_putev(struct ev *ev)
 	}
 	dev = mididev_byunit[unit];
 	if (dev != NULL) {
-		nev = conv_unpackev(&mux_ostate, dev->oxctlset, ev, rev);
+		nev = conv_unpackev(&mux_ostate,
+		    dev->oxctlset, dev->oevset, ev, rev);
 		for (i = 0; i < nev; i++) {
 			mididev_putev(dev, &rev[i]);
 		}
@@ -612,7 +613,7 @@ mux_evcb(unsigned unit, struct ev *ev)
 		dbg_puts("\n");
 	}
 #endif
-	if (conv_packev(&mux_istate, dev->ixctlset, ev, &rev)) {
+	if (conv_packev(&mux_istate, dev->ixctlset, dev->ievset, ev, &rev)) {
 		norm_evcb(&rev);
 	}
 }
Index: rmidish.c
===================================================================
RCS file: /var/anoncvs/midish/midish/rmidish.c,v
retrieving revision 1.40
diff -u -p -r1.40 rmidish.c
--- rmidish.c	9 Dec 2012 18:06:20 -0000	1.40
+++ rmidish.c	11 Dec 2012 21:46:58 -0000
@@ -294,6 +294,7 @@ char *builtins[] = {
 	"fswapin", "fswapout", "xlist", "xexists", "xnew", "xdel", "xren",
 	"xinfo", "xrm", "xsetd", "xadd", "dlist", "dnew", "ddel", "dmtcrx",
 	"dmmctx", "dclkrx", "dclktx", "dclkrate", "dinfo", "dixctl", "doxctl",
+	"diev", "doev",
 	NULL
 };
 
Index: saveload.c
===================================================================
RCS file: /var/anoncvs/midish/midish/saveload.c,v
retrieving revision 1.75
diff -u -p -r1.75 saveload.c
--- saveload.c	19 Oct 2011 10:53:29 -0000	1.75
+++ saveload.c	11 Dec 2012 21:46:58 -0000
@@ -919,7 +919,9 @@ parse_track(struct parse *o, struct trac
 				return 0;
 			}
 			if (ev.cmd != EV_NULL) {
-				if (conv_packev(&slist, 0U, &ev, &rev)) {
+				if (conv_packev(&slist, 0U,
+					CONV_XPC | CONV_NRPN | CONV_RPN,
+					&ev, &rev)) {
 					se = seqev_new();
 					se->ev = rev;
 					seqev_ins(pos, se);
Index: smf.c
===================================================================
RCS file: /var/anoncvs/midish/midish/smf.c,v
retrieving revision 1.48
diff -u -p -r1.48 smf.c
--- smf.c	30 Jun 2011 12:30:33 -0000	1.48
+++ smf.c	11 Dec 2012 21:46:58 -0000
@@ -364,7 +364,8 @@ smf_puttrack(struct smf *o, unsigned *us
 			break;
 		}
 		if (EV_ISVOICE(&pos->ev)) {
-			nev = conv_unpackev(&slist, ~1U, &pos->ev, rev);
+			nev = conv_unpackev(&slist, 0U,
+			    CONV_XPC | CONV_NRPN | CONV_RPN, &pos->ev, rev);
 			for (i = 0; i < nev; i++) {
 				smf_putvar(o, used, delta);
 				delta = 0;
@@ -724,7 +725,8 @@ smf_gettrack(struct smf *o, struct song 
 				ev.cmd = EV_NOFF;
 				ev.note_vel = EV_NOFF_DEFAULTVEL;
 			}
-			if (conv_packev(&slist, 0U, &ev, &rev)) {
+			if (conv_packev(&slist, 0U,
+				CONV_XPC | CONV_NRPN | CONV_RPN, &ev, &rev)) {
 				se = seqev_new();
 				se->ev = rev;
 				seqev_ins(pos, se);
Index: user.c
===================================================================
RCS file: /var/anoncvs/midish/midish/user.c,v
retrieving revision 1.151
diff -u -p -r1.151 user.c
--- user.c	9 Dec 2012 18:06:20 -0000	1.151
+++ user.c	11 Dec 2012 21:46:58 -0000
@@ -687,6 +687,37 @@ data_list2ctlset(struct data *d, unsigne
 	return 1;
 }
 
+/*
+ * convert a list to bitmap of CONV_xxx constants
+ */
+unsigned
+data_list2xev(struct data *d, unsigned *res)
+{
+	static unsigned cmds[] = {EV_XPC, EV_NRPN, EV_RPN};
+	unsigned i, conv, cmd;
+
+	conv = 0;
+	while (d) {
+		if (d->type != DATA_REF) {
+		err:
+			cons_err("xpc, rpn, or nrpn expected as flag");
+			return 0;
+		}
+		i = 0;
+		for (;;) {
+			if (i == sizeof(cmds) / sizeof(int))
+				goto err;
+			cmd = cmds[i];
+			if (str_eq(d->val.ref, evinfo[cmd].ev))
+				break;
+			i++;
+		}
+		conv |= (1 << cmd);
+		d = d->next;
+	}
+	*res = conv;
+	return 1;
+}
 
 /*
  * check if the pattern in data (list of integers)
@@ -1111,6 +1142,12 @@ user_mainloop(void)
 	exec_newbuiltin(exec, "doxctl", blt_doxctl,
 			name_newarg("devnum",
 			name_newarg("ctlset", NULL)));
+	exec_newbuiltin(exec, "diev", blt_diev,
+			name_newarg("devnum",
+			name_newarg("flags", NULL)));
+	exec_newbuiltin(exec, "doev", blt_doev,
+			name_newarg("devnum",
+			name_newarg("flags", NULL)));
 
 	/*
 	 * run the user startup script: $HOME/.midishrc or /etc/midishrc
Index: user.h
===================================================================
RCS file: /var/anoncvs/midish/midish/user.h,v
retrieving revision 1.49
diff -u -p -r1.49 user.h
--- user.h	30 Jun 2011 12:30:34 -0000	1.49
+++ user.h	11 Dec 2012 21:46:58 -0000
@@ -65,6 +65,7 @@ unsigned data_list2range(struct data *, 
 unsigned data_matchsysex(struct data *, struct sysex *, unsigned *);
 unsigned data_list2ctl(struct data *, unsigned *);
 unsigned data_list2ctlset(struct data *, unsigned *);
+unsigned data_list2xev(struct data *, unsigned *);
 unsigned data_getctl(struct data *, unsigned *);
 
 /* track functions */
Received on Tue, 11 Dec 2012 23:07:10 +0100

This archive was generated by hypermail 2.1.8 : Wed Nov 08 2017 - 16:32:24 CET