abcmidi/0000755000000000000000000000000013237135155011151 5ustar rootrootabcmidi/Makefile.in0000644000000000000000000001223012604163406013211 0ustar rootroot# Generic unix/gcc Makefile for abcMIDI package # # # compilation #ifdefs - you need to compile with these defined to get # the code to compile with PCC. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # ANSILIBS includes some ANSI header files (which gcc can live without, # but other compilers may want). # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # KANDR selects functions prototypes without argument prototypes. # currently yaps will only compile in ANSI mode. # # # On running make, you may get the mysterious message : # # ', needed by `parseabc.o'. Stop `abc.h # # This means you are using GNU make and this file is in DOS text format. To # cure the problem, change this file from using PC-style end-of-line (carriage # return and line feed) to unix style end-of-line (line feed). VERSION = @VERSION@ CC = @CC@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ CFLAGS = -DANSILIBS @CFLAGS@ CPPFLAGS = @DEFS@ @CPPFLAGS@ -I. LDFLAGS = @LDFLAGS@ -lm prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ VPATH = @srcdir@ bindir = @bindir@ libdir = @libdir@ datadir = @datarootdir@ docdir = @datarootdir@/doc/abcmidi mandir = @datarootdir@/man/man1 binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o abc2midi : $(OBJECTS_ABC2MIDI) $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm $(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile OBJECTS_ABC2ABC=parseabc.o toabc.o abc2abc : $(OBJECTS_ABC2ABC) $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) $(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile OBJECTS_MIDI2ABC=midifile.o midi2abc.o midi2abc : $(OBJECTS_MIDI2ABC) $(CC) $(CFLAGS) -o midi2abc $(OBJECTS_MIDI2ABC) $(LDFLAGS) $(OBJECTS_MIDI2ABC): abc.h midifile.h config.h Makefile OBJECTS_MFTEXT=midifile.o mftext.o crack.o mftext : $(OBJECTS_MFTEXT) $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) $(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o yaps : $(OBJECTS_YAPS) $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) $(OBJECTS_YAPS): abc.h midifile.h config.h Makefile OBJECTS_MIDICOPY=midicopy.o midicopy : $(OBJECTS_MIDICOPY) $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) $(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o abcmatch : $(OBJECTS_ABCMATCH) $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) $(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile parseabc.o : parseabc.c abc.h parseabc.h parser2.o : parser2.c abc.h parseabc.h parser2.h toabc.o : toabc.c abc.h parseabc.h # could use -DNOFTELL here genmidi.o : genmidi.c abc.h midifile.h genmidi.h stresspat.o : stresspat.c store.o : store.c abc.h parseabc.h midifile.h genmidi.h queues.o : queues.c genmidi.h # could use -DNOFTELL here midifile.o : midifile.c midifile.h midi2abc.o : midi2abc.c midifile.h midicopy.o : midicopy.c midicopy.h abcmatch.o: abcmatch.c abc.h crack.o : crack.c mftext.o : mftext.c midifile.h # objects needed by yaps # yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h pslib.o: pslib.c drawtune.h position.o: position.c abc.h structs.h sizes.h debug.o: debug.c structs.h abc.h #objects for abcmatch # matchsup.o : matchsup.c abc.h parseabc.h parser2.h clean : rm *.o ${binaries} install: abc2midi midi2abc abc2abc mftext midicopy yaps abcmatch $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -m 755 ${binaries} $(DESTDIR)$(bindir) # install documentation $(INSTALL) -d $(DESTDIR)${docdir} $(INSTALL) -m 644 doc/*.txt $(DESTDIR)$(docdir) $(INSTALL) -m 644 doc/AUTHORS $(DESTDIR)$(docdir) $(INSTALL) -m 644 doc/CHANGES $(DESTDIR)$(docdir) $(INSTALL) -m 644 VERSION $(DESTDIR)$(docdir) # install manpages $(INSTALL) -d $(DESTDIR)${mandir} $(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir) uninstall: echo "uninstalling..."; #rm -f $(DESTDIR)$(bindir)/$(binaries) rm -f $(DESTDIR)$(bindir)/abc2midi rm -f $(DESTDIR)$(bindir)/abc2abc rm -f $(DESTDIR)$(bindir)/yaps rm -f $(DESTDIR)$(bindir)/midi2abc rm -f $(DESTDIR)$(bindir)/mftext rm -f $(DESTDIR)$(bindir)/abcmatch rm -f $(DESTDIR)$(bindir)/midicopy rm -f $(DESTDIR)$(docdir)/*.txt rm -f $(DESTDIR)$(docdir)/AUTHORS rm -f $(DESTDIR)$(docdir)/CHANGES rm -f $(DESTDIR)$(docdir)/VERSION rm -f $(DESTDIR)$(mandir)/*.1 rmdir $(DESTDIR)$(docdir) abcmidi/config.h.in0000644000000000000000000000002411617507070013167 0ustar rootroot/* config.h.in */ abcmidi/toabc.c0000644000000000000000000020355113243543173012413 0ustar rootroot/* * toabc.c - part of abc2abc - program to manipulate abc files. * Copyright (C) 1999 James Allwright * e-mail: J.R.Allwright@westminster.ac.uk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * */ /* back-end for outputting (possibly modified) abc */ #define VERSION "1.98 February 22 2018 abc2abc" /* for Microsoft Visual C++ 6.0 or higher */ #ifdef _MSC_VER #define ANSILIBS #endif #include "abc.h" #include "parseabc.h" #include /* define USE_INDEX if your C libraries have index() instead of strchr() */ #ifdef USE_INDEX #define strchr index #endif #ifdef ANSILIBS #include #include #include #else extern char* strchr(); #endif #define MAX_VOICES 30 /* should be plenty! */ programname fileprogram = ABC2ABC; extern int oldchordconvention; /* for handling +..+ chords */ /* holds a fraction */ struct fract { int num; int denom; }; struct fract barlen; /* length of a bar as given by the time signature */ struct fract unitlen; /* unit length as given by the L: field */ struct fract count; /* length of bar so far */ struct fract prevcount; /* length of bar before last increment */ struct fract tuplefactor; /* factor associated with a tuple (N */ struct fract chordfactor; /* factor of the first note in a chord [PHDM] 2013-03-10 */ struct fract breakpoint; /* used to break bar into beamed sets of notes */ int barno; /* number of bar within tune */ int newspacing; /* was -s option selected ? */ int barcheck, repcheck; /* indicate -b and -r options selected */ int echeck; /* was error-checking turned off ? (-e option) */ int newbreaks; /* was -n option selected ? */ int nodouble_accidentals; int totalnotes, notecount; int bars_per_line; /* number supplied after -n option */ int barcount; int expect_repeat; int tuplenotes, barend; int xinhead, xinbody; /* are we in head or body of abc tune ? */ int inmusic; /* are we in a line of notes (in the tune body) ? */ int startline, blankline; int transpose; /* number of semitones to transpose by (-t option) */ struct fract lenfactor; /* fraction to scale note lengths; -v,-d options */ int newkey; /* key after transposition (expressed as no. of sharps) */ int lines; /* used by transposition */ int orig_key_number; /* used for gchord transposition */ int new_key_number; /* used for gchord transposition */ int oldtable[7], newtable[7]; /* for handling transposition */ int inchord; /* are we in a chord [ ] ? */ int ingrace; /* are we in a grace note set { } ? */ int chordcount; /* number of notes or rests in current chord */ int inlinefield; /* boolean - are we in [: ] ? */ int cleanup; /* boolean to indicate -u option (update notation) */ char tmp[2000]; /* buffer to hold abc output being assembled */ int output_on = 1; /* if 0 suppress output */ int passthru = 0; /* output original abc file [SS] 2011-06-07 */ long selected_voices = -1; /* all voices are selected [PHDM] 2013-03-08 */ int newrefnos; /* boolean for -X option (renumber X: fields) */ int newref; /* next new number for X: field */ int useflats=0; /* flag associated with nokey.*/ int adapt_useflats_to_gchords = 1; /* experimental flag */ int usekey = 0; int drumchan=0; /* flag to suppress transposition */ int noplus; /* flag for outputting !..! instructions instead of +...+ */ int xmatch = -1; /* selected tune to process [SS] 2017-07-10 */ extern int nokey; /* signals no key signature assumed */ extern int nokeysig; /* signals -nokeys or -nokeysf option */ extern int voicecodes ; /* from parseabc.c */ extern char voicecode[16][30]; /*for interpreting V: string */ struct voicetype { /* information needed for each voice */ int number; /* voice number from V: field */ int barcount; int foundbar; struct abctext* currentline; int bars_remaining; int bars_complete; int drumchan; } voice[MAX_VOICES]; int voicecount, this_voice, next_voice; enum abctype {field, bar, barline}; /* linestat is used by -n for deciding when to generate a newline */ enum linestattype {fresh, midmusic, endmusicline, postfield}; enum linestattype linestat; /* struct abctext is used to store abc lines for re-formatting (-n option) */ struct lyricwords{ struct lyricwords* nextverse; char* words; }; struct abctext{ /* linked list used to store output before re-formatting */ struct abctext* next; char* text; enum abctype type; int notes; struct lyricwords* lyrics; }; struct abctext* head; struct abctext* tail; extern char *mode[]; extern int modekeyshift[]; int basemap[7], workmap[7]; /* for -nokey and pitchof() */ int workmul[7]; void copymap(); void printpitch(int); void setup_sharps_flats (int sf); int pitchof(char note,int accidental,int mult,int octave); void transpose_note(char xaccidental,int xmult,char xnote,int xoctave,int transpose, char* accidental, int* mult, char* note, int* octave); static int purgespace(p) char* p; /* if string p is empty or consists of spaces, set p to the empty string */ /* and return 1, otherwise return 0. Used to test tmp */ /* part of new linebreak option (-n) */ { int blank; char *s; blank = 1; s = p; while (*s != '\0') { if (*s != ' ') blank = 0; s = s + 1; }; if (blank) { *p = '\0'; }; return(blank); } int zero_barcount(foundbar) /* initialize bar counter for abctext elements */ /* part of new linebreak option (-n) */ int *foundbar; { *foundbar = 0; return(0); } int new_barcount(type, foundbar, oldcount) enum abctype type; int *foundbar; int oldcount; /* work out whether we have reached the end of a bar in abctext elements */ /* and increment barcount if we have */ /* part of new linebreak option (-n) */ { int new_value; new_value = oldcount; if (type == bar) { *foundbar = 1; }; if ((type == barline) && (*foundbar == 1)) { new_value = new_value + 1; *foundbar = 0; }; return(new_value); } static void setline(t) enum linestattype t; /* generates newline, or continuation, or nothing at all */ /* part of new linebreak option (-n) */ { if ((t == fresh) && ((linestat == postfield) || (linestat == endmusicline))) { printf("\n"); }; if ((t == fresh) && (linestat == midmusic)) { printf("\\\n"); }; linestat = t; } static int flush_abctext(bars, termination) int bars; enum linestattype termination; /* outputs up to the specified number of bars of stored music */ /* and frees up the storage allocated for those bars. */ /* returns the number of bars actually output */ /* part of new linebreak option (-n) */ { struct abctext *p, *nextp; struct lyricwords *q, *r; struct lyricwords *barlyrics; int count, donewords, wordline; int i, foundtext; int foundbar; /* printf("flush_abctext called\n"); */ /* print music */ p = head; count = zero_barcount(&foundbar); while ((p != NULL) && (count < bars)) { if (p->type == field) { setline(fresh); }; printf("%s", p->text); if (p->type == field) { setline(postfield); setline(fresh); } else { setline(midmusic); }; count = new_barcount(p->type, &foundbar, count); if ((count == bars) && (p->type == barline)) { setline(endmusicline); }; p = p->next; }; if (linestat == midmusic) { setline(termination); }; if (bars > 0) { /* print out any w: lines */ donewords = 0; wordline = 0; while (donewords == 0) { p = head; foundtext = 0; count = zero_barcount(&foundbar); while ((p != NULL) && (count < bars)) { barlyrics = p->lyrics; for (i=0; inextverse; }; }; if (barlyrics != NULL) { if (foundtext == 0) { setline(fresh); printf("w:"); foundtext = 1; }; printf("%s",barlyrics->words); }; count = new_barcount(p->type, &foundbar, count); p = p->next; }; if (foundtext == 0) { donewords = 1; } else { setline(postfield); setline(fresh); }; wordline = wordline + 1; }; }; /* move head on and free up space used by stuff printed out */ count = zero_barcount(&foundbar); p = head; foundbar = 0; while ((p != NULL) && (count < bars)) { if (p != NULL) { free(p->text); q = p->lyrics; while (q != NULL) { free(q->words); r = q->nextverse; free(q); q = r; }; count = new_barcount(p->type, &foundbar, count); nextp = p->next; free(p); p = nextp; }; head = p; }; if (head == NULL) { tail = NULL; }; return(count); } void complete_bars(v) /* mark all bars as completed (i.e. having associated w: fields parsed) */ /* and out put all music lines which contain the full set of bars */ /* part of new linebreak option (-n) */ struct voicetype *v; { int bars_done; v->bars_complete = v->bars_complete + v->barcount; v->barcount = 0; while (v->bars_complete > v->bars_remaining) { bars_done = flush_abctext(v->bars_remaining, endmusicline); setline(fresh); v->bars_complete = v->bars_complete - bars_done; v->bars_remaining = v->bars_remaining - bars_done; if (v->bars_remaining == 0) { v->bars_remaining = bars_per_line; }; }; } void complete_all(v, termination) struct voicetype *v; enum linestattype termination; /* output all remaining music and fields */ /* part of new linebreak option (-n) */ { int bars_done; complete_bars(v); bars_done = flush_abctext(v->bars_remaining+1, termination); v->bars_complete = v->bars_complete - bars_done; v->bars_remaining = v->bars_remaining - bars_done; if (v->bars_remaining == 0) { v->bars_remaining = bars_per_line; }; head = NULL; tail = NULL; voice[this_voice].currentline = NULL; } static struct abctext* newabctext(t) enum abctype t; /* called at newlines and barlines */ /* adds current output text to linked list structure */ /* part of new linebreak option (-n) */ { struct abctext* p; if (output_on == 0) { p = NULL; return(p); }; if (newbreaks) { /* if ((t == field) && (!xinbody || (this_voice != next_voice))) { */ if (t == field) { complete_all(&voice[this_voice], midmusic); this_voice = next_voice; }; p = (struct abctext*) checkmalloc(sizeof(struct abctext)); p->text = addstring(tmp); tmp[0] = '\0'; p->next = NULL; p->type = t; p->lyrics = NULL; if (t == bar) { p->notes = notecount; totalnotes = totalnotes + notecount; notecount = 0; } else { p->notes = 0; }; if (xinbody) { voice[this_voice].barcount = new_barcount(t, &voice[this_voice].foundbar, voice[this_voice].barcount); }; if (head == NULL) { head = p; tail = p; } else { tail->next = p; tail = p; }; if ((t != field) && (voice[this_voice].currentline == NULL)) { voice[this_voice].currentline = p; }; } else { printf("%s", tmp); /* output to stdout is here */ tmp[0] = '\0'; p = NULL; }; inmusic = 1; return(p); } static int nextnotes() /* return the number of notes in the next bar */ /* part of new linebreak option (-n) */ { int n, got; struct abctext* p; p = head; n = 100; got = 0; while ((p != NULL) && (!got)) { if (p->type == bar) { n = p->notes; got = 1; } else { p = p->next; }; }; return(n); } static void reduce(a, b) int *a, *b; { int t, n, m; /* find HCF using Euclid's algorithm */ if (*a > *b) { n = *a; m = *b; } else { n = *b; m = *a; }; while (m != 0) { t = n % m; n = m; m = t; }; *a = *a/n; *b = *b/n; } /* * addunits must be called for each single note or rest and * at each chord end. When called at chordoff time, make * sure that inchord is still true. [PHDM] 2013-03-10 */ static void addunits(n, m) int n, m; /* add fraction n/m to count */ { if (inchord) { /* [PHDM] 2013-03-10 */ if (!chordcount) /* empty chord */ return; n *= chordfactor.num; m *= chordfactor.denom; } if (tuplenotes) { /* [PHDM] 2013-03-10 */ n *= tuplefactor.num; m *= tuplefactor.denom; tuplenotes = tuplenotes - 1; }; count.num = n*count.denom + count.num*(m*unitlen.denom); count.denom = (m*unitlen.denom)*count.denom; reduce(&count.num, &count.denom); } void parse_voices_selection(voices_string) /* [PHDM] 2013-03-08 */ char *voices_string; { char *s = voices_string; selected_voices = 0; if (voices_string == 0x0) return; /* [SS] 2015-02-22 */ do { int v = readnump(&s); selected_voices |= 1 << v; } while (*s++); } int must_emit_voice(n) /* [PHDM] 2013-03-08 */ int n; { return selected_voices & (1 << n); } void event_init(argc, argv, filename) int argc; char* argv[]; char** filename; /* routine called on program start-up */ { int targ, narg; if ((getarg("-h", argc, argv) != -1) || (argc < 2)) { printf("abc2abc version %s\n",VERSION); printf("Usage: abc2abc [-s] [-n X] [-b] [-r] [-e] [-t X]\n"); printf(" [-u] [-d] [-v] [-V X[,Y,,,]] [-P X[,Y...]] [-ver] [-X n]\n"); printf(" -s for new spacing\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(" -r to remove repeat checking\n"); printf(" -e to remove all error reports\n"); printf(" -t X to transpose X semitones\n"); printf(" -nda No double accidentals in guitar chords\n"); printf(" -nokeys No key signature. Use sharps\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(" -d to notate with doubled note lengths\n"); printf(" -v to notate with halved note lengths\n"); printf(" -V X[,Y...] to output only voices X,Y...\n"); printf(" -P X[,Y...] restricts action to voice X,Y..., leaving other voices intact\n"); printf(" -ver prints version number and exits\n"); printf(" -X n renumber the all X: fields as n, n+1, ..\n"); printf(" -xref n output only the tune with X reference number n.\n"); printf(" -OCC old chord convention (eg. +CE+)\n"); /*printf(" -noplus use !...! instead of +...+ for instructions\n"); [SS] 2012-06-04 */ exit(0); } else { *filename = argv[1]; }; nodouble_accidentals = 0; /* use correct guitar chords */ if (getarg("-ver",argc,argv) != -1) { printf("%s\n",VERSION); exit(0); } if (getarg("-u", argc, argv) == -1) { cleanup = 0; } else { cleanup = 1; oldchordconvention = 1; }; if (getarg("-s", argc, argv) == -1) { newspacing = 0; } else { newspacing = 1; }; narg = getarg("-X", argc, argv); if (narg == -1) { newrefnos = 0; } else { newrefnos = 1; if (narg < argc) { newref = readnumf(argv[narg]); } else { newref = 1; }; }; /* [SS] 2017-07-10 */ narg = getarg("-xref",argc,argv); if (narg != -1 && narg = argc) { event_error("No value for bars per line after -n"); bars_per_line = 4; } else { bars_per_line = readnumf(argv[narg]); if (bars_per_line < 1) { bars_per_line = 4; }; }; }; if (getarg("-b", argc, argv) != -1) { barcheck = 0; } else { barcheck = 1; }; if (getarg("-r", argc, argv) != -1) { repcheck = 0; } else { repcheck = 1; }; if (getarg("-v", argc, argv) != -1) { lenfactor.num = 1; lenfactor.denom = 2; } else { if (getarg("-d", argc, argv) != -1) { lenfactor.num = 2; lenfactor.denom = 1; } else { lenfactor.num = 1; lenfactor.denom = 1; }; }; targ = getarg("-t", argc, argv); if (targ == -1) { transpose = 0; } else { if (targ >= argc) { event_error("No tranpose value supplied"); } else { if (*argv[targ] == '-') { transpose = -readnumf(argv[targ]+1); } else if (*argv[targ] == '+') { transpose = readnumf(argv[targ]+1); } else { transpose = readnumf(argv[targ]); }; }; }; targ = getarg("-nda",argc,argv); if (targ != -1) nodouble_accidentals = 1; targ = getarg("-nokeys",argc,argv); if (targ != -1) nokeysig=1; /* [SS] 2016-03-03 */ targ = getarg("-nokeyf",argc,argv); if (targ != -1) {nokeysig=1; useflats=1;} /* [SS] 2016-03-03 */ targ = getarg("-V", argc, argv); if (targ != -1) { parse_voices_selection(argv[targ]); /* [PHDM] 2013-03-08 */ }; targ = getarg("-P", argc, argv); /* [SS] 2011-06-07 */ if (targ != -1) { passthru = 1; parse_voices_selection(argv[targ]); /* [PHDM] 2013-03-08 */ } targ = getarg("-usekey",argc,argv); if (targ != -1) { usekey = readsnumf(argv[targ]); nokey = 1; if (usekey < 0) useflats=1; if (usekey <-5) usekey = -5; if (usekey >5) usekey = 5; setup_sharps_flats (usekey); } if (getarg("-OCC",argc,argv) != -1) oldchordconvention=1; /*if (getarg("-noplus",argc,argv) != -1) noplus = 1; [SS] 2012-06-04*/ /* printf("%% output from abc2abc\n"); */ startline = 1; blankline = 0; xinbody =0; inmusic = 0; inchord = 0; ingrace = 0; head = NULL; tail = NULL; tmp[0] = '\0'; totalnotes = 0; } void emit_string(s) char *s; /* output string */ { if (output_on) { strcpy(tmp+strlen(tmp), s); }; } void emit_char(ch) char ch; /* output single character */ { char *place; if (output_on) { place = tmp+strlen(tmp); *place = ch; *(place+1) = '\0'; }; } void emit_int(n) int n; /* output integer */ { if (output_on) { sprintf(tmp+strlen(tmp), "%d", n); }; } void emit_string_sprintf(s1, s2) char *s1; char *s2; /* output string containing string expression %s */ { if (output_on) { sprintf(tmp+strlen(tmp), s1, s2); }; } void emit_int_sprintf(s, n) char *s; int n; /* output string containing int expression %d */ { if (output_on) { sprintf(tmp+strlen(tmp), s, n); }; } void unemit_inline() /* remove previously output start of inline field */ /* needed for -V voice selection option */ { int len; len = strlen(tmp); if ((len > 0) && (tmp[len-1] == '[')) { tmp[len-1] = '\0'; /* delete last character */ } else { event_error("Internal error - Could not delete ["); }; } static void close_newabc() /* output all remaining abc_text elements */ /* part of new linebreak option (-n) */ { if (newbreaks) { complete_all(&voice[this_voice], endmusicline); if (linestat == midmusic) setline(endmusicline); setline(fresh); }; } void event_eof() { close_newabc(); } extern int parsing; /* [SS] 2017-07-10 */ void event_blankline() { if(parsing != 1) return; /* [SS] 2017-07-10 */ output_on = 1; close_newabc(); /* if (newbreaks) [SS] 2006-09-23 */ printf("\n"); xinbody = 0; xinhead = 0; parseroff(); blankline = 1; } void event_text(p) char *p; { emit_string_sprintf("%%%s", p); inmusic = 0; } void event_reserved(p) char p; { emit_char(p); inmusic = 0; } void event_tex(s) char *s; { emit_string(s); inmusic = 0; } void print_inputline(); /* from parseabc.c */ void event_linebreak() { if (!output_on && passthru) print_inputline(); /* [SS] 2011-06-07*/ if (newbreaks) { if (!purgespace(tmp)) { if (inmusic) { newabctext(bar); } else { newabctext(field); }; }; } else { newabctext(bar); if (output_on) { printf("\n"); /* linefeed to stdout is here */ }; /* don't output new line if voice is already suppressed otherwise we will get lots of blank lines where we are suppressing output. [SS] feb-10-2002. */ }; } void event_startmusicline() /* encountered the start of a line of notes */ { voice[this_voice].currentline = NULL; complete_bars(&voice[this_voice]); } void event_endmusicline(endchar) char endchar; /* encountered the end of a line of notes */ { } void event_error(s) char *s; { if (echeck && output_on) { /* [SS] 2011-04-14 */ printf("\n%%Error : %s\n", s); }; } void event_warning(s) char *s; { if (echeck && output_on) { /* [SS] 2011-04-14 */ printf("\n%%Warning : %s\n", s); }; } void event_comment(s) char *s; { if (newbreaks && (!purgespace(tmp))) { if (inmusic) { newabctext(bar); } else { newabctext(field); }; }; emit_string_sprintf("%%%s", s); inmusic = 0; } void event_specific(package, s) char *package, *s; { char command[40]; int ch; char *p; emit_string("%%"); emit_string(package); emit_string(s); inmusic = 0; /* detect drum channel by searching for %%MIDI channel 10 */ if (strcmp(package,"MIDI") != 0) return; p = s; skipspace(&p); readstr(command, &p, 40); if (strcmp(command, "channel") != 0) return; skipspace(&p); ch = readnump(&p); if(ch == 10) { voice[next_voice].drumchan = 1; drumchan = 1; } /* printf("event_specific: next_voice = %d\n",next_voice); */ } void event_info(f) /* handles info field I: */ char *f; { emit_string_sprintf("I:%s", f); inmusic = 0; } void event_field(k, f) char k; char *f; { emit_char(k); emit_char(':'); emit_string(f); inmusic = 0; } struct abctext* getbar(place) struct abctext *place; /* find first element in list which is a bar of music */ { struct abctext *newplace; newplace = place; while ((newplace != NULL) && ((newplace->type != bar) || (newplace->notes == 0))) { newplace = newplace->next; }; return(newplace); } struct abctext* getnextbar(place) struct abctext *place; /* find next element in list which is a bar of music */ { struct abctext *newplace; newplace = place; if (newplace != NULL) { newplace = getbar(newplace->next); }; return(newplace); }; void append_lyrics(place, newwords) struct abctext *place; char *newwords; /* add lyrics to end of lyric list associated with bar */ { struct lyricwords* new_words; struct lyricwords *new_place; if (place == NULL) { return; }; /* printf("append_lyrics has %s at %s\n", newwords, place->text); */ new_words = (struct lyricwords*)checkmalloc(sizeof(struct lyricwords)); /* add words to bar */ new_words->nextverse = NULL; new_words->words = addstring(newwords); if (place->lyrics == NULL) { place->lyrics = new_words; } else { new_place = place->lyrics; /* find end of list */ while (new_place->nextverse != NULL) { new_place = new_place->nextverse; }; new_place->nextverse = new_words; }; } struct abctext* apply_bar(syll, place, notesleft, barwords) /* advance to next bar (on finding '|' in a w: field) */ char* syll; struct abctext *place; int *notesleft; struct vstring *barwords; { struct abctext* new_place; if (place == NULL) { return(NULL); }; new_place = place; addtext(syll, barwords); append_lyrics(place, barwords->st); /* go on to next bar */ clearvstring(barwords); new_place = getnextbar(place); if (new_place != NULL) { *notesleft = new_place->notes; }; return(new_place); } struct abctext* apply_syllable(syll, place, notesleft, barwords) /* attach syllable to appropriate place in abctext structure */ char* syll; struct abctext *place; int *notesleft; struct vstring *barwords; { struct abctext* new_place; char msg[80]; if (place == NULL) { sprintf(msg, "Cannot find note to match \"%s\"", syll); event_error(msg); return(NULL); }; new_place = place; addtext(syll, barwords); *notesleft = *notesleft - 1; if (*notesleft == 0) { append_lyrics(place, barwords->st); /* go on to next bar */ clearvstring(barwords); new_place = getnextbar(place); if (new_place != NULL) { *notesleft = new_place->notes; }; }; return(new_place); } void parse_words(p) char* p; /* Break up a line of lyrics (w: ) into component syllables */ { struct vstring syll; struct vstring barwords; char* q; unsigned char ch; int errors; int found_hyphen; struct abctext *place; int notesleft; if (!xinbody) { event_error("w: field outside tune body"); return; }; place = getbar(voice[this_voice].currentline); if (place == NULL) { event_error("No music to match w: line to"); return; }; notesleft = voice[this_voice].currentline->notes; initvstring(&barwords); errors = 0; if (place == NULL) { event_error("No notes to match words"); return; }; initvstring(&syll); q = p; skipspace(&q); while (*q != '\0') { found_hyphen = 0; clearvstring(&syll); ch = *q; while(ch=='|') { addch('|', &syll); addch(' ', &syll); place = apply_bar(syll.st, place, ¬esleft, &barwords); clearvstring(&syll); q++; ch = *q; }; /* PCC seems to require (ch != ' ') on the next line */ /* presumably PCC's version of ispunct() thinks ' ' is punctuation */ while (((ch>127)||isalnum(ch)||ispunct(ch))&&(ch != ' ')&& (ch != '_')&&(ch != '-')&&(ch != '*')&& (ch != '|')) { if ((ch == '\\') && (*(q+1)=='-')) { addch('\\', &syll); ch = '-'; q++; }; /* syllable[i] = ch; */ addch(ch, &syll); q++; ch = *q; }; skipspace(&q); if (ch == '-') { found_hyphen = 1; addch(ch, &syll); while (isspace(ch)||(ch=='-')) { q++; ch = *q; }; }; if (syll.len > 0) { if (!found_hyphen) { addch(' ', &syll); }; place = apply_syllable(syll.st, place, ¬esleft, &barwords); } else { if (ch=='_') { clearvstring(&syll); addch('_', &syll); addch(' ', &syll); place = apply_syllable(syll.st, place, ¬esleft, &barwords); q++; ch = *q; }; if (ch=='*') { clearvstring(&syll); addch('*', &syll); addch(' ', &syll); place = apply_syllable(syll.st, place, ¬esleft, &barwords); q++; ch = *q; }; }; }; if (errors > 0) { event_error("Lyric line too long for music"); } else { clearvstring(&syll); }; freevstring(&syll); } void event_words(p, continuation) char* p; int continuation; /* a w: field has been encountered */ { struct vstring afield; if (xinbody && newbreaks) { parse_words(p); } else { initvstring(&afield); addtext(p, &afield); if (continuation) { addch(' ', &afield); addch('\\', &afield); }; event_field('w', afield.st); }; } /* [SS] 2014-09-07 */ void appendfield (morewords) char *morewords; { emit_string("+: "); emit_string(morewords); } void event_part(s) char* s; { if (xinbody) { complete_bars(&voice[this_voice]); }; output_on = 1; /* [SS] 2011-04-14 */ emit_string_sprintf("P:%s", s); inmusic = 0; } int setvoice(num) int num; /* we need to keep track of current voice for new linebreak handling (-n) */ /* change voice to num. If voice does not exist, start new one */ { int i, voice_index; i = 0; while ((i < voicecount) && (voice[i].number != num)) { i = i + 1; }; if ((i < voicecount) && (voice[i].number == num)) { voice_index = i; drumchan = voice[voice_index].drumchan; /* printf("voice_index = %d drumchan = %d\n",voice_index,drumchan); */ } else { voice_index = voicecount; if (voicecount < MAX_VOICES) { voicecount = voicecount + 1; } else { event_error("Number of voices exceeds static limit MAX_VOICES"); }; voice[voice_index].number = num; voice[voice_index].barcount = zero_barcount(&voice[voice_index].foundbar); voice[voice_index].bars_complete = 0; voice[voice_index].bars_remaining = bars_per_line; voice[voice_index].drumchan = 0; }; voice[voice_index].currentline = NULL; return(voice_index); } void event_voice(n, s, vp) int n; char *s; struct voice_params *vp; { char output[256]; /* [SS] 2017-10-09 2017-10-11 */ if (xinbody) { next_voice = setvoice(n); }; if (!must_emit_voice(n)) { /* [PHDM] 2013-03-08 */ if ((inlinefield) && (output_on == 1)) { unemit_inline(); }; /*output_on = 0; [SS] 2011-06-10 */ if (xinbody) output_on = 0; /* [SS] 2011-06-10 */ } else { if (output_on == 0) { output_on = 1; if (inlinefield) { emit_string("["); /* regenerate missing [ */ }; }; }; if (strlen(s) == 0) { if(voicecodes >= n) emit_string_sprintf("V:%s",voicecode[n-1]); else emit_int_sprintf("V:%d", n); if (vp->gotclef) {sprintf(output," clef=%s", vp->clefname); emit_string(output);} if (vp->gotoctave) {sprintf(output," octave=%d", vp->octave); emit_string(output);} if (vp->gottranspose) {sprintf(output," transpose=%d", vp->transpose); emit_string(output);} if (vp->gotname) {sprintf(output," name=%s", vp->namestring); emit_string(output);} if (vp->gotsname) {sprintf(output," sname=%s", vp->snamestring); emit_string(output);} if( vp->gotmiddle ) { sprintf(output, " middle=%s", vp->middlestring); emit_string(output);} if( vp->gotother ) { sprintf(output, " %s", vp->other); emit_string(output);} /* [SS] 2011-04-18 */ } else { if(voicecodes >= n) emit_string_sprintf("V:%s",voicecode[n-1]); emit_int_sprintf("V:%d ", n); if (vp->gotclef) {sprintf(output," clef=%s", vp->clefname); emit_string(output);} if (vp->gotoctave) {sprintf(output," octave=%d", vp->octave); emit_string(output);} if (vp->gottranspose) {sprintf(output," transpose=%d", vp->transpose); emit_string(output);} if (vp->gotname) {sprintf(output," name=%s", vp->namestring); emit_string(output);} if( vp->gotmiddle ) { sprintf(output, " middle=%s", vp->middlestring); emit_string(output);} if( vp->gotother ) { sprintf(output, " %s", vp->other); emit_string(output);} /* [SS] 2011-04-18 */ emit_string(s); }; inmusic = 0; } void event_length(n) int n; { struct fract newunit; newunit.num = lenfactor.denom; newunit.denom = lenfactor.num * n; reduce(&newunit.num, &newunit.denom); emit_int_sprintf("L:%d/", newunit.num); emit_int(newunit.denom); unitlen.num = 1; unitlen.denom = n; inmusic = 0; } void event_refno(n) int n; { /* [SS] 2017-07-10 */ if (xmatch == n || xmatch == -1) parseron(); else {parseroff(); return;} if (xinbody) { close_newabc(); }; output_on = 1; if (newrefnos) { emit_int_sprintf("X:%d", newref); newref = newref + 1; } else { emit_int_sprintf("X:%d", n); }; parseron(); xinhead = 1; notecount = 0; unitlen.num = 0; unitlen.denom = 1; barlen.num = 0; barlen.denom = 1; inmusic = 0; barcount = 0; } void event_tempo(n, a, b, relative, pre, post) int n, a, b; int relative; char *pre; char *post; { struct fract newlen; emit_string("Q:"); if (pre != NULL) { emit_string_sprintf("\"%s\"", pre); }; if (n != 0) { if ((a == 0) && (b == 0)) { emit_int(n); } else { if (relative) { newlen.num = a * lenfactor.num; newlen.denom = b * lenfactor.denom; reduce(&newlen.num, &newlen.denom); emit_int_sprintf("C%d/", newlen.num); emit_int(newlen.denom); emit_int_sprintf("=%d", n); } else { emit_int_sprintf("%d/", a); emit_int(b); emit_int_sprintf("=%d", n); }; }; }; if (post != NULL) { emit_string_sprintf("\"%s\"", post); }; inmusic = 0; } void event_timesig(n, m, checkbars) int n, m, checkbars; /* [code contributed by Larry Myerscough 2015-11-5] * checkbars definition extended: * 0=> no, * 1=>yes, use numerical notation * 2=>yes, use 'common' notation for 2/2 or 4/4 according to numerator * */ { if (checkbars == 1) { emit_int_sprintf("M:%d/", n); emit_int(m); } else if (checkbars == 2) { emit_int_sprintf("M:C", n); if (n != 4) emit_string("|"); } else { emit_string("M:none"); barcheck = 0; }; barlen.num = n; barlen.denom = m; breakpoint.num = n; breakpoint.denom = m; if ((n == 9) || (n == 6)) { breakpoint.num = 3; breakpoint.denom = barlen.denom; }; if (n%2 == 0) { breakpoint.num = barlen.num/2; breakpoint.denom = barlen.denom; }; barend = n/breakpoint.num; inmusic = 0; } static void setmap(sf, map) int sf; int map[7]; { /* map[0] to map[7] corresponds to keys a to g and indicates whether they are flattened or sharpened. sf encodes the key signature by indicating the number of sharps (positive numbers) or flats (negative numbers) */ int j; for (j=0; j<7; j++) { map[j] = 0; }; if (sf >= 1) map['f'-'a'] = 1; if (sf >= 2) map['c'-'a'] = 1; if (sf >= 3) map['g'-'a'] = 1; if (sf >= 4) map['d'-'a'] = 1; if (sf >= 5) map['a'-'a'] = 1; if (sf >= 6) map['e'-'a'] = 1; if (sf >= 7) map['b'-'a'] = 1; if (sf <= -1) map['b'-'a'] = -1; if (sf <= -2) map['e'-'a'] = -1; if (sf <= -3) map['a'-'a'] = -1; if (sf <= -4) map['d'-'a'] = -1; if (sf <= -5) map['g'-'a'] = -1; if (sf <= -6) map['c'-'a'] = -1; if (sf <= -7) map['f'-'a'] = -1; } static void start_tune() { parseron(); count.num =0; count.denom = 1; barno = 0; tuplenotes = 0; expect_repeat = -1; /* repeat from start may occur [J-FM] 2012-06-04 */ inlinefield = 0; if (barlen.num == 0) { /* generate missing time signature */ event_linebreak(); event_timesig(4, 4, 1); inmusic = 0; }; if (unitlen.num == 0) { if ((float) barlen.num / (float) barlen.denom < 0.75) { unitlen.num = 1; unitlen.denom = 16; } else { unitlen.num = 1; unitlen.denom = 8; }; }; voicecount = 0; this_voice = setvoice(1); next_voice = this_voice; } void compute_keysignature (int sf,int modeindex, char * keysignature) { char *notes[7] = {"A","B","C","D","E","F","G"}; int sf2note[12] = {3,0,4,1,5,2,6,3,0,4,1,5}; char *flatsharp[2] = {"b","#"}; int index0,index1,index; int map[7]; index0 = sf+5; /* -5 6) index -=7; strcpy(keysignature,notes[index]); /* propagate sharp or flat to key signature of mode */ if (map[index] == -1) strcat(keysignature,flatsharp[0]); if (map[index] == 1) strcat(keysignature,flatsharp[1]); /* add mode name */ strcat(keysignature,mode[modeindex]); } /* [SS] 2011-02-15 */ /* Support functions to transpose key signature modifiers (eg. K: DPhr ^F * K: D exp _b_e^f ). * Method: we represent the notes in the key signature (with modifiers) in * a chromatic scale semiseq. semiseq(i) == 1 means the note is in the * key signature, semiseq(i) == 0 means the note is not present in the * key signature. semiseq(0) corresponds to A natural, semiseq(11) * represents G# or Ab. We transpose the notes by shifting (with * rotation) semiseq() left or right. We then read back the notes * of the shifted sequence, ignoring all flats and sharps in the * new key signature corresponding to this transpose. modmap indicates the key modifiers using the convention in event_key. */ char modmap[7]; int modmap_not_empty (char* modmap) { int i; for (i=0;i<7;i++) if (modmap[i] != ' ') {return 1;} return 0; } /* end of [SS] 2011-02-15 */ void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, octave, xtranspose, gotoctave, gottranspose, explict) int sharps; char *s; int modeindex; char modmap[7]; int modmul[7]; struct fraction modmicrotone[7]; /* [SS[ 2014-01-06 */ int gotkey, gotclef; char* clefname; int octave, xtranspose, gotoctave, gottranspose; int explict; { static char* keys[12] = {"Db", "Ab", "Eb", "Bb", "F", "C", "G", "D", "A", "E", "B", "F#"}; char signature[10]; /* [SS] 2016-05-05 */ int i,k,slength; int xmult,xoctave; int mult; char accidental,note,xnote; char trans_string[32]; if (!xinbody && passthru) {print_inputline_nolinefeed(); /* [SS] 2011-06-10 */ if ((xinhead) && (!xinbody)) { xinbody = 1; start_tune(); }; inmusic = 0; return; } if (gotkey) { setmap(sharps, basemap); /* required by copymap and pitchof */ setmap(sharps, oldtable); copymap(); newkey = (sharps+7*transpose)%12; if (sharps < -5) orig_key_number = (int) keys[sharps+17][0] - (int) 'A'; else if (sharps > 6) orig_key_number = (int)keys[sharps-7][0] - (int) 'A'; else orig_key_number = (int) keys[sharps+5][0] - (int) 'A'; lines = (sharps+7*transpose)/12; if (newkey > 6) { newkey = newkey - 12; lines = lines + 1; }; if (newkey < -5) { newkey = newkey + 12; lines = lines - 1; }; setmap(newkey, newtable); /* used by event_note1 */ new_key_number = (int) keys[newkey+5][0] - (int) 'A'; /* [SS] 2016-05-05 begin */ trans_string[0] = 0; if (modmap_not_empty (modmap)) { k=0; trans_string[k++] = ' '; xmult = 1; xoctave = 1; slength = strlen(s); /*printf("length of s = %d\n",slength);*/ for (i = 0; i 'g') { event_error ("expecting A-G or a-g after accidental in key modifier"); break; } transpose_note(*(s+i),xmult, xnote, xoctave, transpose, &accidental, &mult, ¬e, &octave); /*printf("%c%c\n",accidental,note); */ trans_string[k++] = accidental; if (mult == 2) trans_string[k++] = accidental; trans_string[k++] = note; break; } } trans_string[k] =0; } /* [SS] 2016-05-05 end */ }; emit_string("K:"); if (transpose == 0 && !nokey) { emit_string(s); } else { if (gotkey) { if (!nokey) { /* emit_string(keys[newkey+5]); */ compute_keysignature(newkey,modeindex,signature); /* [SS] 2006-07-30*/ emit_string(signature); /* [SS] 2006-07-30 */ if (explict) emit_string(" exp"); /* 2011-02-21*/ emit_string(trans_string); /* [SS] 2011-02-20 */ } else if (usekey == 0) emit_string("none"); else emit_string(keys[usekey+5]); if (gotclef) { emit_string(" "); }; }; if (gotclef) { emit_string_sprintf("clef=%s", clefname); }; if (gotoctave) { emit_int_sprintf(" octave=%d", octave); }; if (gottranspose) { emit_int_sprintf(" transpose=%d", xtranspose); }; }; if ((xinhead) && (!xinbody)) { xinbody = 1; start_tune(); }; inmusic = 0; } /* [JM] 2018-02-22 (add code to treat / and // lengths when SHORT_HALFS is defined during compilation */ static void printlen(a, b) int a, b; { if (a != 1) { emit_int(a); }; #ifdef SHORT_HALFS else { if (b == 2) { emit_string("/"); return; } if (b == 4) { emit_string("//"); return; } } #endif if (b != 1) { emit_int_sprintf("/%d", b); }; } void event_spacing(n, m) int n, m; { emit_string("y"); printlen(n, m); } void event_rest(decorators,n,m,type) int n, m, type; int decorators[DECSIZE]; { struct fract newlen; inmusic = 1; if( type == 1) emit_string("x"); else emit_string("z"); newlen.num = n * lenfactor.num; newlen.denom = m * lenfactor.denom; reduce(&newlen.num, &newlen.denom); printlen(newlen.num, newlen.denom); if (inchord) { chordcount = chordcount + 1; if (chordcount == 1) { /* [PHDM] 2013-03-10 */ chordfactor.num = n; chordfactor.denom = m; } }; if ((!ingrace) && (!inchord)) { addunits(n, m); }; } void event_mrest(n,m,c) int n, m; char c; /* [SS] 2017-04-19 to distinguish X from Z */ { inmusic = 1; emit_char(c); /* [SS] 2017-04-19 */ printlen(n,m); if (inchord) { event_error("Multiple bar rest not allowed in chord"); }; if (tuplenotes != 0) { event_error("Multiple bar rest not allowed in tuple"); }; } void event_bar(type, replist) int type; char* replist; { char msg[40]; if (!purgespace(tmp)) { if (inmusic) { newabctext(bar); } else { newabctext(field); }; }; switch(type) { case SINGLE_BAR: emit_string_sprintf("|%s", replist); break; case DOUBLE_BAR: emit_string("||"); break; case THIN_THICK: emit_string("|]"); break; case THICK_THIN: emit_string("[|"); break; case BAR_REP: emit_string("|:"); if (expect_repeat > 0 /* no error if first repeat [J-FM] 2012-06-04 */ && repcheck) { event_error("Expecting repeat, found |:"); }; expect_repeat = 1; break; case REP_BAR: emit_string_sprintf(":|%s", replist); if ((!expect_repeat) && (repcheck)) { event_warning("No repeat expected, found :|"); }; expect_repeat = 0; break; case BAR1: emit_string("|1"); if ((!expect_repeat) && (repcheck)) { event_warning("found |1 in non-repeat section"); }; break; case REP_BAR2: emit_string(":|2"); if ((!expect_repeat) && (repcheck)) { event_warning("No repeat expected, found :|2"); }; expect_repeat = 0; break; case DOUBLE_REP: emit_string("::"); if ((!expect_repeat) && (repcheck)) { event_error("No repeat expected, found ::"); }; expect_repeat = 1; break; }; if ((count.num*barlen.denom != barlen.num*count.denom) && (count.num != 0) && (barno != 0) && (barcheck)) { /* [J-FM] 2012-06-04 start */ switch (type) { case BAR_REP: case REP_BAR: case BAR1: case REP_BAR2: case DOUBLE_REP: break; /* no error if repeat bar */ default: sprintf(msg, "Bar %d is %d/%d not %d/%d", barno, count.num, count.denom, barlen.num, barlen.denom ); event_error(msg); count.num = 0; count.denom = 1; break; } } else { count.num = 0; count.denom = 1; } /* [J-FM] 2012-06-04 end */ newabctext(barline); barno = barno + 1; copymap(); } void event_space() { if (!newspacing) { emit_string(" "); }; } void event_graceon() { emit_string("{"); ingrace = 1; } void event_graceoff() { emit_string("}"); ingrace = 0; } void event_rep1() { emit_string(" [1"); } void event_rep2() { emit_string(" [2"); } void event_playonrep(s) char*s; { emit_string_sprintf(" [%s", s); } void event_broken(type, n) int type, n; { int i; if (type == GT) { for (i=0; i'); }; } else { for (i=0; i') || (*s == '@')) { emit_string_sprintf("\"%s\"", s); } else { char* p; int pitch; int j; if (newkey >= 0) { roots = sharproots; bases = sharpbases; } else { roots = flatroots; bases = flatbases; }; p = s; chordstart = 1; j = 0; while (*p != '\0') { if (chordstart) { if ((*p >= 'A') && (*p <= 'G')) { key_number = (int) *p - ((int) 'A'); old_triad_number = key_number - orig_key_number+1; if (old_triad_number < 1) old_triad_number += 7; pitch = (offset[key_number] + transpose)%12; p = p + 1; if (*p == 'b') { pitch = pitch - 1; p = p + 1; }; if (*p == '#') { pitch = pitch + 1; p = p + 1; }; pitch = (pitch + 12)%12; key_number = (int) roots[pitch][0] - (int) 'A'; new_triad_number = key_number - new_key_number +1; if (new_triad_number < 1) new_triad_number += 7; triad_diff = new_triad_number - old_triad_number; if (!nodouble_accidentals && (triad_diff == -1 || triad_diff == 6)) { /* printf("*** %d old chord = %s (%d) new chord = %s (%d)\n", triad_diff,s,old_triad_number,roots[pitch],new_triad_number); */ pitch = pitch+1; pitch = (pitch+12)%12; strcpy(&newchord[j],roots[pitch]); j = strlen(newchord); strcpy(&newchord[j],"b"); j = j+1; if (adapt_useflats_to_gchords) useflats=1; } else if (!nodouble_accidentals && (triad_diff ==1 || triad_diff == -6)) { /* printf("*** %d old chord = %s (%d) new chord = %s (%d)\n", triad_diff,s,old_triad_number,roots[pitch],new_triad_number); */ pitch = pitch-1; pitch = (pitch+12)%12; strcpy(&newchord[j],roots[pitch]); j = strlen(newchord); strcpy(&newchord[j],"#"); j = j+1; if (adapt_useflats_to_gchords) useflats=0; } else /* no extra flats or sharps needed */ { strcpy(&newchord[j], roots[pitch]); j = strlen(newchord); } chordstart = 0; } else { if ((*p >= 'a') && (*p <= 'g')) { key_number = (int) *p - ((int) 'a'); old_triad_number = key_number - orig_key_number+1; if (old_triad_number < 1) old_triad_number += 7; pitch = (offset[key_number] + transpose)%12; p = p + 1; if (*p == 'b') { pitch = pitch - 1; p = p + 1; }; if (*p == '#') { pitch = pitch + 1; p = p + 1; }; pitch = (pitch + 12)%12; key_number = (int) bases[pitch][0] - (int) 'a'; new_triad_number = key_number - new_key_number +1; if (new_triad_number < 1) new_triad_number += 7; triad_diff = new_triad_number - old_triad_number; if (!nodouble_accidentals && (triad_diff == -1 || triad_diff == 6)) { /* printf("*** %d old chord = %s (%d) new chord = %s (%d)\n", triad_diff,s,old_triad_number,bases[pitch],new_triad_number); */ pitch = pitch+1; pitch = (pitch+12)%12; strcpy(&newchord[j],bases[pitch]); j = strlen(newchord); strcpy(&newchord[j],"b"); j = j+1; } else if (!nodouble_accidentals && (triad_diff ==1 || triad_diff == -6)) { /* printf("*** %d old chord = %s (%d) new chord = %s (%d)\n", triad_diff,s,old_triad_number,bases[pitch],new_triad_number);*/ pitch = pitch-1; pitch = (pitch+12)%12; strcpy(&newchord[j],bases[pitch]); j = strlen(newchord); strcpy(&newchord[j],"#"); j = j+1; } else { strcpy(&newchord[j], bases[pitch]); j = strlen(newchord); } chordstart = 0; } else { if (isalpha(*p)) { chordstart = 0; }; newchord[j] = *p; p = p + 1; j = j + 1; newchord[j] = '\0'; }; }; } else { if ((*p == '/') || (*p == '(') || (*p == ' ')) { chordstart = 1; }; newchord[j] = *p; p = p + 1; j = j + 1; newchord[j] = '\0'; }; if (j >= 49) { event_error("guitar chord contains too much text"); while (*p != '\0') { p = p + 1; }; }; }; emit_string_sprintf("\"%s\"", newchord); }; } void event_gchord(s) char* s; { splitstring(s, ';', event_handle_gchord); } void event_instruction(s) char* s; { if (oldchordconvention || noplus) emit_string_sprintf("!%s!", s); else emit_string_sprintf("+%s+", s); } void event_slur(t) int t; { if (cleanup) { if (t) { emit_string("("); } else { emit_string(")"); }; } else { emit_string("s"); }; } void event_sluron(t) int t; { emit_string("("); } void event_sluroff(t) int t; { emit_string(")"); } void event_tie() { emit_string("-"); } void event_lineend(ch, n) char ch; int n; { int i; if (!newbreaks) { for (i = 0; i 0) { *accidental = '^'; *mult = acc; }; if (acc < 0) { *accidental = '_'; *mult = -acc; }; }; } } void event_note1(decorators, xaccidental, xmult, xnote, xoctave, n, m) int decorators[DECSIZE]; int xmult; char xaccidental, xnote; int xoctave, n, m; { int t; struct fract barpoint; struct fract newlen; int mult; char accidental, note; int octave; mult = 0; /* [SS] 2006-10-27 */ if (transpose == 0 || drumchan) { accidental = xaccidental; mult = xmult; note = xnote; octave = xoctave; } else { int val, newval; int acc; char *anoctave = "cdefgab"; octave = xoctave; val = (int) ((long) strchr(anoctave, xnote) - (long) anoctave); newval = val + lines; octave = octave + (newval/7); newval = newval % 7; if (newval < 0) { newval = newval + 7; octave = octave - 1; }; note = *(anoctave+newval); if (xaccidental == ' ') { accidental = ' '; } else { switch (xaccidental) { case '_': acc = -xmult; break; case '^': acc = xmult; break; case '=': acc = 0; break; default: event_error("Internal error"); }; acc = acc - oldtable[(int)anoctave[val] - (int)'a'] + newtable[(int)anoctave[newval] - (int)'a']; mult = 1; accidental = '='; if (acc > 0) { accidental = '^'; mult = acc; }; if (acc < 0) { accidental = '_'; mult = -acc; }; }; }; if (!ingrace) { notecount = notecount + 1; }; for (t=0; t= 1) { emit_char(note); t = octave; while (t > 1) { emit_string("'"); t = t - 1; }; } else { emit_char((char) ((int)note + 'C' - 'c')); t = octave; while (t < 0) { emit_string(","); t = t + 1; }; }; newlen.num = n * lenfactor.num; newlen.denom = m * lenfactor.denom; reduce(&newlen.num, &newlen.denom); printlen(newlen.num, newlen.denom); if (inchord) { chordcount = chordcount + 1; if (chordcount == 1) { /* [PHDM] 2013-03-10 */ chordfactor.num = n; chordfactor.denom = m; } }; if ((!ingrace) && (!inchord)) { addunits(n, m); }; if (newspacing) { barpoint.num = count.num * breakpoint.denom; barpoint.denom = breakpoint.num * count.denom; reduce(&barpoint.num, &barpoint.denom); if ((barpoint.denom == 1) && (barpoint.num != 0) && (barpoint.num != barend)) { emit_string(" "); }; }; } /* these functions are here to satisfy the linker */ void event_microtone(int dir, int a, int b) { } void event_normal_tone() { } int accidental_to_code (char xaccidental) { switch (xaccidental) { case ' ': return 10; break; case '_': return -1; break; case '^': return 1; break; case '=': return 0; break; default: return 10; } } void event_note2(decorators, xaccidental, xmult, xnote, xoctave, n, m) /* this function is called if flag nokey is set */ int decorators[DECSIZE]; int xmult; char xaccidental, xnote; int xoctave, n, m; { int t; struct fract barpoint; struct fract newlen; int acc,assumed_acc; int propogate; int val; char *anoctave = "cdefgab"; int midipitch; for (t=0; t=1) {sharpsym[6] = 0; sharpsym[5] = 2;} if (sf >=2) {sharpsym[1] = 0; sharpsym[0] = 2;} if (sf >=3) {sharpsym[8] = 0; sharpsym[7] = 2;} if (sf >=4) {sharpsym[3] = 0; sharpsym[2] = 2;} if (sf >=5) {sharpsym[10]= 0; sharpsym[9] = 2;} if (sf <= -1) {flatsym[10] = 0; flatsym[11] = 2;} if (sf <= -2) {flatsym[3] = 0; flatsym[4] =2;} if (sf <= -3) {flatsym[8] = 0; flatsym[9] =2;} if (sf <= -4) {flatsym[1] = 0; flatsym[2] =2;} if (sf <= -5) {flatsym[6] = 0; flatsym[6] =2;} } void printpitch(int pitch) /* convert midi pitch value to abc note */ { int p; char keylet,symlet; int keynum,symcod; char string[16]; p = pitch%12; if (useflats) {keynum = flatmap[p]; symcod = flatsym[p]; } else {keynum = sharpmap[p]; symcod = sharpsym[p]; } if (pitch= MIDDLE + 12) { emit_string("'"); p = p - 12; }; while (p < MIDDLE - 12) { emit_string(","); p = p + 12; }; } int main(argc,argv) int argc; char *argv[]; { char *filename; oldchordconvention = 0; /* for handling +..+ chords */ noplus = 1; /* [SS] 2012-06-04 */ /*for (i=0;i #ifdef ANSILIBS #include #endif #include "abc.h" #include "structs.h" #include "sizes.h" extern struct tune thetune; extern double scaledwidth; static void addfract(f, n, m) struct fract* f; int n, m; /* add n/m to fraction pointed to by f */ /* like addunits(), but does not use unitlength */ { f->num = n*f->denom + m*f->num; f->denom = m*f->denom; reducef(f); } static void mulfract(f, n, m) struct fract* f; int n, m; /* multiply n/m to fraction pointed to by f */ /* like addunits(), but does not use unitlength */ { f->num = n*f->num; f->denom = m*f->denom; reducef(f); } static void advance(struct voice* v, int phase, int* items, double* itemspace, double x) /* move on one symbol in the specified voice */ { struct feature* p; struct rest* arest; struct note* anote; struct fract tuplefactor, notelen; int done; int stepon; int zerotime, newline; switch(phase) { case 1: zerotime = 1; newline=0; break; case 2: zerotime = 0; newline=0; break; case 3: zerotime = 0; newline=1; break; default: printf("Internal error: phase = %d\n", phase); exit(1); break; }; *itemspace = 0.0; *items = 0; p = v->place; if (p == NULL) { v->atlineend = 1; }; done = 0; while ((p != NULL) && (done==0)) { p->x = (float) (x + p->xleft); stepon = 1; switch(p->type) { case MUSICLINE: v->inmusic = 1; break; case PRINTLINE: v->inmusic = 0; done = 1; if (!newline) { v->atlineend = 1; stepon = 0; }; break; case CLEF: case KEY: case TIME: if (!v->inmusic) { break; }; case SINGLE_BAR: case DOUBLE_BAR: case BAR_REP: case REP_BAR: case BAR1: case REP_BAR2: case DOUBLE_REP: case THICK_THIN: case THIN_THICK: *itemspace = *itemspace + p->xleft + p->xright; *items = *items + 1; if (!newline) { done = 1; }; break; case REST: case NOTE: tuplefactor = v->tuplefactor; if ((zerotime==1) && (!v->ingrace)) { done = 1; stepon = 0; } else { if ((!v->inchord)&&(!newline)) { done = 1; }; *itemspace = *itemspace + p->xleft + p->xright; *items = *items + 1; if (p->type == REST) { arest = p->item; addfract(&v->time, arest->len.num, arest->len.denom); }; if ((p->type == NOTE) && (!v->ingrace)) { anote = p->item; notelen = anote->len; if (anote->tuplenotes >0) { mulfract(¬elen,tuplefactor.num,tuplefactor.denom); } addfract(&v->time, notelen.num, notelen.denom); /* printf("%c %d/%d %d/%d\n",anote->pitch,notelen.num,notelen.denom, v->time.num,v->time.denom); */ }; }; break; case CHORDON: if ((zerotime==1)&&(!v->ingrace)) { done = 1; stepon = 0; } else { v->inchord = 1; }; break; case CHORDOFF: if (v->inchord == 1) { v->inchord = 0; if ((!v->ingrace)&&(!newline)) { done = 1; }; }; break; case GRACEON: v->ingrace = 1; break; case GRACEOFF: v->ingrace = 0; break; default: break; }; if (stepon) { p = p->next; } else { done = 1; }; }; v->place = p; if (p == NULL) { v->atlineend = 1; }; } static int gefract(struct fract* a, struct fract* b) /* compare two fractions a greater than or equal to b */ /* returns (a >= b) */ { if ((a->num*b->denom) >= (b->num*a->denom)) { return(1); } else { return(0); }; } static int gtfract(struct fract* a, struct fract* b) /* compare two fractions a greater than b */ /* returns (a > b) */ { if ((a->num*b->denom) > (b->num*a->denom)) { return(1); } else { return(0); }; } static int spacemultiline(struct fract* mastertime, struct tune* t) /* calculate spacing for one line (but possibly multiple voices) */ { int i; int items, thisitems, maxitems; int totalitems; double thiswidth, maxwidth; double totalwidth; double x, gap; int done; struct voice* v; struct fract minlen; /* two passes - on the second pass, inter-symbol spacing is */ /* known so elements can be given their correct x position */ gap = 0.0; for (i=0; i<2; i++) { setfract(mastertime, 0, 1); v = firstitem(&t->voices); while (v != NULL) { v->place = v->lineplace; v->ingrace = 0; v->atlineend = 0; setfract(&v->time, 0, 1); v = nextitem(&t->voices); }; done = 0; items = 0; x = 0.0; totalitems = 0; totalwidth = 0.0; /* count up items in a line */ while (done == 0) { maxitems = 0; maxwidth = 0.0; /* first do zero-time symbols */ v = firstitem(&t->voices); while (v != NULL) { if ((!v->atlineend)&&(gefract(mastertime, &v->time))) { advance(v, 1, &thisitems, &thiswidth, x); if (thisitems > maxitems) { maxitems = thisitems; }; if (thiswidth > maxwidth) { maxwidth = thiswidth; }; }; v = nextitem(&t->voices); }; if (maxitems == 0) { /* now try moving forward in time */ /* advance all voices at or before mastertime */ v = firstitem(&t->voices); while (v != NULL) { if ((!v->atlineend)&&(gefract(mastertime, &v->time))) { advance(v, 2, &thisitems, &thiswidth, x); if (thisitems > maxitems) { maxitems = thisitems; }; if (thiswidth > maxwidth) { maxwidth = thiswidth; }; }; v = nextitem(&t->voices); }; /* calculate new mastertime */ v = firstitem(&t->voices); setfract(&minlen, 0, 1); done = 1; while (v != NULL) { if (!v->atlineend) { done = 0; if (minlen.num == 0) { setfract(&minlen, v->time.num, v->time.denom); } else { if (gtfract(&minlen, &v->time)) { setfract(&minlen, v->time.num, v->time.denom); }; }; }; v = nextitem(&t->voices); }; setfract(mastertime, minlen.num, minlen.denom); }; totalitems = totalitems + maxitems; totalwidth = totalwidth + maxwidth; if (maxitems > 0) { x = x + maxwidth + gap; }; }; /* now calculate inter-symbol gap */ if (totalitems > 1) { gap = (scaledwidth - totalwidth)/(totalitems-1); } else { gap = 1.0; }; if (gap < 0.0) { event_error("Overfull music line"); }; if (gap > MAXGAP) { event_error("Underfull music line"); gap = MAXGAP; }; }; if (totalitems == 0) { return(1); } else { return(0); }; } void spacevoices(struct tune* t) { struct fract mastertime; int donelines; struct voice* v; int items; double x1; /* initialize voices */ v = firstitem(&t->voices); while (v != NULL) { v->lineplace = v->first; v->inmusic=0; v = nextitem(&t->voices); }; donelines = 0; while(donelines == 0) { donelines = spacemultiline(&mastertime, t); v = firstitem(&t->voices); while (v != NULL) { v->lineplace = v->place; advance(v, 3, &items, &x1, 0.0); v->lineplace = v->place; v = nextitem(&t->voices); }; }; } static int spaceline(struct voice* v) /* allocate spare space across the width of a single stave line */ /* thereby fixing the x position of all notes and other elements */ /* returns 0 when the end of the voice is reached, 1 otherwise */ { struct feature* p; double x, lastx; int inmusic, items; double itemspace; double gap; itemspace = 0.0; items = 0; inmusic = 0; p = v->place; while ((p != NULL) && (p->type != PRINTLINE)) { switch(p->type) { case MUSICLINE: inmusic = 1; break; case PRINTLINE: inmusic = 0; break; case CLEF: case KEY: case TIME: if (!inmusic) { break; }; case SINGLE_BAR: case DOUBLE_BAR: case BAR_REP: case REP_BAR: case BAR1: case REP_BAR2: case DOUBLE_REP: case THICK_THIN: case THIN_THICK: case REST: case NOTE: itemspace = itemspace + p->xleft + p->xright; items = items + 1; break; default: break; }; p = p->next; }; if (items > 1) { gap = (scaledwidth - itemspace)/((double)(items-1)); } else { gap = 1.0; }; if (gap < 0.0) { event_error("Overfull music line"); }; if (gap > MAXGAP) { event_error("Underfull music line"); gap = MAXGAP; }; /* now assign positions */ x = 0.0; p = v->place; inmusic = 0; while ((p != NULL) && (p->type != PRINTLINE)) { switch(p->type) { case MUSICLINE: inmusic = 1; break; case PRINTLINE: inmusic = 0; break; case CHORDNOTE: p->x = (float) lastx; break; case CLEF: case KEY: case TIME: if (!inmusic) { break; }; case SINGLE_BAR: case DOUBLE_BAR: case BAR_REP: case REP_BAR: case BAR1: case REP_BAR2: case DOUBLE_REP: case THICK_THIN: case THIN_THICK: case REST: case NOTE: x = x + p->xleft; p->x = (float) x; lastx = x; x = x + p->xright + gap; break; default: break; }; p = p->next; }; while ((p!=NULL)&&((p->type == PRINTLINE)||(p->type==LINENUM))) { p = p->next; }; v->place = p; if (p == NULL) { return(0); } else { return(1); }; } void monospace(struct tune* t) { int doneline; struct voice* v; v = firstitem(&t->voices); while (v != NULL) { doneline = 1; v->place = v->first; while (doneline == 1) { doneline = spaceline(v); }; v = nextitem(&t->voices); }; } abcmidi/midifile.h0000644000000000000000000000672511326713012013105 0ustar rootroot/* definitions for MIDI file parsing code */ #include extern int (*Mf_getc)(); extern void (*Mf_header)(); extern void (*Mf_trackstart)(); extern void (*Mf_trackend)(); extern void (*Mf_noteon)(); extern void (*Mf_noteoff)(); extern void (*Mf_pressure)(); extern void (*Mf_parameter)(); extern void (*Mf_pitchbend)(); extern void (*Mf_program)(); extern void (*Mf_chanpressure)(); extern void (*Mf_sysex)(); extern void (*Mf_metamisc)(); extern void (*Mf_seqspecific)(); extern void (*Mf_seqnum)(); extern void (*Mf_text)(); extern void (*Mf_eot)(); extern void (*Mf_timesig)(); extern void (*Mf_smpte)(); extern void (*Mf_tempo)(); extern void (*Mf_keysig)(); extern void (*Mf_arbitrary)(); extern void (*Mf_error)(); extern long Mf_currtime; extern int Mf_nomerge; /* definitions for MIDI file writing code */ extern int (*Mf_putc)(); extern long (*Mf_writetrack)(); extern int (*Mf_writetempotrack)(); float mf_ticks2sec(); long mf_sec2ticks(); void mfwrite(); void mfread(); int mf_write_meta_event(); int mf_write_midi_event(); void mf_write_tempo(); void mferror(); /* MIDI status commands most significant bit is 1 */ #define note_off 0x80 #define note_on 0x90 #define poly_aftertouch 0xa0 #define control_change 0xb0 #define program_chng 0xc0 #define channel_aftertouch 0xd0 #define pitch_wheel 0xe0 #define system_exclusive 0xf0 #define delay_packet (1111) /* 7 bit controllers */ #define damper_pedal 0x40 #define portamento 0x41 #define sostenuto 0x42 #define soft_pedal 0x43 #define general_4 0x44 #define hold_2 0x45 #define general_5 0x50 #define general_6 0x51 #define general_7 0x52 #define general_8 0x53 #define tremolo_depth 0x5c #define chorus_depth 0x5d #define detune 0x5e #define phaser_depth 0x5f /* parameter values */ #define data_inc 0x60 #define data_dec 0x61 /* parameter selection */ #define non_reg_lsb 0x62 #define non_reg_msb 0x63 #define reg_lsb 0x64 #define reg_msb 0x65 /* Standard MIDI Files meta event definitions */ #define meta_event 0xFF #define sequence_number 0x00 #define text_event 0x01 #define copyright_notice 0x02 #define sequence_name 0x03 #define instrument_name 0x04 #define lyric 0x05 #define marker 0x06 #define cue_point 0x07 #define channel_prefix 0x20 #define end_of_track 0x2f #define set_tempo 0x51 #define smpte_offset 0x54 #define time_signature 0x58 #define key_signature 0x59 #define sequencer_specific 0x74 /* Manufacturer's ID number */ #define Seq_Circuits (0x01) /* Sequential Circuits Inc. */ #define Big_Briar (0x02) /* Big Briar Inc. */ #define Octave (0x03) /* Octave/Plateau */ #define Moog (0x04) /* Moog Music */ #define Passport (0x05) /* Passport Designs */ #define Lexicon (0x06) /* Lexicon */ #define Tempi (0x20) /* Bon Tempi */ #define Siel (0x21) /* S.I.E.L. */ #define Kawai (0x41) #define Roland (0x42) #define Korg (0x42) #define Yamaha (0x43) /* miscellaneous definitions */ #define MThd 0x4d546864 #define MTrk 0x4d54726b #define lowerbyte(x) ((unsigned char)(x & 0xff)) #define upperbyte(x) ((unsigned char)((x & 0xff00)>>8)) abcmidi/legacy_code/0000755000000000000000000000000011414423560013402 5ustar rootrootabcmidi/legacy_code/casecmp.c0000644000000000000000000000225111020106056015150 0ustar rootrootstatic int casecmp(s1, s2) /* case-insensitive compare 2 strings */ /* return 0 if equal */ /* 1 if s1 > s2 */ /* -1 if s1 > s2 */ char s1[]; char s2[]; { int i, val, done; char c1, c2; i = 0; done = 0; while (done == 0) { c1 = tolower(s1[i]); c2 = tolower(s2[i]); if (c1 > c2) { val = 1; done = 1; } else { if (c1 < c2) { val = -1; done = 1; } else { if (c1 == '\0') { val = 0; done = 1; } else { i = i + 1; }; }; }; }; return(val); } static int stringcmp(s1, s2) /* case sensitive compare 2 strings */ /* return 0 if equal */ /* 1 if s1 > s2 */ /* -1 if s1 > s2 */ char s1[]; char s2[]; { int i, val, done; i = 0; done = 0; while (done == 0) { if (s1[i] > s2[i]) { val = 1; done = 1; } else { if (s1[i] < s2[i]) { val = -1; done = 1; } else { if (s1[i] == '\0') { val = 0; done = 1; } else { i = i + 1; }; }; }; }; return(val); } abcmidi/drawtune.h0000644000000000000000000000151111020106056013133 0ustar rootroot/* drawtune.h - part of yaps */ /* this file declares the routines in drawtune.c that are used elsewhere */ /* for Microsoft Visual C++ version 6.0 or higher */ extern int eps_out; /* bounding box for encapsulated PostScript */ struct bbox { int llx, lly, urx, ury; }; #ifdef ANSILIBS extern void setmargins(char* s); extern void setpagesize(char* s); extern void open_output_file(char* filename, struct bbox* boundingbox); extern void close_output_file(void); extern void newpage(void); extern void centretext(char* s); extern void lefttext(char* s); extern void vskip(double gap); #else extern void setmargins(); extern void setpagesize(); extern void open_output_file(); extern void close_output_file(); extern void newpage(); extern void centretext(); extern void lefttext(); extern void vskip(); #endif abcmidi/Makefile0000644000000000000000000001223113232352671012607 0ustar rootroot# Generic unix/gcc Makefile for abcMIDI package # # # compilation #ifdefs - you need to compile with these defined to get # the code to compile with PCC. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # ANSILIBS includes some ANSI header files (which gcc can live without, # but other compilers may want). # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # KANDR selects functions prototypes without argument prototypes. # currently yaps will only compile in ANSI mode. # # # On running make, you may get the mysterious message : # # ', needed by `parseabc.o'. Stop `abc.h # # This means you are using GNU make and this file is in DOS text format. To # cure the problem, change this file from using PC-style end-of-line (carriage # return and line feed) to unix style end-of-line (line feed). VERSION = @VERSION@ CC = gcc INSTALL = /usr/bin/install -c INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} CFLAGS = -DANSILIBS -O2 CPPFLAGS = -DHAVE_CONFIG_H -I. LDFLAGS = -lm prefix = /usr/local exec_prefix = ${prefix} srcdir = . VPATH = . bindir = ${exec_prefix}/bin libdir = ${exec_prefix}/lib datadir = ${prefix}/share docdir = ${prefix}/share/doc/abcmidi mandir = ${prefix}/share/man/man1 binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o abc2midi : $(OBJECTS_ABC2MIDI) $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm $(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile OBJECTS_ABC2ABC=parseabc.o toabc.o abc2abc : $(OBJECTS_ABC2ABC) $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) $(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile OBJECTS_MIDI2ABC=midifile.o midi2abc.o midi2abc : $(OBJECTS_MIDI2ABC) $(CC) $(CFLAGS) -o midi2abc $(OBJECTS_MIDI2ABC) $(LDFLAGS) $(OBJECTS_MIDI2ABC): abc.h midifile.h config.h Makefile OBJECTS_MFTEXT=midifile.o mftext.o crack.o mftext : $(OBJECTS_MFTEXT) $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) $(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o yaps : $(OBJECTS_YAPS) $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) $(OBJECTS_YAPS): abc.h midifile.h config.h Makefile OBJECTS_MIDICOPY=midicopy.o midicopy : $(OBJECTS_MIDICOPY) $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) $(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o abcmatch : $(OBJECTS_ABCMATCH) $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) $(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile parseabc.o : parseabc.c abc.h parseabc.h parser2.o : parser2.c abc.h parseabc.h parser2.h toabc.o : toabc.c abc.h parseabc.h # could use -DNOFTELL here genmidi.o : genmidi.c abc.h midifile.h genmidi.h stresspat.o : stresspat.c store.o : store.c abc.h parseabc.h midifile.h genmidi.h queues.o : queues.c genmidi.h # could use -DNOFTELL here midifile.o : midifile.c midifile.h midi2abc.o : midi2abc.c midifile.h midicopy.o : midicopy.c midicopy.h abcmatch.o: abcmatch.c abc.h crack.o : crack.c mftext.o : mftext.c midifile.h # objects needed by yaps # yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h pslib.o: pslib.c drawtune.h position.o: position.c abc.h structs.h sizes.h debug.o: debug.c structs.h abc.h #objects for abcmatch # matchsup.o : matchsup.c abc.h parseabc.h parser2.h clean : rm *.o ${binaries} install: abc2midi midi2abc abc2abc mftext midicopy yaps abcmatch $(INSTALL) -d $(DESTDIR)$(bindir) $(INSTALL) -m 755 ${binaries} $(DESTDIR)$(bindir) # install documentation $(INSTALL) -d $(DESTDIR)${docdir} $(INSTALL) -m 644 doc/*.txt $(DESTDIR)$(docdir) $(INSTALL) -m 644 doc/AUTHORS $(DESTDIR)$(docdir) $(INSTALL) -m 644 doc/CHANGES $(DESTDIR)$(docdir) $(INSTALL) -m 644 VERSION $(DESTDIR)$(docdir) # install manpages $(INSTALL) -d $(DESTDIR)${mandir} $(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir) uninstall: echo "uninstalling..."; #rm -f $(DESTDIR)$(bindir)/$(binaries) rm -f $(DESTDIR)$(bindir)/abc2midi rm -f $(DESTDIR)$(bindir)/abc2abc rm -f $(DESTDIR)$(bindir)/yaps rm -f $(DESTDIR)$(bindir)/midi2abc rm -f $(DESTDIR)$(bindir)/mftext rm -f $(DESTDIR)$(bindir)/abcmatch rm -f $(DESTDIR)$(bindir)/midicopy rm -f $(DESTDIR)$(docdir)/*.txt rm -f $(DESTDIR)$(docdir)/AUTHORS rm -f $(DESTDIR)$(docdir)/CHANGES rm -f $(DESTDIR)$(docdir)/VERSION rm -f $(DESTDIR)$(mandir)/*.1 rmdir $(DESTDIR)$(docdir) abcmidi/configure0000755000000000000000000043053312564631460013072 0ustar rootroot#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.67 for abcmidi 2011-08-03. # # Report bugs to seymour shlien fy733@ncf.ca . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Seymour Shlien (fy733@ncf.ca) about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='abcmidi' PACKAGE_TARNAME='abcmidi' PACKAGE_VERSION='2011-08-03' PACKAGE_STRING='abcmidi 2011-08-03' PACKAGE_BUGREPORT='fy733@ncf.ca' PACKAGE_URL='' ac_unique_file="abc.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP CPP INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_debug ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures abcmidi 2011-08-03 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/abcmidi] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of abcmidi 2011-08-03:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-debug Enable debugging information Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to Seymour Shlien fy733@ncf.ca . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF abcmidi configure 2011-08-03 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------ ## ## Report this to Seymour Shlien fy733@ncf.ca ## ## ------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_type # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by abcmidi $as_me 2011-08-03, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" # Checks for programs. cflags_save="$CFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CFLAGS="$cflags_save" # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; USE_DEBUG="$enableval" else USE_DEBUG="no" fi if test $USE_DEBUG = yes ; then CFLAGS="$CFLAGS -g" else CFLAGS="$CFLAGS -O2" fi ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Checks for libraries. # FIXME: Replace `main' with a function in `-lm': { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lm" >&5 $as_echo_n "checking for main in -lm... " >&6; } if test "${ac_cv_lib_m_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_main=yes else ac_cv_lib_m_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_main" >&5 $as_echo "$ac_cv_lib_m_main" >&6; } if test "x$ac_cv_lib_m_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="-lm $LIBS" fi # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in stdlib.h string.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = x""yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if test "${ac_cv_lib_error_at_line+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi for ac_func in strcasecmp strchr do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by abcmidi $as_me 2011-08-03, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to Seymour Shlien ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ abcmidi config.status 2011-08-03 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi abcmidi/midicopy.h0000644000000000000000000000475611020106056013135 0ustar rootroot/* definitions for MIDI file writing code */ float mf_ticks2sec(); long mf_sec2ticks(); void mfwrite(); void mfread(); /* MIDI status commands most significant bit is 1 */ #define note_off 0x80 #define note_on 0x90 #define poly_aftertouch 0xa0 #define control_change 0xb0 #define program_chng 0xc0 #define channel_aftertouch 0xd0 #define pitch_wheel 0xe0 #define system_exclusive 0xf0 #define delay_packet (1111) /* 7 bit controllers */ #define damper_pedal 0x40 #define portamento 0x41 #define sostenuto 0x42 #define soft_pedal 0x43 #define general_4 0x44 #define hold_2 0x45 #define general_5 0x50 #define general_6 0x51 #define general_7 0x52 #define general_8 0x53 #define tremolo_depth 0x5c #define chorus_depth 0x5d #define detune 0x5e #define phaser_depth 0x5f /* parameter values */ #define data_inc 0x60 #define data_dec 0x61 /* parameter selection */ #define non_reg_lsb 0x62 #define non_reg_msb 0x63 #define reg_lsb 0x64 #define reg_msb 0x65 /* Standard MIDI Files meta event definitions */ #define meta_event 0xFF #define sequence_number 0x00 #define text_event 0x01 #define copyright_notice 0x02 #define sequence_name 0x03 #define instrument_name 0x04 #define lyric 0x05 #define marker 0x06 #define cue_point 0x07 #define channel_prefix 0x20 #define end_of_track 0x2f #define set_tempo 0x51 #define smpte_offset 0x54 #define time_signature 0x58 #define key_signature 0x59 #define sequencer_specific 0x74 /* Manufacturer's ID number */ #define Seq_Circuits (0x01) /* Sequential Circuits Inc. */ #define Big_Briar (0x02) /* Big Briar Inc. */ #define Octave (0x03) /* Octave/Plateau */ #define Moog (0x04) /* Moog Music */ #define Passport (0x05) /* Passport Designs */ #define Lexicon (0x06) /* Lexicon */ #define Tempi (0x20) /* Bon Tempi */ #define Siel (0x21) /* S.I.E.L. */ #define Kawai (0x41) #define Roland (0x42) #define Korg (0x42) #define Yamaha (0x43) /* miscellaneous definitions */ #define MThd 0x4d546864 #define MTrk 0x4d54726b #define lowerbyte(x) ((unsigned char)(x & 0xff)) #define upperbyte(x) ((unsigned char)((x & 0xff00)>>8)) abcmidi/yapstree.c0000644000000000000000000021345613203605077013162 0ustar rootroot/* * yaps - program to convert abc files to PostScript. * Copyright (C) 1999 James Allwright * e-mail: J.R.Allwright@westminster.ac.uk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * */ /* yapstree.c - back-end for abc parser. */ /* generates a data structure suitable for typeset music */ #define VERSION "1.70 November 17 2017 yaps" #include #ifdef USE_INDEX #define strchr index #endif /* for Microsoft VC 6++ or higher */ #ifdef _MSC_VER #define ANSILIBS #endif #ifdef ANSILIBS #include #include #include #else char* strchr(); #endif #include "abc.h" #include "parseabc.h" #include "parser2.h" #include "structs.h" #include "drawtune.h" extern void setscaling(char *s); extern void font_command(); extern void setup_fonts(); extern void printtune(struct tune *t); extern void set_keysig(struct key *k, struct key *newval); programname fileprogram = YAPS; extern int oldchordconvention; /* for handling +..+ chords */ struct voice* cv; struct tune thetune; char outputname[256]; char outputroot[256]; char matchstring[256]; int fileopen; int repcheck; int xinhead; int xinbody; int suppress; int debugging; int pagenumbering; int separate_voices; int print_xref; int landscape; int barnums,nnbars; extern int gchords_above; extern int decorators_passback[DECSIZE]; /* a kludge for passing information from the event_handle_instruction to parsenote in parseabc.c */ enum linestattype {fresh, midmusic, endmusicline, postfield}; enum linestattype linestat; int dummydecorator[DECSIZE]; /* used in event_chord */ void setfract(f, a, b) struct fract* f; int a, b; /* assign value to fraction */ { f->num = a; f->denom = b; } void reducef(f) struct fract* f; /* reducef fraction to smallest terms */ { int t, n, m; /* find HCF using Euclid's algorithm */ if (f->num > f->denom) { n = f->num; m = f->denom; } else { n = f->denom; m = f->num; }; while (m != 0) { t = n % m; n = m; m = t; }; f->num = f->num/n; f->denom = f->denom/n; } static struct fract* newfract(int a, int b) /* create an initialized fraction */ { struct fract* f; f = (struct fract*)checkmalloc(sizeof(struct fract)); f->num = a; f->denom = b; return(f); } static struct slurtie* newslurtie() /* create a new slur/tie data structure */ { struct slurtie* f; f = (struct slurtie*)checkmalloc(sizeof(struct slurtie)); f->begin = NULL; f->end = NULL; f->crossline = 0; return(f); } static struct atempo* newtempo(int count, int n, int m, int relative, char *pre, char *post) /* create an initialized tempo data structure */ { struct atempo* t; t = (struct atempo*)checkmalloc(sizeof(struct atempo)); t->count = count; t->basenote.num = n; t->basenote.denom = m; t->relative = relative; if (pre == NULL) { t->pre = NULL; } else { t->pre = addstring(pre); }; if (post == NULL) { t->post = NULL; } else { t->post = addstring(post); }; return(t); } static struct vertspacing* newvertspacing() /* create new vertspacing structure */ { struct vertspacing* p; p = (struct vertspacing*)checkmalloc(sizeof(struct vertspacing)); p->height = 0.0; p->descender = 0.0; p->yend = 0.0; p->yinstruct = 0.0; p->ygchord = 0.0; p->ywords = 0.0; return(p); } static struct tuple* newtuple(int n, int q, int r, int label) /* create tuple data structure */ { struct tuple* f; f = (struct tuple*)checkmalloc(sizeof(struct tuple)); f->n = n; f->q = q; f->r = r; f->label = label; f->beamed = 1; return(f); } static struct chord* newchord() /* create chord data structure */ { struct chord* f; f = (struct chord*)checkmalloc(sizeof(struct chord)); f->ytop = 0; f->ybot = 0; return(f); } struct aclef* newclef(enum cleftype t, int octave) /* create and initialize clef data structure */ { struct aclef* f; f = (struct aclef*)checkmalloc(sizeof(struct aclef)); f->type = t; f->octave = octave; return(f); } struct key* newkey(char* name, int sharps, char accidental[], int mult[]) /* create and initialize key signature */ { struct key* k; int i; k = (struct key*)checkmalloc(sizeof(struct key)); k->name = addstring(name); k->sharps = sharps; for (i=0; i<7; i++) { k->map[i] = accidental[i]; k->mult[i] = mult[i]; }; return(k); } void init_llist(struct llist* l) /* initialize a linked list */ { l->first = NULL; l->last = NULL; l->place = NULL; } void addtolist(struct llist* p, void* item) /* append an item to a linked list */ { struct el* x; x = (struct el*)checkmalloc(sizeof(struct el)); x->next = NULL; x->datum = item; if (p->first == NULL) { p->first = x; p->last = x; } else { p->last->next = x; p->last = x; }; } void* firstitem(struct llist* p) /* find the first item in the list */ /* also initialize for a traversal using nextitem() */ { if (p == NULL) { return(NULL); }; p->place = p->first; if (p->place == NULL) { return(NULL); } else { return(p->place->datum); }; } void* nextitem(struct llist* p) /* return 'next' item in the list. Successive calls return successive */ /* items or NULL after the end of the list has been reached. firstitem() */ /* must be called prior to the first call to nextitem() */ { if (p->place == NULL) { return(NULL); } else { p->place = p->place->next; if (p->place == NULL) { return(NULL); } else { return(p->place->datum); }; }; } void freellist(struct llist* l) /* frees up all dynamically allocated memory used to build the linked list */ { void* p; struct el* e; struct el* olde; /* printf("freellist\n"); */ if (l != NULL) { p = firstitem(l); while (p != NULL) { free(p); p = nextitem(l); }; e = l->first; while (e != NULL) { olde = e; e = e->next; free(olde); }; init_llist(l); }; } static void closebeam(struct voice* v) /* called after a run of notes to be beamed together */ { struct note* n; struct feature* ft; int stemup; int ingrace; if (cv->tuplenotes > 0) { cv->thistuple->beamed = 0; }; if (v->beamroot == v->beamend) { ft = v->beamroot; n = ft->item; n->beaming = single; v->beamroot = NULL; return; }; if (v->beammax + v->beammin > 2*4) { stemup = 0; } else { stemup = 1; }; ft = v->beamroot; ingrace = 0; while ((ft != NULL) && (ft != v->beamend)) { switch (ft->type) { case NOTE: if (ingrace == 0) { n = ft->item; n->stemup = stemup; }; break; case GRACEON: ingrace = 1; break; case GRACEOFF: ingrace = 0; break; default: break; }; ft = ft->next; }; if (ft == v->beamend) { n = ft->item; n->stemup = stemup; n->beaming = endbeam; } else { printf("closebeam: internal data error\n"); exit(1); }; v->beamroot = NULL; } static void closegracebeam(struct voice* v) /* called after a run of grace notes to be beamed together */ { struct note* n; struct feature* ft; ft = v->gracebeamend; if (ft == NULL) { event_error("Missing grace notes"); } else { n = ft->item; if (v->gracebeamroot == v->gracebeamend) { n->beaming = single; } else { n->beaming = endbeam; }; }; } static void insertnote(struct feature* chordplace, struct feature* newfeature) /* place NOTE in decreasing pitch order within chord */ { struct note* n; struct note* newnote; struct feature* f; struct feature* previous; int foundplace; newnote = newfeature->item; previous = chordplace; f = chordplace->next; foundplace = 0; n = NULL; while ((f != NULL)&&(f->type==NOTE)&&(foundplace == 0)) { n = f->item; if (newnote->y > n->y) { foundplace = 1; } else { previous = f; f = f->next; }; }; /* printvoiceline in drawtune.c expects the gchord or * instructions to be associated with the first note in * chord. If the notes are reordered then we need * to move these fields. * if previous == chordplace then move n->gchords and * n->instructions to newnote->gchords and newnote->instructions */ if (previous == chordplace && n != NULL) { newnote->gchords = n->gchords; newnote->instructions = n->instructions; n->gchords = NULL; n->instructions = NULL; } newfeature->next = previous->next; previous->next = newfeature; if (newfeature->next == NULL) { cv->last = newfeature; }; } static void beamitem(featuretype mytype, void* newitem, struct feature* x) /* This routine is responsible for working out which notes are to be */ /* beamed together and recording this in the note structure record */ { struct note* n; /* deal with beaming here */ if (cv->ingrace) { if (mytype == NOTE) { n = newitem; n->stemup = 1; if (cv->gracebeamroot == NULL) { cv->gracebeamroot = x; cv->gracebeamend = x; n->beaming = startbeam; } else { cv->gracebeamend = x; n->beaming = midbeam; }; }; } else { if (cv->beamroot != NULL) { switch (mytype) { case NOTE: n = newitem; if (n->base_exp >= -2) { n->beaming = single; closebeam(cv); } else { /* extend beam */ if (n->y > cv->beammax) { cv->beammax = n->y; }; if (n->y < cv->beammin) { cv->beammin = n->y; }; cv->beamend = x; n->beaming = midbeam; }; break; case KEY: case REST: case NOBEAM: case SINGLE_BAR: case DOUBLE_BAR: case BAR_REP: case REP_BAR: case BAR1: case REP_BAR2: case DOUBLE_REP: case THICK_THIN: case THIN_THICK: case TUPLE: case MUSICSTOP: /* closebeam */ closebeam(cv); break; default: break; }; } else { if (mytype == NOTE) { n = newitem; if (n->base_exp >= -2) { n->beaming = single; } else { n->beaming = startbeam; cv->beammax = n->y; cv->beammin = n->y; cv->beamroot = x; cv->beamend = x; }; }; }; }; } static struct feature* addfeature(featuretype mytype, void* newitem) /* append a new data element to the linked list for the current voice */ /* The element can be a note or lots of other things */ { struct voice* p; struct feature* x; p = cv; /* printf("in addfeature type=%d\n", mytype); */ if (cv == NULL) { printf("ERROR: no current voice in addfeature type=%d\n", mytype); printf("xinhead = %d xinbody = %d\n", xinhead, xinbody); exit(0); }; x = (struct feature*)checkmalloc(sizeof(struct feature)); x->next = NULL; x->type = mytype; x->item = newitem; x->xleft = 0; x->xright = 0; x->yup = 0; x->ydown = 0; if (cv->first == NULL) { cv->first = x; cv->last = x; beamitem(mytype, newitem, x); } else { if ((cv->last == NULL)||(cv->last->next != NULL)) { printf("expecting NULL at list end!\n"); exit(0); }; if ((cv->inchord)&&(mytype==NOTE)) { insertnote(cv->chordplace, x); } else { cv->last->next = x; cv->last = x; beamitem(mytype, newitem, x); }; }; return(x); } struct llist* newlist() /* create and initialize a new linked list */ { struct llist* l; l = (struct llist*)checkmalloc(sizeof(struct llist)); init_llist(l); return(l); } static int notenum(int octave, char ch, enum cleftype clef, int clefoctave) /* converts note to number for stave position */ /* note E is zero (bottom line of stave) */ { int n; n = 5 + (7 + ch -'c')%7 + 7*(octave-1); switch (clef) { case treble: break; case soprano: n = n + 2; break; case mezzo: n = n + 4; break; case alto: n = n + 6; break; case tenor: n = n + 8; break; case baritone: n = n + 10; break; case bass: n = n + 12; break; case noclef: break; }; switch (clefoctave) { case -22: n = n + 21; break; case -15: n = n + 14; break; case -8: n = n + 7; break; case 8: n = n - 7; break; case 15: n = n - 14; break; case 22: n = n - 21; break; default: break; }; return(n); } int count_dots(int *base, int *base_exp, int n, int m) /* convert fraction to 2^base_exp followed by dots */ /* previously used 1/base instead of 2^base_exp */ /* -1 indicates a note value which is impossible to represent */ { int dots; int start; int a, b; *base = 1; /* set default value if we fail */ *base_exp = 0; if ((n<1)||(m<1)) { return(-1); }; /* check denominator is power of 2 */ a = m; while (a>1) { if (a%2 == 1) { return(-1); }; a = a/2; }; dots = 0; start = m; while (start < n) { start = start*2; *base_exp = *base_exp + 1; }; while (start > n) { start = start/2; *base_exp = *base_exp - 1; }; if (start == 0) { printf("Problem with %d / %d\n", n, m); exit(0); }; *base = m/start; a = n - start; b = start; while (a>0) { dots = dots + 1; b = b/2; a = a - b; if (a< 0) { return(-1); }; }; return(dots); } static char* decstring(int decorators[]) /* creates a string of decorators (ornament, staccato, roll, up-bow etc.) */ /* from a boolean array */ { int i, j; char decs[DECSIZE+1]; j = 0; for (i=0; ilen, a, b); reducef(&n->len); n->dots = count_dots(&n->base, &n->base_exp, n->len.num, n->len.denom); /* if (n->dots == -1) { event_error("Illegal note length"); }; */ n->accents = decstring(decorators); n->accidental = xaccidental; n->acc_offset = 0; n->fliphead = 0; n->mult = xmult; n->octave = xoctave; n->pitch = xnote; n->y = notenum(xoctave, xnote, cv->clef->type, cv->clef->octave); if (n->y < 4) { n->stemup = 1; } else { n->stemup = 0; }; n->stemlength = 0.0; n->syllables = NULL; if (cv->ingrace) { n->gchords = NULL; n->instructions = NULL; } else { n->gchords = cv->gchords_pending; cv->gchords_pending = NULL; n->instructions = cv->instructions_pending; cv->instructions_pending = NULL; }; return(n); } static struct rest* newrest(int a, int b, int multi) /* create and set up a new rest structure */ { struct rest* n; n = (struct rest*)checkmalloc(sizeof(struct rest)); setfract(&n->len, a, b); n->dots = count_dots(&n->base, &n->base_exp, a, b); if (n->dots == -1) { event_error("Illegal rest length"); }; n->multibar = multi; if (cv->ingrace) { n->gchords = NULL; n->instructions = NULL; } else { n->gchords = cv->gchords_pending; cv->gchords_pending = NULL; n->instructions = cv->instructions_pending; cv->instructions_pending = NULL; }; return(n); } static void addunits(f, n, m) struct fract* f; int n, m; /* add n/m to fraction pointed to by f */ { f->num = n*f->denom*(cv->unitlen.num) + f->num*(m*cv->unitlen.denom); f->denom = (m*cv->unitlen.denom)*f->denom; reducef(f); } static void addfractions(f,n,m) struct fract* f; int n,m; { f->num = n*f->denom + f->num*m; f->denom = m*f->denom; reducef(f); } static struct voice* newvoice(int n) /* create and set up a new voice data structure */ { struct voice* v; v = (struct voice*)checkmalloc(sizeof(struct voice)); v->first = NULL; v->last = NULL; v->voiceno = n; v->octaveshift = thetune.octaveshift; setfract(&v->unitlen, thetune.unitlen.num, thetune.unitlen.denom); v->changetime = 0; v->inslur = 0; v->ingrace = 0; v->inchord = 0; v->expect_repeat = 0; v->tuplenotes = 0; v->thistuple = NULL; v->tuple_count = 0; v->brokenpending = -1; v->tiespending = 0; v->slurpending = 0; v->slurcount = 0; v->barno = 0; v->barchecking = thetune.barchecking; setfract(&v->barlen, thetune.meter.num, thetune.meter.denom); v->clef = newclef(thetune.clef.type, thetune.clef.octave); if (thetune.keysig == NULL) { printf("Trying to set up voice with no key signature\n"); exit(0); } else { v->keysig = newkey(thetune.keysig->name, thetune.keysig->sharps, thetune.keysig->map, thetune.keysig->mult); }; v->tempo = NULL; setfract(&v->barcount, 0, 1); setfract(&v->meter, thetune.meter.num, thetune.meter.denom); v->lastnote = NULL; v->laststart = NULL; v->lastend = NULL; v->line = header; v->thisstart = NULL; v->thisend = NULL; v->gchords_pending = NULL; v->instructions_pending = NULL; v->beamed_tuple_pending = 0; v->linestart = NULL; v->lineend = NULL; v->more_lyrics = 0; v->lyric_errors = 0; v->thischord = NULL; v->chordplace = NULL; v->beamroot = NULL; v->beamend = NULL; v->gracebeamroot = NULL; v->gracebeamend = NULL; return(v); } static void setvoice(int n) /* set current voice to voice n. If voice n does not exist, create it */ { struct voice* v; struct el* l; int done; if (thetune.voices.first == NULL) { cv = newvoice(n); v = cv; addtolist(&thetune.voices, (void*)v); } else { l = thetune.voices.first; done = 0; while ((done == 0) && (l != NULL)) { if (((struct voice*)l->datum)->voiceno == n) { done = 1; cv = (struct voice*)l->datum; } else { l = l->next; }; }; if (done == 0) { cv = newvoice(n); v = cv; addtolist(&thetune.voices, (void*)v); }; }; } static void init_tune(struct tune* t, int x) /* initialize tune structure */ { t->no = x; t->octaveshift = 0; init_llist(&t->title); t->composer = NULL; t->origin = NULL; t->parts = NULL; init_llist(&t->notes); init_llist(&t->voices); setfract(&t->meter, 0, 1); setfract(&t->unitlen, 0, 1); t->cv = NULL; t->keysig = NULL; t->clef.type = treble; t->clef.octave = 0; t->tempo = NULL; init_llist(&t->words); }; static void freekey(struct key* k) /* free up memory allocated for key data structure */ { if (k != NULL) { if (k->name != NULL) { free(k->name); }; free(k); }; } static void freetempo(struct atempo *t) /* free up memory allocated for temp data structure */ { if (t->pre != NULL) { free(t->pre); }; if (t->post != NULL) { free(t->post); }; } static void freefeature(void* item, featuretype type) /* free memory allocated for feature in voice */ { struct note *n; struct rest *r; switch(type) { case NOTE: n = item; if (n->accents != NULL) { free(n->accents); }; if (n->syllables != NULL) { freellist(n->syllables); free(n->syllables); }; if (n->gchords != NULL) { freellist(n->gchords); free(n->gchords); }; if (n->instructions != NULL) { freellist(n->instructions); free(n->instructions); }; free(n); break; case REST: r = item; if (r->gchords != NULL) { freellist(r->gchords); free(r->gchords); }; if (r->instructions != NULL) { freellist(r->instructions); free(r->instructions); }; free(r); break; case KEY: freekey(item); break; case TEMPO: freetempo(item); break; case CLEF: case TIME: case PART: case CHORDON: case TUPLE: case SLUR_ON: case TIE: case PLAY_ON_REP: case LEFT_TEXT: case PRINTLINE: if (item != NULL) { free(item); }; break; default: break; }; } static void freevoice(struct voice* v) /* free up memory allocated for voice data structure and voice data */ { struct feature* ft; struct feature* oldft; ft = v->first; while (ft != NULL) { freefeature(ft->item, ft->type); oldft = ft; ft = ft->next; free(oldft); }; if (v->keysig != NULL) { freekey(v->keysig); v->keysig = NULL; }; if (v->tempo != NULL) { freetempo(v->tempo); v->tempo = NULL; }; if (v->clef != NULL) { free(v->clef); }; v->clef = NULL; } static void freetune(struct tune* t) /* free up all dynamically allocated memory associated with tune */ { struct voice* v; if (t->composer != NULL) { free(t->composer); t->composer = NULL; }; if (t->origin != NULL) { free(t->origin); t->origin = NULL; }; if (t->parts != NULL) { free(t->parts); t->parts = NULL; }; freellist(&t->title); freellist(&t->notes); if (t->keysig != NULL) { freekey(t->keysig); t->keysig = NULL; }; if (t->tempo != NULL) { freetempo(t->tempo); t->tempo = NULL; }; v = firstitem(&t->voices); while (v != NULL) { freevoice(v); v = nextitem(&t->voices); }; freellist(&t->voices); freellist(&t->words); } static int checkmatch(int refno) /* compares current reference number against list of numbers */ /* following -e argument */ /* returns 1 if tune has been selected and 0 otherwise */ { int select; int n1, n2; char* place; place = matchstring; if (strlen(matchstring)==0) { select = 1; } else { select = 0; while ((select==0)&&(*place >= '0')&&(*place <='9')) { n1 = readnump(&place); if (n1 == refno) { select = 1; } else { if (*place == ',') { place = place+1; } else { if (*place == '-') { place = place+1; n2 = readnump(&place); if ((refno >= n1)&&(refno <= n2)) { select = 1; } else { if (*place == ',') { place = place+1; }; }; }; }; }; }; if ((select==0)&&(*place != '\0')) { event_warning("Number list after -e not fully parsed"); }; }; return(select); } void event_init(argc, argv, filename) int argc; char* argv[]; char** filename; /* initialization routine - called once at the start of the program */ /* interprets the parameters in argv */ { char* place; int filearg; int refmatch; int papsize, margins, newscale; int ier; int j; if (getarg("-ver",argc, argv) != -1) { printf("%s\n",VERSION); exit(0); } if (getarg("-d", argc, argv) != -1) { debugging = 1; } else { debugging = 0; }; if (getarg("-E", argc, argv) != -1) { eps_out = 1; } else { eps_out = 0; }; if (getarg("-OCC",argc,argv) != -1) oldchordconvention=1; if (getarg("-V", argc, argv) != -1) { separate_voices = 1; } else { separate_voices = 0; }; if (getarg("-x", argc, argv) != -1) { print_xref = 1; } else { print_xref = 0; }; if (getarg("-N", argc, argv) != -1) { pagenumbering = 1; } else { pagenumbering = 0; }; if (getarg("-l", argc, argv) != -1) { landscape = 1; } else { landscape = 0; }; newscale = getarg("-s", argc, argv); if ((newscale != -1) && (argc >= newscale+1)) { /* [SS] 2015-02-22 */ setscaling(argv[newscale]); } else { setscaling(""); }; margins = getarg("-M", argc, argv); if ((margins != -1) && (argc >= margins)) { setmargins(argv[margins]); } else { setmargins(""); }; papsize = getarg("-P", argc, argv); if ((papsize != -1) && (argc >= papsize)) { setpagesize(argv[papsize]); } else { setpagesize(""); }; barnums = getarg("-k",argc,argv); ier = 0; if ((barnums != -1) && (argc > barnums)) ier = sscanf(argv[barnums],"%d",&nnbars); if ((barnums != -1) && (ier <1)) nnbars = 1; refmatch = getarg("-e", argc, argv); if (refmatch == -1) { *matchstring = '\0'; } else { if (strlen(argv[refmatch]) < 255) { strcpy(matchstring, argv[refmatch]); } else { event_error("Exceeded character limit for -e string"); exit(1); }; }; if ((getarg("-h", argc, argv) != -1) || (argc < 2)) { printf("yaps version %s\n",VERSION); printf("Usage: yaps []\n"); printf(" possible options are -\n"); printf(" -ver :prints version number and exits\n"); printf(" -d : debug - display data structure\n"); printf(" -e : draw tunes with reference numbers in list\n"); printf(" list is comma-separated and may contain ranges\n"); printf(" but no spaces e.g. 1,3,7-20\n"); printf(" -E : generate Encapsulated PostScript\n"); printf(" -l : landscape mode\n"); printf(" -M XXXxYYY : set margin sizes in points\n"); printf(" 28.3 points = 1cm, 72 points = 1 inch\n"); printf(" -N : add page numbering\n"); printf(" -k [nn] : number every nn bars\n"); printf(" -o : specify output file\n"); printf(" -P ss : paper size; 0 is A4, 1 is US Letter\n"); printf(" or XXXxYYY to set size in points\n"); printf(" -s XX : scaling factor (default is 0.7)\n"); printf(" -V : separate voices in multi-voice tune\n"); printf(" -x : print tune number in X: field\n"); printf(" -OCC : old chord convention (eg. +CE+)\n"); printf("Takes an abc music file and converts it to PostScript.\n"); printf("If no output filename is given, then by default it is\n"); printf("the input filename but with extension .ps .\n"); exit(0); } else { *filename = argv[1]; }; fileopen = 0; filearg = getarg("-o", argc, argv); if (filearg != -1) { /*strcpy(outputname, argv[filearg]); security risk buffer overflow */ strncpy(outputname, argv[filearg],256); } else { /* strcpy(outputname, argv[1]); security risk: buffer overflow */ strncpy(outputname, argv[1],256); place = strchr(outputname, '.'); if (place == NULL) { strcat(outputname, ".ps"); } else { strcpy(place, ".ps"); }; if (strcmp(argv[1], outputname)==0) { printf("argument must be abc file, not PostScript file\n"); exit(1); }; }; /* create filename root for EPS output */ strcpy(outputroot, outputname); place = strchr(outputroot, '.'); if (place != NULL) { *place = '\0'; }; xinbody =0; xinhead = 0; suppress = 0; init_tune(&thetune, -1); setup_fonts(); /* open_output_file(outputname); */ for (j=0;jinchord) { event_error("incomplete chord at end of voice"); v->inchord = 0; }; if (v->brokenpending != -1) { event_error("incomplete broken rhythm at end of voice"); v->brokenpending = -1; }; if ((v->slurcount > 0)||(v->slurpending)) { event_error("incomplete slur at end of voice"); v->slurcount = 0; v->slurpending = 0; }; if (v->tiespending) { event_error("incomplete ties at end of voice"); v->tiespending = 0; }; if (v->gchords_pending != NULL) { freellist(v->gchords_pending); free(v->gchords_pending); v->gchords_pending = NULL; }; if (v->instructions_pending != NULL) { freellist(v->instructions_pending); free(v->instructions_pending); v->instructions_pending = NULL; }; if (v->tuplenotes > 0) { event_error("incomplete tuple at end of voice"); v->tuplenotes = 0; }; } static void check_tune_end(struct tune* t) /* check that all voices have been completed properly */ { struct voice* v; v = firstitem(&t->voices); while (v != NULL) { check_voice_end(v); v = nextitem(&t->voices); }; } void event_eof() /* end of input file has been encountered */ { if (xinbody) { check_tune_end(&thetune); printtune(&thetune); }; freetune(&thetune); close_output_file(); } void event_blankline() /* A blank line has been encountered */ { if (xinbody) { check_tune_end(&thetune); printtune(&thetune); }; freetune(&thetune); xinbody = 0; xinhead = 0; suppress = 0; parseroff(); } void event_text(p) /* Text outside an abc tune has been encountered */ char *p; { } void event_x_reserved(p) char p; { } void event_abbreviation(symbol, string, container) /* abbreviation declaratiion - handled by parser. Ignore it here */ char symbol; char *string; char container; { } void event_acciaccatura() { /* does nothing but outputs a / in toabc.c */ return; } /* [SS] 2015-03-23 */ void event_start_extended_overlay() { event_error("extended overlay not implemented in yaps"); } void event_stop_extended_overlay() { event_error("extended overlay not implemented in yaps"); } void event_split_voice() { /* [SS] 2015-11-15 * changed (void*) to (int *) */ addfeature(SPLITVOICE, (int *) lineno); event_error("voice split not implemented in yaps"); } void event_tex(s) char *s; /* A TeX command has been found in the abc */ { } void event_linebreak() /* A linebreak has been encountered */ { /* [SS] 2015-11-15 * changed (void*) to (int *) */ if (xinbody) { addfeature(LINENUM, (int *)lineno); }; } static void tidy_ties() /* create CLOSE_TIE features for ties straddling two lines of music */ /* CLOSE_TIE appears in the new music line */ { struct feature* ft; struct slurtie* s; int i; for (i=0; itiespending; i++) { ft = cv->tie_place[i]; /* pointer to TIE feature */ s = ft->item; addfeature(CLOSE_TIE, s); }; } void event_startmusicline() /* We are at the start of a line of abc notes */ { cv->linestart = addfeature(MUSICLINE, (void*)NULL); if (cv->more_lyrics != 0) { event_error("Missing continuation w: field"); cv->more_lyrics = 0; }; if ((cv->line == header) || (cv->line == newline)) { addfeature(CLEF, newclef(cv->clef->type, cv->clef->octave)); addfeature(KEY, newkey(cv->keysig->name, cv->keysig->sharps, cv->keysig->map, cv->keysig->mult)); if ((cv->line == header)||(cv->changetime)) { addfeature(TIME, newfract(cv->meter.num, cv->meter.denom)); cv->changetime = 0; }; cv->line = midline; tidy_ties(); }; cv->lineend = NULL; } static void divide_ties() /* mark unresolved ties and slurs as straddling two lines of music */ { struct feature* ft; struct slurtie* s; int i; for (i=0; itiespending; i++) { ft = cv->tie_place[i]; /* pointer to TIE feature */ s = ft->item; s->crossline = 1; }; for (i=0; islurcount; i++) { s = cv->slur_place[i]; s->crossline = 1; }; } void event_endmusicline(endchar) char endchar; /* We are at the end of a line of abc notes */ { cv->lineend = addfeature(MUSICSTOP, (void*)NULL); if ((endchar == ' ') || (endchar == '!')) { addfeature(PRINTLINE, newvertspacing()); cv->line = newline; divide_ties(); }; } void event_error(s) char *s; /* report any error message */ { printf("Error in line %d : %s\n", lineno, s); } void event_warning(s) char *s; /* report any warning message */ { printf("Warning in line %d : %s\n", lineno, s); } void event_comment(s) char *s; /* A comment has been encountered in the input */ { } int make_open() /* called as fileopen = make_open() */ /* if file is not already open, open it and set fileopen */ { if (fileopen == 0) { open_output_file(outputname, (void*)NULL); fileopen = 1; }; return(1); } void event_specific(p, str) char *p; /* first word after %% */ char *str; /* string following first word */ /* The special comment %% has been found */ /* abc2midi uses it for the %%MIDI commands */ /* yaps implements some of the abc2ps commands */ { char* s; double vspace; char units[80]; int count; /* ensure file has been opened since most commands require this */ if (!eps_out) { fileopen = make_open(); }; s = str; skipspace(&s); if (strcmp(p, "newpage") == 0) { if (xinbody == 0) { if (fileopen) { newpage(); }; } else { addfeature(NEWPAGE, (void*)NULL); }; }; if (strcmp(p, "text") == 0) { if (xinbody == 0) { if (fileopen) { lefttext(s); }; } else { addfeature(LEFT_TEXT, addstring(s)); }; }; if ((strcmp(p, "centre") == 0) || (strcmp(p, "center") == 0)) { if (xinbody == 0) { if (fileopen) { centretext(s); }; } else { addfeature(CENTRE_TEXT, addstring(s)); }; }; if (strcmp(p, "vskip") == 0) { count = sscanf(s, "%lf%s", &vspace, units); if (count > 0) { if ((count >= 2) && (strncmp(units, "cm", 2) == 0)) { vspace = vspace*28.3; }; if ((count >= 2) && (strncmp(units, "in", 2) == 0)) { vspace = vspace*72.0 ; }; if (xinbody == 0) { if (fileopen) { vskip(vspace); }; } else { addfeature(VSKIP, (int*)((int)vspace)); }; }; }; if (strcmp(p, "chordsabove") == 0) { gchords_above = 1; }; if (strcmp(p, "chordsbelow") == 0) { gchords_above = 0; }; /* look for font-related commands */ font_command(p, s); } void event_field(k, f) char k; char *f; /* A field line has been encountered in the input abc */ { switch (k) { case 'T': if (debugging) { printf("T:%s\n", f); }; addtolist(&thetune.title, addstring(f)); break; case 'C': if (thetune.composer != NULL) { event_error("More than one C: field in tune"); } else { thetune.composer = addstring(f); }; break; case 'O': if (thetune.origin != NULL) { event_error("More than one O: field in tune"); } else { thetune.origin = addstring(f); }; break; case 'W': if (debugging) { printf("W:%s\n", f); }; addtolist(&thetune.words, addstring(f)); break; case 'N': addtolist(&thetune.notes, addstring(f)); break; default: break; }; } struct feature* findbar(struct feature* wordplace, int* errors) /* hunts through voice to find next bar data structure */ { struct feature* ft; ft = wordplace; while ((ft != NULL) && (ft != cv->lineend) && (ft->type != MUSICSTOP) && (ft->type != SINGLE_BAR) && (ft->type != DOUBLE_BAR) && (ft->type != BAR_REP) && (ft->type != REP_BAR) && (ft->type != DOUBLE_REP) && (ft->type != THICK_THIN) && (ft->type != THIN_THICK) && (ft->type != BAR1) && (ft->type != REP_BAR2)) { ft = ft->next; }; if ((ft == NULL) || (ft == cv->lineend) || (ft->type == MUSICSTOP)) { *errors = *errors + 1; } else { ft = ft->next; }; return(ft); } struct feature* apply_syll(char* s, struct feature* wordplace, int* errors) /* attaches a syllable from the lyrics to the appropriate note */ { struct note* n; struct feature* ft; int inchord; ft = wordplace; inchord = 0; while ((ft != NULL) && (ft != cv->lineend) && (ft->type != NOTE)) { if (ft->type == CHORDON) { inchord = 1; }; ft = ft->next; /* skip over any grace notes */ if ((ft != NULL) && (ft->type == GRACEON)) { while ((ft != NULL) && (ft != cv->lineend) && (ft->type != GRACEOFF)) { ft = ft->next; }; }; }; if ((ft == NULL) || (ft == cv->lineend)) { *errors = *errors + 1; return(ft); }; if (ft->type == NOTE) { n = ft->item; if (n->syllables == NULL) { n->syllables = newlist(); }; /* if (strlen(s) < 80) { ISOdecode(s, isocode); addtolist(n->syllables, addstring(isocode)); } else { */ addtolist(n->syllables, addstring(s)); /* }; */ }; ft = ft->next; /* skip over any chord */ if (inchord) { while ((ft != NULL) && (ft->type != CHORDOFF) && (ft != cv->lineend)) { ft = ft->next; }; }; return(ft); } void event_words(p, continuation) char* p; int continuation; /* A line of lyrics (w: ) has been encountered in the abc */ { struct vstring syll; char* q; struct feature* wordplace; unsigned char ch; int errors; if (!xinbody) { if (!suppress) { event_error("w: field outside tune body"); }; return; }; wordplace = cv->linestart; if (cv->more_lyrics) { errors = cv->lyric_errors; } else { errors = 0; }; if (wordplace == NULL) { event_error("No notes to match words"); return; }; initvstring(&syll); q = p; skipspace(&q); while (*q != '\0') { clearvstring(&syll); ch = *q; while(ch=='|') { wordplace = findbar(wordplace, &errors); q++; ch = *q; }; while (((ch>127)||isalnum(ch)||ispunct(ch))&& (ch != '_')&&(ch != '-')&&(ch != '*')&& (ch != '|')) { if (ch == '~') { ch = ' '; }; if ((ch == '\\') && (*(q+1)=='-')) { ch = '-'; q++; }; /* syllable[i] = ch; */ addch(ch, &syll); q++; ch = *q; }; skipspace(&q); if (ch == '-') { addch(ch, &syll); while (isspace(ch)||(ch=='-')) { q++; ch = *q; }; }; if (syll.len > 0) { wordplace = apply_syll(syll.st, wordplace, &errors); } else { if (ch=='_') { clearvstring(&syll); addch('_', &syll); wordplace = apply_syll(syll.st, wordplace, &errors); q++; ch = *q; }; if (ch=='*') { clearvstring(&syll); addch(' ', &syll); wordplace = apply_syll(syll.st, wordplace, &errors); q++; ch = *q; }; }; }; if (continuation) { cv->more_lyrics = 1; cv->lyric_errors = errors; cv->linestart = wordplace; } else { cv->more_lyrics = 0; if (errors > 0) { event_error("Lyric line too long for music"); } else { clearvstring(&syll); wordplace = apply_syll(syll.st, wordplace, &errors); if (errors == 0) { event_error("Lyric line too short for music"); }; }; }; freevstring(&syll); } /* [SS] 2014-08-16 */ void appendfield (morewords) char *morewords; { printf("appendfield not implemented here\n"); } void event_part(s) char* s; /* A part field (P: ) has been encountered in the abc */ { char label[200]; /* [SS] 2010-12-12 */ if (xinhead) { if (thetune.parts != NULL) { event_error("Multiple P: fields in header"); } else { thetune.parts = addstring(s); }; }; if (xinbody) { /* addfeature(PART, addstring(s)); */ /* PART is handled like an instruction */ if (cv->instructions_pending == NULL) { cv->instructions_pending = newlist(); }; sprintf(label, ":p%s", s); addtolist(cv->instructions_pending, addstring(label)); }; } void event_voice(n, s, vp) int n; char *s; struct voice_params *vp; /* A voice field (V: ) has been encountered */ { if (xinbody) { setvoice(n); } else { if (!suppress) { event_error("V: field outside tune body"); }; }; } void event_length(n) int n; /* A length field (L: ) has been encountered */ { if (xinhead) { setfract(&thetune.unitlen, 1, n); } else { if (xinbody) { setfract(&cv->unitlen, 1, n); } else { if (!suppress) { event_warning("L: field outside tune ignored"); }; }; }; } void event_refno(n) int n; /* A reference field (X: ) has been encountered. This indicates the start */ /* of a new tune */ { if (xinhead) { event_error("incomplete tune"); }; if (xinbody) { check_tune_end(&thetune); printtune(&thetune); }; freetune(&thetune); xinbody = 0; xinhead = 0; suppress = 0; parseroff(); if (debugging) { printf("X:%d\n", n); }; if (checkmatch(n)) { parseron(); /* fileopen = make_open(); */ xinhead = 1; xinbody = 0; init_tune(&thetune, n); } else { suppress = 1; }; } void event_tempo(n, a, b, relative, pre, post) int n, a, b; int relative; char *pre; /* text before tempo */ char *post; /* text after tempo */ /* A tempo field Q: has been encountered in the abc */ /* Q:a/b=N will have relative = 0 */ /* Q:N will have a=0 and b=0 */ /* Q:Ca/b = N will have relative = 1 */ { if (xinhead) { thetune.tempo = newtempo(n, a, b, relative, pre, post); } else { if (xinbody) { if ((a == 0) && (b == 0)) { addfeature(TEMPO, newtempo(n, cv->unitlen.num, cv->unitlen.denom, 0, pre, post)); } else { addfeature(TEMPO, newtempo(n, a, b, relative, pre, post)); }; } else { if (!suppress) { event_warning("Q: field outside tune ignored"); }; }; }; } void event_timesig(n, m, checkbars) int n, m, checkbars; /* A time signature (M: ) has been encountered in the abc */ { if (xinhead) { setfract(&thetune.meter, n, m); thetune.barchecking = checkbars; } else { if (xinbody) { if (checkbars == 1) { addfeature(TIME, newfract(n,m)); setfract(&cv->meter, n, m); setfract(&cv->barlen, n, m); if (cv->line != midline) { cv->changetime = 1; }; cv->barchecking = 1; } else { cv->barchecking = 0; }; } else { if (!suppress) { event_warning("M: field outside tune ignored"); }; }; }; } enum cleftype findclef(clefstr, oct) char* clefstr; int* oct; /* converts a clef name string to an enumerated type */ /* also looks for +8 +15 +22 -8 -15 -22 octave shift */ { enum cleftype type; char* p; int interval; type = noclef; p = clefstr; if (strncmp(clefstr, "treble", 6)==0) { type = treble; p = p + 6; }; if (strncmp(clefstr, "bass", 4)==0) { type = bass; p = p + 4; }; if (strncmp(clefstr, "baritone", 8)==0) { type = baritone; p = p + 8; }; if (strncmp(clefstr, "tenor", 5)==0) { type = tenor; p = p + 5; }; if (strncmp(clefstr, "alto", 4)==0) { type = alto; p = p + 4; }; if (strncmp(clefstr, "mezzo", 5)==0) { type = mezzo; p = p + 5; }; if (strncmp(clefstr, "mezzo-soprano", 13)==0) { type = mezzo; p = p + 13; }; if (strncmp(clefstr, "soprano", 7)==0) { type = soprano; p = p + 7; }; interval = 0; if ((type != noclef) && ((*p == '+') || (*p == '-'))) { sscanf(p+1, "%d", &interval); if ((interval == 8) || (interval == 15) || (interval == 22)) { if (*p == '-') { interval = -interval; }; } else { interval = 0; }; }; *oct = interval; return(type); } void event_clef(char* clefstr) /* a clef has been encountered in the abc */ { enum cleftype clef; int num; clef = findclef(clefstr, &num); if (xinbody) { cv->clef->type = clef; cv->clef->octave = num; addfeature(CLEF, newclef(clef, num)); }; if ((xinhead) && (!xinbody)) { if (clef != noclef) { thetune.clef.type = clef; thetune.clef.octave = num; }; }; } void setmap(sf, map, mult) /* work out accidentals to be applied to each note */ int sf; /* number of sharps in key signature -7 to +7 */ char map[7]; int mult[7]; { int j; for (j=0; j<7; j++) { map[j] = '='; mult[j] = 1; }; if (sf >= 1) map['f'-'a'] = '^'; if (sf >= 2) map['c'-'a'] = '^'; if (sf >= 3) map['g'-'a'] = '^'; if (sf >= 4) map['d'-'a'] = '^'; if (sf >= 5) map['a'-'a'] = '^'; if (sf >= 6) map['e'-'a'] = '^'; if (sf >= 7) map['b'-'a'] = '^'; if (sf <= -1) map['b'-'a'] = '_'; if (sf <= -2) map['e'-'a'] = '_'; if (sf <= -3) map['a'-'a'] = '_'; if (sf <= -4) map['d'-'a'] = '_'; if (sf <= -5) map['g'-'a'] = '_'; if (sf <= -6) map['c'-'a'] = '_'; if (sf <= -7) map['f'-'a'] = '_'; } void altermap(basemap, basemul, modmap, modmul) /* apply modifiers to a set of accidentals */ char basemap[7], modmap[7]; int basemul[7], modmul[7]; { int i; for (i=0; i<7; i++) { if (modmap[i] != ' ') { basemap[i] = modmap[i]; basemul[i] = modmul[i]; }; }; } void resolve_tempo(struct atempo* t, struct fract* unitlen) /* Tempo may be given relative to the unit note length. At the start of */ /* the tune, we will know what this is and can deduce the tempo value. */ /* Can also deduce tempo if it has been given as a number only. */ { if (t->relative==1) { setfract(&t->basenote, t->basenote.num*unitlen->num, t->basenote.denom*unitlen->denom); reducef(&t->basenote); t->relative = 0; }; if ((t->basenote.num == 0) && (t->basenote.denom == 0)) { setfract(&t->basenote, unitlen->num, unitlen->denom); reducef(&t->basenote); }; } static void start_body() /* We have reached the end of the header section and need to set */ /* default values for anything not explicitly declared */ { parseron(); if (thetune.meter.num == 0) { event_warning("no M: field, assuming 4/4"); /* generate missing time signature */ event_timesig(4, 4, 1); event_linebreak(); }; if (thetune.unitlen.num == 0) { event_warning("no L: field, using default rule"); if ((double) thetune.meter.num / (double) thetune.meter.denom < 0.75) { /*setfract(&thetune.unitlen, 1, 16); [SS] 2004-09-06 */ event_length(16); } else { /* setfract(&thetune.unitlen, 1, 8); */ event_length(8); }; }; if (thetune.tempo != NULL) { resolve_tempo(thetune.tempo, &thetune.unitlen); }; } void event_true_key(sharps, s, modeindex, modmap, modmul) int sharps; char *s; int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ char modmap[7]; int modmul[7]; /* key detected in K: field */ { char basemap[7]; int basemul[7]; struct key* akey; int minor; minor =0; if (modeindex >0 && modeindex <4) minor = 1; setmap(sharps, basemap, basemul); altermap(basemap, basemul, modmap, modmul); if (xinbody) { akey = newkey(s, sharps, basemap, basemul); addfeature(KEY, akey); set_keysig(cv->keysig, akey); }; if (xinhead) { if (thetune.keysig == NULL) { thetune.keysig = newkey(s, sharps, basemap, basemul); } else { event_warning("Key specified twice"); }; xinbody = 1; xinhead = 0; setvoice(1); start_body(); }; } void event_octave(int num, int local) /* deals with the special command I:octave=N */ { if (xinhead) { thetune.octaveshift = num; }; if (xinbody) { cv->octaveshift = num; }; } void event_key(sharps, s, minor, modmap, modmul, modmicrotone, gotkey, gotclef, clefstr, octave, transpose, gotoctave, gottranspose, explict) int sharps; char *s; int minor; char modmap[7]; int modmul[7]; struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ int gotkey, gotclef; char* clefstr; int octave, transpose, gotoctave, gottranspose; int explict; /* A key field (K: ) has been encountered */ { if (xinhead || xinbody) { if (gotclef==1) { event_clef(clefstr); }; if (gotkey==1) { event_true_key(sharps, s, minor, modmap, modmul); }; }; if (gotoctave) { event_octave(octave,0); }; } static void checkbar(int type) /* Make sure that bar lasts for the correct musical time */ { int valid; char msg[80]; int a1, a2; valid = 0; a1 = cv->barlen.num*cv->barcount.denom; a2 = cv->barcount.num*cv->barlen.denom; if (a1 == a2) { cv->barcount.num = 0; cv->barcount.denom = 1; cv->barno = cv->barno + 1; } else { if (((type==BAR_REP)||(type==REP_BAR)||(type==DOUBLE_REP)) && (a1 > a2)) { /* do nothing */ } else { if ((cv->barno > 0) && (cv->barcount.num != 0) && (cv->barchecking != 0)) { sprintf(msg, "Bar %d is %d/%d not %d/%d", cv->barno, cv->barcount.num, cv->barcount.denom, cv->barlen.num, cv->barlen.denom); event_warning(msg); cv->barcount.num = 0; cv->barcount.denom = 1; cv->barno = cv->barno + 1; } else { cv->barcount.num = 0; cv->barcount.denom = 1; cv->barno = cv->barno + 1; }; }; }; } void event_bar(type, playonrep_list) int type; char* playonrep_list; /* A bar has been encountered in the abc */ { if (cv->inchord) { event_warning("Bar line not permitted within chord"); return; }; checkbar(type); /* increment bar number if bar complete */ /* [SS] 2015-11-15 * changed (void*) to (int *) */ addfeature(type, (int *)cv->barno); /* save bar number */ switch(type) { case SINGLE_BAR: break; case DOUBLE_BAR: break; case THIN_THICK: break; case THICK_THIN: break; case BAR_REP: if ((cv->expect_repeat) && (repcheck)) { event_error("Expecting repeat, found |:"); }; cv->expect_repeat = 1; break; case REP_BAR: if ((!cv->expect_repeat) && (repcheck)) { event_error("No repeat expected, found :|"); }; cv->expect_repeat = 0; break; case BAR1: if ((!cv->expect_repeat) && (repcheck)) { event_error("found |1 in non-repeat section"); }; break; case REP_BAR2: if ((!cv->expect_repeat) && (repcheck)) { event_error("No repeat expected, found :|2"); }; cv->expect_repeat = 0; break; case DOUBLE_REP: if ((!cv->expect_repeat) && (repcheck)) { event_error("No repeat expected, found ::"); }; cv->expect_repeat = 1; break; }; if ((playonrep_list != NULL) && (strlen(playonrep_list) > 0)) { event_playonrep(playonrep_list); }; } void event_space() /* A region of whitespace has been encountered */ { addfeature(NOBEAM, NULL); } void event_graceon() /* start of grace note(s) */ { if (cv->inchord) { event_error("grace notes not allowed within chord"); return; }; if (cv->ingrace) { event_error("nested grace notes not allowed"); return; }; cv->gracebeamroot = NULL; cv->gracebeamend = NULL; cv->ingrace = 1; addfeature(GRACEON, NULL); } void event_graceoff() /* end of grace note(s) */ { if (!cv->ingrace) { event_error("No grace notes to close"); return; }; if (cv->inchord) { event_error("cannot close grace notes within chord"); return; }; addfeature(GRACEOFF, NULL); closegracebeam(cv); cv->ingrace = 0; cv->gracebeamroot = NULL; cv->gracebeamend = NULL; } void event_rep1() /* start of first repeat */ { addfeature(REP1, NULL); } void event_rep2() /* start of second repeat */ { addfeature(REP2, NULL); } void event_playonrep(s) char* s; /* play on repeat(s) X - where X can be a list */ { addfeature(PLAY_ON_REP, addstring(s)); } void event_broken(type, mult) /* handles > >> >>> < << <<< in the abc */ int type, mult; { if (cv->inchord) { event_error("Broken rhythm not allowed in chord"); } else { if (cv->ingrace) { event_error("Broken rhythm not allowed in grace notes"); } else { cv->brokentype = type; cv->brokenmult = mult; cv->brokenpending = 0; }; }; } void event_tuple(n, q, r) int n, q, r; /* Start of a tuple has been encountered (e.g. triplet) */ /* Meaning is "play next r notes at q/n of notated value" */ /* where all 3 exist, otherwise r defaults to n and ratio */ /* is deduced from standard rules if q is missing */ { if (cv->tuplenotes != 0) { event_error("tuple within tuple not allowed"); return; }; if (r != 0) { cv->tuplenotes = r; } else { cv->tuplenotes = n; }; if (q != 0) { cv->tuplefactor.num = q; cv->tuplefactor.denom = n; } else { cv->tuplefactor.denom = n; if ((n == 2) || (n == 4) || (n == 8)) cv->tuplefactor.num = 3; if ((n == 3) || (n == 6)) cv->tuplefactor.num = 2; if ((n == 5) || (n == 7) || (n == 9)) { if ((cv->barlen.num % 3) == 0) { cv->tuplefactor.num = 3; } else { cv->tuplefactor.num = 2; }; }; }; cv->thistuple = newtuple(cv->tuplefactor.denom, cv->tuplefactor.num, cv->tuplenotes, n); addfeature(TUPLE, cv->thistuple); } void event_startinline() { } void event_closeinline() { } void event_handle_gchord(s) char* s; /* Guitar/Accompaniment chord placed in linked list for association */ /* with next suitable note */ { if (cv->gchords_pending == NULL) { cv->gchords_pending = newlist(); }; if (*s == '_') { if (cv->instructions_pending == NULL) { cv->instructions_pending = newlist(); }; addtolist(cv->instructions_pending, addstring(s+1)); } else { addtolist(cv->gchords_pending, addstring(s)); }; } void event_handle_instruction(s) char* s; /* An instruction (! !) has been encountered */ { char* inst; static char segno[3] = ":s"; static char coda[3] = ":c"; struct dynamic *psaction; int done; done = 0; inst = s; if (strcmp(s, "fermata") == 0) { decorators_passback[4] =1; /* don't show !fermata!. Treat it like H in music line */ return; } if (strcmp(s, "trill") == 0) { decorators_passback[6] =1; /* don't show !trill!. Treat it like T in music line */ return; } if (strcmp(s, "segno") == 0) { inst = segno; done = 1; }; if (strcmp(s, "coda") == 0) { inst = coda; done = 1; }; if (done == 1) { if (cv->instructions_pending == NULL) { cv->instructions_pending = newlist(); }; addtolist(cv->instructions_pending, addstring(inst)); return; } if (strcmp(s,"red") == 0) { psaction = (struct dynamic*) checkmalloc(sizeof(struct note)); psaction->color = 'r'; addfeature(DYNAMIC,psaction); } if (strcmp(s,"black") == 0) { psaction = (struct dynamic*) checkmalloc(sizeof(struct note)); psaction->color = 'b'; addfeature(DYNAMIC,psaction); } } struct slurtie* resolve_slur(struct feature* lastnote) /* when an end-of-slur marker ')' is found, this routine works out */ /* where the other end of the slur was */ { int i; int resolved; struct slurtie* s; resolved = 0; if (lastnote != NULL) { for (i=0; islurcount; i++) { if ((resolved == 0) && (cv->slur_place[i]->begin != NULL) && (cv->slur_place[i]->begin != lastnote)) { resolved = 1; cv->slur_place[i]->end = lastnote; s = cv->slur_place[i]; cv->slur_place[i] = cv->slur_place[cv->slurcount-1]; cv->slurcount = cv->slurcount - 1; }; }; }; if (resolved == 0) { event_error("Could not find start of slur to match close slur"); s = NULL; }; return(s); } static void startslurs(struct feature* firstnote) /* When a note is found after a (, set note to be start of slur */ /* Note may be the start of more than one slur */ { int i; for (i=0; islurcount; i++) { if (cv->slur_place[i]->begin == NULL) { cv->slur_place[i]->begin = firstnote; }; }; } void event_sluron(t) int t; /* start of slur */ { struct slurtie* s; s = newslurtie(); addfeature(SLUR_ON, s); cv->slurpending = 1; if (cv->slurcount < MAX_SLURS) { cv->slur_place[cv->slurcount] = s; cv->slurcount = cv->slurcount+1; } else { event_error("Static limit on number of slurs exceeded"); }; } void event_sluroff(t) int t; /* end of slur */ { struct slurtie* s; s = resolve_slur(cv->lastnote); addfeature(SLUR_OFF, s); } static void resolve_ties(struct feature* f) /* try to match up note to previous tied note */ { struct feature* ft; struct slurtie* s; struct note* m; struct note* n; int i, j; n = f->item; for (i=0; itiespending; i++) { ft = cv->tie_place[i]; /* pointer to TIE feature */ s = ft->item; ft = s->begin; /* pointer to NOTE feature */ m = ft->item; if (m->y == n->y) { /* pitch match found */ s->end = f; j = cv->tiespending; cv->tie_place[i] = cv->tie_place[j-1]; cv->tie_status[i] = cv->tie_status[j-1]; cv->tiespending = j-1; }; }; } static void advance_ties() /* deal with unresolved tied notes as musical time advances */ { int i, j; for (i=0; itiespending; i++) { cv->tie_status[i]++; }; i = 0; j = cv->tiespending; while (i < j) { if (cv->tie_status[i] >= 2) { event_error("No note to tie to"); cv->tie_place[i] = cv->tie_place[j-1]; cv->tie_status[i] = cv->tie_status[j-1]; j = j - 1; } else { i = i + 1; }; }; cv->tiespending = j; } void event_tie() /* tie encountered in the abc */ { struct slurtie* s; struct feature* place; int i; if ((cv->lastnote == NULL)||(cv->lastnote->type != NOTE)) { event_error("No note to tie"); } else { s = newslurtie(); place = addfeature(TIE, s); s->begin = cv->lastnote; cv->lastnote = NULL; i = cv->tiespending; if (i < MAX_TIES) { cv->tie_place[i] = place; cv->tie_status[i] = 0; cv->tiespending = cv->tiespending + 1; } else { event_error("Internal limit on ties exceeded"); }; }; } void event_lineend(ch, n) char ch; int n; /* Line ending with n copies of special character ch */ { } static void lenmul(n, a, b) /* multiply note length by a/b */ struct feature* n; int a, b; { struct note *anote; struct rest* arest; struct fract* afract; if (n->type == NOTE) { anote = n->item; afract = &anote->len; afract->num = afract->num * a; afract->denom = afract->denom * b; reducef(afract); /* re-calculate base, base_exp and dots */ anote->dots = count_dots(&anote->base, &anote->base_exp, anote->len.num, anote->len.denom); }; if (n->type == REST) { arest = n->item; afract = &arest->len; afract->num = afract->num * a; afract->denom = afract->denom * b; reducef(afract); /* re-calculate base, base_exp and dots */ arest->dots = count_dots(&arest->base, &arest->base_exp, arest->len.num, arest->len.denom); }; } struct fract* getlenfract(struct feature *f) /* find fractional length of NOTE or REST */ { struct fract *len; struct note *anote; struct rest *arest; len = NULL; if (f->type == NOTE) { anote = f->item; len = &(anote->len); }; if (f->type == REST) { arest = f->item; len = &(arest->len); }; return(len); } static void brokenadjust() /* adjust lengths of broken notes */ { int num1, num2, denom12; struct feature* j; struct fract* fr1; struct fract* fr2; int temp; int failed; int done; switch(cv->brokenmult) { case 1: num1 = 3; num2 = 1; break; case 2: num1 = 7; num2 = 1; break; case 3: num1 = 15; num2 = 1; break; }; denom12 = (num1 + num2)/2; if (cv->brokentype == LT) { temp = num1; num1 = num2; num2 = temp; }; failed = 0; if ((cv->laststart == NULL) || (cv->lastend == NULL) || (cv->thisstart == NULL) || (cv->thisend == NULL)) { failed = 1; } else { /* check for same length notes */ fr1 = getlenfract(cv->laststart); fr2 = getlenfract(cv->thisstart); /* fr1 = cv->laststart->item; fr2 = cv->thisstart->item; */ if ((fr1->num * fr2->denom) != (fr2->num * fr1->denom)) { failed = 1; }; }; if (failed) { event_error("Cannot apply broken rhythm"); } else { /* printf("Adjusting %d to %d and %d to %d\n", cv->laststart, cv->lastend, cv->thisstart, cv->thisend); */ j = cv->laststart; done = 0; while (done == 0) { lenmul(j, num1, denom12); done = (j == cv->lastend); j = j->next; }; j = cv->thisstart; done = 0; while (done == 0) { lenmul(j, num2, denom12); done = (j == cv->thisend); j = j->next; }; }; } static void marknotestart(struct feature* place) /* voice data structure keeps a record of last few notes encountered */ /* in order to process broken rhythm. This is called at the start of */ /* a note or chord */ { cv->laststart = cv->thisstart; cv->lastend = cv->thisend; cv->thisstart = place; } static void marknoteend(struct feature* place) /* voice data structure keeps a record of last few notes encountered */ /* in order to process broken rhythm. This is called at the end of */ /* a note or chord */ { cv->thisend = place; if (cv->brokenpending != -1) { cv->brokenpending = cv->brokenpending + 1; if (cv->brokenpending == 1) { brokenadjust(); cv->brokenpending = -1; }; }; } static void marknote(struct feature* place) /* when handling a single note, not a chord, marknotestart() and */ /* marknoteend() can be called together */ { marknotestart(place); marknoteend(place); } static void markchord(struct feature* chordplace) /* find start and end of chord for applying broken rhythm */ { struct feature* first; struct feature* last; first = chordplace->next; last = first; while ((last->next != NULL)&&(last->next->type==NOTE)) { last = last->next; }; marknotestart(first); marknoteend(last); } void event_chord() /* handles old '+' notation which marks the start and end of each chord */ { if (cv->inchord) { event_chordoff(1,1); } else { event_chordon(dummydecorator); }; } void event_chordon(int chorddecorators[]) /* start of a chord */ /* the array chorddecorators is not used yet. */ { if (cv->inchord) { event_error("nested chords found"); return; }; cv->inchord = 1; cv->chordcount = 0; cv->thischord = newchord(); cv->chordplace = addfeature(CHORDON, cv->thischord); } void fix_enclosed_note_lengths(struct feature* chordplace, int chord_n, int chord_m, int * base, int * base_exp) { struct feature* f; struct note* anote; if (chord_n ==1 && chord_m ==1) return; f = chordplace->next; anote = f->item; /* remove old note length from barcount */ addfractions(&cv->barcount, -anote->len.num, anote->len.denom); while ((f != NULL)&&((f->type==NOTE)||(f->type=CHORDNOTE))) { anote = f->item; /* remove old note length from barcount */ setfract(&anote->len, chord_n*cv->unitlen.num, chord_m*cv->unitlen.denom); reducef(&anote->len); /*printf("NOTE %c%c %d / %d\n", anote->accidental, anote->pitch, anote->len.num, anote->len.denom); */ anote->dots = count_dots(&anote->base, &anote->base_exp, anote->len.num, anote->len.denom); f = f->next; *base = anote->base; *base_exp = anote->base_exp; } /* and new note length to barcount */ addfractions(&cv->barcount, anote->len.num, anote->len.denom); } void event_chordoff(int chord_n, int chord_m) /* end of a chord */ { struct feature* ft; struct chord* thechord; struct note* firstnote; int base,base_exp; if (!cv->inchord) { event_error("no chord to close"); return; }; ft = cv->chordplace; if ((ft != NULL) && (ft->next != NULL) && (ft->next->type == NOTE)) { thechord = ft->item; firstnote = ft->next->item; /* beaming for 1st note in chord */ beamitem(NOTE, firstnote, ft->next); markchord(ft); thechord->base = firstnote->base; thechord->base_exp = firstnote->base_exp; } else { event_error("mis-formed chord"); }; if (cv->chordplace) { fix_enclosed_note_lengths(cv->chordplace,chord_n,chord_m,&base,&base_exp); if (chord_n != 1 || chord_m != 1) { thechord->base = base; thechord->base_exp = base_exp; } } cv->inchord = 0; cv->thischord = NULL; cv->chordplace = NULL; advance_ties(); addfeature(CHORDOFF, NULL); } /* just a stub to ignore 'y' */ void event_spacing(n, m) int n,m; { } void xevent_rest(n, m, multi) int n, m, multi; /* A rest has been encountered in the abc */ /* multi is 0 for ordinary rests or count for multibar rests */ { struct feature* restplace; if (cv->ingrace) { event_warning("rest in grace notes ignored"); return; }; if (cv->inchord) { event_warning("rest in chord ignored"); return; }; if ((multi > 0) && (cv->tuplenotes > 0)) { event_error("Multiple bar rest not allowed in tuple"); }; advance_ties(); restplace = addfeature(REST, newrest(n*cv->unitlen.num, m*cv->unitlen.denom, multi)); if (cv->slurpending) { startslurs(restplace); cv->slurpending = 0; }; cv->lastnote = restplace; if (cv->inchord) { cv->chordcount = cv->chordcount + 1; } else { marknote(restplace); }; if ((!cv->ingrace) && (!cv->inchord || (cv->chordcount == 1))) { if (cv->tuplenotes == 0) { if (multi == 0) { addunits(&cv->barcount, n, m); }; } else { addunits(&cv->barcount, n*cv->tuplefactor.num, m*cv->tuplefactor.denom); cv->thistuple->beamed = 0; cv->tuplenotes = cv->tuplenotes - 1; if (cv->tuplenotes == 0) { cv->thistuple = NULL; }; }; }; } void event_rest(decorators,n,m,type) int n, m,type; int decorators[DECSIZE]; /* A rest has been encountered in the abc */ { xevent_rest(n, m, 0); } void event_mrest(n,m,c) int n, m; char c; /* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ /* A multiple bar rest has been encountered in the abc */ { xevent_rest(1, 1, n); } void event_note(decorators, xaccidental, xmult, xnote, xoctave, n, m) int decorators[DECSIZE]; int xmult; char xaccidental, xnote; int xoctave, n, m; /* note found in abc */ { struct note* nt; struct feature* noteplace; struct chord* thechord; int pitchval; nt = newnote(decorators, xaccidental, xmult, xnote, xoctave+cv->octaveshift, n * cv->unitlen.num, m * cv->unitlen.denom); nt->tuplenotes = cv->tuplenotes; noteplace = addfeature(NOTE, nt); cv->lastnote = noteplace; resolve_ties(noteplace); if (cv->slurpending) { startslurs(noteplace); cv->slurpending = 0; }; if (!cv->inchord) { marknote(noteplace); advance_ties(); } else { thechord = cv->thischord; pitchval = notenum(xoctave, xnote, cv->clef->type, cv->clef->octave); if (cv->chordcount == 0) { thechord->ytop = pitchval; thechord->ybot = pitchval; } else { if (pitchval > thechord->ytop) { thechord->ytop = pitchval; }; if (pitchval < thechord->ybot) { thechord->ybot = pitchval; }; }; cv->chordcount = cv->chordcount + 1; }; if ((!cv->ingrace) && (!cv->inchord || (cv->chordcount == 1))) { if (cv->tuplenotes == 0) { addunits(&cv->barcount, n, m); } else { addunits(&cv->barcount, n*cv->tuplefactor.num, m*cv->tuplefactor.denom); if (nt->base_exp > -3) { cv->thistuple->beamed = 0; }; cv->tuplenotes = cv->tuplenotes - 1; if (cv->tuplenotes == 0) { cv->thistuple = NULL; /* prevent beaming from tuple to non-tuple notes */ addfeature(NOBEAM, NULL); }; }; }; } /* these functions are here to satisfy the linker */ void event_microtone(int dir, int a, int b) { } void event_normal_tone() { } void event_info_key(key, value) char* key; char* value; /* handles a (key,value) pair found in an I: field */ { int num; if (strcmp(key, "clef")==0) { event_clef(value); }; if (strcmp(key, "octave")==0) { num = readsnumf(value); event_octave(num,0); }; } int main(argc,argv) int argc; char *argv[]; { char *filename; int i; oldchordconvention = 0; for (i=0;i #include #ifdef ANSILIBS #include #include #else char *strcpy(), *strcat(); #endif /* int exit(), free(); */ /* Line commmented out JRA 19/12/95 */ /* public stuff */ /* Functions to be called while processing the MIDI file. */ int (*Mf_getc)() = NULLFUNC; void (*Mf_error)() = NULLFUNC; void (*Mf_header)() = NULLFUNC; void (*Mf_trackstart)() = NULLFUNC; void (*Mf_trackend)() = NULLFUNC; void (*Mf_noteon)() = NULLFUNC; void (*Mf_noteoff)() = NULLFUNC; void (*Mf_pressure)() = NULLFUNC; void (*Mf_parameter)() = NULLFUNC; void (*Mf_pitchbend)() = NULLFUNC; void (*Mf_program)() = NULLFUNC; void (*Mf_chanpressure)() = NULLFUNC; void (*Mf_sysex)() = NULLFUNC; void (*Mf_arbitrary)() = NULLFUNC; void (*Mf_metamisc)() = NULLFUNC; void (*Mf_seqnum)() = NULLFUNC; void (*Mf_eot)() = NULLFUNC; void (*Mf_smpte)() = NULLFUNC; void (*Mf_tempo)() = NULLFUNC; void (*Mf_timesig)() = NULLFUNC; void (*Mf_keysig)() = NULLFUNC; void (*Mf_seqspecific)() = NULLFUNC; void (*Mf_text)() = NULLFUNC; /* Functions to implement in order to write a MIDI file */ int (*Mf_putc)() = NULLFUNC; long (*Mf_writetrack)() = NULLFUNC; int (*Mf_writetempotrack)() = NULLFUNC; int Mf_nomerge = 0; /* 1 => continue'ed system exclusives are */ /* not collapsed. */ long Mf_currtime = 0L; /* current time in delta-time units */ /* private stuff */ long Mf_toberead = 0L; long Mf_bytesread = 0L; static long Mf_numbyteswritten = 0L; static long readvarinum(); static long read32bit(); static long to32bit(); static int read16bit(); static int to16bit(); static char *msg(); int skiptrack (); /* this block was previously in midifile.h [SS] 2010-01-23*/ static int readtrack(); static void readheader(); static void badbyte(); static void metaevent(); static void sysex(); static void chanmessage(); static void msginit(); static void msgadd(); static void biggermsg(); static void mf_write_track_chunk(); static void mf_write_header_chunk(); static void WriteVarLen(); static void write32bit(); static void write16bit(); static int msgleng(); static int eputc(); /* end of block */ /* following declaration added 27/8/96 JRA static readheader(), readtrack(), badbyte(), metaevent(), sysex(), chanmessage(), msginit(), msgleng(), msgadd(), biggermsg(); */ int ntrks; void mfread() /* The only non-static function in this file. */ { int track; if ( Mf_getc == NULLFUNC ) mferror("mfread() called without setting Mf_getc"); readheader(); track =1; while (readtrack()) {track++; if(track>ntrks) break; } } void mfreadtrk(itrack) /* The only non-static function in this file. */ int itrack; { int track,ok; if ( Mf_getc == NULLFUNC ) mferror("mfprocess() called without setting Mf_getc"); readheader(); track =1; ok = 1; for (track=1;track<=ntrks && ok == 1;track++) {if (track == itrack) ok = readtrack(); else ok = skiptrack(); } } /* for backward compatibility with the original lib */ void midifile() { mfread(); } static int readmt(s) /* read through the "MThd" or "MTrk" header string */ char *s; { int n = 0; char *p = s; int c; while ( n++<4 && (c=(*Mf_getc)()) != EOF ) { if ( c != *p++ ) { char buff[32]; (void) strcpy(buff,"expecting "); (void) strcat(buff,s); mferror(buff); } } return(c); } static int egetc() /* read a single character and abort on EOF */ { int c = (*Mf_getc)(); if ( c == EOF ) mferror("premature EOF"); Mf_toberead--; Mf_bytesread++; return(c); } static void readheader() /* read a header chunk */ { int format, division; if ( readmt("MThd") == EOF ) return; Mf_toberead = read32bit(); Mf_bytesread = 0; format = read16bit(); ntrks = read16bit(); division = read16bit(); if ( Mf_header ) (*Mf_header)(format,ntrks,division); /* flush any extra stuff, in case the length of header is not 6 */ while ( Mf_toberead > 0 ) (void) egetc(); } int skiptrack () { int byte; if ( readmt("MTrk") == EOF ) return(0); Mf_toberead = read32bit(); byte = 0; while (Mf_toberead && byte != EOF) byte = egetc(); if (byte == EOF) {mferror("premature EOF\n"); return(0);} return(1); } int readtrack() /* read a track chunk */ { /* This array is indexed by the high half of a status byte. It's */ /* value is either the number of bytes needed (1 or 2) for a channel */ /* message, or 0 (meaning it's not a channel message). */ static int chantype[] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 through 0x70 */ 2, 2, 2, 2, 1, 1, 2, 0 /* 0x80 through 0xf0 */ }; long lookfor; int c, c1, type; int sysexcontinue = 0; /* 1 if last message was an unfinished sysex */ int running = 0; /* 1 when running status used */ int status = 0; /* status value (e.g. 0x90==note-on) */ int laststatus; /* for running status */ int needed; long varinum; laststatus = 0; if ( readmt("MTrk") == EOF ) return(0); Mf_toberead = read32bit(); Mf_currtime = 0; Mf_bytesread =0; if ( Mf_trackstart ) (*Mf_trackstart)(); while ( Mf_toberead > 0 ) { Mf_currtime += readvarinum(); /* delta time */ c = egetc(); if ( sysexcontinue && c != 0xf7 ) mferror("didn't find expected continuation of a sysex"); /* if bit 7 not set, there is no status byte following the * delta time, so it must a running status and we assume the * last status occuring in the preceding channel message. */ if ( (c & 0x80) == 0 ) { /* running status? */ if ( status == 0 ) mferror("unexpected running status"); running = 1; } else { /* [SS] 2013-09-10 */ if (c>>4 != 0x0f) { /* if it is not a meta event save the status*/ laststatus = c; } running = 0; status = c; } /* [SS] 2013-09-10 */ if (running) needed = chantype[ (laststatus>>4) & 0xf]; else needed = chantype[ (status>>4) & 0xf ]; if ( needed ) { /* ie. is it a channel message? */ if ( running ) { c1 = c; chanmessage( laststatus, c1, (needed>1) ? egetc() : 0 ); } else { c1 = egetc(); chanmessage( status, c1, (needed>1) ? egetc() : 0 ); } continue;; } switch ( c ) { case 0xff: /* meta event */ type = egetc(); varinum = readvarinum(); lookfor = Mf_toberead - varinum; msginit(); while ( Mf_toberead > lookfor ) msgadd(egetc()); metaevent(type); break; case 0xf0: /* start of system exclusive */ varinum = readvarinum(); lookfor = Mf_toberead - varinum; msginit(); msgadd(0xf0); while ( Mf_toberead > lookfor ) msgadd(c=egetc()); if ( c==0xf7 || Mf_nomerge==0 ) sysex(); else sysexcontinue = 1; /* merge into next msg */ break; case 0xf7: /* sysex continuation or arbitrary stuff */ varinum = readvarinum(); lookfor = Mf_toberead - varinum; if ( ! sysexcontinue ) msginit(); while ( Mf_toberead > lookfor ) msgadd(c=egetc()); if ( ! sysexcontinue ) { if ( Mf_arbitrary ) (*Mf_arbitrary)(msgleng(),msg()); } else if ( c == 0xf7 ) { sysex(); sysexcontinue = 0; } break; default: badbyte(c); break; } } if ( Mf_trackend ) (*Mf_trackend)(); return(1); } static void badbyte(c) int c; { char buff[32]; (void) sprintf(buff,"unexpected byte: 0x%02x",c); mferror(buff); } static void metaevent(type) int type; { int leng; char *m; leng = msgleng(); m = msg(); switch ( type ) { case 0x00: if ( Mf_seqnum ) (*Mf_seqnum)(to16bit(m[0],m[1])); break; case 0x01: /* Text event */ case 0x02: /* Copyright notice */ case 0x03: /* Sequence/Track name */ case 0x04: /* Instrument name */ case 0x05: /* Lyric */ case 0x06: /* Marker */ case 0x07: /* Cue point */ case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: /* These are all text events */ if ( Mf_text ) (*Mf_text)(type,leng,m); break; case 0x2f: /* End of Track */ if ( Mf_eot ) (*Mf_eot)(); break; case 0x51: /* Set tempo */ if ( Mf_tempo ) (*Mf_tempo)(to32bit(0,m[0],m[1],m[2])); break; case 0x54: if ( Mf_smpte ) (*Mf_smpte)(m[0],m[1],m[2],m[3],m[4]); break; case 0x58: if ( Mf_timesig ) (*Mf_timesig)(m[0],m[1],m[2],m[3]); break; case 0x59: if ( Mf_keysig ) (*Mf_keysig)(m[0],m[1]); break; case 0x7f: if ( Mf_seqspecific ) (*Mf_seqspecific)(leng,m); break; default: if ( Mf_metamisc ) (*Mf_metamisc)(type,leng,m); } } static void sysex() { if ( Mf_sysex ) (*Mf_sysex)(msgleng(),msg()); } static void chanmessage(status,c1,c2) int status; int c1, c2; { int chan = status & 0xf; switch ( status & 0xf0 ) { case 0x80: if ( Mf_noteoff ) (*Mf_noteoff)(chan,c1,c2); break; case 0x90: if ( Mf_noteon ) (*Mf_noteon)(chan,c1,c2); break; case 0xa0: if ( Mf_pressure ) (*Mf_pressure)(chan,c1,c2); break; case 0xb0: if ( Mf_parameter ) (*Mf_parameter)(chan,c1,c2); break; case 0xe0: if ( Mf_pitchbend ) (*Mf_pitchbend)(chan,c1,c2); break; case 0xc0: if ( Mf_program ) (*Mf_program)(chan,c1); break; case 0xd0: if ( Mf_chanpressure ) (*Mf_chanpressure)(chan,c1); break; } } /* readvarinum - read a varying-length number, and return the */ /* number of characters it took. */ static long readvarinum() { long value; int c; c = egetc(); value = c; if ( c & 0x80 ) { value &= 0x7f; do { c = egetc(); value = (value << 7) + (c & 0x7f); } while (c & 0x80); } return (value); } static long to32bit(c1,c2,c3,c4) int c1, c2, c3, c4; { long value = 0L; value = (c1 & 0xff); value = (value<<8) + (c2 & 0xff); value = (value<<8) + (c3 & 0xff); value = (value<<8) + (c4 & 0xff); return (value); } static int to16bit(c1,c2) int c1, c2; { return ((c1 & 0xff ) << 8) + (c2 & 0xff); } static long read32bit() { int c1, c2, c3, c4; c1 = egetc(); c2 = egetc(); c3 = egetc(); c4 = egetc(); return to32bit(c1,c2,c3,c4); } static int read16bit() { int c1, c2; c1 = egetc(); c2 = egetc(); return to16bit(c1,c2); } /* static */ void mferror(s) char *s; { if ( Mf_error ) { (*Mf_error)(s); exit(1); } else { printf("MIDI read/write error : %s\n", s); exit(1); }; } /* The code below allows collection of a system exclusive message of */ /* arbitrary length. The Msgbuff is expanded as necessary. The only */ /* visible data/routines are msginit(), msgadd(), msg(), msgleng(). */ #define MSGINCREMENT 128 static char *Msgbuff = NULL; /* message buffer */ static int Msgsize = 0; /* Size of currently allocated Msg */ static int Msgindex = 0; /* index of next available location in Msg */ static void msginit() { Msgindex = 0; } static char * msg() { return(Msgbuff); } static int msgleng() { return(Msgindex); } static void msgadd(c) int c; { /* If necessary, allocate larger message buffer. */ if ( Msgindex >= Msgsize ) biggermsg(); Msgbuff[Msgindex++] = c; } static void biggermsg() { /* char *malloc(); */ char *newmess; char *oldmess = Msgbuff; int oldleng = Msgsize; Msgsize += MSGINCREMENT; /* to ensure a string is terminated with 0 [SS] 2017-08-30 */ /* newmess = (char *) malloc( (unsigned)(sizeof(char)*Msgsize) ); */ newmess = (char *) calloc( (unsigned)(sizeof(char)*Msgsize), sizeof(char)); if(newmess == NULL) mferror("malloc error!"); /* copy old message into larger new one */ if ( oldmess != NULL ) { register char *p = newmess; register char *q = oldmess; register char *endq = &oldmess[oldleng]; for ( ; q!=endq ; p++,q++ ) *p = *q; free(oldmess); } Msgbuff = newmess; } /* * mfwrite() - The only fuction you'll need to call to write out * a midi file. * * format 0 - Single multi-channel track * 1 - Multiple simultaneous tracks * 2 - One or more sequentially independent * single track patterns * ntracks The number of tracks in the file. * division This is kind of tricky, it can represent two * things, depending on whether it is positive or negative * (bit 15 set or not). If bit 15 of division is zero, * bits 14 through 0 represent the number of delta-time * "ticks" which make up a quarter note. If bit 15 of * division is a one, delta-times in a file correspond to * subdivisions of a second similiar to SMPTE and MIDI * time code. In this format bits 14 through 8 contain * one of four values - 24, -25, -29, or -30, * corresponding to the four standard SMPTE and MIDI * time code frame per second formats, where -29 * represents 30 drop frame. The second byte * consisting of bits 7 through 0 corresponds the the * resolution within a frame. Refer the Standard MIDI * Files 1.0 spec for more details. * fp This should be the open file pointer to the file you * want to write. It will have be a global in order * to work with Mf_putc. */ void mfwrite(format,ntracks,division,fp) int format,ntracks,division; FILE *fp; { int i; if ( Mf_putc == NULLFUNC ) mferror("mf_write() called without setting Mf_putc"); if ( Mf_writetrack == NULLFUNC ) mferror("mf_write() called without setting Mf_writetrack"); /* every MIDI file starts with a header */ mf_write_header_chunk(format,ntracks,division); /* In format 1 files, the first track is a tempo map */ if(format == 1 && ( Mf_writetempotrack )) { (*Mf_writetempotrack)(); } /* The rest of the file is a series of tracks */ for(i = 0; i < ntracks; i++) mf_write_track_chunk(i,fp); } #ifdef NOFTELL int nullpass = 0; #endif int nullputc(c) /* dummy putc for abc checking option */ /* also used for FTELL work-around */ char c; { int t; t = ((int) c) & 0xFF; return (t); } static void mf_write_track_chunk(which_track,fp) int which_track; FILE *fp; { long trkhdr,trklength; long offset, place_marker; long endspace; /* There is an alternate version of this code selected by NOFTELL which doesn't require use of file seek */ #ifdef NOFTELL int (*tempfunc)() = NULLFUNC; extern int myputc(); trkhdr = MTrk; trklength = 0; tempfunc = Mf_putc; Mf_putc = nullputc; Mf_numbyteswritten = 0L; /* the header's length doesn't count */ /* dummy write track */ nullpass = 1; if( Mf_writetrack ) { endspace = (*Mf_writetrack)(which_track); } WriteVarLen(endspace); /* mf_write End of track meta event */ /* eputc(0); */ eputc(meta_event); eputc(end_of_track); eputc(0); trklength = Mf_numbyteswritten; /* now actually write track */ Mf_putc = tempfunc; nullpass = 0; write32bit(trkhdr); write32bit(trklength); Mf_numbyteswritten = 0L; /* the header's length doesn't count */ /* now output the data */ if( Mf_writetrack ) { endspace = (*Mf_writetrack)(which_track); } WriteVarLen(endspace); eputc(meta_event); eputc(end_of_track); eputc(0); if (trklength != Mf_numbyteswritten) { mferror("NOFTELL workaround failed to predict tracklength"); } #else /* this is the original code */ trkhdr = MTrk; trklength = 0; /* Remember where the length was written, because we don't know how long it will be until we've finished writing */ offset = ftell(fp); #ifdef DEBUG printf("offset = %d\n",(int) offset); #endif /* Write the track chunk header */ write32bit(trkhdr); write32bit(trklength); Mf_numbyteswritten = 0L; /* the header's length doesn't count */ if( Mf_writetrack ) { endspace = (*Mf_writetrack)(which_track); } /* mf_write End of track meta event */ WriteVarLen(endspace); /* eputc(0); */ eputc(meta_event); eputc(end_of_track); eputc(0); /* It's impossible to know how long the track chunk will be beforehand, so the position of the track length data is kept so that it can be written after the chunk has been generated */ place_marker = ftell(fp); /* This method turned out not to be portable because the parameter returned from ftell is not guaranteed to be in bytes on every machine */ /* track.length = place_marker - offset - (long) sizeof(track); */ #ifdef DEBUG printf("length = %d\n",(int) trklength); #endif if(fseek(fp,offset,0) < 0) mferror("error seeking during final stage of write"); trklength = Mf_numbyteswritten; /* Re-mf_write the track chunk header with right length */ write32bit(trkhdr); write32bit(trklength); fseek(fp,place_marker,0); #endif } /* End gen_track_chunk() */ static void mf_write_header_chunk(format,ntracks,division) int format,ntracks,division; { long ident,length; ident = MThd; /* Head chunk identifier */ length = 6; /* Chunk length */ /* individual bytes of the header must be written separately to preserve byte order across cpu types :-( */ write32bit(ident); write32bit(length); write16bit(format); write16bit(ntracks); write16bit(division); } /* end gen_header_chunk() */ /* * mf_write_midi_event() * * Library routine to mf_write a single MIDI track event in the standard MIDI * file format. The format is: * * * * In this case, event can be any multi-byte midi message, such as * "note on", "note off", etc. * * delta_time - the time in ticks since the last event. * type - the type of meta event. * chan - The midi channel. * data - A pointer to a block of chars containing the META EVENT, * data. * size - The length of the meta-event data. */ int mf_write_midi_event(delta_time, type, chan, data, size) long delta_time; int chan,type; int size; char *data; { int i; char c; WriteVarLen(delta_time); /* all MIDI events start with the type in the first four bits, and the channel in the lower four bits */ c = (char) (type | chan); if(chan > 15) { mferror("error: MIDI channel greater than 16"); }; eputc(c); /* write out the data bytes */ for(i = 0; i < size; i++) eputc(data[i]); return(size); } /* end mf_write MIDI event */ /* * mf_write_meta_event() * * Library routine to mf_write a single meta event in the standard MIDI * file format. The format of a meta event is: * * * * delta_time - the time in ticks since the last event. * type - the type of meta event. * data - A pointer to a block of chars containing the META EVENT, * data. * size - The length of the meta-event data. */ int mf_write_meta_event(delta_time, type, data, size) long delta_time; char *data; int type; int size; { int i; WriteVarLen(delta_time); /* This marks the fact we're writing a meta-event */ eputc(meta_event); /* The type of meta event */ eputc(type); /* The length of the data bytes to follow */ WriteVarLen((long)size); for(i = 0; i < size; i++) { if(eputc((data[i] & 0xff)) != (data[i] & 0xff)) return(-1); } return(size); } /* end mf_write_meta_event */ void mf_write_tempo(tempo) long tempo; { /* Write tempo */ /* all tempos are written as 120 beats/minute, */ /* expressed in microseconds/quarter note */ eputc(0); eputc(meta_event); eputc(set_tempo); eputc(3); eputc((char)(0xff & (tempo >> 16))); eputc((char)(0xff & (tempo >> 8))); eputc((char)(0xff & tempo)); } /* * This routine converts delta times in seconds into ticks. The * else statement is needed because the formula is different for tracks * based on notes and tracks based on SMPTE times. * */ long mf_sec2ticks(secs,division,tempo) float secs; int division; long tempo; { long ticks; float smpte_format, smpte_resolution; if(division > 0) { ticks = (long) ((secs * ((float)(division))* 1000000.0) / ((float)(tempo))+0.5); } else { smpte_format = upperbyte(division); smpte_resolution = lowerbyte(division); ticks = (long) (secs * smpte_format * smpte_resolution * 1000000.0 + 0.5); }; return (ticks); } /* end of sec2ticks() */ /* * Write multi-length bytes to MIDI format files */ static void WriteVarLen(value) long value; { long buffer; buffer = value & 0x7f; while((value >>= 7) > 0) { buffer <<= 8; buffer |= 0x80; buffer += (value & 0x7f); } while(1){ eputc((char)(buffer & 0xff)); if(buffer & 0x80) buffer >>= 8; else return; } }/* end of WriteVarLen */ void single_note_tuning_change(int key, float midipitch) { unsigned char kk,xx,yy,zz; 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(127); /* universal sysex command (0x7f) */ eputc(0); /* device id */ eputc(8); /* midi tuning */ eputc(2); /* note change */ eputc(0); /* program number 0 - 127 */ eputc(1); /* only one change */ kk = (unsigned char) 127 & key; eputc(kk); /* MIDI key 0 - 127 */ number = (int) midipitch; fraction = midipitch - (float) number; if (fraction < 0.0) fraction = -fraction; intfraction = (int) fraction*16384; xx = 0x7f & number; yy = intfraction/128; zz = intfraction % 128; yy = 0x7f & yy; zz = 0x7f & zz; eputc(xx); eputc(yy); eputc(zz); eputc(247); /* 0xf7 terminates sysex command */ } /* * This routine converts delta times in ticks into seconds. The * else statement is needed because the formula is different for tracks * based on notes and tracks based on SMPTE times. * */ float mf_ticks2sec(ticks,division,tempo) int division; long tempo; long ticks; { float ret; float smpte_format, smpte_resolution; if(division > 0) { ret = ((float) (((float)(ticks) * (float)(tempo)) / ((float)(division) * 1000000.0))); } else { smpte_format = upperbyte(division); smpte_resolution = lowerbyte(division); ret = (float) ((float) ticks / (smpte_format * smpte_resolution * 1000000.0)); } return (ret); } /* end of ticks2sec() */ /* * write32bit() * write16bit() * * These routines are used to make sure that the byte order of * the various data types remains constant between machines. This * helps make sure that the code will be portable from one system * to the next. It is slightly dangerous that it assumes that longs * have at least 32 bits and ints have at least 16 bits, but this * has been true at least on PCs, UNIX machines, and Macintosh's. * */ static void write32bit(data) long data; { eputc((char)((data >> 24) & 0xff)); eputc((char)((data >> 16) & 0xff)); eputc((char)((data >> 8 ) & 0xff)); eputc((char)(data & 0xff)); } static void write16bit(data) int data; { eputc((char)((data & 0xff00) >> 8)); eputc((char)(data & 0xff)); } /* write a single character and abort on error */ static int eputc(c) char c; { int return_val; if((Mf_putc) == NULLFUNC) { mferror("Mf_putc undefined"); return(-1); } return_val = (*Mf_putc)(c); if ( return_val == EOF ) mferror("error writing"); #ifdef PCCFIX /* This seems to be needed for the FTELL workaround */ if (return_val != -1) { return_val = (int) c; }; #endif Mf_numbyteswritten++; if(Mf_numbyteswritten > 500000) { printf("eputc: aborting because of file runaway (infinite loop)\n"); exit(1); } return(return_val); } abcmidi/makefiles/0000755000000000000000000000000012610756027013112 5ustar rootrootabcmidi/makefiles/makefile.bcc0000644000000000000000000001020011736200610015317 0ustar rootroot# Borland command line compiler bcc version 5.5 Makefile for abcMIDI package # Can also use mingw or gnu standard make program with this makefile. # # # compilation #ifdefs - you may need to change these defined to get # the code to compile with a different C compiler. # # NOFTELL in midifile.c and tomidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # ANSILIBS causes code to include some ANSI standard headers # # KANDR selects functions prototypes without argument prototypes. # # If your Borland compiler is in another path, change the include # and library options below in CFLAGS and LDFLAGS. # CC=bcc32 CFLAGS=-g0 -v -WC -c -I/bcc55/include LNK=ilink32 LDFLAGS=/ap /L\bcc55\lib c0x32.obj LDFLAGS2=import32.lib cw32.lib all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcmatch.exe abc2midi.exe : parseabc.obj store.obj genmidi.obj queues.obj midifile.obj parser2.obj stresspat.obj -lm $(LNK) $(LDFLAGS) parseabc.obj genmidi.obj store.obj \ queues.obj midifile.obj parser2.obj stresspat.obj, abc2midi.exe,, $(LDFLAGS2) abc2abc.exe : parseabc.obj toabc.obj $(LNK) $(LDFLAGS) parseabc.obj toabc.obj, abc2abc.exe,, $(LDFLAGS2) midi2abc.exe : midifile.obj midi2abc.obj $(LNK) $(LDFLAGS) midifile.obj midi2abc.obj, midi2abc.exe,, $(LDFLAGS2) mftext.exe : midifile.obj mftext.obj crack.obj $(LNK) $(LDFLAGS) midifile.obj mftext.obj crack.obj, mftext.exe,, $(LDFLAGS2) yaps.exe : parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj $(LNK) $(LDFLAGS) parseabc.obj yapstree.obj drawtune.obj debug.obj \ position.obj pslib.obj parser2.obj, yaps.exe,, $(LDFLAGS2) midicopy.exe: midicopy.obj $(LNK) $(LDFLAGS) midicopy.obj, midicopy.exe,, $(LDFLAGS2) abcmatch.exe : abcmatch.obj matchsup.obj parseabc.obj $(LNK) $(LDFLAGS) abcmatch.obj matchsup.obj parseabc.obj, abcmatch.exe,, $(LDFLAGS2) # common parser object code # parseabc.obj : parseabc.c abc.h parseabc.h $(CC) $(CFLAGS) parseabc.c parser2.obj : parser2.c parseabc.h parser2.h $(CC) $(CFLAGS) parser2.c # objects needed by abc2abc # toabc.obj : toabc.c abc.h parseabc.h $(CC) $(CFLAGS) toabc.c # objects needed by abc2midi # store.obj : store.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) store.c genmidi.obj : genmidi.c abc.h midifile.h genmidi.h $(CC) $(CFLAGS) genmidi.c stresspat.obj : stresspat.c $(CC) $(CFLAGS) stresspat.c queues.obj: queues.c genmidi.h $(CC) $(CFLAGS) queues.c # common midifile library # # could use -DNOFTELL here midifile.obj : midifile.c midifile.h $(CC) $(CFLAGS) midifile.c # objects needed by yaps # yapstree.obj: yapstree.c abc.h parseabc.h structs.h drawtune.h parser2.h $(CC) $(CFLAGS) yapstree.c drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h $(CC) $(CFLAGS) drawtune.c pslib.obj: pslib.c drawtune.h $(CC) $(CFLAGS) pslib.c position.obj: position.c abc.h structs.h sizes.h $(CC) $(CFLAGS) position.c debug.obj: debug.c structs.h abc.h $(CC) $(CFLAGS) debug.c # objects needed by midi2abc # midi2abc.obj : midi2abc.c midifile.h $(CC) $(CFLAGS) midi2abc.c # objects for mftext # crack.obj : crack.c $(CC) $(CFLAGS) crack.c mftext.obj : mftext.c midifile.h $(CC) $(CFLAGS) mftext.c # objects for midicopy # midicopy.obj :midicopy.c midicopy.h $(CC) $(CFLAGS) midicopy.c # objects for abcmatch # abcmatch.obj : abcmatch.c abc.h $(CC) $(CFLAGS) abcmatch. matchsup.obj : matchsup.c abc.h parseabc.h parser2.h $(CC) $(CFLAGS) matchsup.c clean: rm *.obj rm *.exe zipfile: midi2abc.exe abc2midi.exe mftext.exe yaps.exe abc2abc.exe midicopy.exe zip pcexe2.zip *.exe readme.txt abcguide.txt demo.abc yaps.txt abcmidi/makefiles/pcc.mak0000644000000000000000000000465411736200542014354 0ustar rootroot# PCC Makefile for abcMIDI package # # # compilation #ifdefs - you need to define some of these to get # the code to compile with PCC. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # and applies a fix needed for file writing # # ANSILIBS causes appropriate ANSI .h files to be #included. # # KANDR selects function prototypes with argument prototypes. # # USE_INDEX replaces calls to strchr() with calls to index(). # CC=pcc CFLAGS=-nPCCFIX -nNOFTELL -nUSE_INDEX -nKANDR LNK=pccl all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcmatch.exe abc2midi.exe : parseabc.o store.o genmidi.o queues.o midifile.o parser2.o stresspat.o -lm $(LNK) -Lc:\bin\pcc\ -Oabc2midi parseabc.o store.o genmidi.o queues.o midifile.o parser2.o stresspat.o abc2abc.exe : parseabc.o toabc.o $(LNK) -Lc:\bin\pcc\ -Oabc2abc parseabc.o toabc.o midi2abc.exe : midifile.o midi2abc.o $(LNK) -Lc:\bin\pcc\ midifile.o midi2abc.o -Omidi2abc mftext.exe : midifile.o mftext.o crack.o $(LNK) -Lc:\bin\pcc\ midifile.o mftext.o crack.o -Omftext midicopy.exe: midicopy.o $(LNK) -Lc:\bin\pcc\ midicopy.o -Omidicopy $(CFLAGS) parseabc.o : parseabc.c abc.h parseabc.h $(CC) parseabc.c $(CFLAGS) parser2.o : parser2.c abc.h parseabc.h parser2.h $(CC) parser2.c $(CFLAGS) toabc.o : toabc.c abc.h parseabc.h $(CC) toabc.c $(CFLAGS) genmidi.o : genmidi.c abc.h midifile.h parseabc.h genmidi.h $(CC) genmidi.c $(CFLAGS) stresspat.o : stresspat.c $(CC) stresspat.c $(CFLAGS) store.o : store.c abc.h midifile.h parseabc.h $(CC) store.c $(CFLAGS) queues.o : queues.c genmidi.h $(CC) queues.c $(CFLAGS) midifile.o : midifile.c midifile.h $(CC) midifile.c $(CFLAGS) midi2abc.o : midi2abc.c midifile.h $(CC) midi2abc.c $(CFLAGS) crack.o : crack.c $(CC) crack.c $(CFLAGS) mftext.o : mftext.c midifile.h $(CC) mftext.c $(CFLAGS) midicopy.o : midicopy.c $(CC) midicopy.c $(CFLAGS) abcmatch.o : abcmatch.c $(CC) abcmatch.c $(CFLAGS) matchsup.o : matchsup.c $(CC) matchsup.c $(CFLAGS) clean: del *.exe del *.o zipfile: abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe midicopy.exe abcmatch.exe zip pcexe.zip *.exe readme.txt abcguide.txt demo.abc abcmidi/makefiles/djgpp.mak0000644000000000000000000000741413232353274014714 0ustar rootroot# DJGPP (DOS port of gcc) Makefile for abcMIDI package # # # compilation #ifdefs - you may need to change these defined to get # the code to compile with a different C compiler. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # ANSILIBS causes code to include some ANSI standard headers # # KANDR selects functions prototypes without argument prototypes. # # NO_SNPRINTF causes code to use printf instead of snprintf which # is less secure. CC=gcc CFLAGS=-c -ansi -DANSILIBS -DNO_SNPRINTF -Wformat -Wtraditional # -ansi forces ANSI compliance LNK=gcc all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe\ midicopy.exe abcmatch.exe abc2midi.exe : parseabc.o store.o genmidi.o queues.o midifile.o parser2.o $(LNK) -o abc2midi.exe parseabc.o genmidi.o store.o \ queues.o midifile.o parser2.o stresspat.o -lm abc2abc.exe : parseabc.o toabc.o $(LNK) -o abc2abc.exe parseabc.o toabc.o midi2abc.exe : midifile.o midi2abc.o $(LNK) midifile.o midi2abc.o -o midi2abc.exe -lm mftext.exe : midifile.o mftext.o crack.o $(LNK) midifile.o mftext.o crack.o -o mftext.exe midicopy.exe : midicopy.o $(LNK) midicopy.o -o midicopy.exe abcmatch.exe : abcmatch.o matchsup.o parseabc.o $(LNK) abcmatch.o matchsup.o parseabc.o -o abcmatch.exe yaps.exe : parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o $(LNK) -o yaps.exe parseabc.o yapstree.o drawtune.o debug.o \ position.o pslib.o parser2.o # common parser object code # parseabc.o : parseabc.c abc.h parseabc.h $(CC) $(CFLAGS) parseabc.c parser2.o : parser2.c parseabc.h parser2.h $(CC) $(CFLAGS) parser2.c # objects needed by abc2abc # toabc.o : toabc.c abc.h parseabc.h $(CC) $(CFLAGS) toabc.c # objects needed by abc2midi # store.o : store.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) store.c genmidi.o : genmidi.c abc.h midifile.h genmidi.h $(CC) $(CFLAGS) genmidi.c stresspat.o: stresspat.c $(CC) $(CFLAGS) stresspat.c # could use -DNOFTELL here tomidi.o : tomidi.c abc.h midifile.h $(CC) $(CFLAGS) tomidi.c queues.o: queues.c genmidi.h $(CC) $(CFLAGS) queues.c midicopy.o: midicopy.c midicopy.h $(CC) $(CFLAGS) midicopy.c abcmatch.o: abcmatch.c abc.h $(CC) $(CFLAGS) abcmatch.c # common midifile library # # could use -DNOFTELL here midifile.o : midifile.c midifile.h $(CC) $(CFLAGS) midifile.c # objects needed by yaps # yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h parser2.h $(CC) $(CFLAGS) yapstree.c drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h $(CC) $(CFLAGS) drawtune.c pslib.o: pslib.c drawtune.h $(CC) $(CFLAGS) pslib.c position.o: position.c abc.h structs.h sizes.h $(CC) $(CFLAGS) position.c debug.o: debug.c structs.h abc.h $(CC) $(CFLAGS) debug.c # objects needed by midi2abc # midi2abc.o : midi2abc.c midifile.h $(CC) $(CFLAGS) midi2abc.c # objects for mftext # crack.o : crack.c $(CC) $(CFLAGS) crack.c mftext.o : mftext.c midifile.h $(CC) $(CFLAGS) mftext.c # objects for abcmatch # matchsup.o : matchsup.c abc.h parseabc.h parser2.h $(CC) $(CFLAGS) matchsup.c clean: del *.o del *.exe zipfile: midi2abc.exe abc2midi.exe mftext.exe yaps.exe\ abc2abc.exe midicopy.exe zip pcexe2.zip *.exe readme.txt abcguide.txt demo.abc yaps.txt abcmidi/makefiles/makefile.wd0000644000000000000000000001014211736200672015217 0ustar rootroot# Watcom DOS 32 bit Makefile for abcMIDI package # Use mingw or gnu standard make program with this makefile. # # # compilation #ifdefs - you may need to change these defined to get # the code to compile with a different C compiler. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # ANSILIBS causes code to include some ANSI standard headers # # KANDR selects functions prototypes without argument prototypes. # CC=wcc386 CFLAGS=-ic:\\watcom\\h -w4 -e25 -zq -od -d2 -5r -bt=dos -mf -DANSILIBS LDFLAGS=sys dos4g name LDFLAGS2=d all op inc op st=200000 op maxe=25 op q op symf LNK=wlink all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcmatch.exe abc2midi.exe : parseabc.obj store.obj genmidi.obj queues.obj midifile.obj parser2.obj -lm $(LNK) $(LDFLAGS) abc2midi.exe $(LDFLAGS2) FILE parseabc.obj FILE genmidi.obj FILE store.obj \ FILE queues.obj FILE midifile.obj FILE parser2.obj FILE stresspat.obj abc2abc.exe : parseabc.obj toabc.obj $(LNK) $(LDFLAGS) abc2abc.exe $(LDFLAGS2) FILE parseabc.obj FILE toabc.obj midi2abc.exe : midifile.obj midi2abc.obj $(LNK) $(LDFLAGS) midi2abc.exe $(LDFLAGS2) FILE midifile.obj FILE midi2abc.obj mftext.exe : midifile.obj mftext.obj crack.obj $(LNK) $(LDFLAGS) mftext.exe $(LDFLAGS2) FILE midifile.obj FILE mftext.obj FILE crack.obj midicopy.exe: midicopy.obj $(LNK) $(LDFLAGS) midicopy.exe $(LDFLAGS2) FILE midicopy.obj abcmatch.exe : abcmatch.obj matchsup.obj parseabc.obj $(LNK) $(LDFLAGS) abcmatch.exe $(LDFLAGS) FILE abcmatch.obj matchsup.obj parseabc.obj yaps.exe : parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj $(LNK) $(LDFLAGS) yaps.exe $(LDFLAGS2) FILE parseabc.obj FILE yapstree.obj FILE drawtune.obj FILE debug.obj FILE position.obj FILE pslib.obj FILE parser2.obj # common parser object code # parseabc.obj : parseabc.c abc.h parseabc.h $(CC) $(CFLAGS) parseabc.c parser2.obj : parser2.c parseabc.h parser2.h $(CC) $(CFLAGS) parser2.c # objects needed by abc2abc # toabc.obj : toabc.c abc.h parseabc.h $(CC) $(CFLAGS) toabc.c # objects needed by abc2midi # store.obj : store.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) store.c genmidi.obj : genmidi.c abc.h midifile.h genmidi.h $(CC) $(CFLAGS) genmidi.c stresspat.obj : stresspat.c $(CC) $(CFLAGS) stresspat.c # could use -DNOFTELL here queues.obj: queues.c genmidi.h $(CC) $(CFLAGS) queues.c # common midifile library # # could use -DNOFTELL here midifile.obj : midifile.c midifile.h $(CC) $(CFLAGS) midifile.c # objects needed by yaps # yapstree.obj: yapstree.c abc.h parseabc.h structs.h drawtune.h parser2.h $(CC) $(CFLAGS) yapstree.c drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h $(CC) $(CFLAGS) drawtune.c pslib.obj: pslib.c drawtune.h $(CC) $(CFLAGS) pslib.c position.obj: position.c abc.h structs.h sizes.h $(CC) $(CFLAGS) position.c debug.obj: debug.c structs.h abc.h $(CC) $(CFLAGS) debug.c # objects needed by midi2abc # midi2abc.obj : midi2abc.c midifile.h $(CC) $(CFLAGS) midi2abc.c # objects for mftext # crack.obj : crack.c $(CC) $(CFLAGS) crack.c mftext.obj : mftext.c midifile.h $(CC) $(CFLAGS) mftext.c # objects for midicopy # midicopy.obj :midicopy.c midicopy.h $(CC) $(CFLAGS) midicopy.c # objects for abcmatch # abcmatch.obj :abcmatch.c abc.h $(CC) $(CFLAGS) abcmatch.c matchsup.obj :matchsup.c abc.h parseabc.h parser2.h $(CC) $(CFLAGS) matchsup.c clean: rm *.obj rm *.exe zipfile: midi2abc.exe abc2midi.exe mftext.exe yaps.exe abc2abc.exe zip pcexe2.zip *.exe readme.txt abcguide.txt demo.abc yaps.txt abcmidi/makefiles/makefile.w320000755000000000000000000000532012610755652015232 0ustar rootroot # tested with MS Visual C++ 2010 Express # build with: # nmake /F makefiles\makefile.w32 all !include # $(cvars) static link # $(cvarsdll) dynamically link # add -O2 to end of line for speed optimization # add -O1 for size optimization #comp = $(cc) /wd4996 -D_CRT_SECURE_NO_WARNINGS $(cflags) $(cvars) comp = $(cc) /wd4996 -D_CRT_SECURE_NO_WARNINGS $(cflags) $(cvarsdll) #all: abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch all: abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcmatch.exe abc2midi.exe: parseabc.obj store.obj genmidi.obj midifile.obj queues.obj parser2.obj stresspat.obj $(link) $(conflags) -out:abc2midi.exe parseabc.obj store.obj genmidi.obj queues.obj parser2.obj midifile.obj stresspat.obj abcmatch.exe: abcmatch.obj matchsup.obj parseabc.obj $(link) $(conflags) -out:abcmatch.exe abcmatch.obj matchsup.obj parseabc.obj midi2abc.exe: midifile.obj midi2abc.obj $(link) $(conflags) -out:midi2abc.exe midifile.obj midi2abc.obj abc2abc.exe: parseabc.obj toabc.obj $(link) $(conflags) -out:abc2abc.exe parseabc.obj toabc.obj mftext.exe: midifile.obj mftext.obj crack.obj $(link) $(conflags) -out:mftext.exe midifile.obj mftext.obj crack.obj midicopy.exe: midicopy.obj $(link) $(conflags) -out:midicopy.exe midicopy.obj yaps.exe: parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj $(link) $(conflags) -out:yaps.exe parseabc.obj yapstree.obj drawtune.obj debug.obj position.obj pslib.obj parser2.obj $(conlibs) abcmatch.obj: abcmatch.c abc.h $(comp) abcmatch.c crack.obj: crack.c $(comp) crack.c debug.obj: debug.c structs.h abc.h $(comp) debug.c drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h $(comp) drawtune.c genmidi.obj: genmidi.c abc.h midifile.h genmidi.h $(comp) genmidi.c matchsup.obj: matchsup.c abc.h parseabc.h parser2.h $(comp) matchsup.c mftext.obj: mftext.c midifile.h $(comp) mftext.c midi2abc.obj: midi2abc.c midifile.h $(comp) midi2abc.c midifile.obj: midifile.c midifile.h $(comp) midifile.c parseabc.obj: parseabc.c abc.h parseabc.h $(comp) parseabc.c parser2.obj: parser2.c abc.h parseabc.h parser2.h $(comp) parser2.c position.obj: position.c abc.h structs.h sizes.h $(comp) position.c pslib.obj: pslib.c drawtune.h $(comp) pslib.c queues.obj: queues.c genmidi.h $(comp) queues.c store.obj: store.c abc.h parseabc.h midifile.h genmidi.h $(comp) store.c stresspat.obj: stresspat.c $(comp) stresspat.c toabc.obj: toabc.c abc.h parseabc.h $(comp) toabc.c yapstree.obj: yapstree.c abc.h parseabc.h structs.h drawtune.h $(comp) yapstree.c clean: del *.obj del *.exe abcmidi/makefiles/unix.mak0000644000000000000000000000733213232353442014567 0ustar rootroot# Generic unix/gcc Makefile for abcMIDI package # # # compilation #ifdefs - you need to compile with these defined to get # the code to compile with PCC. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # ANSILIBS includes some ANSI header files (which gcc can live without, # but other compilers may want). # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # KANDR selects functions prototypes without argument prototypes. # currently yaps will only compile in ANSI mode. # # # On running make, you may get the mysterious message : # # ', needed by `parseabc.o'. Stop `abc.h # # This means you are using GNU make and this file is in DOS text format. To # cure the problem, change this file from using PC-style end-of-line (carriage # return and line feed) to unix style end-of-line (line feed). CC=gcc CFLAGS=-DANSILIBS -O2 LNK=gcc INSTALL=install prefix=/usr/local binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch docdir=share/doc/abcmidi bindir=bin mandir=share/man/man1 all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch abc2midi : parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o -lm $(LNK) -o abc2midi parseabc.o store.o genmidi.o queues.o \ parser2.o midifile.o stresspat.o abc2abc : parseabc.o toabc.o $(LNK) -o abc2abc parseabc.o toabc.o midi2abc : midifile.o midi2abc.o $(LNK) midifile.o midi2abc.o -o midi2abc -lm mftext : midifile.o mftext.o crack.o $(LNK) midifile.o mftext.o crack.o -o mftext yaps : parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o $(LNK) -o yaps parseabc.o yapstree.o drawtune.o debug.o \ position.o pslib.o parser2.o -o yaps midicopy : midicopy.o $(LNK) -o midicopy midicopy.o abcmatch : abcmatch.o matchsup.o parseabc.o $(LNK) abcmatch.o matchsup.o parseabc.o -o abcmatch parseabc.o : parseabc.c abc.h parseabc.h parser2.o : parser2.c abc.h parseabc.h parser2.h toabc.o : toabc.c abc.h parseabc.h # could use -DNOFTELL here genmidi.o : genmidi.c abc.h midifile.h genmidi.h stresspat.o : stresspat.c store.o : store.c abc.h parseabc.h midifile.h genmidi.h queues.o : queues.c genmidi.h # could use -DNOFTELL here midifile.o : midifile.c midifile.h midi2abc.o : midi2abc.c midifile.h midicopy.o : midicopy.c midicopy.h abcmatch.o: abcmatch.c abc.h crack.o : crack.c mftext.o : mftext.c midifile.h # objects needed by yaps # yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h pslib.o: pslib.c drawtune.h position.o: position.c abc.h structs.h sizes.h debug.o: debug.c structs.h abc.h #objects for abcmatch # matchsup.o : matchsup.c abc.h parseabc.h parser2.h clean : rm *.o ${binaries} install: abc2midi midi2abc abc2abc mftext midicopy yaps abcmatch $(INSTALL) -m 755 ${binaries} ${prefix}/${bindir} # install documentation test -d ${PREFIX}/share/doc/abcmidi || mkdir -p ${prefix}/${docdir} $(INSTALL) -m 644 doc/*.txt ${prefix}/${docdir} $(INSTALL) -m 644 doc/AUTHORS ${prefix}/${docdir} $(INSTALL) -m 644 doc/CHANGES ${prefix}/${docdir} $(INSTALL) -m 644 VERSION ${prefix}/${docdir} # install manpages test -d ${prefix}/${mandir} || mkdir -p ${prefix}/${mandir}; $(INSTALL) -m 644 doc/*.1 ${prefix}/${mandir} abcmidi/makefiles/makefile.wat0000644000000000000000000001034111736200510015370 0ustar rootroot# Watcom Win32 Makefile for abcMIDI package # Use mingw or gnu standard make program with this makefile. # # # compilation #ifdefs - you may need to change these defined to get # the code to compile with a different C compiler. # # NOFTELL in midifile.c and genmidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # ANSILIBS causes code to include some ANSI standard headers # # KANDR selects functions prototypes without argument prototypes. # CC=wcc386 CFLAGS=-ic:\\watcom\\h;c:\\watcom\\h\\nt -w4 -e25 -zq -od -d2 -5r -bt=nt -mf -DANSILIBS LDFLAGS=sys nt name LDFLAGS2=d all op inc op st=200000 op maxe=25 op q op symf LNK=wlink all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe midicopy.exe abcmatch.exe abc2midi.exe : parseabc.obj store.obj genmidi.obj queues.obj midifile.obj parser2.obj stresspat.obj -lm $(LNK) $(LDFLAGS) abc2midi.exe $(LDFLAGS2) FILE parseabc.obj FILE genmidi.obj FILE store.obj \ FILE queues.obj FILE midifile.obj FILE parser2.obj FILE stresspat.obj abc2abc.exe : parseabc.obj toabc.obj $(LNK) $(LDFLAGS) abc2abc.exe $(LDFLAGS2) FILE parseabc.obj FILE toabc.obj midi2abc.exe : midifile.obj midi2abc.obj $(LNK) $(LDFLAGS) midi2abc.exe $(LDFLAGS2) FILE midifile.obj FILE midi2abc.obj mftext.exe : midifile.obj mftext.obj crack.obj $(LNK) $(LDFLAGS) mftext.exe $(LDFLAGS2) FILE midifile.obj FILE mftext.obj FILE crack.obj midicopy.exe : midicopy.obj $(LNK) $(LDFLAGS) midicopy.exe $(LDFLAGS2) FILE midicopy.obj yaps.exe : parseabc.obj yapstree.obj drawtune.obj debug.obj pslib.obj position.obj parser2.obj $(LNK) $(LDFLAGS) yaps.exe $(LDFLAGS2) FILE parseabc.obj FILE yapstree.obj FILE drawtune.obj FILE debug.obj FILE position.obj FILE pslib.obj FILE parser2.obj abcmatch.exe : abcmatch.obj matchsup.obj parseabc.obj $(LNK) $(LDFLAGS) abcmatch.exe $(LDFLAGS2) FILE abcmatch.obj FILE matchsup.obj FILE parseabc.obj # common parser object code # parseabc.obj : parseabc.c abc.h parseabc.h $(CC) $(CFLAGS) parseabc.c parser2.obj : parser2.c parseabc.h parser2.h $(CC) $(CFLAGS) parser2.c # objects needed by abc2abc # toabc.obj : toabc.c abc.h parseabc.h $(CC) $(CFLAGS) toabc.c # objects needed by abc2midi # store.obj : store.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) store.c genmidi.obj : genmidi.c abc.h midifile.h genmidi.h $(CC) $(CFLAGS) genmidi.c stresspat.obj : stresspat.c $(CC) $(CFLAGS) stresspat.c # could use -DNOFTELL here tomidi.obj : tomidi.c abc.h midifile.h $(CC) $(CFLAGS) tomidi.c queues.obj: queues.c genmidi.h $(CC) $(CFLAGS) queues.c # common midifile library # # could use -DNOFTELL here midifile.obj : midifile.c midifile.h $(CC) $(CFLAGS) midifile.c # objects needed by yaps # yapstree.obj: yapstree.c abc.h parseabc.h structs.h drawtune.h parser2.h $(CC) $(CFLAGS) yapstree.c drawtune.obj: drawtune.c structs.h sizes.h abc.h drawtune.h $(CC) $(CFLAGS) drawtune.c pslib.obj: pslib.c drawtune.h $(CC) $(CFLAGS) pslib.c position.obj: position.c abc.h structs.h sizes.h $(CC) $(CFLAGS) position.c debug.obj: debug.c structs.h abc.h $(CC) $(CFLAGS) debug.c # objects needed by midi2abc # midi2abc.obj : midi2abc.c midifile.h $(CC) $(CFLAGS) midi2abc.c # objects for mftext # crack.obj : crack.c $(CC) $(CFLAGS) crack.c mftext.obj : mftext.c midifile.h $(CC) $(CFLAGS) mftext.c # objects for midicopy # midicopy.obj : midicopy.c midicopy.h $(CC) $(CFLAGS) midicopy.c #objects for abcmtch # abcmatch.obj : abcmatch.c abc.h $(CC) $(CFLAGS) abcmatch.c matchsup.obj : matchsup.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) matchsup.c clean: rm *.obj rm *.exe zipfile: midi2abc.exe abc2midi.exe mftext.exe yaps.exe abc2abc.exe abcmatch.exe zip pcexe2.zip *.exe readme.txt abcguide.txt demo.abc yaps.txt abcmidi/makefiles/makefile.ming0000644000000000000000000000715513232353356015552 0ustar rootroot# Mingw Win32 Makefile for abcMIDI package # # # compilation #ifdefs - you may need to change these defined to get # the code to compile with a different C compiler. # # NOFTELL in midifile.c and tomidi.c selects a version of the file-writing # code which doesn't use file seeking. # # PCCFIX in mftext.c midifile.c midi2abc.c # comments out various things that aren't available in PCC # # USE_INDEX causes index() to be used instead of strchr(). This is needed # by some pre-ANSI C compilers. # # ASCTIME causes asctime() to be used instead of strftime() in pslib.c. # If ANSILIBS is not set, neither routine is used. # # ANSILIBS causes code to include some ANSI standard headers # # KANDR selects functions prototypes without argument prototypes. # # If your mingw compiler is in another path, change the include # options below in CFLAGS. # CC=gcc CFLAGS=-c -I/mingw/i386-mingw32/include LNK=gcc LDFLAGS=-o all : abc2midi.exe midi2abc.exe abc2abc.exe mftext.exe yaps.exe \ midicopy.exe abcmatch.exe abc2midi.exe : parseabc.o store.o genmidi.o queues.o midifile.o parser2.o $(LNK) $(LDFLAGS) abc2midi.exe parseabc.o genmidi.o store.o \ queues.o midifile.o parser2.o -stresspat.o -lm abc2abc.exe : parseabc.o toabc.o $(LNK) $(LDFLAGS) abc2abc.exe parseabc.o toabc.o midi2abc.exe : midifile.o midi2abc.o $(LNK) $(LDFLAGS) midi2abc.exe midifile.o midi2abc.o -lm mftext.exe : midifile.o mftext.o crack.o $(LNK) $(LDFLAGS) mftext.exe midifile.o mftext.o crack.o yaps.exe : parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o $(LNK) $(LDFLAGS) yaps.exe parseabc.o yapstree.o drawtune.o debug.o \ position.o pslib.o parser2.o midicopy.exe: midicopy.o $(LNK) $(LDFLAGS) midicopy.exe midicopy.o abcmatch.exe : abcmatch.o matchsup.o parseabc.o $(LNK) abcmatch.o matchsup.o parseabc.o -o abcmatch.exe # common parser object code # parseabc.o : parseabc.c abc.h parseabc.h $(CC) $(CFLAGS) parseabc.c parser2.o : parser2.c parseabc.h parser2.h $(CC) $(CFLAGS) parser2.c # objects needed by abc2abc # toabc.o : toabc.c abc.h parseabc.h $(CC) $(CFLAGS) toabc.c # objects needed by abc2midi # store.o : store.c abc.h parseabc.h parser2.h genmidi.h $(CC) $(CFLAGS) store.c genmidi.o : genmidi.c abc.h midifile.h genmidi.h $(CC) $(CFLAGS) genmidi.c stresspat.o : stresspat.c $(CC) $(CFLAGS) stresspat.c # could use -DNOFTELL here tomidi.o : tomidi.c abc.h midifile.h $(CC) $(CFLAGS) tomidi.c queues.o: queues.c genmidi.h $(CC) $(CFLAGS) queues.c # common midifile library # # could use -DNOFTELL here midifile.o : midifile.c midifile.h $(CC) $(CFLAGS) midifile.c # objects needed by yaps # yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h parser2.h $(CC) $(CFLAGS) yapstree.c drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h $(CC) $(CFLAGS) drawtune.c pslib.o: pslib.c drawtune.h $(CC) $(CFLAGS) pslib.c position.o: position.c abc.h structs.h sizes.h $(CC) $(CFLAGS) position.c debug.o: debug.c structs.h abc.h $(CC) $(CFLAGS) debug.c # objects needed by midi2abc # midi2abc.o : midi2abc.c midifile.h $(CC) $(CFLAGS) midi2abc.c # objects for mftext # crack.o : crack.c $(CC) $(CFLAGS) crack.c mftext.o : mftext.c midifile.h $(CC) $(CFLAGS) mftext.c # objects needed for midicopy # midicopy.o : midicopy.c $(CC) $(CFLAGS) midicopy.c clean: rm *.o rm *.exe zipfile: midi2abc.exe abc2midi.exe mftext.exe yaps.exe abc2abc.exe midicopy.exe zip pcexe2.zip *.exe readme.txt abcguide.txt demo.abc yaps.txt abcmidi/midi2abc.c0000644000000000000000000032412413243552625012777 0ustar rootroot/* midi2abc - program to convert MIDI files to abc notation. * Copyright (C) 1998 James Allwright * e-mail: J.R.Allwright@westminster.ac.uk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* new midi2abc - converts MIDI file to abc format files * * * re-written to use dynamic data structures * James Allwright * 5th June 1998 * * added output file option -o * added summary option -sum * added option -u to enter xunit directly * fixed computation of xunit using -b option * added -obpl (one bar per line) option * add check for carriage return embedded inside midi text line * Seymour Shlien 04/March/00 * made to conform as much as possible to the official version. * check for drum track added * when midi program channel is command encountered, we ensure that * we are using the correct channel number for the Voice by sending * a %%MIDI channel message. * * Many more changes (see doc/CHANGES) * * Seymour Shlien 2005 * * based on public domain 'midifilelib' package. */ #define VERSION "3.21 February 22 2018" #define SPLITCODE /* Microsoft Visual C++ Version 6.0 or higher */ #ifdef _MSC_VER #define ANSILIBS #endif #include #include #ifdef PCCFIX #define stdout 1 #endif /* define USE_INDEX if your C libraries have index() instead of strchr() */ #ifdef USE_INDEX #define strchr index #endif #ifdef ANSILIBS #include #include #include #else extern char* malloc(); extern char* strchr(); #endif #include "midifile.h" #define BUFFSIZE 200 /* declare MIDDLE C */ #define MIDDLE 72 void initfuncs(); void setupkey(int); void stats_finish(); int testtrack(int trackno, int barbeats, int anacrusis); int open_note(int chan, int pitch, int vol); int close_note(int chan, int pitch, int *initvol); float histogram_entropy (int *histogram, int size); void stats_noteoff(int chan,int pitch,int vol); /* Global variables and structures */ extern long Mf_toberead; static FILE *F; static FILE *outhandle; /* for producing the abc file */ int tracknum=0; /* track number */ int division; /* pulses per quarter note defined in MIDI header */ long tempo = 500000; /* the default tempo is 120 quarter notes/minute */ int unitlen; /* abc unit length usually defined in L: field */ int header_unitlen; /* first unitlen set */ int unitlen_set =0; /* once unitlen is set don't allow it to change */ int parts_per_unitlen = 2; /* specifies minimum quantization size */ long laston = 0; /* length of MIDI track in pulses or ticks */ char textbuff[BUFFSIZE]; /*buffer for handling text output to abc file*/ int trans[256], back[256]; /*translation tables for MIDI pitch to abc note*/ char atog[256]; /* translation tables for MIDI pitch to abc note */ int symbol[256]; /*translation tables for MIDI pitch to abc note */ int key[12]; int sharps; int trackno; int maintrack; int format; /* MIDI file type */ int karaoke, inkaraoke; int midline; int tempocount=0; /* number of tempo indications in MIDI file */ int gotkeysig=0; /*set to 1 if keysignature found in MIDI file */ /* global parameters that may be set by command line options */ int xunit; /* pulses per abc unit length */ int tsig_set; /* flag - time signature already set by user */ int ksig_set; /* flag - key signature already set by user */ int xunit_set;/* flat - xunit already set by user */ int extracta; /* flag - get anacrusis from strong beat */ int guessu; /* flag - estimate xunit from note durations */ int guessa; /* flag - get anacrusis by minimizing tied notes */ int guessk; /* flag - guess key signature */ int summary; /* flag - output summary info of MIDI file */ int keep_short; /*flag - preserve short notes */ int swallow_rests; /* flag - absorb short rests */ int midiprint; /* flag - run midigram instead of midi2abc */ int stats = 0; /* flag - gather and print statistics */ #ifdef SPLITCODE int usesplits; /* flag - split measure into parts if needed */ #endif int restsize; /* smallest rest to absorb */ /* [SS] 2017-01-01 */ /*int no_triplets; flag - suppress triplets or broken rhythm */ int allow_triplets; /* flag to allow triplets */ int allow_broken; /* flag to allow broken rhythms > < */ int obpl = 0; /* flag to specify one bar per abc text line */ int nogr = 0; /* flag to put a space between every note */ int bars_per_line=4; /* number of bars per output line */ int bars_per_staff=4; /* number of bars per music staff */ int asig, bsig; /* time signature asig/bsig */ int header_asig =0; /* first time signature encountered */ int header_bsig =0; /* first time signature encountered */ int header_bb; /* first ticks/quarter note encountered */ int active_asig,active_bsig; /* last time signature declared */ int last_asig, last_ksig; /* last time signature printed */ int barsize; /* barsize in parts_per_unitlen units */ int chordthreshold; /* number of maximum number of pulses separating note */ int Qval; /* tempo - quarter notes per minute */ int verbosity=0; /* control amount of detail messages in abcfile*/ /* global arguments dependent on command line options or computed */ int anacrusis=0; int bars; int keysig; int header_keysig= -50; /* header key signature */ int active_keysig = -50; /* last key signature declared */ int xchannel; /* channel number to be extracted. -1 means all */ /* structure for storing music notes */ struct anote { int pitch; /* MIDI pitch */ int chan; /* MIDI channel */ int vel; /* MIDI velocity */ long time; /* MIDI onset time in pulses */ long dtnext; /* time increment to next note in pulses */ long tplay; /* note duration in pulses */ int xnum; /* number of xunits to next note */ int playnum; /* note duration in number of xunits */ int posnum; /* note position in xunits */ int splitnum; /* voice split number */ /* int denom; */ }; /* linked list of notes */ struct listx { struct listx* next; struct anote* note; }; /* linked list of text items (strings) */ struct tlistx { struct tlistx* next; char* text; long when; /* time in pulses to output */ int type; /* 0 - comments, other - field commands */ }; /* a MIDI track */ struct atrack { struct listx* head; /* first note */ struct listx* tail; /* last note */ struct tlistx* texthead; /* first text string */ struct tlistx* texttail; /* last text string */ int notes; /* number of notes in track */ long tracklen; long startwait; int startunits; int drumtrack; }; /* can cope with up to 64 track MIDI files */ struct atrack track[64]; int trackcount = 0; int maxbarcount = 0; /* maxbarcount is used to return the numbers of bars created.*/ /* obpl is a flag for one bar per line. */ /* double linked list of notes */ /* used for temporary list of chords while abc is being generated */ struct dlistx { struct dlistx* next; struct dlistx* last; struct anote* note; }; int notechan[2048],notechanvol[2048]; /*for linking on and off midi channel commands */ int last_tick[17]; /* for getting last pulse number in MIDI file */ char *title = NULL; /* for pasting title from argv[] */ char *origin = NULL; /* for adding O: info from argv[] */ void remove_carriage_returns(); int validnote(); void printpitch(struct anote*); void printfract(int, int); /* The following variables are used by the -stats option * which is used by a separate application called midiexplorer.tcl. * The channel numbers go from 1 to 16 instead of 0 to 15 */ struct trkstat { int notecount[17]; int chordcount[17]; int notemeanpitch[17]; int notelength[17]; int pitchbend[17]; int pressure[17]; int cntlparam[17]; int program[17]; int tempo[17]; int npulses[17]; } trkdata; /* The trkstat references the individual channels in the midi file. * notecount is the number of notes or bass notes in the chord. * chordcount is the number of notes not counting the bass notes. * notemeanpitch is the average pitch for the channel. * notelength is the average note length. * pitchbend is the number of pitch bends for the channel. * pressure is the number of control pressure commands. * cntlparam is the number of control parameter commands. * program is number of times there is a program command for the channel. * tempo is the number of times there is a tempo command. * npulses is the number of pulses. */ int progcolor[17]; /* used by stats_program */ int drumhistogram[82]; /* counts drum noteons */ int pitchhistogram[12]; /* pitch distribution for non drum notes */ int channel2prog[17]; /* maps channel to program */ int channel2nnotes[17]; /*maps channel to note count */ int chnactivity[17]; /* [SS] 2018-02-02 */ int progactivity[128]; /* [SS] 2018-02-02 */ int pitchclass_activity[12]; /* [SS] 2018-02-02 */ /* [SS] 2017-11-01 */ static int progmapper[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 4, 2, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 2, 7, 10, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 2, 2, 2, 2, 2, 12, 6, 12, 1, 1, 10, 10, 10, 10, 10, 1, 16, 16, 16, 16, 16, 16, 16, 16 }; /* Stage 1. Parsing MIDI file */ /* Functions called during the reading pass of the MIDI file */ /* The following C routines are required by midifilelib. */ /* They specify the action to be taken when various items */ /* are encountered in the MIDI. The mfread function scans*/ /* the MIDI file and calls these functions when needed. */ int filegetc() { return(getc(F)); } void fatal_error(s) char* s; /* fatal error encounterd - abort program */ { fprintf(stderr, "%s\n", s); exit(1); } void event_error(s) char *s; /* problem encountered but OK to continue */ { char msg[256]; sprintf(msg, "Error: Time=%ld Track=%d %s\n", Mf_currtime, trackno, s); printf("%s",msg); } int* checkmalloc(bytes) /* malloc with error checking */ int bytes; { int *p; p = (int*) malloc(bytes); if (p == NULL) { fatal_error("Out of memory error - cannot malloc!"); }; return (p); } char* addstring(s) /* create space for string and store it in memory */ char* s; { char* p; p = (char*) checkmalloc(strlen(s)+1); strncpy(p, s,strlen(s)+2); /* [SS] 2017-08-30 */ return(p); } void addtext(s, type) /* add structure for text */ /* used when parsing MIDI file */ char* s; int type; { struct tlistx* newx; newx = (struct tlistx*) checkmalloc(sizeof(struct tlistx)); newx->next = NULL; newx->text = addstring(s); newx->type = type; newx->when = Mf_currtime; if (track[trackno].texthead == NULL) { track[trackno].texthead = newx; track[trackno].texttail = newx; } else { track[trackno].texttail->next = newx; track[trackno].texttail = newx; }; } /* The MIDI file has separate commands for starting */ /* and stopping a note. In order to determine the duration of */ /* the note it is necessary to find the note_on command associated */ /* with the note off command. We rely on the note's pitch and channel*/ /* number to find the right note. While we are parsing the MIDI file */ /* we maintain a list of all the notes that are currently on */ /* head and tail of list of notes still playing. */ /* The following doubly linked list is used for this purpose */ struct dlistx* playinghead; struct dlistx* playingtail; void noteplaying(p) /* This function adds a new note to the playinghead list. */ struct anote* p; { struct dlistx* newx; newx = (struct dlistx*) checkmalloc(sizeof(struct dlistx)); newx->note = p; newx->next = NULL; newx->last = playingtail; if (playinghead == NULL) { playinghead = newx; }; if (playingtail == NULL) { playingtail = newx; } else { playingtail->next = newx; playingtail = newx; }; } void addnote(p, ch, v) /* add structure for note */ /* used when parsing MIDI file */ int p, ch, v; { struct listx* newx; struct anote* newnote; track[trackno].notes = track[trackno].notes + 1; newx = (struct listx*) checkmalloc(sizeof(struct listx)); newnote = (struct anote*) checkmalloc(sizeof(struct anote)); newx->next = NULL; newx->note = newnote; if (track[trackno].head == NULL) { track[trackno].head = newx; track[trackno].tail = newx; } else { track[trackno].tail->next = newx; track[trackno].tail = newx; }; if (ch == 9) { track[trackno].drumtrack = 1; }; newnote->pitch = p; newnote->chan = ch; newnote->vel = v; newnote->time = Mf_currtime; laston = Mf_currtime; newnote->tplay = Mf_currtime; noteplaying(newnote); } void notestop(p, ch) /* MIDI note stops */ /* used when parsing MIDI file */ int p, ch; { struct dlistx* i; int found; char msg[80]; i = playinghead; found = 0; while ((found == 0) && (i != NULL)) { if ((i->note->pitch == p)&&(i->note->chan==ch)) { found = 1; } else { i = i->next; }; }; if (found == 0) { sprintf(msg, "Note terminated when not on - pitch %d", p); event_error(msg); return; }; /* fill in tplay field */ i->note->tplay = Mf_currtime - (i->note->tplay); /* remove note from list */ if (i->last == NULL) { playinghead = i->next; } else { (i->last)->next = i->next; }; if (i->next == NULL) { playingtail = i->last; } else { (i->next)->last = i->last; }; free(i); } FILE * efopen(name,mode) char *name; char *mode; { FILE *f; if ( (f=fopen(name,mode)) == NULL ) { char msg[256]; sprintf(msg,"Error - Cannot open file %s",name); fatal_error(msg); } return(f); } void error(s) char *s; { fprintf(stderr,"Error: %s\n",s); } /* [SS] 2017-11-19 */ void stats_error(s) char *s; { fprintf(stderr,"Error: %s\n",s); fprintf(stderr,"activetrack %d\n",tracknum); stats_finish(); } void txt_header(xformat,ntrks,ldivision) int xformat, ntrks, ldivision; { division = ldivision; format = xformat; if (format != 0) { /* fprintf(outhandle,"%% format %d file %d tracks\n", format, ntrks);*/ if(summary>0) printf("This midi file has %d tracks\n\n",ntrks); } else { /* fprintf(outhandle,"%% type 0 midi file\n"); */ if(summary>0) { printf("This is a type 0 midi file.\n"); printf("All the channels are in one track.\n"); printf("You may need to process the channels separately\n\n"); } } } void txt_trackstart() { laston = 0L; track[trackno].notes = 0; track[trackno].head = NULL; track[trackno].tail = NULL; track[trackno].texthead = NULL; track[trackno].texttail = NULL; track[trackno].tracklen = Mf_currtime; track[trackno].drumtrack = 0; } void txt_trackend() { /* check for unfinished notes */ if (playinghead != NULL) { printf("Error in MIDI file - notes still on at end of track!\n"); }; track[trackno].tracklen = Mf_currtime - track[trackno].tracklen; trackno = trackno + 1; trackcount = trackcount + 1; } void txt_noteon(chan,pitch,vol) int chan, pitch, vol; { if ((xchannel == -1) || (chan == xchannel)) { if (vol != 0) { addnote(pitch, chan, vol); } else { notestop(pitch, chan); }; }; } void txt_noteoff(chan,pitch,vol) int chan, pitch, vol; { if ((xchannel == -1) || (chan == xchannel)) { notestop(pitch, chan); }; } void txt_pressure(chan,pitch,press) int chan, pitch, press; { } void stats_pressure(chan,press) int chan, press; { trkdata.pressure[0]++; } void txt_parameter(chan,control,value) int chan, control, value; { } void txt_pitchbend(chan,lsb,msb) int chan, msb, lsb; { } void txt_program(chan,program) int chan, program; { /* sprintf(textbuff, "%%%%MIDI program %d %d", chan+1, program); */ sprintf(textbuff, "%%%%MIDI program %d", program); addtext(textbuff,0); /* abc2midi does not use the same channel number as specified in the original midi file, so we should not specify that channel number in the %%MIDI program. If we leave it out the program will refer to the current channel assigned to this voice. */ } void txt_sysex(leng,mess) int leng; char *mess; { } void txt_metamisc(type,leng,mess) int type, leng; char *mess; { } void txt_metaspecial(type,leng,mess) int type, leng; char *mess; { } void txt_metatext(type,leng,mess) int type, leng; char *mess; { char *ttype[] = { NULL, "Text Event", /* type=0x01 */ "Copyright Notice", /* type=0x02 */ "Sequence/Track Name", "Instrument Name", /* ... */ "Lyric", "Marker", "Cue Point", /* type=0x07 */ "Unrecognized" }; int unrecognized = (sizeof(ttype)/sizeof(char *)) - 1; unsigned char c; int n; char *p = mess; char *buff; char buffer2[BUFFSIZE]; if ((type < 1)||(type > unrecognized)) type = unrecognized; buff = textbuff; for (n=0; n0) return; /* ignore other tempo indications */ tempo = ltempo; tempocount++; } void setup_timesig(nn, denom, bb) int nn,denom,bb; { asig = nn; bsig = denom; /* we must keep unitlen and xunit fixed for the entire tune */ if (unitlen_set == 0) { unitlen_set = 1; if ((asig*4)/bsig >= 3) { unitlen =8; } else { unitlen = 16; }; } /* set xunit for this unitlen */ if(!xunit_set) xunit = (division*bb*4)/(8*unitlen); barsize = parts_per_unitlen*asig*unitlen/bsig; /* printf("setup_timesig: unitlen=%d xunit=%d barsize=%d\n",unitlen,xunit,barsize); */ if (header_asig ==0) {header_asig = asig; header_bsig = bsig; header_unitlen = unitlen; header_bb = bb; } } void txt_timesig(nn,dd,cc,bb) int nn, dd, cc, bb; { int denom = 1; while ( dd-- > 0 ) denom *= 2; sprintf(textbuff, "%% Time signature=%d/%d MIDI-clocks/click=%d 32nd-notes/24-MIDI-clocks=%d", nn,denom,cc,bb); if (verbosity) addtext(textbuff,0); sprintf(textbuff,"%d %d %d\n",nn,denom,bb); if (!tsig_set) { addtext(textbuff,2); setup_timesig(nn, denom,bb); } if (summary>0) { if(tsig_set) printf("Time signature = %d/%d suppressed\n",nn,denom); else printf("Time signature = %d/%d\n",nn,denom); } } void txt_smpte(hr,mn,se,fr,ff) int hr, mn, se, fr, ff; { } void txt_arbitrary(leng,mess) char *mess; int leng; { } /* Dummy functions for handling MIDI messages. * */ void no_op0() {} void no_op1(int dummy1) {} void no_op2(int dummy1, int dummy2) {} void no_op3(int dummy1, int dummy2, int dummy3) { } void no_op4(int dummy1, int dummy2, int dummy3, int dummy4) { } void no_op5(int dummy1, int dummy2, int dummy3, int dummy4, int dummy5) { } void print_txt_header(xformat,ntrks,ldivision) int xformat, ntrks, ldivision; { division = ldivision; format = xformat; printf("Header %d %d\n",format,ntrks); } void print_txt_noteon(chan, pitch, vol) int chan, pitch, vol; { int start_time; int initvol; if (vol > 0) open_note(chan, pitch, vol); else { start_time = close_note(chan, pitch,&initvol); if (start_time >= 0) /* printf("%8.4f %8.4f %d %d %d %d\n", (double) start_time/(double) division, (double) Mf_currtime/(double) division, trackno+1, chan +1, pitch,initvol); */ printf("%d %ld %d %d %d %d\n", start_time, Mf_currtime, trackno+1, chan +1, pitch,initvol); if(Mf_currtime > last_tick[chan+1]) last_tick[chan+1] = Mf_currtime; } } void print_txt_noteoff(chan, pitch, vol) int chan, pitch, vol; { int start_time,initvol; start_time = close_note(chan, pitch, &initvol); if (start_time >= 0) /* printf("%8.4f %8.4f %d %d %d %d\n", (double) start_time/(double) division, (double) Mf_currtime/(double) division, trackno+1, chan+1, pitch,initvol); */ printf("%d %ld %d %d %d %d\n", start_time, Mf_currtime, trackno+1, chan +1, pitch,initvol); if(Mf_currtime > last_tick[chan+1]) last_tick[chan+1] = Mf_currtime; } /* In order to associate a channel note off message with its * corresponding note on message, we maintain the information * the notechan array. When a midi pitch (0-127) is switched * on for a particular channel, we record the time that it * was turned on in the notechan array. As there are 16 channels * and 128 pitches, we initialize an array 128*16 = 2048 elements * long. **/ void init_notechan() { /* signal that there are no active notes */ int i; for (i = 0; i < 2048; i++) notechan[i] = -1; } /* The next two functions update notechan when a channel note on or note off is encountered. The second function close_note, returns the time when the note was turned on. */ int open_note(int chan, int pitch, int vol) { notechan[128 * chan + pitch] = Mf_currtime; notechanvol[128 * chan + pitch] = vol; return 0; } int close_note(int chan, int pitch, int *initvol) { int index, start_tick; index = 128 * chan + pitch; if (notechan[index] < 0) return -1; start_tick = notechan[index]; *initvol = notechanvol[index]; notechan[index] = -1; return start_tick; } void print_txt_program(int chan,int program) { printf("Program %2d %d \n",chan+1, program); } /* mftext mode */ int prtime() { /* if(Mf_currtime >= pulses) ignore=0; if (ignore) return 1; linecount++; if(linecount > maxlines) {fclose(F); exit(0);} */ int units; units = 2; if(units==1) /*seconds*/ printf("%6.2f ",mf_ticks2sec(Mf_currtime,division,tempo)); else if (units==2) /*beats*/ printf("%6.2f ",(float) Mf_currtime/(float) division); else /*pulses*/ printf("%6ld ",Mf_currtime); return 0; } char * pitch2key(int note) { static char name[5]; char* s = name; switch(note % 12) { case 0: *s++ = 'c'; break; case 1: *s++ = 'c'; *s++ = '#'; break; case 2: *s++ = 'd'; break; case 3: *s++ = 'd'; *s++ = '#'; break; case 4: *s++ = 'e'; break; case 5: *s++ = 'f'; break; case 6: *s++ = 'f'; *s++ = '#'; break; case 7: *s++ = 'g'; break; case 8: *s++ = 'g'; *s++ = '#'; break; case 9: *s++ = 'a'; break; case 10: *s++ = 'a'; *s++ = '#'; break; case 11: *s++ = 'b'; break; } sprintf(s, "%d", (note / 12)-1); /* octave (assuming Piano C4 is 60)*/ return name; } void pitch2drum(midipitch) int midipitch; { static char *drumpatches[] = { "Acoustic Bass Drum", "Bass Drum 1", "Side Stick", "Acoustic Snare", "Hand Clap", "Electric Snare", "Low Floor Tom", "Closed Hi Hat", "High Floor Tom", "Pedal Hi-Hat", "Low Tom", "Open Hi-Hat", "Low-Mid Tom", "Hi Mid Tom", "Crash Cymbal 1", "High Tom", "Ride Cymbal 1", "Chinese Cymbal", "Ride Bell", "Tambourine", "Splash Cymbal", "Cowbell", "Crash Cymbal 2", "Vibraslap", "Ride Cymbal 2", "Hi Bongo", "Low Bongo", "Mute Hi Conga", "Open Hi Conga", "Low Conga", "High Timbale", "Low Timbale", "High Agogo", "Low Agogo", "Cabasa", "Maracas", "Short Whistle", "Long Whistle", "Short Guiro", "Long Guiro", "Claves", "Hi Wood Block", "Low Wood Block", "Mute Cuica", "Open Cuica", "Mute Triangle", "Open Triangle" }; if (midipitch >= 35 && midipitch <= 81) { printf(" (%s)",drumpatches[midipitch-35]); } } void mftxt_header (int format, int ntrks, int ldivision) { division = ldivision; printf("Header format=%d ntrks=%d division=%d\n",format,ntrks,division); } void stats_header (int format, int ntrks, int ldivision) { int i; division = ldivision; printf("ntrks %d\n",ntrks); printf("ppqn %d\n",ldivision); chordthreshold = ldivision/16; /* [SS] 2018-01-21 */ trkdata.tempo[0] = 0; trkdata.pressure[0] = 0; trkdata.program[0] = 0; for (i=0;i<17;i++) { trkdata.npulses[i] = 0; trkdata.pitchbend[i] = 0; progcolor[i] = 0; channel2prog[i] = -1; channel2nnotes[i] = 0; chnactivity[i] = 0; /* [SS] 2018-02-02 */ } for (i=0;i<82;i++) drumhistogram[i] = 0; for (i=0;i<12;i++) pitchhistogram[i] = 0; /* [SS] 2017-11-01 */ for (i=0;i<12;i++) pitchclass_activity[i] = 0; /* [SS] 2018-02-02 */ for (i=0;i<128;i++) progactivity[i] = 0; /* [SS] 2018-02-02 */ } void determine_progcolor () { int i; for (i=0;i<128;i++) { progcolor[progmapper[i]] += progactivity[i]; } } void old_determine_progcolor () { int i; int p; for (i=1;i<17;i++) { /* skip drum channel 10 */ if (i == 10) continue; if (channel2nnotes[i] > 0) { p = channel2prog[i]; if (p == -1) p =0; /* missing program for channel */ if (p >=0 && p < 128) progcolor[progmapper[p]] += channel2nnotes[i]; } } } void stats_finish() { int i,sum; int p; int npulses; determine_progcolor(); npulses = trkdata.npulses[0]; printf("npulses %d\n",trkdata.npulses[0]); printf("tempocmds %d\n",trkdata.tempo[0]); printf("pitchbends %d\n",trkdata.pitchbend[0]); for (i=1;i<17;i++) { if (trkdata.pitchbend[i] > 0) { printf("pitchbendin %d %d\n",i,trkdata.pitchbend[i]); } } if (trkdata.pressure[0] > 0) printf("pressure %d\n",trkdata.pressure[0]); printf("programcmd %d\n",trkdata.program[0]); printf("progs "); for (i=0;i<128;i++) if(progactivity[i] > 0) printf(" %d",i); printf("\nprogsact "); for (i=0;i<128;i++) if(progactivity[i] > 0) printf(" %d",progactivity[i]); printf("\nprogcolor "); if (npulses > 0) for (i=0;i<17;i++) printf("%5.2f ",progcolor[i]/(double) npulses); else for (i=0;i<17;i++) printf("%5.2f ",(double) progcolor[i]); printf("\n"); printf("drums "); for (i=35;i<82;i++) { if (drumhistogram[i] > 0) printf("%d ",i); } printf("\ndrumhits "); for (i=35;i<82;i++) { if (drumhistogram[i] > 0) printf("%d ",drumhistogram[i]); } printf("\npitches "); /* [SS] 2017-11-01 */ for (i=0;i<12;i++) printf("%d ",pitchhistogram[i]); printf("\npitchact "); /* [SS] 2018-02-02 */ if (npulses > 0) for (i=0;i<12;i++) printf("%5.2f ",pitchclass_activity[i]/(double) npulses); else for (i=0;i<12;i++) printf("%5.2f ",(double) pitchclass_activity[i]); printf("\nchnact "); /* [SS] 2018-02-08 */ if (npulses > 0) for (i=1;i<17;i++) printf("%5.2f ",chnactivity[i]/(double) trkdata.npulses[0]); else for (i=0;i<17;i++) printf("%5.2f ",(double) chnactivity[i]); printf("\npitchentropy %f\n",histogram_entropy(pitchclass_activity,12)); printf("\n"); } float histogram_entropy (int *histogram, int size) { int i; int total; float entropy; float e,p; total = 0; entropy = 0.0; for (i=0;i0) { printf("%s ",name); printf("%d %d ",i,data_array[i]); printf("\n"); } } } void output_track_summary () { int i; int p,n; /* find first channel containing data */ for (i=0;i<17;i++) { if(trkdata.notecount[i] == 0 && trkdata.chordcount[i] == 0) continue; printf("trkinfo "); printf("%d %d ",i,trkdata.program[i]); /* channel number and program*/ printf("%d %d ",trkdata.notecount[i],trkdata.chordcount[i]); printf("%d %d",trkdata.notemeanpitch[i], trkdata.notelength[i]); printf("\n"); channel2nnotes[i] += trkdata.notecount[i] + trkdata.chordcount[i]; } } void stats_trackstart() { int i; tracknum++; for (i=0;i<17;i++) { trkdata.notecount[i] = 0; trkdata.notemeanpitch[i] = 0; trkdata.notelength[i] = 0; trkdata.chordcount[i] = 0; trkdata.cntlparam[i] = 0; last_tick[i] = -1; } printf("trk %d \n",tracknum); } void stats_trackend() { trkdata.npulses[tracknum] = Mf_currtime; if (trkdata.npulses[0] < Mf_currtime) trkdata.npulses[0] = Mf_currtime; output_track_summary(); } void mftxt_noteon(chan,pitch,vol) int chan, pitch, vol; { char *key; /* if (onlychan >=0 && chan != onlychan) return; */ if (prtime()) return; key = pitch2key(pitch); printf("Note on %2d %2d (%3s) %3d",chan+1, pitch, key,vol); if (chan == 9) pitch2drum(pitch); printf("\n"); } void stats_noteon(chan,pitch,vol) int chan, pitch, vol; { if (vol == 0) { /* treat as noteoff */ stats_noteoff(chan,pitch,vol); return; } trkdata.notemeanpitch[chan+1] += pitch; if (abs(Mf_currtime - last_tick[chan+1]) < chordthreshold) trkdata.chordcount[chan+1]++; else trkdata.notecount[chan+1]++; if(Mf_currtime > last_tick[chan+1]) last_tick[chan+1] = Mf_currtime; if (chan == 9) { if (pitch < 0 || pitch > 81) printf("****illegal drum value %d\n",pitch); else drumhistogram[pitch]++; } else pitchhistogram[pitch % 12]++; /* [SS] 2017-11-01 */ } void mftxt_noteoff(chan,pitch,vol) int chan, pitch, vol; { char *key; /* if (onlychan >=0 && chan != onlychan) return; */ if (prtime()) return; key = pitch2key(pitch); printf("Note off %2d %2d (%3s) %3d\n",chan+1,pitch, key,vol); } void stats_noteoff(int chan,int pitch,int vol) { int length; int program; /* ignore if there was no noteon */ if (last_tick[chan+1] == -1) return; length = Mf_currtime - last_tick[chan+1]; trkdata.notelength[chan+1] += length; chnactivity[chan+1] += length; if (chan == 9) return; /* drum channel */ pitchclass_activity[pitch % 12] += length; program = trkdata.program[chan+1]; progactivity[program] += length; } void mftxt_pressure(chan,pitch,press) int chan, pitch, press; { char *key; if (prtime()) return; key = pitch2key(pitch); printf("Pressure %2d %3s %3d\n",chan+1,key,press); } void mftxt_pitchbend(chan,lsb,msb) int chan, lsb, msb; { float bend; int pitchbend; /* if (onlychan >=0 && chan != onlychan) return; */ if (prtime()) return; /* [SS] 2014-01-05 2015-08-04*/ pitchbend = (msb*128 + lsb); bend = (float) (pitchbend - 8192); bend = bend/4096.0f; printf("Pitchbend %2d %d bend = %6.4f\n",chan+1,pitchbend,bend); } void stats_pitchbend(chan,lsb,msb) int chan, lsb, msb; { trkdata.pitchbend[0]++; trkdata.pitchbend[chan+1]++; } void mftxt_program(chan,program) int chan, program; { static char *patches[] = { "Acoustic Grand","Bright Acoustic","Electric Grand","Honky-Tonk", "Electric Piano 1","Electric Piano 2","Harpsichord","Clav", "Celesta", "Glockenspiel", "Music Box", "Vibraphone", "Marimba", "Xylophone", "Tubular Bells", "Dulcimer", "Drawbar Organ", "Percussive Organ", "Rock Organ", "Church Organ", "Reed Organ", "Accordian", "Harmonica", "Tango Accordian", "Acoustic Guitar (nylon)", "Acoustic Guitar (steel)", "Electric Guitar (jazz)", "Electric Guitar (clean)", "Electric Guitar (muted)", "Overdriven Guitar", "Distortion Guitar", "Guitar Harmonics", "Acoustic Bass", "Electric Bass (finger)", "Electric Bass (pick)", "Fretless Bass", "Slap Bass 1", "Slap Bass 2", "Synth Bass 1", "Synth Bass 2", "Violin", "Viola", "Cello", "Contrabass", "Tremolo Strings", "Pizzicato Strings", "Orchestral Strings", "Timpani", "String Ensemble 1", "String Ensemble 2", "SynthStrings 1", "SynthStrings 2", "Choir Aahs", "Voice Oohs", "Synth Voice", "Orchestra Hit", "Trumpet", "Trombone", "Tuba", "Muted Trumpet", "French Horn", "Brass Section", "SynthBrass 1", "SynthBrass 2", "Soprano Sax", "Alto Sax", "Tenor Sax", "Baritone Sax", "Oboe", "English Horn", "Bassoon", "Clarinet", "Piccolo", "Flute", "Recorder", "Pan Flute", "Blown Bottle", "Skakuhachi", "Whistle", "Ocarina", "Lead 1 (square)", "Lead 2 (sawtooth)", "Lead 3 (calliope)", "Lead 4 (chiff)", "Lead 5 (charang)", "Lead 6 (voice)", "Lead 7 (fifths)", "Lead 8 (bass+lead)", "Pad 1 (new age)", "Pad 2 (warm)", "Pad 3 (polysynth)", "Pad 4 (choir)", "Pad 5 (bowed)", "Pad 6 (metallic)", "Pad 7 (halo)", "Pad 8 (sweep)", "FX 1 (rain)", "(soundtrack)", "FX 3 (crystal)", "FX 4 (atmosphere)", "FX 5 (brightness)", "FX 6 (goblins)", "FX 7 (echoes)", "FX 8 (sci-fi)", "Sitar", "Banjo", "Shamisen", "Koto", "Kalimba", "Bagpipe", "Fiddle", "Shanai", "Tinkle Bell", "Agogo", "Steel Drums", "Woodblock", "Taiko Drum", "Melodic Tom", "Synth Drum", "Reverse Cymbal", "Guitar Fret Noise", "Breath Noise", "Seashore", "Bird Tweet", "Telephone ring", "Helicopter", "Applause", "Gunshot"}; /* if (onlychan >=0 && chan != onlychan) return; */ if (prtime()) return; printf("Program %2d %d (%s)\n",chan+1, program,patches[program]); } void stats_program(chan,program) int chan, program; { int beatnumber; if (trkdata.program[chan+1] != 0) { beatnumber = Mf_currtime/division; printf("cprogram %d %d %d\n",chan+1,program,beatnumber); /* count number of times the program was modified for a channel */ trkdata.program[0] = trkdata.program[0]+1; } else { printf("program %d %d\n",chan+1,program); trkdata.program[chan+1] = program; } if (channel2prog[chan+1]== -1) channel2prog[chan+1] = program; } void mftxt_parameter(chan,control,value) int chan, control, value; { static char *ctype[] = { "Bank Select", "Modulation Wheel", /*1*/ "Breath controller", "unknown", /*3*/ "Foot Pedal", "Portamento Time", /*5*/ "Data Entry", "Volume", /*7*/ "Balance", "unknown", /*9*/ "Pan position", "Expression", /*11*/ "Effect Control 1", "Effect Control 2", /*13*/ "unknown", "unknown", /*15*/ "Slider 1", "Slider 2", /*17*/ "Slider 3", "Slider 4", /*19*/ "unknown", "unknown", /*21*/ "unknown", "unknown", /*23*/ "unknown", "unknown", /*25*/ "unknown", "unknown", /*27*/ "unknown", "unknown", /*29*/ "unknown", "unknown", /*31*/ "Bank Select (fine)", "Modulation Wheel (fine)", /*33*/ "Breath controller (fine)", "unknown", /*35*/ "Foot Pedal (fine)", "Portamento Time (fine)", /*37*/ "Data Entry (fine)", "Volume (fine)", /*39*/ "Balance (fine)", "unknown", /*41*/ "Pan position (fine)", "Expression (fine)", /*43*/ "Effect Control 1 (fine)", "Effect Control 2 (fine)", /*45*/ "unknown", "unknown", /*47*/ "unknown", "unknown", /*49*/ "unknown", "unknown", /*51*/ "unknown", "unknown", /*53*/ "unknown", "unknown", /*55*/ "unknown", "unknown", /*57*/ "unknown", "unknown", /*59*/ "unknown", "unknown", /*61*/ "unknown", "unknown", /*63*/ "Hold Pedal", "Portamento", /*65*/ "Susteno Pedal", "Soft Pedal", /*67*/ "Legato Pedal", "Hold 2 Pedal", /*69*/ "Sound Variation", "Sound Timbre", /*71*/ "Sound Release Time", "Sound Attack Time", /*73*/ "Sound Brightness", "Sound Control 6", /*75*/ "Sound Control 7", "Sound Control 8", /*77*/ "Sound Control 9", "Sound Control 10", /*79*/ "GP Button 1", "GP Button 2", /*81*/ "GP Button 3", "GP Button 4", /*83*/ "unknown", "unknown", /*85*/ "unknown", "unknown", /*87*/ "unknown", "unknown", /*89*/ "unknown", "Effects Level", /*91*/ "Tremolo Level", "Chorus Level", /*93*/ "Celeste Level", "Phaser Level", /*95*/ "Data button increment", "Data button decrement", /*97*/ "NRP (fine)", "NRP (coarse)", /*99*/ "Registered parameter (fine)", "Registered parameter (coarse)", /*101*/ "unknown", "unknown", /*103*/ "unknown", "unknown", /*105*/ "unknown", "unknown", /*107*/ "unknown", "unknown", /*109*/ "unknown", "unknown", /*111*/ "unknown", "unknown", /*113*/ "unknown", "unknown", /*115*/ "unknown", "unknown", /*117*/ "unknown", "unknown", /*119*/ "All Sound Off", "All Controllers Off", /*121*/ "Local Keyboard (on/off)","All Notes Off", /*123*/ "Omni Mode Off", "Omni Mode On", /*125*/ "Mono Operation", "Poly Operation"}; /* if (onlychan >=0 && chan != onlychan) return; */ if (prtime()) return; printf("CntlParm %2d %s = %d\n",chan+1, ctype[control],value); } void stats_parameter(chan,control,value) int chan, control, value; { /*if (control == 7) { printf("cntrlvolume %d %d \n",chan+1,value); } */ trkdata.cntlparam[chan+1]++; } void mftxt_metatext(type,leng,mess) int type, leng; char *mess; { static char *ttype[] = { NULL, "Text Event", /* type=0x01 */ "Copyright Notice", /* type=0x02 */ "Seqnce/Track Name", "Instrument Name", /* ... */ "Lyric", "Marker", "Cue Point", /* type=0x07 */ "Unrecognized" }; int unrecognized = (sizeof(ttype)/sizeof(char *)) - 1; int len; register int n, c; register char *p = mess; if ( type < 1 || type > unrecognized ) type = unrecognized; if (prtime()) return; printf("Metatext (%s) ",ttype[type]); len = leng; if (len > 15) len = 15; for ( n=0; n */ printf( (isprint(c)||isspace(c)) ? "%c" : "\\0x%02x" , c); } if (leng>15) printf("..."); printf("\n"); } void stats_metatext(type,leng,mess) int type, leng; char *mess; { int i,b; if (type != 3) return; printf("metatext %d ",type); for (i=0;i12) return; if (mi) printf("keysig %s %d %d %6.2f\n",minor[index],sf,mi,beatnumber); else printf("keysig %s %d %d %6.2f\n",major[index],sf,mi,beatnumber); } void mftxt_tempo(ltempo) long ltempo; { tempo = ltempo; if (prtime()) return; printf("Metatext tempo = %6.2f bpm\n",60000000.0/tempo); } /* [SS] 2018-01-02 */ void stats_tempo(ltempo) long ltempo; { float beatnumber; tempo = ltempo; beatnumber = Mf_currtime/division; if (trkdata.tempo[0] == 0) printf("tempo %6.2f bpm\n",60000000.0/tempo); else if (trkdata.tempo[0] < 10) printf("ctempo %6.2f %6.2f\n",60000000.0/tempo,beatnumber); trkdata.tempo[0]++; } void mftxt_timesig(nn,dd,cc,bb) int nn, dd, cc, bb; { int denom = 1; while ( dd-- > 0 ) denom *= 2; if (prtime()) return; printf("Metatext time signature=%d/%d\n",nn,denom); /* printf("Time signature=%d/%d MIDI-clocks/click=%d \ 32nd-notes/24-MIDI-clocks=%d\n", nn,denom,cc,bb); */ } void stats_timesig(nn,dd,cc,bb) int nn, dd, cc, bb; { float beatnumber; int denom = 1; beatnumber = Mf_currtime/division; while ( dd-- > 0 ) denom *= 2; printf("timesig %d/%d %6.2f\n",nn,denom,beatnumber); } void mftxt_smpte(hr,mn,se,fr,ff) int hr, mn, se, fr, ff; { if (prtime()) return; printf("Metatext SMPTE, %d:%d:%d %d=%d\n", hr,mn,se,fr,ff); } void mftxt_metaeot() { if (prtime()) return; printf("Meta event, end of track\n"); } void initfunc_for_midinotes() { Mf_error = error; Mf_header = print_txt_header; Mf_trackstart = no_op0; Mf_trackend = txt_trackend; Mf_noteon = print_txt_noteon; Mf_noteoff = print_txt_noteoff; Mf_pressure = no_op3; Mf_parameter = no_op3; Mf_pitchbend = no_op3; Mf_program = print_txt_program; 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 initfunc_for_mftext() { Mf_error = error; Mf_header = mftxt_header; Mf_trackstart = mftxt_trackstart; Mf_trackend = txt_trackend; Mf_noteon = mftxt_noteon; Mf_noteoff = mftxt_noteoff; Mf_pressure =mftxt_pressure; Mf_parameter = mftxt_parameter; Mf_pitchbend = mftxt_pitchbend; Mf_program = mftxt_program; Mf_chanpressure = mftxt_pressure; Mf_sysex = no_op2; Mf_metamisc = no_op3; Mf_seqnum = no_op1; Mf_eot = mftxt_metaeot; Mf_timesig = mftxt_timesig; Mf_smpte = mftxt_smpte; Mf_tempo = mftxt_tempo; Mf_keysig = mftxt_keysig; Mf_seqspecific = no_op3; Mf_text = mftxt_metatext; Mf_arbitrary = no_op2; } void initfunc_for_stats() { Mf_error = stats_error; /* [SS] 2017-11-19 */ Mf_header = stats_header; Mf_trackstart = stats_trackstart; Mf_trackend = stats_trackend; Mf_noteon = stats_noteon; Mf_noteoff = stats_noteoff; Mf_pressure = no_op3; Mf_parameter = stats_parameter; Mf_pitchbend = stats_pitchbend; Mf_program = stats_program; Mf_chanpressure = stats_pressure; Mf_sysex = no_op2; Mf_metamisc = no_op3; Mf_seqnum = no_op1; Mf_eot = no_op0; Mf_timesig = stats_timesig; Mf_smpte = no_op5; Mf_tempo = stats_tempo; Mf_keysig = stats_keysig; Mf_seqspecific = no_op3; Mf_text = stats_metatext; Mf_arbitrary = no_op2; } void initfuncs() { Mf_error = error; Mf_header = txt_header; Mf_trackstart = txt_trackstart; Mf_trackend = txt_trackend; Mf_noteon = txt_noteon; Mf_noteoff = txt_noteoff; Mf_pressure = txt_pressure; Mf_parameter = txt_parameter; Mf_pitchbend = txt_pitchbend; Mf_program = txt_program; Mf_chanpressure = txt_pressure; Mf_sysex = txt_sysex; Mf_metamisc = txt_metamisc; Mf_seqnum = txt_metaseq; Mf_eot = txt_metaeot; Mf_timesig = txt_timesig; Mf_smpte = txt_smpte; Mf_tempo = txt_tempo; Mf_keysig = txt_keysig; Mf_seqspecific = txt_metaspecial; Mf_text = txt_metatext; Mf_arbitrary = txt_arbitrary; } /* Stage 2 Quantize MIDI tracks. Get key signature, time signature... */ void postprocess(trackno) /* This routine calculates the time interval before the next note */ /* called after the MIDI file has been read in */ int trackno; { struct listx* i; i = track[trackno].head; if (i != NULL) { track[trackno].startwait = i->note->time; } else { track[trackno].startwait = 0; }; while (i != NULL) { if (i->next != NULL) { i->note->dtnext = i->next->note->time - i->note->time; } else { i->note->dtnext = i->note->tplay; }; i = i->next; }; } void scannotes(trackno) int trackno; /* diagnostic routine to output notes in a track */ { struct listx* i; i = track[trackno].head; while (i != NULL) { printf("Pitch %d chan %d vel %d time %ld %ld xnum %d playnum %d\n", i->note->pitch, i->note->chan, i->note->vel, i->note->dtnext, i->note->tplay, i->note->xnum, i->note->playnum); i = i->next; }; } int xnum_to_next_nonchordal_note(fromitem,spare,quantum) struct listx* fromitem; int spare,quantum; { struct anote* jnote; struct listx* nextitem; int i,xxnum; jnote = fromitem->note; if (jnote->xnum > 0) return jnote->xnum; i = 0; nextitem = fromitem->next; while (nextitem != NULL && i < 5) { jnote = nextitem->note; xxnum = (2*(jnote->dtnext + spare + (quantum/4)))/quantum; if (xxnum > 0) return xxnum; i++; nextitem = nextitem->next; } return 0; } int quantize(trackno, xunit) /* Work out how long each note is in musical time units. * The results are placed in note.playnum */ int trackno, xunit; { struct listx* j; struct anote* this; int spare; int toterror; int quantum; int posnum,xxnum; /* fix to avoid division by zero errors in strange MIDI */ if (xunit == 0) { return(10000); }; quantum = (int) (2.*xunit/parts_per_unitlen); /* xunit assume 2 parts_per_unit */ track[trackno].startunits = (2*(track[trackno].startwait + (quantum/4)))/quantum; spare = 0; toterror = 0; j = track[trackno].head; posnum = 0; while (j != NULL) { this = j->note; /* this->xnum is the quantized inter onset time */ /* this->playnum is the quantized note length */ this->xnum = (2*(this->dtnext + spare + (quantum/4)))/quantum; this->playnum = (2*(this->tplay + (quantum/4)))/quantum; if ((this->playnum == 0) && (keep_short)) { this->playnum = 1; }; /* In the event of short rests, the inter onset time * will be larger than the note length. However, for * chords the inter onset time can be zero. */ xxnum = xnum_to_next_nonchordal_note(j,spare,quantum); if ((swallow_rests>=0) && (xxnum - this->playnum <= restsize) && xxnum > 0) { this->playnum = xxnum; }; /* this->denom = parts_per_unitlen; this variable is never used ! */ spare = spare + this->dtnext - (this->xnum*xunit/parts_per_unitlen); if (spare > 0) { toterror = toterror + spare; } else { toterror = toterror - spare; }; /* gradually forget old errors so that if xunit is slightly off, errors don't accumulate over several bars */ spare = (spare * 96)/100; this->posnum = posnum; posnum += this->xnum; j = j->next; }; return(toterror); } void guesslengths(trackno) /* work out most appropriate value for a unit of musical time */ int trackno; { int i; int trial[100]; float avlen, factor, tryx; long min; min = track[trackno].tracklen; if (track[trackno].notes == 0) { return; }; avlen = ((float)(min))/((float)(track[trackno].notes)); tryx = avlen * (float) 0.75; factor = tryx/100; for (i=0; i<100; i++) { trial[i] = quantize(trackno, (int) tryx); if ((long) trial[i] < min) { min = (long) trial[i]; xunit = (int) tryx; }; tryx = tryx + factor; }; xunit_set = 1; } int findana(maintrack, barsize) /* work out anacrusis from MIDI */ /* look for a strong beat marking the start of a bar */ int maintrack; int barsize; { int min, mincount; int place; struct listx* p; min = 0; mincount = 0; place = 0; p = track[maintrack].head; while ((p != NULL) && (place < barsize)) { if ((p->note->vel > min) && (place > 0)) { min = p->note->vel; mincount = place; }; place = place + (p->note->xnum); p = p->next; }; return(mincount); } int guessana(barbeats) int barbeats; /* try to guess length of anacrusis */ { int score[64]; int min, minplace; int i,j; if (barbeats > 64) { fatal_error("Bar size exceeds static limit of 64 units!"); }; for (j=0; jnote->pitch; max = min; totalnotes = 0; for (j=0; jnote->pitch; if (thispitch > max) { max = thispitch; } else { if (thispitch < min) { min = thispitch; }; }; n[thispitch % 12] = n[thispitch % 12] + 1; p = p->next; }; }; /* count black notes for each key */ /* assume pitch = 0 is C */ minkey = 0; minblacks = totalnotes; for (j=0; j<12; j++) { key_score[j] = n[(j+1)%12] + n[(j+3)%12] + n[(j+6)%12] + n[(j+8)%12] + n[(j+10)%12]; /* printf("Score for key %d is %d\n", j, key_score[j]); */ if (key_score[j] < minblacks) { minkey = j; minblacks = key_score[j]; }; }; /* do conversion to abc pitches */ /* Code changed to use absolute rather than */ /* relative choice of pitch for 'c' */ /* MIDDLE = (min + (max - min)/2 + 6)/12 * 12; */ /* Do last note analysis */ lastpitch = track[maintrack].tail->note->pitch; if (minkey != (lastpitch%12)) { fprintf(outhandle,"%% Last note suggests "); switch((lastpitch+12-minkey)%12) { case(2): fprintf(outhandle,"Dorian "); break; case(4): fprintf(outhandle,"Phrygian "); break; case(5): fprintf(outhandle,"Lydian "); break; case(7): fprintf(outhandle,"Mixolydian "); break; case(9): fprintf(outhandle,"minor "); break; case(11): fprintf(outhandle,"Locrian "); break; default: fprintf(outhandle,"unknown "); break; }; fprintf(outhandle,"mode tune\n"); }; /* switch to minor mode if it gives same number of accidentals */ if ((minkey != ((lastpitch+3)%12)) && (key_score[minkey] == key_score[(lastpitch+3)%12])) { minkey = (lastpitch+3)%12; }; /* switch to major mode if it gives same number of accidentals */ if ((minkey != (lastpitch%12)) && (key_score[minkey] == key_score[lastpitch%12])) { minkey = lastpitch%12; }; sharps = keysharps[minkey]; return(sharps); } /* Stage 3 output MIDI tracks in abc format */ /* head and tail of list of notes in current chord playing */ /* used while abc is being generated */ struct dlistx* chordhead; struct dlistx* chordtail; void printchordlist() /* diagnostic routine */ { struct dlistx* i; i = chordhead; printf("----CHORD LIST------\n"); while(i != NULL) { printf("pitch %d len %d\n", i->note->pitch, i->note->playnum); if (i->next == i) { fatal_error("Loopback problem!"); }; i = i->next; }; } void checkchordlist() /* diagnostic routine */ /* validates data structure */ { struct dlistx* i; int n; if ((chordhead == NULL) && (chordtail == NULL)) { return; }; if ((chordhead == NULL) && (chordtail != NULL)) { fatal_error("chordhead == NULL and chordtail != NULL"); }; if ((chordhead != NULL) && (chordtail == NULL)) { fatal_error("chordhead != NULL and chordtail == NULL"); }; if (chordhead->last != NULL) { fatal_error("chordhead->last != NULL"); }; if (chordtail->next != NULL) { fatal_error("chordtail->next != NULL"); }; i = chordhead; n = 0; while((i != NULL) && (i->next != NULL)) { if (i->next->last != i) { char msg[80]; sprintf(msg, "chordlist item %d : i->next->last!", n); fatal_error(msg); }; i = i->next; n = n + 1; }; /* checkchordlist(); */ } void addtochord(p) /* used when printing out abc */ struct anote* p; { struct dlistx* newx; struct dlistx* place; newx = (struct dlistx*) checkmalloc(sizeof(struct dlistx)); newx->note = p; newx->next = NULL; newx->last = NULL; if (chordhead == NULL) { chordhead = newx; chordtail = newx; checkchordlist(); return; }; place = chordhead; while ((place != NULL) && (place->note->pitch > p->pitch)) { place = place->next; }; if (place == chordhead) { newx->next = chordhead; chordhead->last = newx; chordhead = newx; checkchordlist(); return; }; if (place == NULL) { newx->last = chordtail; chordtail->next = newx; chordtail = newx; checkchordlist(); return; }; newx->next = place; newx->last = place->last; place->last = newx; newx->last->next = newx; checkchordlist(); } struct dlistx* removefromchord(i) /* used when printing out abc */ struct dlistx* i; { struct dlistx* newi; /* remove note from list */ if (i->last == NULL) { chordhead = i->next; } else { (i->last)->next = i->next; }; if (i->next == NULL) { chordtail = i->last; } else { (i->next)->last = i->last; }; newi = i->next; free(i); checkchordlist(); return(newi); } int findshortest(gap) /* find the first note in the chord to terminate */ int gap; { int min, v; struct dlistx* p; p = chordhead; min = gap; while (p != NULL) { v = p->note->playnum; if (v < min) { min = v; }; p = p->next; }; return(min); } void advancechord(len) /* adjust note lengths for all notes in the chord */ int len; { struct dlistx* p; p = chordhead; while (p != NULL) { if (p->note->playnum <= len) { if (p->note->playnum < len) { fatal_error("Error - note too short!"); }; /* remove note */ checkchordlist(); p = removefromchord(p); } else { /* shorten note */ p->note->playnum = p->note->playnum - len; p = p->next; }; }; } void freshline() /* if the current line of abc or text is non-empty, start a new line */ { if (midline == 1) { fprintf(outhandle,"\n"); midline = 0; }; } void printnote (struct listx *i) { printf("%ld ",i->note->time); printpitch(i->note); printfract(i->note->playnum, parts_per_unitlen); printf(" %d %d %d %d\n",i->note->xnum, i->note->playnum, i->note->posnum,i->note->splitnum); } void listnotes(int trackno, int start, int end) /* A diagnostic like scannotes. I usually call it when I am in the debugger (for example in printtrack). */ { struct listx* i; int k; i = track[trackno].head; k = 0; printf("ticks pitch xnum,playnum,posnum,splitnum\n"); while (i != NULL && k < end) { if (k >= start) printnote(i); k++; i = i->next; } } int testtrack(trackno, barbeats, anacrusis) /* print out one track as abc */ int trackno, barbeats, anacrusis; { struct listx* i; int step, gap; int barnotes; int barcount; int breakcount; breakcount = 0; chordhead = NULL; chordtail = NULL; i = track[trackno].head; gap = 0; if (anacrusis > 0) { barnotes = anacrusis; } else { barnotes = barbeats; }; barcount = 0; while((i != NULL)||(gap != 0)) { if (gap == 0) { /* add notes to chord */ addtochord(i->note); gap = i->note->xnum; i = i->next; advancechord(0); /* get rid of any zero length notes */ } else { step = findshortest(gap); if (step > barnotes) { step = barnotes; }; if (step == 0) { fatal_error("Advancing by 0 in testtrack!"); }; advancechord(step); gap = gap - step; barnotes = barnotes - step; if (barnotes == 0) { if (chordhead != NULL) { breakcount = breakcount + 1; }; barnotes = barbeats; barcount = barcount + 1; if (barcount>0 && barcount%4 ==0) { /* can't zero barcount because I use it for computing maxbarcount */ freshline(); barcount = 0; }; }; }; }; return(breakcount); } void printpitch(j) /* convert numerical value to abc pitch */ struct anote* j; { int p, po,i; p = j->pitch; if (p == -1) { fprintf(outhandle,"z"); } else { po = p % 12; if ((back[trans[p]] != p) || (key[po] == 1)) { fprintf(outhandle,"%c%c", symbol[po], atog[p]); for (i=p%12; i<256; i += 12) /* apply accidental to all octaves */ back[trans[i]] = i; } else { fprintf(outhandle,"%c", atog[p]); }; while (p >= MIDDLE + 12) { fprintf(outhandle,"'"); p = p - 12; }; while (p < MIDDLE - 12) { fprintf(outhandle,","); p = p + 12; }; }; } static void reduce(a, b) int *a, *b; { int t, n, m; /* find HCF using Euclid's algorithm */ if (*a > *b) { n = *a; m = *b; } else { n = *b; m = *a; }; while (m != 0) { t = n % m; n = m; m = t; }; *a = *a/n; *b = *b/n; } void printfract(a, b) /* print fraction */ /* used when printing abc */ int a, b; { int c, d; c = a; d = b; reduce(&c,&d); /* print out length */ if (c != 1) { fprintf(outhandle,"%d", c); }; if (d != 1) { fprintf(outhandle,"/%d", d); }; } void printchord(len) /* Print out the current chord. Any notes that haven't */ /* finished at the end of the chord are tied into the next chord. */ int len; { struct dlistx* i; i = chordhead; if (i == NULL) { /* no notes in chord */ #ifdef SPLITCODE fprintf(outhandle,"x"); #else fprintf(outhandle,"z"); #endif printfract(len, parts_per_unitlen); midline = 1; } else { if (i->next == NULL) { /* only one note in chord */ printpitch(i->note); printfract(len, parts_per_unitlen); midline = 1; if (len < i->note->playnum) { fprintf(outhandle,"-"); }; } else { fprintf(outhandle,"["); while (i != NULL) { printpitch(i->note); printfract(len, parts_per_unitlen); if (len < i->note->playnum) { fprintf(outhandle,"-"); }; if (nogr && i->next != NULL) fprintf(outhandle," "); i = i->next; }; fprintf(outhandle,"]"); midline = 1; }; }; } char dospecial(i, barnotes, featurecount,allow_broken,allow_triplets) /* identify and print out triplets and broken rhythm */ struct listx* i; int* barnotes; int* featurecount; int allow_broken,allow_triplets; { int v1, v2, v3, vt; int xa, xb; int pnum; long total, t1, t2, t3; if ((chordhead != NULL) || (i == NULL) || (i->next == NULL) /* || (asig%3 == 0) || (asig%2 != 0) 2004/may/09 SS*/) { return(' '); }; t1 = i->note->dtnext; v1 = i->note->xnum; pnum = i->note->playnum; if ((v1 < pnum) || (v1 > 1 + pnum) || (pnum == 0)) { return(' '); }; t2 = i->next->note->dtnext; v2 = i->next->note->xnum; pnum = i->next->note->playnum; if (/*(v2 < pnum) ||*/ (v2 > 1 + pnum) || (pnum == 0) || (v1+v2 > *barnotes)) { return(' '); }; /* look for broken rhythm */ total = t1 + t2; if (total == 0L) { /* shouldn't happen, but avoids possible divide by zero */ return(' '); }; /* [SS] 2017-01-01 */ if (allow_broken == 1 && ((v1+v2)%2 == 0) && ((v1+v2)%3 != 0)) { vt = (v1+v2)/2; if (vt == validnote(vt)) { /* do not try to break a note which cannot be legally expressed */ switch ((int) ((t1*6+(total/2))/total)) { case 2: *featurecount = 2; i->note->xnum = vt; i->note->playnum = vt; i->next->note->xnum = vt; i->next->note->playnum = vt; return('<'); break; case 4: *featurecount = 2; i->note->xnum = vt; i->note->playnum = vt; i->next->note->xnum = vt; i->next->note->playnum = vt; return('>'); break; default: break; }; }; }; if (allow_triplets == 0) return(' '); /* [SS] 2017-01-01 */ /* look for triplet */ if (i->next->next != NULL) { t3 = i->next->next->note->dtnext; v3 = i->next->next->note->xnum; pnum = i->next->next->note->playnum; if ((v3 < pnum) || (v3 > 1 + pnum) || (pnum == 0) || (v1+v2+v3 > *barnotes)) { return(' '); }; if ((v1+v2+v3)%2 != 0) { return(' '); }; vt = (v1+v2+v3)/2; if ((vt%2 == 1) && (vt > 1)) { /* don't want strange fractions in triplet */ return(' '); }; total = t1+t2+t3; xa = (int) ((t1*6+(total/2))/total); xb = (int) (((t1+t2)*6+(total/2))/total); if ((xa == 2) && (xb == 4) && (vt%3 != 0) ) { *featurecount = 3; *barnotes = *barnotes + vt; i->note->xnum = vt; i->note->playnum = vt; i->next->note->xnum = vt; i->next->note->playnum = vt; i->next->next->note->xnum = vt; i->next->next->note->playnum = vt; }; }; return(' '); } int validnote(n) int n; /* work out a step which can be expressed as a musical time */ { int v; if (n <= 4) { v = n; } else { v = 4; while (v*2 <= n) { v = v*2; }; if (v + v/2 <= n) { v = v + v/2; }; }; return(v); } void handletext(t, textplace, trackno) /* print out text occuring in the body of the track */ /* The text is printed out at the appropriate place within the track */ /* In addition the function handles key signature and time */ /* signature changes that can occur in the middle of the tune. */ long t; struct tlistx** textplace; int trackno; { char* str; char ch; int type,sf,mi,nn,denom,bb; while (((*textplace) != NULL) && ((*textplace)->when <= t)) { str = (*textplace)->text; ch = *str; type = (*textplace)->type; remove_carriage_returns(str); if (((int)ch == '\\') || ((int)ch == '/')) { inkaraoke = 1; }; if ((inkaraoke == 1) && (karaoke == 1)) { switch(ch) { case ' ': fprintf(outhandle,"%s", str); midline = 1; break; case '\\': freshline(); fprintf(outhandle,"w:%s", str + 1); midline = 1; break; case '/': freshline(); fprintf(outhandle,"w:%s", str + 1); midline = 1; break; default : if (midline == 0) { fprintf(outhandle,"%%%s", str); } else { fprintf(outhandle,"-%s", str); }; break; }; } else { freshline(); ch=*(str+1); switch (type) { case 0: if (ch != '%') fprintf(outhandle,"%%%s\n", str); else fprintf(outhandle,"%s\n", str); break; case 1: /* key signature change */ sscanf(str,"%d %d",&sf,&mi); if((trackno != 0 || trackcount==1) && (active_keysig != sf)) { setupkey(sf); active_keysig=sf; } break; case 2: /* time signature change */ sscanf(str,"%d %d %d",&nn,&denom,&bb); if ((trackno != 0 || trackcount ==1) && (active_asig != nn || active_bsig != denom)) { setup_timesig(nn,denom,bb); fprintf(outhandle,"M: %d/%d\n",nn,denom); fprintf(outhandle,"L: 1/%d\n",unitlen); active_asig=nn; active_bsig=denom; } break; default: break; } } *textplace = (*textplace)->next; } } #ifdef SPLITCODE /* This function identifies irregular chords, (notes which do not exactly overlap in time). The notes in the chords are split into separate lines (split numbers). The xnum (delay) to next note is updated. */ int splitstart[10],splitend[10]; /* used in forming chords from notes*/ int lastposnum[10]; /* posnum of previous note in linked list */ int endposnum; /* posnum at last note in linked list */ struct anote* prevnote[10]; /*previous note in linked list */ struct listx* last_i[10]; /*note after finishing processing bar*/ int existingsplits[10]; /* existing splits in active bar */ struct dlistx* splitchordhead[10]; /* chordhead list for splitnum */ struct dlistx* splitchordtail[10]; /* chordtail list for splitnum */ int splitgap[10]; /* gap to next note at end of split measure */ void label_split(struct anote *note, int activesplit) { /* The function assigns a split number (activesplit), to a specific note, (*note). We also update splitstart and splitend which specifies the region in time where the another note must occur if it forms a proper chord. After assigning a split number to the note we need to update note->xnum as this indicates the gap to the next note in the same split number. The function uses a greedy algorithm. It assigns a note to the first splitnumber code which satisfies the above constraint. If it cannot find a splitnumber, a new one (voice or track) is created. It would be nice if the voices kept the high and low notes (in pitch) separate. */ note->splitnum = activesplit; splitstart[activesplit] = note->posnum; splitend[activesplit] = splitstart[activesplit] + note->playnum; if (prevnote[activesplit]) prevnote[activesplit]->xnum = note->posnum - lastposnum[activesplit]; lastposnum[activesplit] = note->posnum; prevnote[activesplit] = note; /* in case this is the last activesplit note make sure it xnum points to end of track. Otherwise it will be changed when the next activesplit note is labeled. */ note->xnum = endposnum - note->posnum; existingsplits[activesplit]++; } void label_split_voices (int trackno) { /* This function sorts all the notes in the track into separate split part. A note is placed into a separate part if it forms a chord in the current part but does not have the same onset time and same end time. If this occurs, we search for another part where this does not happen. If we can't find such a part a new part (split) is created. The heuristic used needs to be improved, so that split number 0 always contains notes and so that notes in the same pitch range or duration are given the same split number. */ int activesplit,nsplits; int done; struct listx* i; int k; int firstposnum; /* initializations */ activesplit = 0; nsplits = 0; for (k=0;k<10;k++) { splitstart[k]=splitend[k]=lastposnum[k]=0; prevnote[k] = NULL; existingsplits[k] = 0; splitgap[k]=0; } i = track[trackno].head; if (track[trackno].tail == 0x0) return; endposnum =track[trackno].tail->note->posnum + track[trackno].tail->note->playnum; if (i != NULL) label_split(i->note, activesplit); /* now label all the notes in the track */ while (i != NULL) { done =0; if (nsplits == 0) { /*no splits exist, create split number 0 */ activesplit = 0; nsplits++; i->note->splitnum = activesplit; splitstart[activesplit] = i->note->posnum; splitend[activesplit] = splitstart[activesplit] + i->note->playnum; firstposnum = splitstart[activesplit]; } else { /* do a compatibility check with the last split number */ if ( ( i->note->posnum == splitstart[activesplit] && i->note->playnum == (splitend[activesplit] - splitstart[activesplit])) || i->note->posnum >= splitend[activesplit]) { if (existingsplits[activesplit] == 0) { last_i[activesplit] = i; splitgap[activesplit] = i->note->posnum - firstposnum; } label_split(i->note, activesplit); done = 1; } /* need to search for any other compatible split numbers */ if (done == 0) for (activesplit=0;activesplitnote->posnum == splitstart[activesplit] && i->note->playnum == splitend[activesplit] - splitstart[activesplit]) || i->note->posnum >= splitend[activesplit]) { if (existingsplits[activesplit] == 0) { last_i[activesplit] = i; splitgap[activesplit] = i->note->posnum - firstposnum; } label_split(i->note,activesplit); done = 1; break; } } /* No compatible split number found. Create new split */ if (done == 0) { if(nsplits < 10) {nsplits++; activesplit = nsplits-1;} if (existingsplits[activesplit] == 0) { last_i[activesplit] = i; splitgap[activesplit] = i->note->posnum - firstposnum; } label_split(i->note,activesplit); } } /* printf("note %d links to %d %d (%d %d)\n",i->note->pitch,activesplit, i->note->posnum,splitstart[activesplit],splitend[activesplit]); */ i = i->next; } /* end while loop */ } int nextsplitnum(int splitnum) { while (splitnum < 9) { splitnum++; if (existingsplits[splitnum]) return splitnum; } return -1; } int count_splits() { int i,n; n = 0; for (i=0;i<10;i++) if (existingsplits[i]) n++; return n; } void printtrack_with_splits(trackno, anacrusis) int trackno, anacrusis; /* This function is an adaption of printtrack so that notes with separate split numbers are in separated regions in the measure. (Separated with &'s). To do this we must make multiple passes through each bar and maintain separate chordlists (in event that some chords overlap over more than one measure). */ { struct listx* i; struct tlistx* textplace; struct tlistx* textplace0; /* track 0 text storage */ int step, gap; int barnotes; int barcount; int bars_on_line; long now; char broken; int featurecount; int last_barsize,barnotes_correction; int splitnum = 0; int j; int nlines; int done; nlines= 0; label_split_voices (trackno); midline = 0; featurecount = 0; inkaraoke = 0; now = 0L; broken = ' '; for (j=0;j<10;j++) { splitchordhead[j] = NULL; splitchordtail[j] = NULL; } i = track[trackno].head; textplace = track[trackno].texthead; textplace0 = track[0].texthead; /*gap = track[trackno].startunits;*/ gap = 0; if (anacrusis > 0) { barnotes = anacrusis; barcount = -1; } else { barnotes = barsize; barcount = 0; }; bars_on_line = 0; last_barsize = barsize; active_asig = header_asig; active_bsig = header_bsig; setup_timesig(header_asig,header_bsig,header_bb); active_keysig = header_keysig; handletext(now, &textplace, trackno); splitnum = 0; chordhead = splitchordhead[splitnum]; chordtail = splitchordtail[splitnum]; gap = splitgap[splitnum]; while((i != NULL)||(gap != 0)) { if (gap == 0) { /* do triplet here */ if (featurecount == 0) { if (allow_triplets || allow_broken) { /* [SS] 2017-01-01 */ broken = dospecial(i, &barnotes, &featurecount,allow_broken,allow_triplets); }; }; /* ignore any notes that are not in the current splitnum */ if (i->note->splitnum == splitnum) { /*printf("\nadding "); printnote(i); */ addtochord(i->note); gap = i->note->xnum; now = i->note->time; } i = i->next; advancechord(0); /* get rid of any zero length notes */ if (trackcount > 1 && trackno !=0) handletext(now, &textplace0, trackno); handletext(now, &textplace,trackno); barnotes_correction = barsize - last_barsize; barnotes += barnotes_correction; last_barsize = barsize; } else { step = findshortest(gap); if (step > barnotes) { step = barnotes; }; step = validnote(step); if (step == 0) { fatal_error("Advancing by 0 in printtrack!"); }; if (featurecount == 3) { fprintf(outhandle," (3"); }; printchord(step); if ( featurecount > 0) { featurecount = featurecount - 1; }; if ((featurecount == 1) && (broken != ' ')) { fprintf(outhandle,"%c", broken); }; advancechord(step); gap = gap - step; barnotes = barnotes - step; /* at the end of the bar we must decide whether to place a | or &. If we place a & then we have to return to the beginning of the bar and process the next split number. */ if (barnotes == 0) { /* end of bar ? */ nlines++; if (nlines > 5000) { printf("\nProbably infinite loop: aborting\n"); fprintf(outhandle,"\n\nProbably infinite loop: aborting\n"); return; } /* save state for the last splitnum before going to the next */ last_i[splitnum] = i; splitchordhead[splitnum] = chordhead; splitchordtail[splitnum] = chordtail; splitgap[splitnum] = gap; /* look for the next splitnum which contains notes in the current measure. If not, end the measure. */ done = 0; while (done != 1) { splitnum = nextsplitnum(splitnum); if (splitnum == -1) { fprintf(outhandle," | "); splitnum = nextsplitnum(splitnum); done = 1; break; } if (splitgap[splitnum] >= barsize) { splitgap[splitnum] -= barsize; continue; /* look for other splits */ } fprintf(outhandle, " & "); i = last_i[splitnum]; done = 1; } /* restore state for the next splitnum */ chordhead = splitchordhead[splitnum]; chordtail = splitchordtail[splitnum]; checkchordlist(); gap = splitgap[splitnum]; i = last_i[splitnum]; /* printf("returning to %ld ",i->note->time); printpitch(i->note); printf("\n"); */ barnotes = barsize; barcount = barcount + 1; bars_on_line++; if (barcount >0 && barcount%bars_per_staff == 0) { freshline(); bars_on_line=0; } /* can't zero barcount because I use it for computing maxbarcount */ else if(bars_on_line >= bars_per_line && i != NULL) { fprintf(outhandle," \\"); freshline(); bars_on_line=0;} } else if (featurecount == 0) { /* note grouping algorithm */ /* [SS] 2016-07-20 waltz is a special case */ if ((barsize/parts_per_unitlen) % 3 == 0 && asig != 3) { if ( (barnotes/parts_per_unitlen) % 3 == 0 &&(barnotes%parts_per_unitlen) == 0) { fprintf(outhandle," "); }; } else { if (((barsize/parts_per_unitlen) % 2 == 0) && (barnotes % parts_per_unitlen) == 0 && ((barnotes/parts_per_unitlen) % 2 == 0)) { fprintf(outhandle," "); }; }; } if (nogr) fprintf(outhandle," "); }; if (i == NULL) /* end of track before end of measure ? */ { last_i[splitnum] = i; splitchordhead[splitnum] = chordhead; splitchordtail[splitnum] = chordtail; splitgap[splitnum] = gap; splitnum = nextsplitnum(splitnum); if (splitnum == -1) break; chordhead = splitchordhead[splitnum]; chordtail = splitchordtail[splitnum]; gap = splitgap[splitnum]; i = last_i[splitnum]; if (barnotes != barsize) fprintf(outhandle, " & "); barnotes = barsize; } }; /* print out all extra text */ while (textplace != NULL) { handletext(textplace->when, &textplace, trackno); }; freshline(); if (barcount > maxbarcount) maxbarcount = barcount; } void printtrack_split_voice(trackno, anacrusis) /* print out one track as abc */ int trackno, anacrusis; { struct listx* i; struct tlistx* textplace; struct tlistx* textplace0; /* track 0 text storage */ int step, gap; int barnotes; int barcount; int bars_on_line; long now; char broken; int featurecount; int last_barsize,barnotes_correction; int nlines; int splitnum; int lastnote_in_split; nlines= 0; lastnote_in_split = 0; label_split_voices (trackno); midline = 0; featurecount = 0; inkaraoke = 0; now = 0L; broken = ' '; chordhead = NULL; chordtail = NULL; i = track[trackno].head; textplace = track[trackno].texthead; textplace0 = track[0].texthead; gap = track[trackno].startunits; if (anacrusis > 0) { barnotes = anacrusis; barcount = -1; } else { barnotes = barsize; barcount = 0; }; bars_on_line = 0; last_barsize = barsize; active_asig = header_asig; active_bsig = header_bsig; setup_timesig(header_asig,header_bsig,header_bb); active_keysig = header_keysig; handletext(now, &textplace, trackno); splitnum = 0; gap = splitgap[splitnum]; if (count_splits() > 1) fprintf(outhandle,"V: split%d%c\n",trackno+1,'A'+splitnum); while((i != NULL)||(gap != 0)) { if (gap == 0) { if (i->note->posnum + i->note->xnum == endposnum) lastnote_in_split = 1; /* do triplet here */ if (featurecount == 0) { if (allow_triplets || allow_broken) { /* [SS] 2017-01-01 */ broken = dospecial(i, &barnotes, &featurecount,allow_broken,allow_triplets); }; }; /* ignore any notes that are not in the current splitnum */ if (i->note->splitnum == splitnum) { /*printf("\nadding "); printnote(i); */ addtochord(i->note); gap = i->note->xnum; now = i->note->time; } i = i->next; advancechord(0); /* get rid of any zero length notes */ if (trackcount > 1 && trackno !=0) handletext(now, &textplace0, trackno); handletext(now, &textplace,trackno); barnotes_correction = barsize - last_barsize; barnotes += barnotes_correction; last_barsize = barsize; } else { step = findshortest(gap); if (step > barnotes) { step = barnotes; }; step = validnote(step); if (step == 0) { fatal_error("Advancing by 0 in printtrack!"); }; if (featurecount == 3) { fprintf(outhandle," (3"); }; printchord(step); if ( featurecount > 0) { featurecount = featurecount - 1; }; if ((featurecount == 1) && (broken != ' ')) { fprintf(outhandle,"%c", broken); }; advancechord(step); gap = gap - step; barnotes = barnotes - step; if (barnotes == 0) { nlines++; if (nlines > 5000) { printf("\nProbably infinite loop: aborting\n"); fprintf(outhandle,"\n\nProbably infinite loop: aborting\n"); return; } fprintf(outhandle,"|"); barnotes = barsize; barcount = barcount + 1; bars_on_line++; if (barcount >0 && barcount%bars_per_staff == 0) { freshline(); bars_on_line=0; } /* can't zero barcount because I use it for computing maxbarcount */ else if(bars_on_line >= bars_per_line && i != NULL) { if (!lastnote_in_split) fprintf(outhandle," \\"); freshline(); bars_on_line=0;} } else if (featurecount == 0) { /* note grouping algorithm */ /* [SS] 2016-07-20 waltz is a special case */ if ((barsize/parts_per_unitlen) % 3 == 0 && asig != 3) { if ( (barnotes/parts_per_unitlen) % 3 == 0 &&(barnotes%parts_per_unitlen) == 0) { fprintf(outhandle," "); }; } else { if (((barsize/parts_per_unitlen) % 2 == 0) && (barnotes % parts_per_unitlen) == 0 && ((barnotes/parts_per_unitlen) % 2 == 0)) { fprintf(outhandle," "); }; }; } if (nogr) fprintf(outhandle," "); }; if (i == NULL && gap == 0) { i = track[trackno].head; splitnum = nextsplitnum(splitnum); lastnote_in_split = 0; if (splitnum == -1) break; gap = splitgap[splitnum]; if(barnotes != barsize) freshline(); fprintf(outhandle,"V:split%d%c\n",trackno+1,'A'+splitnum); if (anacrusis > 0) { barnotes = anacrusis; barcount = -1; } else { barnotes = barsize; barcount = 0; }; } }; /* print out all extra text */ while (textplace != NULL) { handletext(textplace->when, &textplace, trackno); }; freshline(); if (barcount > maxbarcount) maxbarcount = barcount; } #endif void printtrack(trackno, anacrusis) /* print out one track as abc */ int trackno, anacrusis; { struct listx* i; struct tlistx* textplace; struct tlistx* textplace0; /* track 0 text storage */ int step, gap; int barnotes; int barcount; int bars_on_line; long now; char broken; int featurecount; int last_barsize,barnotes_correction; midline = 0; featurecount = 0; inkaraoke = 0; now = 0L; broken = ' '; chordhead = NULL; chordtail = NULL; i = track[trackno].head; textplace = track[trackno].texthead; textplace0 = track[0].texthead; gap = track[trackno].startunits; if (anacrusis > 0) { barnotes = anacrusis; barcount = -1; } else { barnotes = barsize; barcount = 0; }; bars_on_line = 0; last_barsize = barsize; active_asig = header_asig; active_bsig = header_bsig; setup_timesig(header_asig,header_bsig,header_bb); active_keysig = header_keysig; handletext(now, &textplace, trackno); while((i != NULL)||(gap != 0)) { if (gap == 0) { /* do triplet here */ if (featurecount == 0) { if (allow_triplets || allow_broken) { /* [SS] 2017-01-01 */ broken = dospecial(i, &barnotes, &featurecount,allow_broken,allow_triplets); }; }; /* add notes to chord */ addtochord(i->note); gap = i->note->xnum; now = i->note->time; i = i->next; advancechord(0); /* get rid of any zero length notes */ if (trackcount > 1 && trackno !=0) handletext(now, &textplace0, trackno); handletext(now, &textplace,trackno); barnotes_correction = barsize - last_barsize; barnotes += barnotes_correction; last_barsize = barsize; } else { step = findshortest(gap); if (step > barnotes) { step = barnotes; }; step = validnote(step); if (step == 0) { fatal_error("Advancing by 0 in printtrack!"); }; if (featurecount == 3) { fprintf(outhandle," (3"); }; printchord(step); if ( featurecount > 0) { featurecount = featurecount - 1; }; if ((featurecount == 1) && (broken != ' ')) { fprintf(outhandle,"%c", broken); }; advancechord(step); gap = gap - step; barnotes = barnotes - step; if (barnotes == 0) { fprintf(outhandle,"|"); barnotes = barsize; barcount = barcount + 1; bars_on_line++; if (barcount >0 && barcount%bars_per_staff == 0) { freshline(); bars_on_line=0; } /* can't zero barcount because I use it for computing maxbarcount */ else if(bars_on_line >= bars_per_line && i != NULL) { fprintf(outhandle," \\"); freshline(); bars_on_line=0;} } else if (featurecount == 0) { /* note grouping algorithm */ /* [SS] 2016-07-20 waltz is a special case */ if ((barsize/parts_per_unitlen) % 3 == 0 && asig != 3) { if ( (barnotes/parts_per_unitlen) % 3 == 0 &&(barnotes%parts_per_unitlen) == 0) { fprintf(outhandle," "); }; } else { if (((barsize/parts_per_unitlen) % 2 == 0) && (barnotes % parts_per_unitlen) == 0 && ((barnotes/parts_per_unitlen) % 2 == 0)) { fprintf(outhandle," "); }; }; } if (nogr) fprintf(outhandle," "); }; }; /* print out all extra text */ while (textplace != NULL) { handletext(textplace->when, &textplace, trackno); }; freshline(); if (barcount > maxbarcount) maxbarcount = barcount; } void remove_carriage_returns(char *str) { /* a carriage return might be embedded in a midi text meta-event. do not output this in the abc file or this would make a nonsyntactic abc file. */ char * loc; while (loc = (char *) strchr(str,'\r')) *loc = ' '; while (loc = (char *) strchr(str,'\n')) *loc = ' '; } void printQ() /* print out tempo for abc */ { float Tnote, freq; Tnote = mf_ticks2sec((long)((xunit*unitlen)/4), division, tempo); freq = (float) 60.0/Tnote; fprintf(outhandle,"Q:1/4=%d\n", (int) (freq+0.5)); if (summary>0) printf("Tempo: %d quarter notes per minute\n", (int) (freq + 0.5)); } void setupkey(sharps) int sharps; /* set up variables related to key signature */ { char sharp[13], flat[13], shsymbol[13], flsymbol[13]; int j, t, issharp; int minkey; for (j=0; j<12; j++) key[j] = 0; minkey = (sharps+12)%12; if (minkey%2 != 0) { minkey = (minkey+6)%12; }; /* [SS] 2017-12-20 changed strncpy to memcpy and limit to 12 */ /*strncpy(sharp, "ccddeffggaab",16); [SS] 2017-08-30 */ memcpy(sharp, "ccddeffggaab",12); /* [SS] 2017-12-20 */ memcpy(shsymbol, "=^=^==^=^=^=",12); /* [SS] 2017-12-20 */ if (sharps == 6) { sharp[6] = 'e'; shsymbol[6] = '^'; }; memcpy(flat, "cddeefggaabb",12); /* [SS] 2017-12-20 */ memcpy(flsymbol, "=_=_==_=_=_=",12); /* [SS] 2017-12-20 */ /* Print out key */ if (sharps >= 0) { if (sharps == 6) { fprintf(outhandle,"K:F#"); } else { fprintf(outhandle,"K:%c", sharp[minkey] + 'A' - 'a'); }; issharp = 1; } else { if (sharps == -1) { fprintf(outhandle,"K:%c", flat[minkey] + 'A' - 'a'); } else { fprintf(outhandle,"K:%cb", flat[minkey] + 'A' - 'a'); }; issharp = 0; }; if (sharps >= 0) { fprintf(outhandle," %% %d sharps\n", sharps); } else { fprintf(outhandle," %% %d flats\n", -sharps); }; key[(minkey+1)%12] = 1; key[(minkey+3)%12] = 1; key[(minkey+6)%12] = 1; key[(minkey+8)%12] = 1; key[(minkey+10)%12] = 1; for (j=0; j<256; j++) { t = j%12; if (issharp) { atog[j] = sharp[t]; symbol[j] = shsymbol[t]; } else { atog[j] = flat[t]; symbol[j] = flsymbol[t]; }; trans[j] = 7*(j/12)+((int) atog[j] - 'a'); if (j < MIDDLE) { atog[j] = (char) (int) atog[j] + 'A' - 'a'; }; if (key[t] == 0) { back[trans[j]] = j; }; }; } /* Functions for supporting the command line user interface to midi2abc. */ int readnum(num) /* read a number from a string */ /* used for processing command line */ char *num; { int t; char *p; int neg; t = 0; neg = 1; p = num; if (*p == '-') { p = p + 1; neg = -1; }; while (((int)*p >= '0') && ((int)*p <= '9')) { t = t * 10 + (int) *p - '0'; p = p + 1; }; return neg*t; } int readnump(p) /* read a number from a string (subtly different) */ /* used for processing command line */ char **p; { int t; t = 0; while (((int)**p >= '0') && ((int)**p <= '9')) { t = t * 10 + (int) **p - '0'; *p = *p + 1; }; return t; } void readsig(a, b, sig) /* read time signature */ /* used for processing command line */ int *a, *b; char *sig; { char *p; int t; p = sig; if ((int)*p == 'C') { *a = 4; *b = 4; return; }; *a = readnump(&p); if ((int)*p != '/') { char msg[80]; sprintf(msg, "Expecting / in time signature found %c!", *p); fatal_error(msg); }; p = p + 1; *b = readnump(&p); if ((*a == 0) || (*b == 0)) { char msg[80]; sprintf(msg, "%d/%d is not a valid time signature!", *a, *b); fatal_error(msg); }; t = *b; while (t > 1) { if (t%2 != 0) { fatal_error("Bad key signature, divisor must be a power of 2!"); } else { t = t/2; }; }; } int is_power_of_two(int numb) /* checks whether numb is a power of 2 less than 256 */ { int i,k; k = 1; for (i= 0;i<8;i++) { if(numb == k) return(1); k *= 2; } return(0); } int getarg(option, argc, argv) /* extract arguments from command line */ char *option; char *argv[]; int argc; { int j, place; place = -1; for (j=0; j= argc+1) { /* [SS] 2015-02-22 */ Qval = readnum(argv[arg]); } else { Qval = 0; }; arg = getarg("-u", argc,argv); if (arg != -1) { xunit = readnum(argv[arg]); xunit_set = 1; } else { xunit = 0; xunit_set = 0; }; arg = getarg("-ppu",argc,argv); if (arg != -1) { val = readnum(argv[arg]); if (is_power_of_two(val)) parts_per_unitlen = val; else { printf("*error* -ppu parameter must be a power of 2\n"); parts_per_unitlen = 2; } } else parts_per_unitlen = 2; arg = getarg("-aul",argc,argv); if (arg != -1) { val = readnum(argv[arg]); if (is_power_of_two(val)) { unitlen = val; unitlen_set = 1;} else printf("*error* -aul parameter must be a power of 2\n"); } arg = getarg("-bps",argc,argv); if (arg != -1) bars_per_staff = readnum(argv[arg]); else { bars_per_staff=4; }; arg = getarg("-bpl",argc,argv); if (arg != -1) bars_per_line = readnum(argv[arg]); else { bars_per_line=1; }; extracta = (getarg("-xa", argc, argv) != -1); guessa = (getarg("-ga", argc, argv) != -1); guessu = (getarg("-gu", argc, argv) != -1); guessk = (getarg("-gk", argc, argv) != -1); keep_short = (getarg("-s", argc, argv) != -1); summary = getarg("-sum",argc,argv); swallow_rests = getarg("-sr",argc,argv); if (swallow_rests != -1) { restsize = readnum(argv[swallow_rests]); if(restsize <1) restsize=1; } obpl = getarg("-obpl",argc,argv); if (obpl>= 0) bars_per_line=1; if (!unitlen_set) { if ((asig*4)/bsig >= 3) { unitlen =8; } else { unitlen = 16; }; } arg = getarg("-b", argc, argv); if ((arg != -1) && (arg < argc)) { bars = readnum(argv[arg]); } else { bars = 0; }; arg = getarg("-c", argc, argv); if ((arg != -1) && (arg < argc)) { xchannel = readnum(argv[arg]) - 1; } else { xchannel = -1; }; arg = getarg("-k", argc, argv); if ((arg != -1) && (arg < argc)) { keysig = readnum(argv[arg]); if (keysig<-6) keysig = 12 - ((-keysig)%12); if (keysig>6) keysig = keysig%12; if (keysig>6) keysig = keysig - 12; ksig_set = 1; } else { keysig = -50; ksig_set = 0; }; if(guessk) ksig_set=1; arg = getarg("-o",argc,argv); if ((arg != -1) && (arg < argc)) { outhandle = efopen(argv[arg],"w"); /* open output abc file */ } else { outhandle = stdout; }; arg = getarg("-nt", argc, argv); if (arg == -1) { /* 2017-01-01 */ allow_triplets = 1; } else { allow_triplets = 0; }; arg = getarg("-nb", argc, argv); if (arg == -1) { /* 2017-01-01 */ allow_broken = 1; } else { allow_broken = 0; }; arg = getarg("-nogr",argc,argv); if (arg != -1) nogr=1; else nogr = 0; arg = getarg("-title",argc,argv); if (arg != -1) { title = addstring(argv[arg]); } arg = getarg("-origin",argc,argv); if (arg != -1) { origin = addstring(argv[arg]); } arg = getarg("-f", argc, argv); if (arg == -1) { arg = huntfilename(argc, argv); }; if ((arg != -1) && (arg < argc)) { F = efopen(argv[arg],"rb"); /* fprintf(outhandle,"%% input file %s\n", argv[arg]); */ } else { printf("midi2abc version %s\n usage :\n",VERSION); printf("midi2abc filename \n"); printf(" -a \n"); printf(" -xa Extract anacrusis from file "); printf("(find first strong note)\n"); printf(" -ga Guess anacrusis (minimize ties across bars)\n"); printf(" -gk Guess key signature \n"); printf(" -gu Guess xunit from note duration statistics\n"); printf(" -m