Compare commits

..

2 Commits

Author SHA1 Message Date
Seymour Shlien
2b697536dc 2022.05.20 2022-05-20 16:25:40 -04:00
Seymour Shlien
e564bf9954 2022.05.05 2022-05-05 07:54:35 -04:00
8 changed files with 215 additions and 185 deletions

View File

@@ -1,2 +1,2 @@
2022 April 28 2022
2022 May 20 2022

View File

@@ -14734,3 +14734,48 @@ and abc2svg does not recognize it.
April 28 2022
midi2abc: minor change for -stats function
May 05 2022
midicopy: introduced new options -nopressure and -nocntrl
May 20 2022
Improvements in parsing umlaut characters in the T: Q: commands
and guitar chords in compliance with section 8.2 of the 2.2 Abc standard
(mnemonics). Here are examples where the mnemonics occur.
X:7
T:Slurs and Ties
T: Title with f\"unny chars like \005 Çéñô Àçäßö © …
M:C|
K:Ebm
[| (CDEF) ((3efg) ((3gag)| "_demit\"asse" (C2 EF) (ef(ga)) | ((c2 (3(d)ef) e2)\
A2-|A4 c4-|(c4(e4)|a8) |]
X: 1
T: Traveller's Joy
R: polka
M: 2/4
L: 1/8
Q: "bl\"oop" 1/4=90
K: Gmaj
"^Duggie" f>g ag/2f/2 | "<G\"odel" gG B/2c/2d | "C" ee "G" dg/2B/2 | B/2A/2G/2B/2 "D" A2 |
"D" f>g ag/2f/2 | "G" gG B/2c/2d | "C" ee "G"dg/2g/2 | "D" af "G" g2 :|
%
X: 2
T: Tempo example
M: 4/4
L: 1/4
Q: 1/4=90 "c\"ah\"o\"ots"
K: G
abcd|efga
James Allwright added new functions to do the umlaut handling:
umlaut_get_buffer()
umlaut_build_string()
and parsename/parsesname were combined into one function.

View File

@@ -1,11 +1,11 @@
abcMIDI : abc <-> MIDI conversion utilities
midi2abc version 3.54 April 28 2022
abc2midi version 4.72 April 27 2022
abc2abc version 2.16 February 22 2022
yaps version 1.88 February 22 2022
abc2midi version 4.73 May 20 2022
abc2abc version 2.17 May 20 2022
yaps version 1.89 May 20 2022
abcmatch version 1.80 November 25 2021
midicopy version 1.37 October 10 2020
midicopy version 1.38 May 06 2022
24th January 2002

View File

@@ -52,7 +52,7 @@
#define VERSION "1.37 October 10 2020 midicopy"
#define VERSION "1.38 May 05 2022 midicopy"
#include "midicopy.h"
#define NULLFUNC 0
#define NULL 0
@@ -112,6 +112,8 @@ int chosen_drum = 0; /* [SS] 2013-10-01 */
int drumvelocity = 0; /* [SS] 2013-10-01 */
int attenuation = 70; /* [SS] 2017-11-27 */
int nobends = 0; /* [SS] 2017-12-15 */
int nopressure = 0; /* [SS] 2022-05-05 */
int nocntrl = 0; /* [SS] 2022-05-05 */
int zerochannels = 0; /* [SS] 2020-10-09 */
long Mf_numbyteswritten = 0L;
@@ -1060,9 +1062,10 @@ chanmessage (int status, int c1, int c2)
copy_noteon (chan, c1, c2);
break;
case 0xa0:
copy_pressure (chan, c1, c2);
if (nopressure == 0) copy_pressure (chan, c1, c2);
break;
case 0xb0:
if (nocntrl == 0)
copy_parameter (chan, c1, c2);
break;
case 0xe0:
@@ -1073,7 +1076,7 @@ chanmessage (int status, int c1, int c2)
copy_program (chan, c1);
break;
case 0xd0:
copy_chanpressure (chan, c1);
if (nopressure == 0) copy_chanpressure (chan, c1);
break;
}
}
@@ -1851,6 +1854,8 @@ main (int argc, char *argv[])
printf ("-focusonchannels n1,n2,...\n"); /* [SS] 2017-11-27 */
printf ("-attenuation n\n"); /* [SS] 2017-11-27 */
printf ("-nobends\n"); /* [SS] 2017-11-27 */
printf ("-nopressure\n"); /* [SS] 2022-05-05 */
printf ("-nocntrl\n"); /* [SS] 2022-05-05 */
printf ("-indrums n1,n2,... (drums to include)\n"); /* [SS] 2019-12-22 */
printf ("-xdrums n1,n2,... (drums to exclude)\n"); /* [SS] 2019-12-22 */
printf ("-onlydrums (only channel 10)\n"); /* [SS] 2019-12-22 */
@@ -2091,6 +2096,12 @@ main (int argc, char *argv[])
arg = getarg("-nobends",argc,argv);
if (arg >=0) nobends=1;
/* [SS] 2022-05-05 */
arg = getarg("-nopressure",argc,argv);
if (arg >=0) nopressure=1;
arg = getarg("-nocntrl",argc,argv);
if (arg >=0) nocntrl = 1;
repflag = getarg ("-replace", argc, argv);
if (repflag >= 0)

View File

@@ -52,6 +52,7 @@
#ifdef _MSC_VER
#define ANSILIBS
#define casecmp stricmp
#define strcasecmp _stricmp
#define _CRT_SECURE_NO_WARNINGS
#else
#define casecmp strcasecmp
@@ -1089,114 +1090,96 @@ parseoctave (s, word, gotoctave, octave)
return 1;
};
/* Function added JA 20 May 2022*/
/* parse a string contained in quotes.
* strings may contain the close quote character because
* x umlaut is encoded as \"x, which complicates parsing.
* this is an unfortunate feature of the abc syntax.
*
* on entry, start points to the opening double quote.
* returns pointer to last character before closing quote.
*/
char *umlaut_get_buffer(char *start, char *buffer, int bufferlen)
{
char *p;
int last_ch;
int i;
p = start;
i = 0;
while ((*p != '\0') &&
!((*p == '"') && (last_ch != '\\'))) {
if (i < bufferlen - 2) {
buffer[i] = *p;
i = i + 1;
}
last_ch = *p;
p = p + 1;
}
buffer[i] = '\0';
return p;
}
/* Function added JA 20 May 2022*/
/* construct string using vstring */
char *umlaut_build_string(char *start, struct vstring *gchord)
{
int lastch = ' ';
char *p;
p = start;
//initvstring (&gchord);
/* need to allow umlaut sequence in guitar chords.
* e.g. \"a, \"u
*/
while (!((*p == '\0') ||
((*p == '"') && (lastch != '\\')))) {
addch (*p, gchord);
lastch = *p;
p = p + 1;
}
//printf("umlaut_build_string has >%s<\n", gchord->st);
return p;
}
/* Function modified JA 20 May 2022 */
int
parsename (s, word, gotname, namestring, maxsize)
parsename (s, gotname, namestring, maxsize)
/* parses string name= "string" in V: command
for compatability of abc2abc with abcm2ps
*/
char **s;
char *word;
int *gotname;
char namestring[];
int maxsize;
{
int i;
i = 0;
if (casecmp (word, "name") != 0)
return 0;
skipspace (s);
if (**s != '=')
{
event_error ("name must be followed by '='");
}
else
{
*s = *s + 1;
skipspace (s);
if (**s == '"') /* string enclosed in double quotes */
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
while (i < maxsize && **s != '"' && **s != '\0')
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
}
namestring[i] = (char) **s; /* copy double quotes */
i++;
namestring[i] = '\0';
}
else /* string not enclosed in double quotes */
{
while (i < maxsize && **s != ' ' && **s != '\0')
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
}
namestring[i] = '\0';
}
*gotname = 1;
}
return 1;
};
int
parsesname (s, word, gotname, namestring, maxsize)
/* parses string name= "string" in V: command
for compatability of abc2abc with abcm2ps
*/
char **s;
char *word;
int *gotname;
char namestring[];
int maxsize;
{
int i;
i = 0;
if (casecmp (word, "sname") != 0)
return 0;
skipspace (s);
if (**s != '=')
{
event_error ("name must be followed by '='");
}
else
{
if (**s != '=') {
event_error ("name must be followed by '='");
} else {
*s = *s + 1;
skipspace (s);
if (**s == '"') { /* string enclosed in double quotes */
namestring[i] = (char)**s;
*s = *s + 1;
skipspace (s);
if (**s == '"') /* string enclosed in double quotes */
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
while (i < maxsize && **s != '"' && **s != '\0')
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
}
namestring[i] = (char) **s; /* copy double quotes */
i++;
namestring[i] = '\0';
}
else /* string not enclosed in double quotes */
{
while (i < maxsize && **s != ' ' && **s != '\0')
{
namestring[i] = (char) **s;
*s = *s + 1;
i++;
}
namestring[i] = '\0';
}
*gotname = 1;
*s = umlaut_get_buffer(*s, &namestring[1], maxsize-1);
*s = *s + 1; /* skip over closing double quote */
strcat(namestring, "\"");
} else { /* string not enclosed in double quotes */
while (i < maxsize && **s != ' ' && **s != '\0') {
namestring[i] = (char)**s;
*s = *s + 1;
i++;
}
namestring[i] = '\0';
}
*gotname = 1;
}
return 1;
};
}
int
parsemiddle (s, word, gotmiddle, middlestring, maxsize)
@@ -1665,27 +1648,30 @@ parsevoice (s)
copy_clef (&voicecode[num - 1].clef, &vparams.new_clef);
}
if (!parsed)
parsed =
parsetranspose (&s, word, &vparams.gottranspose,
&vparams.transpose);
parsed =
parsetranspose (&s, word, &vparams.gottranspose,
&vparams.transpose);
if (!parsed)
parsed = parseoctave (&s, word, &vparams.gotoctave, &vparams.octave);
parsed = parseoctave (&s, word, &vparams.gotoctave, &vparams.octave);
if (!parsed)
parsed = parsesound (&s, word, &vparams.gottranspose, &vparams.transpose);
/* Code changed JA 20 May 2022 */
if ((!parsed) && (strcasecmp (word, "name") == 0)) {
parsed =
parsename (&s, &vparams.gotname, vparams.namestring,
V_STRLEN);
}
if ((!parsed) && (strcasecmp (word, "sname") == 0)) {
parsed =
parsename (&s, &vparams.gotsname, vparams.snamestring,
V_STRLEN);
}
if (!parsed)
parsed =
parsename (&s, word, &vparams.gotname, vparams.namestring,
V_STRLEN);
parsed =
parsemiddle (&s, word, &vparams.gotmiddle, vparams.middlestring,
V_STRLEN);
if (!parsed)
parsed =
parsesname (&s, word, &vparams.gotsname, vparams.snamestring,
V_STRLEN);
if (!parsed)
parsed =
parsemiddle (&s, word, &vparams.gotmiddle, vparams.middlestring,
V_STRLEN);
if (!parsed)
parsed = parseother (&s, word, &vparams.gotother, vparams.other, V_STRLEN); /* [SS] 2011-04-18 */
parsed = parseother (&s, word, &vparams.gotother, vparams.other, V_STRLEN); /* [SS] 2011-04-18 */
}
/* [SS] 2015-05-13 allow octave= to change the clef= octave setting */
/* cgotoctave may be set to 1 by a clef=. vparams.gotoctave is set */
@@ -2063,89 +2049,78 @@ FILE * parse_abc_include (s)
return NULL;
}
/* Function mofied for umlaut handling JA 20 May 2022 */
void
parse_tempo (place)
char *place;
/* parse tempo descriptor i.e. Q: field */
{
char *p;
char *after_pre;
int a, b;
int n;
int relative;
char *pre_string;
char *post_string;
struct vstring pre;
struct vstring post;
relative = 0;
p = place;
pre_string = NULL;
if (*p == '"')
{
p = p + 1;
pre_string = p;
while ((*p != '"') && (*p != '\0'))
{
p = p + 1;
};
if (*p == '\0')
{
event_error ("Missing closing double quote");
}
else
{
*p = '\0';
p = p + 1;
place = p;
};
};
initvstring (&pre);
if (*p == '"') {
p = p + 1; /* skip over opening double quote */
p = umlaut_build_string(p, &pre);
pre_string = pre.st;
if (*p == '\0') {
event_error ("Missing closing double quote");
} else {
p = p + 1; /* skip over closing double quote */
place = p;
}
}
after_pre = p;
/* do we have an "=" ? */
while ((*p != '\0') && (*p != '='))
p = p + 1;
if (*p == '=')
{
p = place;
skipspace (&p);
if (((*p >= 'A') && (*p <= 'G')) || ((*p >= 'a') && (*p <= 'g')))
{
relative = 1;
p = p + 1;
};
readlen (&a, &b, &p);
skipspace (&p);
if (*p != '=')
{
event_error ("Expecting = in tempo");
};
if (*p == '=') {
p = place;
skipspace (&p);
if (((*p >= 'A') && (*p <= 'G')) || ((*p >= 'a') && (*p <= 'g'))) {
relative = 1;
p = p + 1;
}
else
{
a = 1; /* [SS] 2013-01-27 */
/*a = 0; [SS] 2013-01-27 */
b = 4;
p = place;
};
readlen (&a, &b, &p);
skipspace (&p);
if (*p != '=') {
event_error ("Expecting = in tempo");
}
p = p + 1;
} else {
/* no "=" found - default to 1/4 note */
a = 1; /* [SS] 2013-01-27 */
b = 4;
p = after_pre;
}
skipspace (&p);
n = readnump (&p);
n = readnump (&p); /* read notes per minute value */
post_string = NULL;
if (*p == '"')
{
p = p + 1;
post_string = p;
while ((*p != '"') && (*p != '\0'))
{
p = p + 1;
};
if (*p == '\0')
{
event_error ("Missing closing double quote");
}
else
{
*p = '\0';
p = p + 1;
};
};
initvstring (&post);
skipspace (&p);
if (*p == '"') {
p = p + 1; /* skip over opening double quote */
p = umlaut_build_string(p, &post);
post_string = post.st;
if (*p == '\0') {
event_error ("Missing closing double quote");
} else {
p = p + 1; /* skip over closing double quote */
}
}
event_tempo (n, a, b, relative, pre_string, post_string);
freevstring (&pre);
freevstring (&post);
}
void appendfield(char *); /* links with store.c and yapstree.c */
@@ -2919,13 +2894,12 @@ parsemusic (field)
{
struct vstring gchord;
p = p + 1;
initvstring (&gchord);
while ((*p != '"') && (*p != '\0'))
{
addch (*p, &gchord);
p = p + 1;
};
/* modified JA 20 May 2022 */
/* need to allow umlaut sequence in "guitar chords" which
* are being used for arbitrary text e.g. "_last time"
*/
p = umlaut_build_string(p+1, &gchord);
if (*p == '\0')
{
event_error ("Guitar chord name not properly closed");

View File

@@ -186,7 +186,7 @@ int main()
*/
#define VERSION "4.72 April 27 2022 abc2midi"
#define VERSION "4.73 May 20 2022 abc2midi"
/* enables reading V: indication in header */
#define XTEN1 1

View File

@@ -21,7 +21,7 @@
/* back-end for outputting (possibly modified) abc */
#define VERSION "2.16 February 21 2022 abc2abc"
#define VERSION "2.17 May 20 2022 abc2abc"
/* for Microsoft Visual C++ 6.0 or higher */
#ifdef _MSC_VER

View File

@@ -22,7 +22,7 @@
/* yapstree.c - back-end for abc parser. */
/* generates a data structure suitable for typeset music */
#define VERSION "1.88 February 22 2022 yaps"
#define VERSION "1.89 May 20 2022 yaps"
#include <stdio.h>
#ifdef USE_INDEX
#define strchr index