diff --git a/VERSION b/VERSION index 39a8dac..989d58a 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -December 12 2022 +December 21 2022 diff --git a/doc/CHANGES b/doc/CHANGES index 0bb20db..ae01f43 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -14869,3 +14869,60 @@ December 9 2022 Cleaning out -stats code in midi2abc. + +December 21 2022 + +abc2midi: +Wnen equals in the instrument=/ directive, +note2 should be treated as c (midi pitch 72). Fix: parsesound in +parseabc.c was modified to return a midi pitch of 72 when the two +notes are equal. + +test file: + +X:1 +T: transpose +M: 4/4 +L: 1/4 +K: C instrument=F/F +FGAB|cdef| + +produces a midi file which looks like + +X: 1 +T: from h1.mid +M: 4/4 +L: 1/8 +Q:1/4=120 +K:C % 0 sharps +V:1 +c2 d2 e2 ^f2| \ +g2 a2 b2 c'2| + +when it was translated back to abc using midi2abc. + +Note that this change also applies to sound= and shift= even though +this may not be specified in the standard +http://abcnotation.com/wiki/abc:standard:v2.2#transposing_instrument_examples + + +December 22 2022 + +abcmidi: segementation fault. The following file produced a +segmentation fault. + +X:1 +T: transpose +M: 4/4 +L: 1/4 +K: C instrument=F +FGAB|cdef| + +Analysis: there is an invisible space following F in the +line K: C instrument=F . As a result the function note2midi +called pitch2midi with an invalid note (a space). The line +p = (int) ((long) strchr(anoctave, note) - (long) anoctave); +returned a bad index into the scale array. + +Fix: tested that p is in the range 0 to 7. + diff --git a/doc/readme.txt b/doc/readme.txt index 5b2ff6f..4f95632 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,7 +1,7 @@ abcMIDI : abc <-> MIDI conversion utilities midi2abc version 3.58 December 09 2022 -abc2midi version 4.76 August 01 2022 +abc2midi version 4.77 December 21 2022 abc2abc version 2.18 June 14 2022 yaps version 1.90 June 14 2022 abcmatch version 1.82 June 14 2022 diff --git a/parseabc.c b/parseabc.c index b6c59ea..b9c58f2 100644 --- a/parseabc.c +++ b/parseabc.c @@ -1050,17 +1050,16 @@ parsesound (s, word, gottranspose, transpose) *s = *s + 1; skipspace (s); p1 = note2midi (s); - /* printf("midi note = %d\n",p1); */ + /*printf("p1 midi note = %d\n",p1);*/ p2 = note2midi (s); + /*printf("p2 midi note = %d\n",p2);*/ + if (p2 == p1) { - *gottranspose = 0; - *transpose = 0; - } else { - /* printf("midi note = %d\n",p2); */ - *transpose = p2 - p1; /* [SS] 2022.02.18 2022.04.27 */ - /* printf("transpose = %d\n",*transpose); */ - *gottranspose = 1; - } + p2 = 72; /* [SS] 2022.12.21 */ + } + *transpose = p2 - p1; /* [SS] 2022.02.18 2022.04.27 */ + /* printf("transpose = %d\n",*transpose); */ + *gottranspose = 1; } return 1; } @@ -2736,6 +2735,10 @@ int mult, octave; noteno = (int)note - 'a'; p = (int) ((long) strchr(anoctave, note) - (long) anoctave); + if (p < 0 || p > 6) { /* [SS] 2022-12-22 */ + printf("illegal note %c\n",note); + return 72; + } p = scale[p]; if (acc == '^') p = p + mul; if (acc == '_') p = p - mul; @@ -2757,8 +2760,9 @@ char msg[80]; int octave; int mult; int pitch; -/*printf("note2midi: %c\n",**s); */ +/*printf("note2midi: %c\n",**s);*/ if (**s == '\0') return 72; +note = **s; mult = 1; accidental = ' '; switch (**s) diff --git a/store.c b/store.c index 84190b5..9e5964b 100644 --- a/store.c +++ b/store.c @@ -186,7 +186,7 @@ int main() */ -#define VERSION "4.76 August 01 2022 abc2midi" +#define VERSION "4.77 December 21 2022 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1