From cc1a30b3b4cfa8147336644c423199a425155fde Mon Sep 17 00:00:00 2001 From: Seymour Shlien Date: Tue, 27 Dec 2022 15:22:18 -0500 Subject: [PATCH] 2022.12.27 --- VERSION | 2 +- doc/CHANGES | 28 ++++++++++++++++++++++++++++ doc/readme.txt | 2 +- parseabc.c | 21 ++++++++++++++------- store.c | 4 ++-- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 989d58a..e28a4be 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -December 21 2022 +December 27 2022 diff --git a/doc/CHANGES b/doc/CHANGES index ae01f43..020e691 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -14926,3 +14926,31 @@ returned a bad index into the scale array. Fix: tested that p is in the range 0 to 7. + +December 27 2022 + +abcmidi: The instrument=/ is defined as a shorthand +for score= sound=c. For instrument=, +indicates the key of the instrument and is either c or C. +The sound= directive specifies the note and how it is played. +For example, sound=c_B indicates that the note c is played as +_B on the instrument. Every note is transposed down by two semitones. +The problem is that, the notes in the instrument directive are +in the opposite order of the sound= and score= directives. +The function parsesound() in parseabc.c treats takes care of +the directives sound =, shift = and instrument =. +Unfortunately, all these directives are treated in the same +manner causing the instrument= directive to transpose +in the wrong direction. + +Fix: for the special case, instrument=, transpose is set to +p1 - p2 instead of p2 - p1. + +The '/' is only part of the instrument= syntax. Note2midi has +an extra parameter, word, indicating the type of directive. +It will issue a warning if it detects a '/' in the sound= or +shift= directives. + + + + diff --git a/doc/readme.txt b/doc/readme.txt index 4f95632..44cfac4 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.77 December 21 2022 +abc2midi version 4.78 December 27 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 b9c58f2..be6995b 100644 --- a/parseabc.c +++ b/parseabc.c @@ -82,7 +82,7 @@ extern char *malloc (); extern char *strchr (); #endif -int note2midi (char** s); +int note2midi (char** s, char* word); /*[SS] 2022-12-27 added word */ int lineno; int parsing_started = 0; int parsing, slur; @@ -1049,16 +1049,19 @@ parsesound (s, word, gottranspose, transpose) } else { *s = *s + 1; skipspace (s); - p1 = note2midi (s); + p1 = note2midi (s,word); /*printf("p1 midi note = %d\n",p1);*/ - p2 = note2midi (s); + p2 = note2midi (s,word); /*printf("p2 midi note = %d\n",p2);*/ if (p2 == p1) { p2 = 72; /* [SS] 2022.12.21 */ } - *transpose = p2 - p1; /* [SS] 2022.02.18 2022.04.27 */ - /* printf("transpose = %d\n",*transpose); */ + if (casecmp(word,"instrument") == 0) { /*2022.12.27 */ + *transpose = p1 - p2; /* [SS] 2022.02.18 2022.04.27 */ + } else { + *transpose = p2 - p1; /* [SS] 2022.02.18 2022.04.27 */ + } *gottranspose = 1; } return 1; @@ -2617,6 +2620,7 @@ print_inputline () static void check_bar_repeats (int bar_type, char *replist) { voice_context_t *cv = &voicecode[voicenum]; + char error_message[140]; switch (bar_type) { case SINGLE_BAR: @@ -2636,7 +2640,6 @@ static void check_bar_repeats (int bar_type, char *replist) break; case REP_BAR: if (!cv->expect_repeat) { - char error_message[80]; if (cv->repeat_count == 0) { @@ -2750,7 +2753,7 @@ return p; /* [SS] 2021-10-11 */ int -note2midi (char** s) +note2midi (char** s, char *word) { /* for implementing sound=, shift= and instrument= key signature options */ @@ -2817,6 +2820,10 @@ switch (**s) /* skip / which occurs in instrument = command */ *s = *s + 1; /* printf("note = %c accidental = %c mult = %d octave= %d \n",note,accidental,mult,octave); */ + if (casecmp(word,"instrument") != 0) { /* [SS] 2022-12-27 */ + event_warning("score and shift directives do not expect an embedded '/'"); + } + pitch = pitch2midi(note, accidental, mult, octave); return pitch; } diff --git a/store.c b/store.c index 9e5964b..a101d50 100644 --- a/store.c +++ b/store.c @@ -186,7 +186,7 @@ int main() */ -#define VERSION "4.77 December 21 2022 abc2midi" +#define VERSION "4.78 December 27 2022 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1 @@ -3450,7 +3450,7 @@ static void brokenadjust() }; }; if (failed) { - event_error("Cannot apply broken rhythm"); + event_error("Cannot apply broken rhythm. Notes not equal durations"); } else { /* printf("Adjusting %d to %d and %d to %d\n",