Allow list values to be repeated.

master
Albert Graef 2018-08-26 10:04:05 +02:00
parent 46d15aa3d2
commit 0329d608e9
2 changed files with 24 additions and 12 deletions

View File

@ -21,11 +21,6 @@ JACK_PORTS 2
# "mackie control" ports to midizap's midi_out and midi_in2 ports, and the
# APCmini to midizap's midi_in and midi_out2 ports.
# "BLINKENLIGHTS" ADD-ON: Decoding MCU metering feedback is beyond midizap's
# capabilities, but there's a Pd patch in APCmini-meter.pd which you can hook
# up to Ardour's Mackie control output to show the channel meters in the
# unused top 5x8 button grid.
# PROTOCOL DOCUMENTATION: The Mackie protocol is fairly ubiquitous, but since
# the manufacturers can't be bothered to properly *document* their stuff these
# days, we have to rely on volunteers who do their work using some reverse
@ -183,14 +178,14 @@ C6 F7
# actually have 8 different values, have to be squashed into 5 LEDs per
# channel.
?CP[16] C2[0,1] G#2[0,0,0,1] E3[0,0,0,0,0,5] C4[0,0,0,0,0,0,0,5] G#4[0,0,0,0,0,0,0,0,3]
?CP[16] C2[0,1] G#2[0:3,1] E3[0:5,5] C4[0:7,5] G#4[0:8,3]
# Here's an alternative decoding, which creates horizontal meters
# covering the full range, with the first channel on top. Note,
# however, that this ranges across the entire 8x8 grid and will thus
# clobber the rec/solo/mute controls!
#?CP[16][-8] G#4[0,1] A4[0,0,1] A#4[0,0,0,1] B4[0,0,0,0,1] C5[0,0,0,0,0,5] C#5[0,0,0,0,0,0,5] D5[0,0,0,0,0,0,0,5] D#5[0,0,0,0,0,0,0,0,3]
#?CP[16][-8] G#4[0,1] A4[0,0,1] A#4[0:3,1] B4[0:4,1] C5[0:5,5] C#5[0:6,5] D5[0:7,5] D#5[0:8,3]
# no feedback for faders (faders aren't motorized)

View File

@ -898,19 +898,36 @@ static char *parse_steps(char *tok, char *p,
int l, n;
if (sscanf(++p, "%d%n", &l, &n) == 1) {
p += n;
if (*p == ',') {
if (*p == ',' || *p == ':') {
int n_st = 1;
static int st[128];
st[0] = l;
while (*p == ',') {
while (*p == ',' || *p == ':') {
char c = *p;
if (sscanf(++p, "%d%n", &l, &n) == 1) {
p += n;
} else
return 0;
if (n_st < 128)
if (c == ':') {
// ':l' repeats the last value l-1 times
if (l <= 0) {
// remove the last value
if (n_st > 0) n_st--;
} else if (n_st > 0 && n_st < 128) {
int last = st[n_st-1];
for (int i = 1; i < l; i++) {
st[n_st++] = last;
if (n_st == 128) {
fprintf(stderr, "warning: too many steps: %s\n", tok);
break;
}
}
}
} else if (n_st < 128) {
st[n_st++] = l;
else if (n_st == 128)
fprintf(stderr, "warning: too many steps: %s\n", tok);
if (n_st == 128)
fprintf(stderr, "warning: too many steps: %s\n", tok);
}
}
*n_steps = n_st;
*steps = st;