mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-15 15:51:01 +00:00
Compare commits
4 Commits
2023.01.21
...
2023.02.20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a410e191d0 | ||
|
|
a29dc35927 | ||
|
|
5202b73bac | ||
|
|
c01220de2d |
10
doc/CHANGES
10
doc/CHANGES
@@ -15069,3 +15069,13 @@ dependent_voice(), is no longer used and is also eliminated.
|
|||||||
to fix the bug addressed at the same date.
|
to fix the bug addressed at the same date.
|
||||||
|
|
||||||
|
|
||||||
|
February 07 2023
|
||||||
|
abc2abc: in toabc.c, James Allwright has introduced a new option -c
|
||||||
|
which replaces /2 with /. He also fixed the -h output in
|
||||||
|
event_init() so that all options are listed.
|
||||||
|
|
||||||
|
|
||||||
|
February 08 2023
|
||||||
|
midi2abc, mftext, midistats: modified midifile.c so that it indicates where
|
||||||
|
it encounters an unexpected byte in the input midi file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
abcMIDI : abc <-> MIDI conversion utilities
|
abcMIDI : abc <-> MIDI conversion utilities
|
||||||
|
|
||||||
midi2abc version 3.58 December 09 2022
|
midi2abc version 3.59 February 08 2023
|
||||||
abc2midi version 4.84 January 06 2023
|
abc2midi version 4.84 January 06 2023
|
||||||
abc2abc version 2.19 January 08 2023
|
abc2abc version 2.20 February 07 2023
|
||||||
yaps version 1.92 January 06 2023
|
yaps version 1.92 January 06 2023
|
||||||
abcmatch version 1.82 June 14 2022
|
abcmatch version 1.82 June 14 2022
|
||||||
midicopy version 1.38 May 06 2022
|
midicopy version 1.38 May 06 2022
|
||||||
midistats version 0.58 December 09 2022
|
midistats version 0.59 February 08 2023
|
||||||
|
|
||||||
24th January 2002
|
24th January 2002
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
* based on public domain 'midifilelib' package.
|
* based on public domain 'midifilelib' package.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "3.58 December 09 2022 midi2abc"
|
#define VERSION "3.59 February 08 2023 midi2abc"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
/* Microsoft Visual C++ Version 6.0 or higher */
|
/* Microsoft Visual C++ Version 6.0 or higher */
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ char *s;
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ( n++<4 && (c=(*Mf_getc)()) != EOF ) {
|
while ( n++<4 && (c=(*Mf_getc)()) != EOF ) {
|
||||||
|
Mf_bytesread++; /* [SS] 2023-02-08 */
|
||||||
if ( c != *p++ ) {
|
if ( c != *p++ ) {
|
||||||
char buff[32];
|
char buff[32];
|
||||||
(void) strcpy(buff,"expecting ");
|
(void) strcpy(buff,"expecting ");
|
||||||
@@ -229,7 +230,7 @@ readheader() /* read a header chunk */
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Mf_toberead = read32bit();
|
Mf_toberead = read32bit();
|
||||||
Mf_bytesread = 0;
|
/* Mf_bytesread = 0; [SS] 2023-01-08 */
|
||||||
format = read16bit();
|
format = read16bit();
|
||||||
ntrks = read16bit();
|
ntrks = read16bit();
|
||||||
division = read16bit();
|
division = read16bit();
|
||||||
@@ -281,7 +282,7 @@ readtrack() /* read a track chunk */
|
|||||||
|
|
||||||
Mf_toberead = read32bit();
|
Mf_toberead = read32bit();
|
||||||
Mf_currtime = 0;
|
Mf_currtime = 0;
|
||||||
Mf_bytesread =0;
|
/* Mf_bytesread =0; [SS] 2022.02.08 */
|
||||||
|
|
||||||
if ( Mf_trackstart )
|
if ( Mf_trackstart )
|
||||||
(*Mf_trackstart)();
|
(*Mf_trackstart)();
|
||||||
@@ -397,9 +398,9 @@ static void
|
|||||||
badbyte(c)
|
badbyte(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
char buff[32];
|
char buff[96]; /* [SS] 2022.02.08 */
|
||||||
|
|
||||||
(void) sprintf(buff,"unexpected byte: 0x%02x",c);
|
(void) sprintf(buff,"unexpected byte: 0x%02x at byte %ld (0x%lX)",c,Mf_bytesread,Mf_bytesread);
|
||||||
mferror(buff);
|
mferror(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
151
midistats.c
151
midistats.c
@@ -18,7 +18,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "0.58 December 08 2022 midistats"
|
#define VERSION "0.60 February 20 2023 midistats"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
/* Microsoft Visual C++ Version 6.0 or higher */
|
/* Microsoft Visual C++ Version 6.0 or higher */
|
||||||
@@ -72,17 +72,29 @@ int trackno;
|
|||||||
int maintrack;
|
int maintrack;
|
||||||
int format; /* MIDI file type */
|
int format; /* MIDI file type */
|
||||||
int debug;
|
int debug;
|
||||||
|
int pulseanalysis;
|
||||||
|
int corestats;
|
||||||
int chordthreshold; /* number of maximum number of pulses separating note */
|
int chordthreshold; /* number of maximum number of pulses separating note */
|
||||||
int beatsPerBar = 4; /* 4/4 time */
|
int beatsPerBar = 4; /* 4/4 time */
|
||||||
int divisionsPerBar;
|
int divisionsPerBar;
|
||||||
int unitDivision;
|
int unitDivision;
|
||||||
|
|
||||||
|
|
||||||
|
struct eventstruc {int onsetTime;
|
||||||
|
unsigned char channel;
|
||||||
|
unsigned char pitch;
|
||||||
|
unsigned char velocity;
|
||||||
|
;} midievents[20000];
|
||||||
|
|
||||||
|
int lastEvent = 0;
|
||||||
|
|
||||||
|
|
||||||
int tempocount=0; /* number of tempo indications in MIDI file */
|
int tempocount=0; /* number of tempo indications in MIDI file */
|
||||||
|
|
||||||
int stats = 0; /* flag - gather and print statistics */
|
int stats = 0; /* flag - gather and print statistics */
|
||||||
|
|
||||||
|
int pulseanalysis = 0;
|
||||||
|
int corestats = 0;
|
||||||
|
|
||||||
|
|
||||||
/* can cope with up to 64 track MIDI files */
|
/* can cope with up to 64 track MIDI files */
|
||||||
@@ -159,6 +171,8 @@ static int progmapper[] = {
|
|||||||
16, 16, 16, 16, 16, 16, 16, 16
|
16, 16, 16, 16, 16, 16, 16, 16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int pulseCounter[480];
|
||||||
|
int pulseDistribution[24];
|
||||||
|
|
||||||
struct barPattern {
|
struct barPattern {
|
||||||
int activeBarNumber;
|
int activeBarNumber;
|
||||||
@@ -776,7 +790,40 @@ int nn, dd, cc, bb;
|
|||||||
printf("timesig %d/%d %6.2f\n",nn,denom,beatnumber);
|
printf("timesig %d/%d %6.2f\n",nn,denom,beatnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void record_noteon(int chan,int pitch,int vol)
|
||||||
|
{
|
||||||
|
if (vol < 1) return; /* noteoff ? */
|
||||||
|
midievents[lastEvent].onsetTime = Mf_currtime;
|
||||||
|
midievents[lastEvent].channel = chan;
|
||||||
|
midievents[lastEvent].pitch = pitch;
|
||||||
|
midievents[lastEvent].velocity = vol;
|
||||||
|
lastEvent++;
|
||||||
|
if (lastEvent > 19999) {printf("ran out of space in midievents structure\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void record_noteoff(int chan,int pitch,int vol)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void record_trackend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_compare_events(const void *a, const void *b) {
|
||||||
|
struct eventstruc *ia = (struct eventstruc *)a;
|
||||||
|
struct eventstruc *ib = (struct eventstruc *)b;
|
||||||
|
if (ib->onsetTime > ia->onsetTime)
|
||||||
|
return -1;
|
||||||
|
else if (ia ->onsetTime > ib->onsetTime)
|
||||||
|
return 1;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_header (int format, int ntrks, int ldivision)
|
||||||
|
{
|
||||||
|
division = ldivision;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void initfunc_for_stats()
|
void initfunc_for_stats()
|
||||||
@@ -806,6 +853,84 @@ void initfunc_for_stats()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initfunc_for_loadNoteEvents()
|
||||||
|
{
|
||||||
|
Mf_error = error;
|
||||||
|
Mf_header = load_header;
|
||||||
|
Mf_trackstart = no_op0;
|
||||||
|
Mf_trackend = record_trackend;
|
||||||
|
Mf_noteon = record_noteon;
|
||||||
|
Mf_noteoff = record_noteoff;
|
||||||
|
Mf_pressure = no_op3;
|
||||||
|
Mf_parameter = no_op3;
|
||||||
|
Mf_pitchbend = no_op3;
|
||||||
|
Mf_program = no_op0;
|
||||||
|
Mf_chanpressure = no_op3;
|
||||||
|
Mf_sysex = no_op2;
|
||||||
|
Mf_metamisc = no_op3;
|
||||||
|
Mf_seqnum = no_op1;
|
||||||
|
Mf_eot = no_op0;
|
||||||
|
Mf_timesig = no_op4;
|
||||||
|
Mf_smpte = no_op5;
|
||||||
|
Mf_tempo = no_op1;
|
||||||
|
Mf_keysig = no_op2;
|
||||||
|
Mf_seqspecific = no_op3;
|
||||||
|
Mf_text = no_op3;
|
||||||
|
Mf_arbitrary = no_op2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dumpMidievents (int from , int to)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = from; i < to; i++) {
|
||||||
|
printf("%5d %d %d %d\n",midievents[i].onsetTime, midievents[i].channel,
|
||||||
|
midievents[i].pitch, midievents[i].velocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_finish()
|
||||||
|
{
|
||||||
|
qsort(midievents,lastEvent,sizeof(struct eventstruc),int_compare_events);
|
||||||
|
/*dumpMidievents(0,50);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void pulseHistogram() {
|
||||||
|
int i,j;
|
||||||
|
int pulsePosition;
|
||||||
|
int decimate;
|
||||||
|
float fraction;
|
||||||
|
for (i = 0; i< 480; i++) pulseCounter[i] = 0;
|
||||||
|
for (i = 0; i < lastEvent; i++) {
|
||||||
|
pulsePosition = midievents[i].onsetTime % division;
|
||||||
|
pulseCounter[pulsePosition]++;
|
||||||
|
if (pulsePosition >= 480) {printf("pulsePosition = %d too large\n",pulsePosition);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < 24; i++) pulseDistribution[i] = 0;
|
||||||
|
/*for (i = 0; i < 480; i++) printf(" %d",pulseCounter[i]);
|
||||||
|
printf("\n");
|
||||||
|
*/
|
||||||
|
decimate = division/24;
|
||||||
|
for (i = 0; i < division; i++) {
|
||||||
|
j = i/decimate;
|
||||||
|
pulseDistribution[j] += pulseCounter[i];
|
||||||
|
}
|
||||||
|
for (i = 0; i < 24; i++)
|
||||||
|
{fraction = (float) pulseDistribution[i] / (float) lastEvent;
|
||||||
|
printf(" %8.4f",fraction);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void corestatsOutput() {
|
||||||
|
printf("%d\t%d\n", division,lastEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int readnum(num)
|
int readnum(num)
|
||||||
/* read a number from a string */
|
/* read a number from a string */
|
||||||
/* used for processing command line */
|
/* used for processing command line */
|
||||||
@@ -910,9 +1035,17 @@ int argc;
|
|||||||
if ((arg != -1) && (arg <argc)) {
|
if ((arg != -1) && (arg <argc)) {
|
||||||
debug = readnum(argv[arg]);
|
debug = readnum(argv[arg]);
|
||||||
}
|
}
|
||||||
|
arg = getarg("-pulseanalysis",argc,argv);
|
||||||
|
if (arg != -1) {
|
||||||
|
pulseanalysis = 1;
|
||||||
|
stats = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
arg = getarg("-corestats",argc,argv);
|
||||||
|
if (arg != -1) {
|
||||||
|
corestats = 1;
|
||||||
|
stats = 0;
|
||||||
|
}
|
||||||
|
|
||||||
arg = getarg("-o",argc,argv);
|
arg = getarg("-o",argc,argv);
|
||||||
if ((arg != -1) && (arg < argc)) {
|
if ((arg != -1) && (arg < argc)) {
|
||||||
@@ -934,6 +1067,8 @@ int argc;
|
|||||||
else {
|
else {
|
||||||
printf("midistats version %s\n usage :\n",VERSION);
|
printf("midistats version %s\n usage :\n",VERSION);
|
||||||
printf("midistats filename <options>\n");
|
printf("midistats filename <options>\n");
|
||||||
|
printf(" -corestats\n");
|
||||||
|
printf(" -pulseanalysis\n");
|
||||||
printf(" -ver version number\n");
|
printf(" -ver version number\n");
|
||||||
printf(" -d <number> debug parameter\n");
|
printf(" -d <number> debug parameter\n");
|
||||||
printf(" The input filename is assumed to be any string not\n");
|
printf(" The input filename is assumed to be any string not\n");
|
||||||
@@ -955,6 +1090,15 @@ mfread();
|
|||||||
stats_finish();
|
stats_finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadEvents() {
|
||||||
|
initfunc_for_loadNoteEvents();
|
||||||
|
Mf_getc = filegetc;
|
||||||
|
mfread();
|
||||||
|
load_finish();
|
||||||
|
if (pulseanalysis) pulseHistogram();
|
||||||
|
if (corestats) corestatsOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(argc,argv)
|
int main(argc,argv)
|
||||||
@@ -966,5 +1110,6 @@ int argc;
|
|||||||
|
|
||||||
arg = process_command_line_arguments(argc,argv);
|
arg = process_command_line_arguments(argc,argv);
|
||||||
if(stats == 1) midistats(argc,argv);
|
if(stats == 1) midistats(argc,argv);
|
||||||
|
if(pulseanalysis || corestats) loadEvents();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
39
toabc.c
39
toabc.c
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
/* back-end for outputting (possibly modified) abc */
|
/* back-end for outputting (possibly modified) abc */
|
||||||
|
|
||||||
#define VERSION "2.19 Jan 08 2022 abc2abc"
|
#define VERSION "2.20 Feb 07 2023 abc2abc"
|
||||||
|
|
||||||
/* for Microsoft Visual C++ 6.0 or higher */
|
/* for Microsoft Visual C++ 6.0 or higher */
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -84,6 +84,7 @@ struct fract breakpoint; /* used to break bar into beamed sets of notes */
|
|||||||
complex_barpoint_t master_bar_break;
|
complex_barpoint_t master_bar_break;
|
||||||
int barno; /* number of bar within tune */
|
int barno; /* number of bar within tune */
|
||||||
int newspacing; /* was -s option selected ? */
|
int newspacing; /* was -s option selected ? */
|
||||||
|
int compact_lengths; /* was -c selected ? [JA] 2023-02-07 */
|
||||||
int have_spacing_scheme; /* do we support spacing for time signature ? [JA] */
|
int have_spacing_scheme; /* do we support spacing for time signature ? [JA] */
|
||||||
int barcheck; /* indicate -b and -r options selected */
|
int barcheck; /* indicate -b and -r options selected */
|
||||||
int echeck; /* was error-checking turned off ? (-e option) */
|
int echeck; /* was error-checking turned off ? (-e option) */
|
||||||
@@ -530,9 +531,13 @@ char** filename;
|
|||||||
|
|
||||||
if ((getarg("-h", argc, argv) != -1) || (argc < 2)) {
|
if ((getarg("-h", argc, argv) != -1) || (argc < 2)) {
|
||||||
printf("abc2abc version %s\n",VERSION);
|
printf("abc2abc version %s\n",VERSION);
|
||||||
printf("Usage: abc2abc <filename> [-s] [-n X] [-b] [-r] [-e] [-t X]\n");
|
printf("Usage: abc2abc <filename> [-s] [-c] [-u] [-n X] [-b] [-r] [-e]\n");
|
||||||
|
printf(" [-t X] [-nda] [-nokeys] [-nokeyf] [-usekey n] [-useclef]\n");
|
||||||
printf(" [-u] [-d] [-v] [-V X[,Y,,,]] [-P X[,Y...]] [-ver] [-X n]\n");
|
printf(" [-u] [-d] [-v] [-V X[,Y,,,]] [-P X[,Y...]] [-ver] [-X n]\n");
|
||||||
|
printf(" [-xref] [-OCC]\n");
|
||||||
printf(" -s for new spacing\n");
|
printf(" -s for new spacing\n");
|
||||||
|
printf(" -c compact note lengths use / instead of /2\n");
|
||||||
|
printf(" -u to update notation ([] for chords and () for slurs)\n");
|
||||||
printf(" -n X to re-format the abc with a new linebreak every X bars\n");
|
printf(" -n X to re-format the abc with a new linebreak every X bars\n");
|
||||||
printf(" -b to remove bar checking\n");
|
printf(" -b to remove bar checking\n");
|
||||||
printf(" -r to remove repeat checking\n");
|
printf(" -r to remove repeat checking\n");
|
||||||
@@ -541,7 +546,6 @@ char** filename;
|
|||||||
printf(" -nda No double accidentals in guitar chords\n");
|
printf(" -nda No double accidentals in guitar chords\n");
|
||||||
printf(" -nokeys No key signature. Use sharps\n");
|
printf(" -nokeys No key signature. Use sharps\n");
|
||||||
printf(" -nokeyf No key signature. Use flats\n");
|
printf(" -nokeyf No key signature. Use flats\n");
|
||||||
printf(" -u to update notation ([] for chords and () for slurs)\n");
|
|
||||||
printf(" -usekey n Use key signature sf (sharps/flats)\n");
|
printf(" -usekey n Use key signature sf (sharps/flats)\n");
|
||||||
printf(" -useclef (treble or bass)\n"); /* [SS] 2020-01-22 */
|
printf(" -useclef (treble or bass)\n"); /* [SS] 2020-01-22 */
|
||||||
printf(" -d to notate with doubled note lengths\n");
|
printf(" -d to notate with doubled note lengths\n");
|
||||||
@@ -576,6 +580,12 @@ char** filename;
|
|||||||
} else {
|
} else {
|
||||||
newspacing = 1;
|
newspacing = 1;
|
||||||
};
|
};
|
||||||
|
/* [JA] 2023-02-07 */
|
||||||
|
if (getarg ("-c", argc, argv) == -1) {
|
||||||
|
compact_lengths = 0;
|
||||||
|
} else {
|
||||||
|
compact_lengths = 1;
|
||||||
|
};
|
||||||
have_spacing_scheme = 0; /* [JA] 2021-05-25 */
|
have_spacing_scheme = 0; /* [JA] 2021-05-25 */
|
||||||
narg = getarg("-X", argc, argv);
|
narg = getarg("-X", argc, argv);
|
||||||
if (narg == -1) {
|
if (narg == -1) {
|
||||||
@@ -1751,30 +1761,19 @@ int explict;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [JM] 2018-02-22 (add code to treat / and // lengths when
|
|
||||||
SHORT_HALFS is defined during compilation
|
|
||||||
*/
|
|
||||||
static void printlen(a, b)
|
static void printlen(a, b)
|
||||||
int a, b;
|
int a, b;
|
||||||
{
|
{
|
||||||
if (a != 1) {
|
if (a != 1) {
|
||||||
emit_int(a);
|
emit_int(a);
|
||||||
};
|
};
|
||||||
#ifdef SHORT_HALFS
|
|
||||||
else {
|
|
||||||
if (b == 2) {
|
|
||||||
emit_string("/");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (b == 4) {
|
|
||||||
emit_string("//");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (b != 1) {
|
if (b != 1) {
|
||||||
emit_int_sprintf("/%d", b);
|
emit_string ("/");
|
||||||
};
|
/* [JA] 2023-02-07 */
|
||||||
|
if ((!compact_lengths) || (b != 2)) {
|
||||||
|
emit_int (b);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_spacing(n, m)
|
void event_spacing(n, m)
|
||||||
|
|||||||
Reference in New Issue
Block a user