mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-08 19:01:02 +00:00
Compare commits
2 Commits
2022.04.28
...
2022.05.20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b697536dc | ||
|
|
e564bf9954 |
45
doc/CHANGES
45
doc/CHANGES
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
17
midicopy.c
17
midicopy.c
@@ -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)
|
||||
|
||||
258
parseabc.c
258
parseabc.c
@@ -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,50 +1090,86 @@ 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 != '=')
|
||||
{
|
||||
if (**s != '=') {
|
||||
event_error ("name must be followed by '='");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*s = *s + 1;
|
||||
skipspace (s);
|
||||
if (**s == '"') /* string enclosed in double quotes */
|
||||
{
|
||||
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')
|
||||
{
|
||||
*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++;
|
||||
@@ -1142,61 +1179,7 @@ parsename (s, word, gotname, namestring, maxsize)
|
||||
*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
|
||||
{
|
||||
*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
|
||||
parsemiddle (s, word, gotmiddle, middlestring, maxsize)
|
||||
@@ -1672,14 +1655,17 @@ parsevoice (s)
|
||||
parsed = parseoctave (&s, word, &vparams.gotoctave, &vparams.octave);
|
||||
if (!parsed)
|
||||
parsed = parsesound (&s, word, &vparams.gottranspose, &vparams.transpose);
|
||||
if (!parsed)
|
||||
/* Code changed JA 20 May 2022 */
|
||||
if ((!parsed) && (strcasecmp (word, "name") == 0)) {
|
||||
parsed =
|
||||
parsename (&s, word, &vparams.gotname, vparams.namestring,
|
||||
parsename (&s, &vparams.gotname, vparams.namestring,
|
||||
V_STRLEN);
|
||||
if (!parsed)
|
||||
}
|
||||
if ((!parsed) && (strcasecmp (word, "sname") == 0)) {
|
||||
parsed =
|
||||
parsesname (&s, word, &vparams.gotsname, vparams.snamestring,
|
||||
parsename (&s, &vparams.gotsname, vparams.snamestring,
|
||||
V_STRLEN);
|
||||
}
|
||||
if (!parsed)
|
||||
parsed =
|
||||
parsemiddle (&s, word, &vparams.gotmiddle, vparams.middlestring,
|
||||
@@ -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')
|
||||
{
|
||||
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 = '\0';
|
||||
p = p + 1;
|
||||
} 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 == '=')
|
||||
{
|
||||
if (*p == '=') {
|
||||
p = place;
|
||||
skipspace (&p);
|
||||
if (((*p >= 'A') && (*p <= 'G')) || ((*p >= 'a') && (*p <= 'g')))
|
||||
{
|
||||
if (((*p >= 'A') && (*p <= 'G')) || ((*p >= 'a') && (*p <= 'g'))) {
|
||||
relative = 1;
|
||||
p = p + 1;
|
||||
};
|
||||
}
|
||||
readlen (&a, &b, &p);
|
||||
skipspace (&p);
|
||||
if (*p != '=')
|
||||
{
|
||||
if (*p != '=') {
|
||||
event_error ("Expecting = in tempo");
|
||||
};
|
||||
p = p + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = p + 1;
|
||||
} else {
|
||||
/* no "=" found - default to 1/4 note */
|
||||
a = 1; /* [SS] 2013-01-27 */
|
||||
/*a = 0; [SS] 2013-01-27 */
|
||||
b = 4;
|
||||
p = place;
|
||||
};
|
||||
skipspace (&p);
|
||||
n = readnump (&p);
|
||||
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");
|
||||
p = after_pre;
|
||||
}
|
||||
skipspace (&p);
|
||||
n = readnump (&p); /* read notes per minute value */
|
||||
post_string = NULL;
|
||||
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 */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = '\0';
|
||||
p = p + 1;
|
||||
};
|
||||
};
|
||||
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");
|
||||
|
||||
2
store.c
2
store.c
@@ -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
|
||||
|
||||
2
toabc.c
2
toabc.c
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user