From 907c8fa19f657d2f9344b77d1f858ca3477f12da Mon Sep 17 00:00:00 2001 From: sshlien Date: Sat, 15 Feb 2025 20:12:53 -0500 Subject: [PATCH] 2025.02.15 --- VERSION | 2 +- doc/CHANGES | 30 ++++++++++++++++++++++++++++++ doc/readme.txt | 4 ++-- midi2abc.c | 31 ++++++++++++++++++++----------- midifile.c | 4 ++-- store.c | 7 ++++--- 6 files changed, 59 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index efb67af..e8aa3ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -February 07 2025 +February 15 2025 diff --git a/doc/CHANGES b/doc/CHANGES index 7eb9ee0..bfe45a0 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -15614,3 +15614,33 @@ for (clef->octave_offset and v->octaveshift are both -1. We want to apply only one of those.) + +February 15 2025 + +abc2midi ignores accidentals when converting to a temperamentequal scale. +In the following example: + +X:1 +T: temperamentequal 19 +M: 4/4 +L: 1/4 +%%MIDI temperamentequal 19 +K: none +C ^C _D D | ^D _E E F | ^F _G G ^G| _A A ^A _B| B c z z| + +the accidentals were ignored when creating the midi file. + +Fix: + +Changed + /* respect accidentals when they do not occur in a microtone */ + if (acc == '^' && !microtone) pitchvalue = pitchvalue + (float) mul; /* [SS] 2025-01-12 */ + if (acc == '_' && !microtone) pitchvalue = pitchvalue - (float) mul; + +To + + /* respect accidentals when they do not occur in a microtone */ + if (acc == '^' && !microtone) pitchvalue = pitchvalue + (float) (mul*accidental_size); /* [SS] 2025-02-15 */ + if (acc == '_' && !microtone) pitchvalue = pitchvalue - (float) (mul*accidental_size); + + diff --git a/doc/readme.txt b/doc/readme.txt index 6cfabc7..6b32ff8 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,7 +1,7 @@ abcMIDI : abc <-> MIDI conversion utilities -midi2abc version 3.62 February 06 2025 -abc2midi version 5.00 February 12 2025 +midi2abc version 3.63 February 13 2025 +abc2midi version 5.01 February 15 2025 abc2abc version 2.22 April 30 2024 yaps version 1.94 April 30 2024 abcmatch version 1.83 February 19 2024 diff --git a/midi2abc.c b/midi2abc.c index 8628dff..cceae1d 100644 --- a/midi2abc.c +++ b/midi2abc.c @@ -45,7 +45,7 @@ * based on public domain 'midifilelib' package. */ -#define VERSION "3.62 February 07 2025 midi2abc" +#define VERSION "3.63 February 13 2025 midi2abc" #include /* Microsoft Visual C++ Version 6.0 or higher */ @@ -703,19 +703,23 @@ if (leng == 12) { return; } } + /* for (i=0;i<12;i++) printf(" %d,",mess[i]); + printf("\n"); + */ midipitch = mess[7]; newpitch = mess[8]; - low = mess[9]; - hi = mess[10]; + hi = mess[9]; + low = mess[10]; hilo = hi*128 + low; - ratio = (float) hilo/16384.0; + ratio = (float) (hilo/16384.0); cents = (int) (0.5 + ratio*100.0); - modifiedPitch = (float) midipitch + ratio; - sysexBentPitches[newpitch] = modifiedPitch; + modifiedPitch = (float) (midipitch + ratio); + sysexBentPitches[midipitch] = modifiedPitch; + /*sysexBentPitches[newpitch] = modifiedPitch; /* why */ - /*printf("%d %d %d %d %f %d\n",midipitch,newpitch,low,hi,ratio,cents); - printf("sysext: %d %d\n",newpitch,cents); - */ + /*printf("%d %d %d %d %f %d\n",midipitch,newpitch,low,hi,ratio,cents);*/ + /*printf("sysext: %d %d\n",newpitch,cents);*/ + return; } else { printf("leng was %d\n",leng); @@ -1004,21 +1008,26 @@ int cents,centvalue,pitchbend; int newpitchint; float newpitch,fcents; + start_time = close_note(chan, pitch, &initvol); if (start_time <= 0) return; if (sysexBentPitches[pitch] >0.0) { newpitch = sysexBentPitches[pitch]; newpitchint = (int) newpitch; cents = (newpitch -newpitchint)*100; + if (cents >= 50) {newpitch = newpitch - 1.0; /* undo rounding */ + newpitchint = (int) newpitch; + cents = (newpitch -newpitchint)*100; + } centvalue = (newpitchint % 12)*100 + cents; - printf("%f\t%d\t%d\n",sysexBentPitches[pitch],cents,centvalue); + printf("%f\t%d\t%d\n",newpitch,cents,centvalue); } else {pitchbend = chanbend[chan+1]; fcents = 100.0 * (float) (pitchbend - 8192)/4096.0; cents = (int) (fcents + 0.5); if (cents < 0) { - pitch--; + /*pitch--; already flattened without pitchbend*/ cents +-100; } centvalue = cents + (pitch % 12)*100; diff --git a/midifile.c b/midifile.c index bfed68d..9b9e1b2 100644 --- a/midifile.c +++ b/midifile.c @@ -1028,7 +1028,7 @@ int number,intfraction; float fraction; eputc(0); /* varinum delta_t (time to next event) */ eputc(0xf0); /* sysex initiation */ - eputc(11); /* 11 bytes included in sysex */ +eputc(11); /* 11 bytes included in sysex */ eputc(127); /* universal sysex command (0x7f) */ eputc(0); /* device id */ eputc(8); /* midi tuning */ @@ -1040,7 +1040,7 @@ eputc(kk); /* MIDI key 0 - 127 */ number = (int) midipitch; fraction = midipitch - (float) number; if (fraction < 0.0) fraction = -fraction; -intfraction = (int) fraction*16384; +intfraction = (int) (fraction*16384); /* [HML] 2025-02-09 */ xx = 0x7f & number; yy = intfraction/128; zz = intfraction % 128; diff --git a/store.c b/store.c index 59d53ce..0940415 100755 --- a/store.c +++ b/store.c @@ -186,7 +186,7 @@ int main() */ -#define VERSION "5.00 February 02 2025 abc2midi" +#define VERSION "5.01 February 15 2025 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1 @@ -3775,9 +3775,10 @@ int *pitchbend; if ((temperament==TEMPERLN) || (temperament==TEMPEREQ)) { pitchvalue = tscale[p]/100.0; /* cents to semitones */ + /* respect accidentals when they do not occur in a microtone */ - if (acc == '^' && !microtone) pitchvalue = pitchvalue + (float) mul; /* [SS] 2025-01-12 */ - if (acc == '_' && !microtone) pitchvalue = pitchvalue - (float) mul; + if (acc == '^' && !microtone) pitchvalue = pitchvalue + (float) (mul*accidental_size); /* [SS] 2025-02-15 */ + if (acc == '_' && !microtone) pitchvalue = pitchvalue - (float) (mul*accidental_size); /* printf("note = %c accidental = %c mul = %d p = %d pitchvalue = %f\n",note,accidental,mul,p,pitchvalue); */ pitchvalue = pitchvalue + octave*octave_size/100.0 + middle_c;