Codebase list abcmidi / 6a61590
New upstream version 20171215 Ross Gammon 6 years ago
12 changed file(s) with 314 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
0 2017 November 10
0 2017 December 15
1
1252112521 w: line and call preparse_words().
1252212522
1252312523
12524 November 01 2017 November 08 2017 November 10 2017
12524 November 01 2017 November 08 2017 November 10 2017 November 19 2017
1252512525
1252612526 Midi2abc: minor enhancement for -stats function.
1252712527
12528
12529 November 27 2017
12530 Midicopy: introducing new options -focusontracks n1,n2,... and
12531 -focusonchannel n1,n2.... This attenuates the velocity values of the
12532 notes in all tracks (channels) except except n1,n2,... by the
12533 attenuation (default 70) units. The attenuation can be specified
12534 by -attenuation n.
12535
12536 December 06 2017
12537 Midicopy: added an option -xchns to exclude specific channels.
12538
12539
12540 December 10 2017
12541 Abc2midi: abc2midi now implements the command
12542 %%abc-include per.abc
12543 where per.abc is typically a header file which defines various
12544 global parameters. For example, the file could remap the channel
12545 pitches to particular percussion instruments using the %%MIDI drummap
12546 command.
12547
12548 Implementation: in genmidi.c the function parse_drummap() is no longer
12549 static so it can be called in store.c. In store.c, the command
12550 %%MIDI drummap is recoginized in the function event_specific_in_header().
12551 The function init_drummap, is no longer activated in the function
12552 finishfile(), but only once in the main() function. This means that,
12553 the %%MIDI drummap command will apply to all the tunes in the file,
12554 irrespective of whether it is in the header (global) area. Finally,
12555 parsefile() in parseabc.c has been extended to recognize the
12556 abc-include file. All the contents of this include file are parsed
12557 as if the lines were included in the open abc file, except that the
12558 line counters do not count the lines in the include file. The
12559 extension to parseabc.c also impacts abc2abc, yaps, and abcmatch.
12560
12561 December 15 2017
12562 Midicopy: added -nobends option.
12563
12564
33 .SH SYNOPSIS
44 \fBmidicopy\fP [\fB-ver\fP] [\fB-trks\fP \fIn1,n2,..\fP]\
55 [\fB-xtrks\fP \fIn1,n2,..\fP]\
6 [\fB-xchns\fP \fIn1,n2,..\fP]\
67 [\fB-chans\fP \fIn1,n2,...\fP]\
78 [\fB-from\fP \fIn (in midi ticks)\fP] [\fB-to\fP \fIn (in midi ticks)\fP]\
89 [\fB-fromsec %f\fP \fIn (in seconds)\fP] [\fB-tosec\fP \fIn (in seconds)\fP]\
9 [\fB-frombeat %f\fP \fIn (in beats)\fP] [\fB-tosec\fP \fIn (in beats)\fP]\
10 [\fB-frombeat %f\fP \fIn (in beats)\fP] [\fB-tobeat\fP \fIn (in beats)\fP]\
1011 [\fB-replace\fP \fItrk,loc,val\fP] [\fB-tempo %n\fP] [\fB-speed %f\fP]\
1112 [\fB-drumfocus\fP \fIn \fIm\fP] [\fB-mutenodrum [%d]\fP]\
1213 [\fB-setdrumloudness\fP \fIn \fIm\fP]\
14 [\fB-focusontrack\fP \fIn1,n2,... (from 1)\fP]\
15 [\fB-focusonchannel\fP \fIn1,n2,... (from 1)\fP]\
16 [\fB-attenuation\fP \fIn\fP]\
17 [\fB-nobends\fP]\
1318 \fIinput.mid output.mid\fP
1419 .SH "DESCRIPTION"
1520 .PP
3742 .B -xtrks n1,n2, etc
3843 Lists the tracks to exclude from copying. All other tracks are copied.
3944 This option does not work in combination with \-trks.
45 .TP
46 .B -xchns n1,n2, etc
47 Lists the channels to exclude from copying. All other channels are copied.
48 This option does not work in combination with \-chns.
4049 .TP
4150 .B -chns n
4251 Like above, it specifies the MIDI channels to be copied. By default
103112 where n is between 35 to 81 inclusive and m is the loudness between
104113 0 and 127. The loudness of all instances of drum n are changed
105114 to m.
115 .TP
116 .B -focusontrack n1,n2,...
117 The velocities of notes in all tracks except n are attenuated.
118 .TP
119 .B -focusonchannel n1,n2,...
120 The velocities of notes in all channels except n are attenuated.
121 .TP
122 .B -attenuation n
123 Specifies the amount the note velocities are reduced by either
124 -focusontracks or -focusonchannels. Current default is 70.
125 .TP
126 .B -nobends
127 Suppresses all channel pitchbend commands.
106128
107129 .SH EXAMPLE
108130 .B midicopy.exe -trks 1,5 -from 2669 -to 8634 uzicko.mid fragment.mid
115137 .SH AUTHOR
116138 This manual page was written by Seymour Shlien.
117139 .SH VERSION
118 This man page describes midicopy version 1.20 from October 28 2013.
140 This man page describes midicopy version 1.30 from December 15 2017.
00 abcMIDI : abc <-> MIDI conversion utilities
11
2 midi2abc version 3.14 November 10 2017
3 abc2midi version 4.00 October 23 2017
2 midi2abc version 3.16 November 26 2017
3 abc2midi version 4.01 December 10 2017
44 abc2abc version 1.97 October 11 2017
5 yaps version 1.69 October 23 2017
5 yaps version 1.70 November 17 2017
66 abcmatch version 1.71 April 19 2017
7 midicopy version 1.26 October 22 2017
7 midicopy version 1.30 December 15 2017
88
99 24th January 2002
1010
418418 midicopy copies selected tracks, channels, time interval of the input midi file.options:
419419 -ver version information
420420 -trks n1,n2,..(starting from 1)
421 -xtrks n1,n2,... (tracks to exclude)
422 -xchns n1,n2,... (channels to exclude)
421423 -chns n1,n2,..(starting from 1)
422424 -from n (in midi ticks)
423425 -to n (in midi ticks)
426 -fromsec %f (in seconds)
427 -tosec %f (in seconds)
428 -frombeat %f
429 -tobeat %f
424430 -replace trk,loc,val
431 -tempo n (in quarter notes/min)
432 -speed %f (between 0.1 and 10.0)
433 -drumfocus n (35 - 81) m (0 - 127)
434 -mutenodrum [level]
435 -setdrumloudness n (35-81) m (0 -127)
436 -focusontrack n1,n2,...
437 -focusonchannel n1,n2,...
438 -attenuation n
439
425440
426441 midicopy.exe -ver
427442
428443 will print out something like
429 1.00 July 11 2004
444 1.29 December 06 2017
430445
431446
432447 midicopy.exe input.mid output.mid
444459
445460 If you include the -to command followed by a midi pulse number, the
446461 midi file is truncated beyond that point, so that when you play the file
447 it will stop at this point.
448
449 If you have selected a time interval using the -from or -to parameters
450 (or both), then the program will print out the estimated duration of
451 the output midi file.
462 it will stop at this point. You can also specify the window using beats
463 with the options -frombeats and -tobeats. The program will print out
464 the estimated duration of the output midi file.
452465
453466 All the tracks will be copied unless you specify them in the list following
454467 keyword -trks. You start counting tracks from 1.
455468
456469 Similarly, all channels will be copied unless you specify them following
457470 keyword -chns. You start counting channels from 1.
471
472 The -xchns and -xtrk options will exclude the indicated channels or
473 tracks from the output midi file. The -xchns does not work together
474 with -chns and neither does -xtrks work with -trks. (Use one or the
475 other.)
458476
459477 The option -replace allows you to overwrite a specific byte given its
460478 track number and offset loc, by the byte whose value is val. This is
462480 is replaced in the output file. If you use the -replace option, all
463481 other options like -from, -to, -chns etc. are ignored.
464482
483 The embedded tempo commands can be replaced using
484 -tempo n
485 in units beats/minute.
486
487 -speed f
488 where f is a decimal number between 0.1 and 10.0 will multiply
489 the current tempo by this factor.
490
491 -drumfocus will accentuate the specified drum (35 to 81) to level
492 m (0 to 127).
493
494 -focusontracks will attenuate all tracks except those specified.
495
496 -focusonchannels will attenuate all channels except those specified.
497
498 -attenuation specifies the amount to reduce the note velocities
499 for the focus options.
465500
466501 -------------------------------------------------------------------------
467502 abcmatch.exe - see abcmatch.txt
11611161 event_error("Internal error: beam with 0 notes");
11621162 showtune(&thetune);
11631163 return;
1164 exit(0);
1164 /* exit(0); [SS] 2017-11-17 */
11651165 };
11661166 if (beamset[0]->type != NOTE) {
11671167 event_error("Internal error: beam does not start with NOTE");
6363 }
6464
6565 void setbeat();
66 static void parse_drummap(char **s);
66 void parse_drummap(char **s); /* [SS] 2017-12-10 no more static */
6767
6868 /* global variables grouped roughly by function */
6969
25182518 drum_map[i] = i;
25192519 }
25202520
2521 static void parse_drummap(char **s)
2521 void parse_drummap(char **s)
25222522 /* parse abc note and advance character pointer */
25232523 /* code stolen from parseabc.c and simplified */
2524 /* [SS] 2017-12-10 no more 'static voice parse_drummap' */
25242525 {
25252526 int mult;
25262527 char accidental, note;
130130 }
131131
132132
133 void txt_pitchbend(chan,msb,lsb)
133 /* [SS] 2017-11-16 submitted by Jonathan Hough (msb,lsb interchanged) */
134 void txt_pitchbend(chan,lsb,msb)
134135 int chan, msb, lsb;
135136 {
136137 prtime();
137 printf("Pitchbend, chan=%d msb=%d lsb=%d\n",chan+1,msb,lsb);
138 printf("Pitchbend, chan=%d lsb=%d msb=%d\n",chan+1,msb,lsb);
138139 }
139140
140141 void txt_program(chan,program)
4545 * based on public domain 'midifilelib' package.
4646 */
4747
48 #define VERSION "3.14 November 10 2017"
48 #define VERSION "3.16 November 23 2017"
4949 #define SPLITCODE
5050
5151 /* Microsoft Visual C++ Version 6.0 or higher */
7878 #define MIDDLE 72
7979 void initfuncs();
8080 void setupkey(int);
81 void stats_finish();
8182 int testtrack(int trackno, int barbeats, int anacrusis);
8283 int open_note(int chan, int pitch, int vol);
8384 int close_note(int chan, int pitch, int *initvol);
104105 int symbol[256]; /*translation tables for MIDI pitch to abc note */
105106 int key[12];
106107 int sharps;
107 int trackno, maintrack;
108 int trackno;
109 int maintrack;
108110 int format; /* MIDI file type */
109111
110112 int karaoke, inkaraoke;
488490 return(f);
489491 }
490492
491
492493 void error(s)
493494 char *s;
494495 {
495496 fprintf(stderr,"Error: %s\n",s);
497 }
498
499
500 /* [SS] 2017-11-19 */
501 void stats_error(s)
502 char *s;
503 {
504 fprintf(stderr,"Error: %s\n",s);
505 fprintf(stderr,"activetrack %d\n",tracknum);
506 stats_finish();
496507 }
497508
498509
9891000 int p;
9901001
9911002 for (i=1;i<17;i++) {
1003 /* skip drum channel 10 */
1004 if (i == 10) continue;
9921005 if (channel2nnotes[i] > 0) {
9931006 p = channel2prog[i];
1007 if (p == -1) p =0; /* missing program for channel */
9941008 if (p >=0 && p < 128)
995 progcolor[progmapper[channel2prog[i]]] += channel2nnotes[i];
1009 progcolor[progmapper[p]] += channel2nnotes[i];
9961010 }
9971011 }
9981012
14991513
15001514 void initfunc_for_stats()
15011515 {
1502 Mf_error = error;
1516 Mf_error = stats_error; /* [SS] 2017-11-19 */
15031517 Mf_header = stats_header;
15041518 Mf_trackstart = stats_trackstart;
15051519 Mf_trackend = stats_trackend;
4848
4949
5050
51 #define VERSION "1.26 October 22 2017"
51 #define VERSION "1.30 December 15 2017"
5252 #include "midicopy.h"
5353 #define NULLFUNC 0
5454 #define NULL 0
106106 int mutenodrum = 0; /* [SS] 2013-09-15 */
107107 int chosen_drum = 0; /* [SS] 2013-10-01 */
108108 int drumvelocity = 0; /* [SS] 2013-10-01 */
109 int attenuation = 70; /* [SS] 2017-11-27 */
110 int nobends = 0; /* [SS] 2017-12-15 */
109111
110112 long Mf_numbyteswritten = 0L;
111113 long readvarinum ();
132134 int notechan[2048]; /* keeps track of running voices */
133135 int tocopy[32]; /* tracks to copy */
134136 int ctocopy[16]; /* channels to copy */
137 int tfocus[32]; /* track focus 2017-11 27*/
138 int cfocus[16]; /* channel focus 2017-11-27*/
135139 int chnflag = 0; /* flag indicating not all channels selected */
136140 int verbatim = 1; /* flag for verbatim transfer */
137141 int haschannel[17]; /* for determining which channels are in use */
142 int hastempo[32]; /* indicates whether tempo command in track */
138143
139144 FILE *F_in, *fp;
140145 int format, ntrks, division;
945950 copy_metaeot ();
946951 break;
947952 case 0x51: /* Set tempo */
953 hastempo[activetrack] = 1; /* [SS] 2017-12-14 */
948954 if (newtempo > 0) /* [SS] 2013-09-04 */
949955 mf_write_tempo (newtempo);
950956 else if (newspeed)
10101016 c2 = nondrumlevel; /*[SS] 2013-09-15 */
10111017 if (chan == 9 && chosen_drum != 0 && c1 == chosen_drum)
10121018 c2 = drumvelocity; /* [SS] 2013-10-01 */
1019 if (cfocus[chan] == 1) { /* [SS] 2017-11-27 */
1020 c2 = c2 - attenuation;
1021 if (c2 <0) c2 = 0;
1022 }
1023 if (tfocus[activetrack] == 1) { /* [SS] 2017-11-27 */
1024 c2 = c2 - attenuation;
1025 if (c2 <0) c2 = 0;
1026 }
10131027 copy_noteon (chan, c1, c2);
10141028 break;
10151029 case 0xa0:
10191033 copy_parameter (chan, c1, c2);
10201034 break;
10211035 case 0xe0:
1022 copy_pitchbend (chan, c1, c2);
1036 if (nobends == 0)
1037 copy_pitchbend (chan, c1, c2);
10231038 break;
10241039 case 0xc0:
10251040 copy_program (chan, c1);
12721287 if (tocopy[i] == 1)
12731288 /*list_channels_in_use(i); */
12741289 /* [SS] 2017-10-19] don't copy redundant tracks */
1290 /* [SS] 2017-12-24 but make sure tracks with tempo is copied */
12751291 for (j=0;j<16;j++) {
1276 if(ctocopy[j] == 1 && haschannel[j] == 1) {
1292 if((ctocopy[j] == 1 && haschannel[j] == 1) || hastempo[i]) {
12771293 /* printf("writing track %d\n",i); */
12781294 mf_write_track_chunk (i, fp);
12791295 break; /* only write the track once */
17401756 int trk[16], mtrks;
17411757 int chn[16], chns;
17421758 int xtrks; /* [SS] 2013-10-28 */
1759 int xchns; /* [SS] 2017-12-06 */
17431760 int i;
17441761 int byteloc, trknum;
17451762 int repflag;
17531770 tocopy[i] = 1;
17541771 for (i = 0; i < 16; i++)
17551772 ctocopy[i] = 1;
1773 for (i=0;i<32;i++) tfocus[i] = 0; /* [SS] 2017-11-27 */
1774 for (i=0;i<16;i++) cfocus[i] = 0; /* [SS] 2017-11-27 */
1775 for (i=0;i<32;i++) hastempo[i] = 0; /* [SS] 2017-12-14 */
17561776 mtrks = 0;
17571777 xtrks = 0;
17581778 chns = 0;
1779 xchns = 0;
17591780 start_tick = -1;
17601781 end_tick = -1;
17611782 start_seconds = -1.0;
17791800 printf ("options:\n");
17801801 printf ("-ver version information\n");
17811802 printf ("-trks n1,n2,..(starting from 1)\n");
1782 printf ("-xtrks n1,n2, (tracks to exclude)\n"); /* [SS] 2013-10-27 */
1803 printf ("-xtrks n1,n2,.. (tracks to exclude)\n"); /* [SS] 2013-10-27 */
1804 printf ("-xchns n1,n2,.. (tracks to exclude)\n"); /* [SS] 2017-12-06 */
17831805 printf ("-chns n1,n2,..(starting from 1)\n");
17841806 printf ("-from n (in midi ticks)\n");
17851807 printf ("-to n (in midi ticks)\n");
17931815 printf ("-drumfocus n (35 - 81) m (0 - 127)\n"); /* [SS] 2013-09-07 */
17941816 printf ("-mutenodrum [level] \n"); /* [SS] 2013-09-15 */
17951817 printf ("-setdrumloudness n (35-81) m (0 -127)\n"); /* [SS] 2013-10-01 */
1818 printf ("-focusontracks n1,n2,... \n"); /* [SS] 2017-11-27 */
1819 printf ("-focusonchannels n1,n2,...\n"); /* [SS] 2017-11-27 */
1820 printf ("-attenuation n\n"); /* [SS] 2017-11-27 */
1821 printf ("-nobends\n"); /* [SS] 2017-11-27 */
17961822 exit (1);
17971823 }
17981824
18031829 */
18041830 arg = getarg ("-trks", argc, argv);
18051831 if (arg >= 0)
1806 mtrks = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
1832 mtrks = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
18071833 &trk[0], &trk[1], &trk[2], &trk[3], &trk[4],
18081834 &trk[5], &trk[6], &trk[7], &trk[8], &trk[9], &trk[10],
1809 &trk[11]);
1835 &trk[11],&trk[12],&trk[13]);
18101836 if (mtrks > 0)
18111837 {
18121838 /* printf("%d tracks specified\n", mtrks); */
18331859 tocopy[trk[i] - 1] = 0;
18341860 }
18351861
1862 arg = getarg("-xchns",argc,argv); /* [SS] 2017-12-06 */
1863 if (arg >= 0)
1864 xchns = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
1865 &chn[0], &chn[1], &chn[2], &chn[3], &chn[4], &chn[5],
1866 &chn[6], &chn[7], &chn[8], &chn[9], &chn[10], &chn[11],
1867 &chn[12],&chn[13]);
1868 if (xchns > 0)
1869 {
1870 for (i = 0; i < 16; i++)
1871 ctocopy[i] = 1;
1872 for (i = 0; i < xchns; i++)
1873 if (chn[i] > 0 && chn[i] < 17)
1874 ctocopy[chn[i] - 1] = 0;
1875 chnflag = 1;
1876 verbatim = 0;
1877 }
1878
18361879 arg = getarg ("-chns", argc, argv);
18371880 if (arg >= 0)
1838 chns = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
1881 chns = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
18391882 &chn[0], &chn[1], &chn[2], &chn[3], &chn[4], &chn[5],
1840 &chn[6], &chn[7], &chn[8], &chn[9], &chn[10], &chn[11]);
1883 &chn[6], &chn[7], &chn[8], &chn[9], &chn[10], &chn[11],
1884 &chn[12],&chn[13]);
18411885 if (chns > 0)
18421886 {
18431887 for (i = 0; i < 16; i++)
18481892 chnflag = 1;
18491893 verbatim = 0;
18501894 }
1895
18511896 arg = getarg ("-from", argc, argv);
18521897 if (arg >= 0)
18531898 {
19672012 }
19682013 }
19692014
2015 /* [SS] 2017-11-27 */
2016 mtrks = 0;
2017 arg = getarg("-focusontracks",argc,argv);
2018 if (arg >= 0)
2019 {
2020 verbatim = 0;
2021 mtrks = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
2022 &trk[0], &trk[1], &trk[2], &trk[3], &trk[4],
2023 &trk[5], &trk[6], &trk[7], &trk[8], &trk[9], &trk[10],
2024 &trk[11]);
2025 if (mtrks > 0)
2026 {
2027 /* printf("%d tracks specified\n", mtrks); */
2028 for (i = 0; i < 32; i++)
2029 tfocus[i] = 1; /* attenuation flag */
2030 for (i = 0; i < mtrks; i++) {
2031 if (trk[i] < 32 && trk[i] >= 0)
2032 tfocus[trk[i]-1] = 0; /* track numbers start from 1*/
2033 }
2034 }
2035 }
2036
2037 /* [SS] 2017-11-27 */
2038 arg = getarg("-focusonchannels",argc,argv);
2039 if (arg >=0) {
2040 chns = sscanf (argv[arg], "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
2041 &chn[0], &chn[1], &chn[2], &chn[3], &chn[4], &chn[5],
2042 &chn[6], &chn[7], &chn[8], &chn[9], &chn[10], &chn[11]);
2043 if (chns > 0)
2044 {
2045 verbatim = 0;
2046 for (i = 0; i < 16; i++)
2047 cfocus[i] = 1; /* attenuation flag */
2048 for (i = 0; i < chns; i++)
2049 if (chn[i] > 0 && chn[i] < 17)
2050 cfocus[chn[i] - 1] = 0; /* channel numbers start from 1 */
2051 }
2052 }
2053
2054 arg = getarg("-attenuation",argc,argv);
2055 if (arg >= 0)
2056 sscanf (argv[arg], "%d", &attenuation);
2057
2058 arg = getarg("-nobends",argc,argv);
2059 if (arg >=0) nobends=1;
19702060
19712061
19722062 repflag = getarg ("-replace", argc, argv);
17671767 char *p;
17681768 int success;
17691769
1770 success = sscanf (s, "%%abc-version %s", &abcversion); /* [SS] 2014-08-11 */
1770 success = sscanf (s, "%%%%abc-version %3s", abcversion); /* [SS] 2014-08-11 */
17711771 if (*s == '%')
17721772 {
17731773 p = s + 1;
17791779 event_comment (s);
17801780 };
17811781 }
1782
1783 /* [SS] 2017-12-10 */
1784 FILE * parse_abc_include (s)
1785 char *s;
1786 {
1787 char includefilename[80];
1788 FILE *includehandle;
1789 int success;
1790 success = sscanf (s, "%%%%abc-include %80s", includefilename); /* [SS] 2014-08-11 */
1791 if (success == 1) {
1792 /* printf("opening include file %s\n",includefilename); */
1793 includehandle = fopen(includefilename,"r");
1794 if (includehandle == NULL)
1795 {
1796 printf ("Failed to open include file %s\n", includefilename);
1797 };
1798 return includehandle;
1799 }
1800 return NULL;
1801 }
1802
17821803
17831804 void
17841805 parse_tempo (place)
27342755 handle_abc2midi_parser (line); /* [SS] 2017-04-12 */
27352756 if (ignore_line == 1) return; /* [SS] 2017-04-12 */
27362757
2737 /*printf("%d parsing : %s\n", lineno, line); */
2758 /*printf("%d parsing : %s\n", lineno, line);*/
27382759 strncpy (inputline, line, sizeof inputline); /* [SS] 2011-06-07 [PHDM] 2012-11-27 */
27392760
27402761 p = line;
28322853 parsefile (name)
28332854 char *name;
28342855 /* top-level routine for parsing file */
2856 /* [SS] 2017-12-10 In order to allow including the directive
2857 "%%abc-include includefile.abc" to insert the includedfile.abc,
2858 we switch the file handle fp to link to the includefile.abc and switch
2859 back to the original file handle when we reach the end of file
2860 of includefile.abc. Thus we keep track of the original handle
2861 using fp_last.
2862 */
28352863 {
28362864 FILE *fp;
2865 FILE *fp_last,*fp_include; /* [SS] 2017-12-10 */
28372866 int reading;
28382867 int fileline;
2868 int last_position;
28392869 struct vstring line;
28402870 /* char line[MAXLINE]; */
28412871 int t;
28422872 int lastch, done_eol;
2873 int err;
2874
2875 fp_last = NULL; /* [SS] 2017-12-10 */
28432876
28442877 /* printf("parsefile called %s\n", name); */
28452878 /* The following code permits abc2midi to read abc from stdin */
28792912 if (parsing)
28802913 event_linebreak ();
28812914 };
2915 if (fp_last != NULL) { /* [SS] 2017-12-10 */
2916 fclose(fp);
2917 fp = fp_last;
2918 err = fseek(fp,last_position,SEEK_SET);
2919 /*printf("fseek return err = %d\n",err);*/
2920 reading = 1;
2921 fp_last = NULL;
2922 }
28822923 }
28832924 else
28842925 {
28992940 }
29002941 else
29012942 {
2902 /* reached end of line */
2903 parseline (line.st);
2904 clearvstring (&line);
2905 fileline = fileline + 1;
2906 lineno = fileline;
2907 if (parsing)
2908 event_linebreak ();
2909 done_eol = 1;
2943 /* reached end of line */
2944 fp_include = parse_abc_include (line.st);/* [SS] 2017-12-10 */
2945 if (fp_include == NULL) {
2946 parseline (line.st);
2947 clearvstring (&line);
2948 if (fp_last == NULL) {
2949 fileline = fileline + 1;
2950 lineno = fileline;
2951 }
2952 if (parsing)
2953 event_linebreak ();
2954 done_eol = 1;
2955 } else {
2956 if (fp_last == NULL) {
2957 last_position = ftell(fp);
2958 /*printf("last position = %d\n",last_position);*/
2959 fp_last = fp;
2960 fp = fp_include;
2961 if (parsing)
2962 event_linebreak ();
2963 done_eol = 1;
2964 clearvstring (&line);
2965 } else {
2966 event_error ("Not allowed to recurse include file");
2967 }
2968 }
29102969 };
29112970 };
29122971 lastch = t;
183183
184184 */
185185
186 #define VERSION "4.00 October 23 2017 abc2midi"
186 #define VERSION "4.01 December 10 2017 abc2midi"
187187
188188 /* enables reading V: indication in header */
189189 #define XTEN1 1
288288 void init_p48toc53 (); /* [SS] 2014-01-12 */
289289 void convert_to_comma53 (char acc, int *midipitch, int* midibend);
290290 void recurse_back_to_original_voice (); /* [SS] 2014-03-26 */
291 void parse_drummap(char **s); /* [SS] 2017-12-10 */
291292
292293
293294 struct voicecontext {
25152516 velocitychange = readnump(&p);
25162517 done = 1;
25172518 }
2519
2520 if (strcmp(command,"drummap") == 0) { /* [SS] 2017-12-10 */
2521 skipspace(&p);
2522 parse_drummap(&p);
2523 done = 1;
2524 }
2525
25182526
25192527 if (done == 0) {
25202528 event_warning("cannot handle this MIDI directive in file header");
58275835 /* dump_voicecontexts(); for debugging*/
58285836 setup_trackstructure();
58295837 clearvoicecontexts();
5830 init_drum_map();
5838 /* init_drum_map(); [SS] 2017-12-10 moved to main() */
58315839 if (!pastheader) {
58325840 event_error("No valid K: field found at start of tune");
58335841 } else {
60076015 /* printf("argc = %d\n", argc); */
60086016 } else {
60096017 init_abbreviations();
6018 init_drum_map(); /* [SS] 2017-12-10 */
60106019 if (!silent) printf("%s\n",VERSION); /* [SS] 2015-07-15 */
60116020 parsefile(filename);
60126021 free_abbreviations();
2121 /* yapstree.c - back-end for abc parser. */
2222 /* generates a data structure suitable for typeset music */
2323
24 #define VERSION "1.69 October 23 2017 yaps"
24 #define VERSION "1.70 November 17 2017 yaps"
2525 #include <stdio.h>
2626 #ifdef USE_INDEX
2727 #define strchr index