From 7b0b1cc77e61299963356bb880a3ea35858cd4aa Mon Sep 17 00:00:00 2001 From: Henning Kiel Date: Thu, 2 Oct 2025 15:54:33 +0200 Subject: [PATCH] ANSI function declarations --- .gitignore | 9 ++ abcmatch.c | 11 +- crack.c | 3 +- debug.c | 5 +- drawtune.c | 49 ++---- genmidi.c | 138 +++++------------ matchsup.c | 259 +++++++++++--------------------- mftext.c | 74 +++------ midi2abc.c | 426 ++++++++++++++++++++-------------------------------- midicopy.c | 73 +++------ midicopy.h | 3 +- midifile.c | 131 ++++++---------- midifile.h | 42 +++--- midistats.c | 183 ++++++++++------------ parseabc.c | 196 ++++++++---------------- parseabc.h | 8 +- parser2.c | 14 +- position.c | 8 +- pslib.c | 49 ++---- queues.c | 28 ++-- store.c | 375 +++++++++++++++------------------------------ toabc.c | 261 +++++++++----------------------- yapstree.c | 196 +++++++----------------- 23 files changed, 851 insertions(+), 1690 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd25aff --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.o +abc2abc +abc2midi +abcmatch +mftext +midi2abc +midicopy +midistats +yaps diff --git a/abcmatch.c b/abcmatch.c index e1645e0..b0703a1 100644 --- a/abcmatch.c +++ b/abcmatch.c @@ -75,8 +75,6 @@ enum ACTION } action; -int *checkmalloc (int); -extern int getarg (char *, int, char **); void free_feature_representation (); /* variables shared with abcparse.c and abcstore.c */ @@ -1200,11 +1198,8 @@ analyze_abc_file (char *filename) void -event_init (argc, argv, filename) +event_init (int argc, char *argv[], char **filename) /* this routine is called first by abcparse.c */ - int argc; - char *argv[]; - char **filename; { int i,j; @@ -1390,9 +1385,7 @@ event_init (argc, argv, filename) int -main (argc, argv) - int argc; - char *argv[]; +main (int argc, char *argv[]) { char *filename; int i; diff --git a/crack.c b/crack.c index 01e20f3..3eb07b6 100644 --- a/crack.c +++ b/crack.c @@ -74,8 +74,7 @@ int arg_index = 0; char *arg_option; char *pvcon = NULL; -char* crack(argc, argv, flags, ign) - int argc; char **argv; char *flags; int ign; +char* crack(int argc, char *argv[], char *flags, int ign) { char *pv, *flgp, *strchr(); while ((arg_index) < argc) diff --git a/debug.c b/debug.c index cfa27c4..c7a0817 100644 --- a/debug.c +++ b/debug.c @@ -170,8 +170,7 @@ void showfeature(struct feature *ft) } -static int showline(v) -struct voice* v; +static int showline(struct voice *v) /* draws one line of music from specified voice */ { struct feature* ft; @@ -181,7 +180,7 @@ struct voice* v; struct fract* afract; struct rest* arest; struct tuple* atuple; - cleftype_t* theclef; /* [JA] 2020-10-19 */ + cleftype_t* theclef;*/ /* [JA] 2020-10-19 */ int sharps; struct chord* thischord; int chordcount; diff --git a/drawtune.c b/drawtune.c index 0563938..d241dc8 100644 --- a/drawtune.c +++ b/drawtune.c @@ -48,7 +48,7 @@ extern int debugging; extern int pagenumbering; extern int barnums, nnbars; extern int make_open(); -extern void printlib(); +extern void printlib(FILE *f, char *filename, struct bbox *boundingbox); extern int count_dots(int *base, int *base_exp, int n, int m); extern void monospace(struct tune* t); @@ -427,8 +427,7 @@ void setscaling(char* s) scale = f; } -void setmargins(s) -char* s; +void setmargins(char *s) /* set margin values from string following -M in arglist */ { int i, j; @@ -446,8 +445,7 @@ char* s; }; } -void setpagesize(s) -char* s; +void setpagesize(char *s) /* set page size from string following -P in arglist */ { int i, j; @@ -483,12 +481,10 @@ char* s; scaledwidth = ((double)(pagewidth))/scale; } -static void set_space(afont, s) +static void set_space(struct font *afont, char *s) /* set vertical space to appear above a line in the given font */ /* s is a string specifying space in points (default), centimetres */ /* or inches */ -struct font* afont; -char* s; { int count; double x; @@ -506,10 +502,8 @@ char* s; }; } -static void init_font(afont, ptsize, spce, defnum, specialnum) +static void init_font(struct font *afont, int ptsize, int spce, int defnum, int specialnum) /* initialize font structure with given values */ -struct font* afont; -int ptsize, spce, defnum, specialnum; { afont->pointsize = ptsize; afont->space = spce; @@ -2082,8 +2076,7 @@ static void define_font(struct font* thefont, char* s) }; } -int read_boolean(s) -char *s; +int read_boolean(char *s) /* set logical parameter from %%command */ /* part of the handling for event_specific */ { @@ -2100,11 +2093,9 @@ char *s; return(result); } -void font_command(p, s) +void font_command(char *p, char *s) /* execute font-related %%commands */ /* called from event_specific */ -char* p; -char*s; { if (strcmp(p, "textfont") == 0) { define_font(&textfont, s); @@ -2718,10 +2709,7 @@ static void measureline(struct feature* ft, double* height, double* descender, *descender = -min; } -static void printtext(place, s, afont) -enum placetype place; -char* s; -struct font* afont; +static void printtext(enum placetype place, char *s, struct font *afont) /* print text a line of text in specified font at specified place */ { newblock((double)(afont->pointsize + afont->space), 0.0); @@ -2747,16 +2735,14 @@ void vskip(double gap) newblock(gap, 0.0); } -void centretext(s) -char* s; +void centretext(char *s) /* print text centred in the middle of the page */ /* used by %%centre command */ { printtext(centre, s, &textfont); } -void lefttext(s) -char* s; +void lefttext(char *s) /* print text up against the left hand margin */ /* used by %%text command */ { @@ -2860,9 +2846,7 @@ void setup_fonts() staffsep = VERT_GAP; } -void open_output_file(filename, boundingbox) -char* filename; -struct bbox* boundingbox; +void open_output_file(char *filename,struct bbox *boundingbox) /* open output file and write the abc2ps library to it */ { f = fopen(filename, "w"); @@ -2887,10 +2871,7 @@ void close_output_file() }; } -static int endrep(inend, end_string, x1, x2, yend) -int inend; -char* end_string; -double x1, x2, yend; +static int endrep(int inend, char *end_string, double x1, double x2, double yend) /* draws either 1st or 2nd ending marker */ { if (inend != 0) { @@ -3451,8 +3432,7 @@ static int finalsizeline(struct voice* v) return(1); } -static void finalsizetune(t) -struct tune* t; +static void finalsizetune(struct tune *t) /* calculate beaming and calculate height of each music line */ { struct voice* thisvoice; @@ -3507,8 +3487,7 @@ static int getlineheight(struct voice* v, double* height) return(1); } -static double tuneheight(t) -struct tune* t; +static double tuneheight(struct tune *t) /* measures the vertical space needed by the tune */ { char* atitle; diff --git a/genmidi.c b/genmidi.c index 93dcb76..ce06c54 100644 --- a/genmidi.c +++ b/genmidi.c @@ -295,9 +295,8 @@ char *featname[] = { "SPLITVOICE", "META", "PEDAL_ON", "PEDAL_OFF", "EFFECT" }; -void reduce(a, b) +void reduce(int *a, int *b) /* elimate common factors in fraction a/b */ -int *a, *b; { int sign; int t, n, m; @@ -325,10 +324,9 @@ int *a, *b; *b = *b/n; } -int gtfract(anum,adenom, bnum,bdenom) +int gtfract(int anum, int adenom, int bnum, int bdenom) /* compare two fractions anum/adenom > bnum/bdenom */ /* returns (a > b) */ -int anum,adenom,bnum,bdenom; { if ((anum*bdenom) > (bnum*adenom)) { return(1); @@ -339,9 +337,8 @@ int anum,adenom,bnum,bdenom; -void addunits(a, b) +void addunits(int a, int b) /* add a/b to the count of units in the bar */ -int a, b; { bar_num = bar_num*(b*b_denom) + (a*b_num)*bar_denom; bar_denom = bar_denom * (b*b_denom); @@ -389,8 +386,7 @@ for (j=0; j= 0) || (barno <= 0)) { @@ -576,10 +569,8 @@ int pass; }; } -static void save_state(vec, a, b, c, d, e, f) +static void save_state(int vec[6], int a, int b, int c, int d, int e, int f) /* save status when we go into a repeat */ -int vec[6]; -int a, b, c, d, e, f; { vec[0] = a; vec[1] = b; @@ -589,10 +580,8 @@ int a, b, c, d, e, f; vec[5] = f; /* [SS] 2013-11-02 */ } -static void restore_state(vec, a, b, c, d, e, f) +static void restore_state(int vec[6], int *a, int *b, int *c, int *d, int *e, int *f) /* restore status when we loop back to do second repeat */ -int vec[6]; -int *a, *b, *c, *d, *e, *f; { *a = vec[0]; *b = vec[1]; @@ -622,8 +611,7 @@ static int findchannel() } -static int findpart(j) -int j; +static int findpart(int j) /* find out where next part starts and update partno */ { int place; @@ -656,10 +644,9 @@ int j; return(place); } -static int partbreak(xtrack, voice, place) +static int partbreak(int xtrack, int voice, int place) /* come to part label in note data - check part length, then advance to */ /* next part if there was a P: field in the header */ -int xtrack, voice, place; { int newplace; @@ -673,10 +660,8 @@ int xtrack, voice, place; return(newplace); } -static int findvoice(initplace, voice, xtrack) +static int findvoice(int initplace, int voice, int xtrack) /* find where next occurrence of correct voice is */ -int initplace; -int voice, xtrack; { int foundvoice; int j; @@ -705,17 +690,15 @@ int voice, xtrack; return(j); } -static void text_data(s) +static void text_data(char *s) /* write text event to MIDI file */ -char* s; { mf_write_meta_event(delta_time, text_event, s, strlen(s)); tracklen = tracklen + delta_time; delta_time = 0L; } -static void karaokestarttrack (track) -int track; +static void karaokestarttrack (int track) /* header information for karaoke track based on w: fields */ { int j; @@ -804,8 +787,7 @@ static int check_wordextend(int startplace) return 0; } -static int findwline(startline) -int startline; +static int findwline(int startline) /* Find next line of lyrics at or after startline. */ { int place; @@ -902,7 +884,7 @@ int startline; -static int getword(place, w) +static int getword(int *place, int w) /* picks up next syllable out of w: field. * It strips out all the control codes ~ - _ * in the * words and sends each syllable out to the Karaoke track. @@ -922,8 +904,6 @@ static int getword(place, w) * karaoke track. The kspace variables signals that a * space was encountered. */ -int* place; -int w; { char syllable[200]; unsigned char c; /* [BY] 2012-10-03 */ @@ -1117,8 +1097,7 @@ int w; -static void write_syllable(place) -int place; +static void write_syllable(int place) /* Write out a syllable. This routine must check that it has a line of * lyrics and find one if it doesn't have one. The function is called * for each note encountered in feature[j] when the global variable @@ -1217,9 +1196,7 @@ static void checksyllables() musicsyllables = 0; } -static int inlist(place, passno) -int place; -int passno; +static int inlist(int place, int passno) /* decide whether passno matches list/number for variant section */ /* handles representation of [X in the abc */ { @@ -1266,9 +1243,8 @@ int passno; }; } -void set_meter(n, m) +void set_meter(int n, int m) /* set up variables associated with meter */ -int n, m; { mtime_num = n; mtime_denom = m; @@ -1295,9 +1271,8 @@ int n, m; }; } -static void write_meter(n, m) +static void write_meter(int n, int m) /* write meter to MIDI file */ -int n, m; { int t, dd; char data[4]; @@ -1326,9 +1301,8 @@ else mf_write_meta_event(0L, time_signature, data, 4); /* [SS] 2010-04-15 2010-07-06*/ } -static void write_keysig(sf, mi) +static void write_keysig(int sf, int mi) /* Write key signature to MIDI file */ -int sf, mi; { char data[2]; @@ -1337,10 +1311,8 @@ int sf, mi; mf_write_meta_event(0L, key_signature, data, 2); } -static void midi_noteon(delta_time, pitch, pitchbend, chan, vel) +static void midi_noteon(long delta_time, int pitch, int pitchbend, int chan, int vel) /* write note on event to MIDI file */ -long delta_time; -int pitch, chan, vel, pitchbend; { char data[2]; #ifdef NOFTELL @@ -1371,10 +1343,8 @@ int pitch, chan, vel, pitchbend; }; } -void midi_noteoff(delta_time, pitch, chan) +void midi_noteoff(long delta_time, int pitch, int chan) /* write note off event to MIDI file */ -long delta_time; -int pitch, chan; { char data[2]; @@ -1388,9 +1358,8 @@ int pitch, chan; }; } -static void noteon_data(pitch, pitchbend, channel, vel) +static void noteon_data(int pitch, int pitchbend, int channel, int vel) /* write note to MIDI file and adjust delta_time */ -int pitch, pitchbend, channel, vel; { midi_noteon(delta_time, pitch, pitchbend, channel, vel); tracklen = tracklen + delta_time; @@ -1613,8 +1582,7 @@ void articulated_stress_factors (int n, int *vel) } /* [SS] 2015-09-07 */ -int apply_velocity_increment_for_one_note (velocity) - int velocity; +int apply_velocity_increment_for_one_note (int velocity) { velocity = velocity + single_velocity_inc; if (velocity < 0) velocity = 0; @@ -1633,9 +1601,8 @@ int set_velocity_for_one_note () /* [SS] 2011-07-04 */ -static void noteon(n) +static void noteon(int n) /* compute note data and call noteon_data to write MIDI note event */ -int n; { int vel; vel = 0; /* [SS] 2013-11-04 */ @@ -1654,9 +1621,8 @@ int n; else noteon_data(pitch[n] + transpose + global_transpose, bentpitch[n], channel, vel); } -static void write_program(p, channel) +static void write_program(int p, int channel) /* write 'change program' (new instrument) command to MIDI file */ -int p, channel; { char data[1]; @@ -1673,12 +1639,8 @@ int p, channel; } /* [SS] 2015-07-27 */ -void write_event_with_delay(delta,event_type, channel, data, n) +void write_event_with_delay(int delta, int event_type, int channel, char data[], int n) /* write MIDI special event such as control_change or pitch_wheel */ -int delta; -int event_type; -int channel, n; -char data[]; { if (channel >= MAXCHANS) { event_error("Channel limit exceeded\n"); @@ -1687,11 +1649,8 @@ char data[]; }; } -void write_event(event_type, channel, data, n) +void write_event(int event_type, int channel, char data[], int n) /* write MIDI special event such as control_change or pitch_wheel */ -int event_type; -int channel, n; -char data[]; { if (channel >= MAXCHANS) { event_error("Channel limit exceeded\n"); @@ -1701,9 +1660,7 @@ char data[]; }; } -static char *select_channel(chan, s) -char *s; -int *chan; +static char *select_channel(int *chan, char *s) /* used by dodeferred() to set channel to be used */ /* reads 'bass', 'chord' or nothing from string pointed to by p */ { @@ -1726,8 +1683,7 @@ int *chan; return(p); } -static int makechordchannels (n) -int n; +static int makechordchannels (int n) { /* Allocate channels for in voice chords containing microtones. n is the number of channels to allocate which should be @@ -1889,14 +1845,11 @@ if (remainder == 0) { } /* [SS] 2020-08-09 */ -static void expand_array (shortarray, size, longarray, factor) +static void expand_array (int shortarray[], int size, int longarray[], int factor) /* if shortarray = {21,-40} and factor = 4 * longarray will be {5,6,5,5,-10,-10,-10,-10} * It is used for smoothing a bendstring. */ -int shortarray[], longarray[]; -int size; -int factor; { float increment, accumulator; float last_accumulator; @@ -1922,11 +1875,9 @@ for (i = 0; i< size; i++) { } -static void dodeferred(s,noteson) +static void dodeferred(char *s, int noteson) /* handle package-specific command which has been held over to be */ /* interpreted as MIDI is being generated */ -char* s; -int noteson; { char* p; char command[40]; @@ -2367,9 +2318,8 @@ int noteson; } -static void delay(a, b, c) +static void delay(int a, int b, int c) /* wait for time a/b */ -int a, b, c; { int dt; @@ -2382,10 +2332,8 @@ int a, b, c; timestep(dt, 0); } -static void save_note(num, denom, pitch, pitchbend, chan, vel) +static void save_note(int num, int denom, int pitch, int pitchbend, int chan, int vel) /* output 'note on' queue up 'note off' for later */ -int num, denom; -int pitch, pitchbend, chan, vel; { /* don't transpose drum channel */ if(chan == 9) {noteon_data(pitch, pitchbend, chan, vel); @@ -2397,14 +2345,13 @@ int pitch, pitchbend, chan, vel; -void dogchords(i) +void dogchords(int i) /* generate accompaniment notes */ /* note no microtone or linear temperament support ! */ -int i; { int j; if (g_ptr >= (int) strlen(gchord_seq)) g_ptr = 0; - if ((i == g_ptr) ) { /* [SS] 2018-06-23 */ + if (i == g_ptr) { /* [SS] 2018-06-23 */ int len; char action; @@ -2534,9 +2481,8 @@ int j; }; }; -void dodrums(i) +void dodrums(int i) /* generate drum notes */ -int i; { if (drum_ptr >= (int) strlen(drum_seq)) drum_ptr = 0; /* [SS] 2018-06-23 */ if (i == drum_ptr) { /* [SS] 2018-06-23 */ @@ -2586,8 +2532,7 @@ void stop_drone() -void progress_sequence(i) -int i; +void progress_sequence(int i) { if (gchordson) { dogchords(i); @@ -2853,9 +2798,8 @@ write_event(control_change, channel, data, 2); } -long writetrack(xtrack) +long writetrack(int xtrack) /* this routine writes a MIDI track */ -int xtrack; { int trackvoice; int inchord; @@ -3318,7 +3262,7 @@ int xtrack; if(feature[j] == VOICE) j = findvoice(j, trackvoice, xtrack); }; barno = barno + 1; - if ((j == notes) /* || (feature[j] == PLAY_ON_REP) */) { + if (j == notes /* || (feature[j] == PLAY_ON_REP) */) { /* end of tune was encountered before finding end of */ /* variant ending. */ sprintf(errmsg, diff --git a/matchsup.c b/matchsup.c index a4dfff3..f6be4a6 100755 --- a/matchsup.c +++ b/matchsup.c @@ -240,39 +240,33 @@ char *featname[] = { -void event_info (place) -char * place; +void event_info (char * place) { } -void event_gchord (chord) -char * chord; +void event_gchord (char * chord) { } -void event_slur (t) -int t; +void event_slur (int t) { } -void event_instruction (s) -char *s; +void event_instruction (char *s) { } -void event_reserved (p) -char p; +void event_reserved (char p) { } int bar_num, bar_denom, barno, barsize; int b_num,b_denom; -void reduce(a, b) +void reduce(int *a, int *b) /* elimate common factors in fraction a/b */ -int *a, *b; { int sign; int t, n, m; @@ -300,9 +294,8 @@ int *a, *b; *b = *b/n; } -void addunits(a, b) +void addunits(int a, int b) /* add a/b to the count of units in the bar */ -int a, b; { bar_num = bar_num*(b*b_denom) + (a*b_num)*bar_denom; bar_denom = bar_denom * (b*b_denom); @@ -310,9 +303,8 @@ int a, b; } -void set_meter(n, m) +void set_meter(int n, int m) /* set up variables associated with meter */ -int n, m; { /* set up barsize */ barsize = n; @@ -338,9 +330,8 @@ int n, m; int dummydecorator[DECSIZE]; /* used in event_chord */ -static struct voicecontext* newvoice(n) +static struct voicecontext* newvoice(int n) /* allocate and initialize the data for a new voice */ -int n; { struct voicecontext *s; int i; @@ -372,9 +363,8 @@ int n; return(s); } -static struct voicecontext* getvoicecontext(n) +static struct voicecontext* getvoicecontext(int n) /* find the data structure for a given voice number */ -int n; { struct voicecontext *p; struct voicecontext *q; @@ -415,32 +405,25 @@ static void clearvoicecontexts() -void event_text(s) +void event_text(char *s) /* text found in abc file */ -char *s; { } /* [JA] 2024-04-30 added in_I argument */ -void event_specific (package, s, in_I) -char *package, *s; -int in_I; +void event_specific (char *package, char *s, int in_I) { } -void event_x_reserved(p) +void event_x_reserved(char p) /* reserved character H-Z found in abc file */ -char p; { } -void event_abbreviation(symbol, string, container) +void event_abbreviation(char symbol, char *string, char container) /* abbreviation encountered - this is handled within the parser */ -char symbol; -char *string; -char container; { } @@ -469,23 +452,20 @@ void event_split_voice() -void event_tex(s) +void event_tex(char *s) /* TeX command found - ignore it */ -char *s; { } -void event_fatal_error(s) +void event_fatal_error(char *s) /* print error message and halt */ -char *s; { event_error(s); exit(1); } -void event_error(s) +void event_error(char *s) /* generic error handler */ -char *s; { if (noerror) return; #ifdef NOFTELL @@ -499,9 +479,8 @@ if (noerror) return; #endif } -void event_warning(s) +void event_warning(char *s) /* generic warning handler - for flagging possible errors */ -char *s; { if (nowarn) return; #ifdef NOFTELL @@ -515,9 +494,8 @@ if (nowarn) return; #endif } -static int autoextend(maxnotes) +static int autoextend(int maxnotes) /* increase the number of abc elements the program can cope with */ -int maxnotes; { int newlimit; int *ptr; @@ -562,9 +540,8 @@ int maxnotes; } -static void addfeature(f, p, n, d) +static void addfeature(int f, int p, int n, int d) /* place feature in internal table */ -int f, p, n, d; { feature[notes] = f; pitch[notes] = p; @@ -604,24 +581,20 @@ void event_startmusicline() addfeature(MUSICLINE, 0, 0, 0); } -void event_endmusicline(endchar) +void event_endmusicline(char endchar) /* finished parsing line of abc music */ -char endchar; { addfeature(MUSICSTOP, 0, 0, 0); } -static void textfeature(type, s) +static void textfeature(int type, char *s) /* called while parsing abc - stores an item which requires an */ /* associared string */ -int type; -char* s; { } -void event_comment(s) +void event_comment(char *s) /* comment found in abc */ -char *s; { } @@ -636,10 +609,8 @@ void event_closeinline() { } -void event_field(k, f) +void event_field(char k, char *f) /* Handles R: T: and any other field not handled elsewhere */ -char k; -char *f; { if (dotune) { switch (k) { @@ -668,17 +639,13 @@ char *f; } /* [JA] 2022.06.14 */ -void event_words(p, append, continuation) +void event_words(char *p, int append, int continuation) /* handles a w: field in the abc */ -char* p; -int append; -int continuation; { } /* [SS] 2014-08-16 */ -void appendfield (morewords) -char *morewords; +void appendfield (char *morewords) { printf("appendfield not implemented here\n"); } @@ -703,21 +670,18 @@ static void checkbreak() } -static void read_spec(spec, part) +static void read_spec(char spec[], struct vstring* part) /* converts a P: field to a list of part labels */ /* e.g. P:A(AB)3(CD)2 becomes P:AABABABCDCD */ /* A '+' indicates 'additive' behaviour (a part may include repeats). */ /* A '-' indicates 'non-additive' behaviour (repeat marks in the music */ /* are ignored and only repeats implied by the part order statement */ /* are played). */ -char spec[]; -struct vstring* part; { } -void event_part(s) +void event_part(char *s) /* handles a P: field in the abc */ -char* s; { char* p; @@ -754,13 +718,8 @@ char* s; }; } -void event_octave(int, int); - -void event_voice(n, s, vp) +void event_voice(int n, char *s, struct voice_params *vp) /* handles a V: field in the abc */ -int n; -char *s; -struct voice_params *vp; { if (pastheader || XTEN1) { voicesused = 1; @@ -782,9 +741,8 @@ struct voice_params *vp; } -void event_length(n) +void event_length(int n) /* handles an L: field in the abc */ -int n; { note_unit_length = 8; if (pastheader) { @@ -794,31 +752,24 @@ int n; }; } -void event_default_length (n) +void event_default_length (int n) /* handles a missing L: field in the abc */ - int n; { } -static void tempounits(t_num, t_denom) +static void tempounits(int *t_num, int *t_denom) /* interprets Q: once default length is known */ -int *t_num, *t_denom; { } -void event_tempo(n, a, b, rel, pre, post) +void event_tempo(int n, int a, int b, int rel, char *pre, char *post) /* handles a Q: field e.g. Q: a/b = n or Q: Ca/b = n */ /* strings before and after are ignored */ -int n; -int a, b, rel; -char *pre; -char *post; { } -void event_timesig (timesig) +void event_timesig (timesig_details_t *timesig) /* handles an M: field M:n/m */ - timesig_details_t *timesig; { int dobarchecks; @@ -839,11 +790,9 @@ void event_timesig (timesig) }; } -void event_octave(num, local) +void event_octave(int num, int local) /* used internally by other routines when octave=N is encountered */ /* in I: or K: fields */ -int num; -int local; { if (dotune) { if (pastheader || local) { @@ -854,9 +803,7 @@ int local; }; } -void event_info_key(key, value) -char* key; -char* value; +void event_info_key(char *key, char *value) { int num; @@ -866,8 +813,7 @@ char* value; }; } -static void stack_broken(v) -struct voicecontext* v; +static void stack_broken(struct voicecontext *v) { v->broken_stack[0] = v->laststart; v->broken_stack[1] = v->lastend; @@ -883,8 +829,7 @@ struct voicecontext* v; v->brokenpending = -1; } -static void restore_broken(v) -struct voicecontext* v; +static void restore_broken(struct voicecontext *v) { if (v->brokenpending != -1) { event_error("Unresolved broken rhythm in grace notes"); @@ -954,8 +899,7 @@ void event_rep2() */ } -void event_playonrep(s) -char* s; +void event_playonrep(char *s) /* [X in the abc, where X is a list of numbers */ { int num, converted; @@ -978,9 +922,8 @@ static void slurtotie() { } -void event_sluron(t) +void event_sluron(int t) /* called when ( is encountered in the abc */ -int t; { if (t == 1) { addfeature(SLUR_ON, 0, 0, 0); @@ -988,9 +931,8 @@ int t; }; } -void event_sluroff(t) +void event_sluroff(int t) /* called when ) is encountered */ -int t; { if (t == 0) { slurtotie(); @@ -1012,17 +954,14 @@ void event_space() /* printf("Space event\n"); */ } -void event_lineend(ch, n) +void event_lineend(char ch, int n) /* called when \ or ! or * or ** is encountered at the end of a line */ -char ch; -int n; { /* ignore */ } -void event_broken(type, mult) +void event_broken(int type, int mult) /* handles > >> >>> < << <<< in the abc */ -int type, mult; { if (v->inchord) { event_error("Broken rhythm not allowed in chord"); @@ -1037,9 +976,8 @@ int type, mult; }; } -void event_tuple(n, q, r) +void event_tuple(int n, int q, int r) /* handles triplets (3 and general tuplets (n:q:r in the abc */ -int n, q, r; { if (tuplecount > 0) { event_error("nested tuples"); @@ -1092,9 +1030,8 @@ void event_chord() void event_ignore () { }; /* [SS] 2018-12-21 */ -static void lenmul(n, a, b) +static void lenmul(int n, int a, int b) /* multiply note length by a/b */ -int n, a, b; { if ((feature[n] == NOTE) || (feature[n] == REST) || (feature[n] == CHORDOFF)) { @@ -1195,15 +1132,12 @@ static void marknote() } /* just a stub to ignore 'y' */ -void event_spacing(n, m) -int n,m; +void event_spacing(int n, int m) { } -void event_rest(decorators,n,m,type) +void event_rest(int decorators[DECSIZE],int n,int m,int type) /* rest of n/m in the abc */ -int n, m,type; -int decorators[DECSIZE]; { int num, denom; @@ -1244,11 +1178,10 @@ int decorators[DECSIZE]; }; } -void event_mrest(n,m,c) +void event_mrest(int n, int m, char c) /* multiple bar rest of n/m in the abc */ /* we check for m == 1 in the parser */ -int n, m; -char c; /* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ +/* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ { int i; int decorators[DECSIZE]; @@ -1303,21 +1236,17 @@ void event_chordoff(int chord_n, int chord_m) } -void event_finger(p) +void event_finger(char *p) /* a 1, 2, 3, 4 or 5 has been found in a guitar chord field */ -char *p; { /* does nothing */ } -static int pitchof(note, accidental, mult, octave, propogate_accs) +static int pitchof(char note, char accidental, int mult, int octave, int propogate_accs) /* finds MIDI pitch value for note */ /* if propogate_accs is 1, apply any accidental to all instances of */ /* that note in the bar. If propogate_accs is 0, accidental does not */ /* apply to other notes */ -char note, accidental; -int mult, octave; -int propogate_accs; { int p; char acc; @@ -1346,10 +1275,9 @@ int propogate_accs; -static void hornp(num, denom) +static void hornp(int num, int denom) /* If we have used R:hornpipe, this routine modifies the rhythm by */ /* applying appropriate broken rhythm */ -int num, denom; { if ((hornpipe) && (notes > 0) && (feature[notes-1] != GT)) { if ((num*last_denom == last_num*denom) && (num == 1) && @@ -1368,14 +1296,8 @@ int num, denom; } -void event_note(decorators, clef, accidental, mult, note, xoctave, n, m) +void event_note(int decorators[DECSIZE], cleftype_t *clef, char accidental, int mult, char note, int xoctave, int n, int m) /* handles a note in the abc */ -int decorators[DECSIZE]; -cleftype_t *clef; -char accidental; -int mult; -char note; -int xoctave, n, m; { int pitch; int pitch_noacc; @@ -1444,10 +1366,10 @@ void event_normal_tone() -char *get_accidental(place, accidental) +char *get_accidental(char *place, char *accidental) /* read in accidental - used by event_handle_gchord() */ -char *place; /* place in string being parsed */ -char *accidental; /* pointer to char variable */ +//char *place; /* place in string being parsed */ +//char *accidental; /* pointer to char variable */ { char *p; @@ -1464,25 +1386,21 @@ char *accidental; /* pointer to char variable */ return(p); } -void event_handle_gchord(s) +void event_handle_gchord(char *s) /* handler for the guitar chords */ -char* s; { } -void event_handle_instruction(s) +void event_handle_instruction(char *s) /* handler for ! ! instructions */ /* does ppp pp p mp mf f ff fff */ /* also does !drum! and !nodrum! */ -char* s; { } -static void setmap(sf, map, mult) +static void setmap(int sf, char map[7], int mult[7]) /* 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 sf; /* number of sharps in key signature -7 to +7 */ { int j; @@ -1506,11 +1424,8 @@ int mult[7]; if (sf <= -7) map['f'-'a'] = '_'; } -static void altermap(v, modmap, modmul) +static void altermap(struct voicecontext *v, char modmap[7], int modmul[7]) /* apply modifiers to a set of accidentals */ -struct voicecontext* v; -char modmap[7]; -int modmul[7]; { int i; @@ -1522,9 +1437,8 @@ int modmul[7]; }; } -static void copymap(v) +static void copymap(struct voicecontext *v) /* sets up working map at the start of each bar */ -struct voicecontext* v; { int j; @@ -1537,17 +1451,13 @@ struct voicecontext* v; /* workaround for problems with PCC compiler */ /* data may be written to an internal buffer */ -int myputc(c) -char c; +int myputc(char c) { return (putc(c,fp)); } -static void addfract(xnum, xdenom, a, b) +static void addfract(int *xnum, int *xdenom, int a, int b) /* add a/b to the count of units in the bar */ -int *xnum; -int *xdenom; -int a, b; { *xnum = (*xnum)*b + a*(*xdenom); *xdenom = (*xdenom) * b; @@ -1555,11 +1465,10 @@ int a, b; } -static void dotie(j, xinchord,voiceno) +static void dotie(int j, int xinchord, int voiceno) /* called in preprocessing stage to handle ties */ /* we need the voiceno in case a tie is broken by a */ /* voice switch. */ -int j, xinchord,voiceno; { int tienote, place; int tietodo, done; @@ -1753,10 +1662,8 @@ static void zerobar() bar_denom = 1; } -void event_bar(type, replist) +void event_bar(int type, char *replist) /* handles bar lines of various types in the abc */ -int type; -char* replist; { int newtype; #ifdef DEBUG @@ -1879,21 +1786,24 @@ static void headerprocess() voicesused = 0; } -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, - gotkey, gotclef, clefname, clef, - octave, transpose, gotoctave, gottranspose, explict) +void event_key( /* handles a K: field */ -int sharps; /* sharps is number of sharps in key signature */ -char *s; /* original string following K: */ -int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ -char modmap[7]; /* array of accidentals to be applied */ -int modmul[7]; /* array giving multiplicity of each accent (1 or 2) */ -struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ -int gotkey, gotclef; -char* clefname; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int octave, transpose, gotoctave, gottranspose; -int explict; + int sharps, /* sharps is number of sharps in key signature */ + char *s, /* original string following K: */ + int modeindex, /* 0 major, 1,2,3 minor, 4 locrian, etc. */ + char modmap[7], /* array of accidentals to be applied */ + int modmul[7], /* array giving multiplicity of each accent (1 or 2) */ + struct fraction modmicrotone[7], /* [SS] 2014-01-06 */ + int gotkey, + int gotclef, + char* clefname, + cleftype_t *clef, /* [JA] 2020-10-19 */ + int octave, + int transpose, + int gotoctave, + int gottranspose, + int explict + ) { int minor; strncpy(keysignature,s,16); @@ -1993,9 +1903,8 @@ void event_blankline() }; } -void event_refno(n) +void event_refno(int n) /* handles an X: field (which indicates the start of a tune) */ -int n; { foundtitle = 0; /* [SS] 2014-01-10 */ if (dotune) { diff --git a/mftext.c b/mftext.c index 2f7178c..be9d0a7 100644 --- a/mftext.c +++ b/mftext.c @@ -16,6 +16,8 @@ void initfuncs(); void midifile(); +extern char* crack(int argc, char *argv[], char *flags, int ign); +extern FILE *efopen(char *name, char *mode); static FILE *F; int SECONDS; /* global that tells whether to display seconds or ticks */ @@ -30,13 +32,9 @@ int filegetc() /* for crack */ extern int arg_index; -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char *argv[]) { - FILE *efopen(); char *ch; - char *crack(); SECONDS = 0; @@ -59,9 +57,7 @@ char **argv; } FILE * -efopen(name,mode) -char *name; -char *mode; +efopen(char *name, char *mode) { FILE *f; @@ -72,8 +68,7 @@ char *mode; return(f); } -void error(s) -char *s; +void error(char *s) { fprintf(stderr,"Error: %s\n",s); } @@ -86,8 +81,7 @@ void prtime() printf("Time=%ld ",Mf_currtime); } -void txt_header(format,ntrks,ldivision) -int format, ntrks, ldivision; +void txt_header(int format, int ntrks, int ldivision) { division = ldivision; printf("Header format=%d ntrks=%d division=%d\n",format,ntrks,division); @@ -103,29 +97,25 @@ void txt_trackend() printf("Track end\n"); } -void txt_noteon(chan,pitch,vol) -int chan, pitch, vol; +void txt_noteon(int chan, int pitch, int vol) { prtime(); printf("Note on, chan=%d pitch=%d vol=%d\n",chan+1,pitch,vol); } -void txt_noteoff(chan,pitch,vol) -int chan, pitch, vol; +void txt_noteoff(int chan, int pitch, int vol) { prtime(); printf("Note off, chan=%d pitch=%d vol=%d\n",chan+1,pitch,vol); } -void txt_pressure(chan,pitch,press) -int chan, pitch,press; +void txt_pressure(int chan, int pitch, int press) { prtime(); printf("Pressure, chan=%d pitch=%d press=%d\n",chan+1,pitch,press); } -void txt_parameter(chan,control,value) -int chan, control, value; +void txt_parameter(int chan, int control, int value) { prtime(); printf("Parameter, chan=%d c1=%d c2=%d\n",chan+1,control,value); @@ -133,54 +123,43 @@ int chan, control, value; /* [SS] 2017-11-16 submitted by Jonathan Hough (msb,lsb interchanged) */ -void txt_pitchbend(chan,lsb,msb) -int chan, msb, lsb; +void txt_pitchbend(int chan, int lsb, int msb) { prtime(); printf("Pitchbend, chan=%d lsb=%d msb=%d\n",chan+1,msb,lsb); } -void txt_program(chan,program) -int chan, program; +void txt_program(int chan, int program) { prtime(); printf("Program, chan=%d program=%d\n",chan+1,program); } -void txt_chanpressure(chan,press) -int chan, press; +void txt_chanpressure(int chan, int pitch, int press) { prtime(); printf("Channel pressure, chan=%d pressure=%d\n",chan+1,press); } -void txt_sysex(leng,mess) -int leng; -char *mess; +void txt_sysex(int leng, char *mess) { prtime(); printf("Sysex, leng=%d\n",leng); } -void txt_metamisc(type,leng,mess) -int type, leng; -char *mess; +void txt_metamisc(int type, int leng, char *mess) { prtime(); printf("Meta event, unrecognized, type=0x%02x leng=%d\n",type,leng); } -void txt_metaspecial(type,leng,mess) -int type, leng; -char *mess; +void txt_metaspecial(int type, int leng, char *mess) { prtime(); printf("Meta event, sequencer-specific, type=0x%02x leng=%d\n",type,leng); } -void txt_metatext(type,leng,mess) -int type, leng; -char *mess; +void txt_metatext(int type, int leng, char *mess) { static char *ttype[] = { NULL, @@ -209,8 +188,7 @@ char *mess; printf(">\n"); } -void txt_metaseq(num) -int num; +void txt_metaseq(int num) { prtime(); printf("Meta event, sequence number = %d\n",num); @@ -222,23 +200,20 @@ void txt_metaeot() printf("Meta event, end of track\n"); } -void txt_keysig(sf,mi) -int sf,mi; +void txt_keysig(int sf, int mi) { prtime(); printf("Key signature, sharp/flats=%d minor=%d\n",sf,mi); } -void txt_tempo(ltempo) -long ltempo; +void txt_tempo(long ltempo) { tempo = ltempo; prtime(); printf("Tempo, microseconds-per-MIDI-quarter-note=%ld\n",tempo); } -void txt_timesig(nn,dd,cc,bb) -int nn, dd, cc, bb; +void txt_timesig(int nn, int dd, int cc, int bb) { int denom = 1; while ( dd-- > 0 ) @@ -248,17 +223,14 @@ int nn, dd, cc, bb; nn,denom,cc,bb); } -void txt_smpte(hr,mn,se,fr,ff) -int hr, mn, se, fr, ff; +void txt_smpte(int hr, int mn, int se, int fr, int ff) { prtime(); printf("SMPTE, hour=%d minute=%d second=%d frame=%d fract-frame=%d\n", hr,mn,se,fr,ff); } -void txt_arbitrary(leng,mess) -int leng; /* [SDE] 2020-06-03 */ -char *mess; +void txt_arbitrary(int leng, char *mess) { prtime(); printf("Arbitrary bytes, leng=%d\n",leng); diff --git a/midi2abc.c b/midi2abc.c index b6e0380..d846d07 100644 --- a/midi2abc.c +++ b/midi2abc.c @@ -238,8 +238,8 @@ char *origin = NULL; /* for adding O: info from argv[] */ int newline_flag = 0; /* [SS] 2019-06-14 signals new line was just issued */ -void remove_carriage_returns(); -int validnote(); +void remove_carriage_returns(char *); +int validnote(int); void printpitch(struct anote*); void printfract(int, int); void txt_trackend(); @@ -267,8 +267,7 @@ int filegetc() } -void fatal_error(s) -char* s; +void fatal_error(char *s) /* fatal error encounterd - abort program */ { fprintf(stderr, "%s\n", s); @@ -276,8 +275,7 @@ char* s; } -void event_error(s) -char *s; +void event_error(char *s) /* problem encountered but OK to continue */ { char msg[256]; @@ -287,9 +285,8 @@ char *s; } -int* checkmalloc(bytes) +int* checkmalloc(int bytes) /* malloc with error checking */ -int bytes; { int *p; @@ -302,9 +299,8 @@ int bytes; -char* addstring(s) +char* addstring(char *s) /* create space for string and store it in memory */ -char* s; { char* p; int numbytes; @@ -322,11 +318,9 @@ char* s; return(p); } -void addtext(s, type) +void addtext(char *s, int type) /* add structure for text */ /* used when parsing MIDI file */ -char* s; -int type; { struct tlistx* newx; @@ -347,12 +341,9 @@ int type; } /* [SS] 2019-05-2019 forwards text to track[chn] */ -void addtext_type0(s, type,chn) +void addtext_type0(char *s, int type, int chn) /* add structure for text */ /* used when parsing MIDI file */ -char* s; -int type; -int chn; { struct tlistx* newx; @@ -388,9 +379,8 @@ struct dlistx* playinghead; struct dlistx* playingtail; -void noteplaying(p) +void noteplaying(struct anote *p) /* This function adds a new note to the playinghead list. */ -struct anote* p; { struct dlistx* newx; @@ -411,10 +401,9 @@ struct anote* p; } -void addnote(p, ch, v) +void addnote(int p, int ch, int v) /* add structure for note */ /* used when parsing MIDI file */ -int p, ch, v; { struct listx* newx; struct anote* newnote; @@ -445,10 +434,9 @@ int p, ch, v; } /* [SS] 2019-05-29 forwards note to track[ch] */ -void addnote_type0(p, ch, v) +void addnote_type0(int p, int ch, int v) /* add structure for note */ /* used when parsing MIDI file */ -int p, ch, v; { struct listx* newx; struct anote* newnote; @@ -480,10 +468,9 @@ int p, ch, v; -void notestop(p, ch) +void notestop(int p, int ch) /* MIDI note stops */ /* used when parsing MIDI file */ -int p, ch; { struct dlistx* i; int found; @@ -526,9 +513,7 @@ int p, ch; FILE * -efopen(name,mode) -char *name; -char *mode; +efopen(char *name, char *mode) { FILE *f; @@ -540,8 +525,7 @@ char *mode; return(f); } -void error(s) -char *s; +void error(char *s) { fprintf(stderr,"Error: %s\n",s); } @@ -549,8 +533,7 @@ char *s; -void txt_header(xformat,ntrks,ldivision) -int xformat, ntrks, ldivision; +void txt_header(int xformat, int ntrks, int ldivision) { division = ldivision; format = xformat; @@ -620,8 +603,7 @@ void txt_trackend() trackcount = trackcount + 1; } -void txt_noteon(chan,pitch,vol) -int chan, pitch, vol; +void txt_noteon(int chan, int pitch, int vol) { if ((xchannel == -1) || (chan == xchannel)) { if (vol != 0) { @@ -634,8 +616,7 @@ int chan, pitch, vol; } /* [SS] 2019-05-29 new. Calls addnote_type0() function */ -void txt_noteon_type0(chan,pitch,vol) -int chan, pitch, vol; +void txt_noteon_type0(int chan, int pitch, int vol) { if ((xchannel == -1) || (chan == xchannel)) { if (vol != 0) { @@ -647,34 +628,30 @@ int chan, pitch, vol; }; } -void txt_noteoff(chan,pitch,vol) -int chan, pitch, vol; +void txt_noteoff(int chan, int pitch, int vol) { if ((xchannel == -1) || (chan == xchannel)) { notestop(pitch, chan); }; } -void txt_pressure(chan,pitch,press) -int chan, pitch, press; +void txt_pressure(int chan, int pitch, int press) { } -void txt_parameter(chan,control,value) -int chan, control, value; +void txt_parameter(int chan, int control, int value) { } -void txt_pitchbend(chan,lsb,msb) -int chan, msb, lsb; +void txt_pitchbend(int chan, int lsb, int msb) { int pitchbend; pitchbend = (msb*128 + lsb); chanbend[chan+1] = pitchbend; } -unsigned char sysexsnt[7] = {240, 127, 0, 8, 2, 0, 1}; +char sysexsnt[7] = {-16, 127, 0, 8, 2, 0, 1}; float sysexBentPitches[128]; @@ -683,9 +660,7 @@ int i; for (i=0; i<128; i++) sysexBentPitches[i]=0.0; } -void txt_sysex_snt (leng,mess) -int leng; -unsigned char *mess; +void txt_sysex_snt (int leng, char *mess) { int i; int midipitch; @@ -715,7 +690,7 @@ if (leng == 12) { cents = (int) (0.5 + ratio*100.0); modifiedPitch = (float) (midipitch + ratio); sysexBentPitches[midipitch] = modifiedPitch; - /*sysexBentPitches[newpitch] = modifiedPitch; /* why */ + /*sysexBentPitches[newpitch] = modifiedPitch;*/ /* why */ /*printf("%d %d %d %d %f %d\n",midipitch,newpitch,low,hi,ratio,cents);*/ /*printf("sysext: %d %d\n",newpitch,cents);*/ @@ -724,8 +699,7 @@ if (leng == 12) { } } -void txt_program(chan,program) -int chan, program; +void txt_program(int chan, int program) { /* suppress the %%MIDI program for channel 10 */ if (chan == 9) return; /* [SS] 2020-02-17 */ @@ -739,8 +713,7 @@ int chan, program; } /* [SS] 2019-05-29 new. Calls addtext_type0 function. */ -void txt_program_type0(chan,program) -int chan, program; +void txt_program_type0(int chan, int program) { if (chan == 9) return; /* [SS] 2020-02-17 */ sprintf(textbuff, "%%%%MIDI program %d", program); @@ -752,27 +725,19 @@ int chan, program; */ } -void txt_sysex(leng,mess) -int leng; -char *mess; +void txt_sysex(int leng, char *mess) { } -void txt_metamisc(type,leng,mess) -int type, leng; -char *mess; +void txt_metamisc(int type, int leng, char *mess) { } -void txt_metaspecial(type,leng,mess) -int type, leng; -char *mess; +void txt_metaspecial(int type, int leng, char *mess) { } -void txt_metatext(type,leng,mess) -int type, leng; -char *mess; +void txt_metatext(int type, int leng, char *mess) { char *ttype[] = { NULL, @@ -819,8 +784,7 @@ char *mess; }; } -void txt_metaseq(num) -int num; +void txt_metaseq(int num) { sprintf(textbuff, "%%Meta event, sequence number = %d",num); addtext(textbuff,0); @@ -831,8 +795,7 @@ void txt_metaeot() { } -void txt_keysig(sf,mi) -char sf, mi; +void txt_keysig(int sf, int mi) { int accidentals; gotkeysig =1; @@ -863,8 +826,7 @@ char sf, mi; else printf("\n"); } -void txt_tempo(ltempo) -long ltempo; +void txt_tempo(long ltempo) { if(tempocount>0) return; /* ignore other tempo indications */ tempo = ltempo; @@ -872,8 +834,7 @@ long ltempo; } -void setup_timesig(nn, denom, bb) -int nn,denom,bb; +void setup_timesig(int nn, int denom, int bb) { asig = nn; bsig = denom; @@ -899,8 +860,7 @@ int nn,denom,bb; } -void txt_timesig(nn,dd,cc,bb) -int nn, dd, cc, bb; +void txt_timesig(int nn, int dd, int cc, int bb) { int denom = 1; while ( dd-- > 0 ) @@ -921,14 +881,11 @@ int nn, dd, cc, bb; } -void txt_smpte(hr,mn,se,fr,ff) -int hr, mn, se, fr, ff; +void txt_smpte(int hr, int mn, int se, int fr, int ff) { } -void txt_arbitrary(leng,mess) -char *mess; -int leng; +void txt_arbitrary(int leng, char *mess) { } @@ -939,13 +896,14 @@ int leng; void no_op0() {} void no_op1(int dummy1) {} void no_op2(int dummy1, int dummy2) {} + void no_op2_is(int dummy1, char *dummy2) {} void no_op3(int dummy1, int dummy2, int dummy3) { } + void no_op3_iis(int dummy1, int dummy2, char * 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; +void print_txt_header(int xformat, int ntrks, int ldivision) { division = ldivision; format = xformat; @@ -953,8 +911,7 @@ int xformat, ntrks, ldivision; } -void print_txt_noteon(chan, pitch, vol) -int chan, pitch, vol; +void print_txt_noteon(int chan, int pitch, int vol) { int start_time; int initvol; @@ -977,8 +934,7 @@ else { -void print_txt_noteoff(chan, pitch, vol) -int chan, pitch, vol; +void print_txt_noteoff(int chan, int pitch, int vol) { int start_time,initvol; @@ -996,8 +952,7 @@ if (start_time >= 0) } -void print_txt_noteoff_and_bends(chan, pitch, vol) -int chan, pitch, vol; +void print_txt_noteoff_and_bends(int chan, int pitch, int vol) /* substitutes pitchbend for volume */ { int start_time,initvol; @@ -1132,8 +1087,7 @@ char* s = name; } -void pitch2drum(midipitch) -int midipitch; +void pitch2drum(int midipitch) { static char *drumpatches[] = { "Acoustic Bass Drum", "Bass Drum 1", "Side Stick", "Acoustic Snare", @@ -1177,8 +1131,7 @@ void mftxt_trackstart() -void mftxt_noteon(chan,pitch,vol) -int chan, pitch, vol; +void mftxt_noteon(int chan, int pitch, int vol) { char *key; /* @@ -1192,8 +1145,7 @@ int chan, pitch, vol; } -void mftxt_noteoff(chan,pitch,vol) -int chan, pitch, vol; +void mftxt_noteoff(int chan, int pitch, int vol) { char *key; /* @@ -1207,16 +1159,15 @@ int chan, pitch, vol; -void mftxt_polypressure(chan,pitch,press) -int chan, pitch, press; +void mftxt_polypressure(int chan, int pitch, int press) { char *key; if (prtime(timeunits)) return; key = pitch2key(pitch); printf("Polyphonic Key Pressure %2d %3s %3d\n",chan+1,key,press); } -void mftxt_chanpressure(chan,pitch,press) -int chan, pitch, press; + +void mftxt_chanpressure(int chan, int pitch, int press) { char *key; if (prtime(timeunits)) return; @@ -1225,8 +1176,7 @@ int chan, pitch, press; } -void mftxt_pitchbend(chan,lsb,msb) -int chan, lsb, msb; +void mftxt_pitchbend(int chan, int lsb, int msb) { float bend; int pitchbend; @@ -1243,8 +1193,7 @@ int chan, lsb, msb; } -void mftxt_program(chan,program) -int chan, program; +void mftxt_program(int chan, int program) { static char *patches[] = { "Acoustic Grand","Bright Acoustic","Electric Grand","Honky-Tonk", @@ -1299,8 +1248,7 @@ static char *patches[] = { -void mftxt_parameter(chan,control,value) -int chan, control, value; +void mftxt_parameter(int chan, int control, int value) { /* removal of spaces [SS] 2022-04-06 in ctype array */ static char *ctype[] = { @@ -1377,9 +1325,7 @@ int chan, control, value; } -void mftxt_metatext(type,leng,mess) -int type, leng; -char *mess; +void mftxt_metatext(int type, int leng, char *mess) { static char *ttype[] = { NULL, @@ -1414,8 +1360,7 @@ char *mess; -void mftxt_keysig(sf,mi) -int sf, mi; +void mftxt_keysig(int sf, int mi) { static char *major[] = {"Cb", "Gb", "Db", "Ab", "Eb", "Bb", "F", "C", "G", "D", "A", "E", "B", "F#", "C#"}; @@ -1432,8 +1377,7 @@ int sf, mi; -void mftxt_tempo(ltempo) -long ltempo; +void mftxt_tempo(long ltempo) { tempo = ltempo; if (prtime(timeunits)) return; @@ -1441,8 +1385,7 @@ long ltempo; } -void mftxt_timesig(nn,dd,cc,bb) -int nn, dd, cc, bb; +void mftxt_timesig(int nn, int dd, int cc, int bb) { int denom = 1; while ( dd-- > 0 ) @@ -1454,8 +1397,7 @@ int nn, dd, cc, bb; } -void mftxt_smpte(hr,mn,se,fr,ff) -int hr, mn, se, fr, ff; +void mftxt_smpte(int hr, int mn, int se, int fr, int ff) { if (prtime(timeunits)) return; printf("Metatext SMPTE, %d:%d:%d %d=%d\n", hr,mn,se,fr,ff); @@ -1470,62 +1412,62 @@ void mftxt_metaeot() 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 = txt_pitchbend; - Mf_program = print_txt_program; - Mf_chanpressure = no_op3; - Mf_sysex = txt_sysex_snt; - 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; + 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 = &txt_pitchbend; + Mf_program = &print_txt_program; + Mf_chanpressure = &no_op3; + Mf_sysex = &txt_sysex_snt; + Mf_metamisc = &no_op3_iis; + 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_midipitch() { initfunc_for_midinotes(); -Mf_noteoff = print_txt_noteoff_and_bends; +Mf_noteoff = &print_txt_noteoff_and_bends; } 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_polypressure; - Mf_parameter = mftxt_parameter; - Mf_pitchbend = mftxt_pitchbend; - Mf_program = mftxt_program; - Mf_chanpressure = mftxt_chanpressure; - 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; + 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_polypressure; + Mf_parameter = &mftxt_parameter; + Mf_pitchbend = &mftxt_pitchbend; + Mf_program = &mftxt_program; + Mf_chanpressure = &mftxt_chanpressure; + Mf_sysex = &no_op2_is; + Mf_metamisc = &no_op3_iis; + 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; } @@ -1533,38 +1475,37 @@ void initfunc_for_mftext() 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; + 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) +void postprocess(int 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; @@ -1586,8 +1527,7 @@ int trackno; }; } -void scannotes(trackno) -int trackno; +void scannotes(int trackno) /* diagnostic routine to output notes in a track */ { struct listx* i; @@ -1603,9 +1543,7 @@ int trackno; } -int xnum_to_next_nonchordal_note(fromitem,spare,quantum) -struct listx* fromitem; -int spare,quantum; +int xnum_to_next_nonchordal_note(struct listx *fromitem, int spare, int quantum) { struct anote* jnote; struct listx* nextitem; @@ -1624,10 +1562,9 @@ while (nextitem != NULL && i < 5) { return 0; } -int quantize(trackno, xunit) +int quantize(int trackno, int 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; @@ -1682,9 +1619,8 @@ int trackno, xunit; } -void guesslengths(trackno) +void guesslengths(int trackno) /* work out most appropriate value for a unit of musical time */ -int trackno; { int i; int trial[100]; @@ -1710,11 +1646,9 @@ xunit_set = 1; } -int findana(maintrack, barsize) +int findana(int maintrack, int 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; @@ -1737,8 +1671,7 @@ int barsize; -int guessana(barbeats) -int barbeats; +int guessana(int barbeats) /* try to guess length of anacrusis */ { int score[64]; @@ -1768,8 +1701,7 @@ int barbeats; } -int findkey(maintrack) -int maintrack; +int findkey(int maintrack) /* work out what key MIDI file is in */ /* algorithm is simply to minimize the number of accidentals needed. */ { @@ -1933,9 +1865,8 @@ void checkchordlist() /* checkchordlist(); */ } -void addtochord(p) +void addtochord(struct anote *p) /* used when printing out abc */ -struct anote* p; { struct dlistx* newx; struct dlistx* place; @@ -1978,9 +1909,8 @@ struct anote* p; checkchordlist(); } -struct dlistx* removefromchord(i) +struct dlistx* removefromchord(struct dlistx *i) /* used when printing out abc */ -struct dlistx* i; { struct dlistx* newi; @@ -2003,9 +1933,8 @@ struct dlistx* i; return(newi); } -int findshortest(gap) +int findshortest(int gap) /* find the first note in the chord to terminate */ -int gap; { int min, v; struct dlistx* p; @@ -2023,9 +1952,8 @@ int gap; return(min); } -void advancechord(len) +void advancechord(int len) /* adjust note lengths for all notes in the chord */ -int len; { struct dlistx* p; @@ -2136,9 +2064,8 @@ for (j=0;j<127;j++) { -int testtrack(trackno, barbeats, anacrusis) +int testtrack(int trackno, int barbeats, int anacrusis) /* print out one track as abc */ -int trackno, barbeats, anacrusis; { struct listx* i; int step, gap; @@ -2194,9 +2121,8 @@ int trackno, barbeats, anacrusis; return(breakcount); } -void printpitch(j) +void printpitch(struct anote *j) /* convert numerical value to abc pitch */ -struct anote* j; { int p, po,i; @@ -2226,8 +2152,7 @@ struct anote* j; }; } -static void reduce(a, b) -int *a, *b; +static void reduce(int *a, int *b) { int t, n, m; @@ -2251,10 +2176,9 @@ while (m != 0) { -void printfract(a, b) +void printfract(int a, int b) /* print fraction */ /* used when printing abc */ -int a, b; { int c, d; @@ -2270,10 +2194,9 @@ int a, b; }; } -void printchord(len) +void printchord(int 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; @@ -2317,12 +2240,8 @@ int len; newline_flag = 0; /* [SS] 2019-06-14 */ } -char dospecial(i, barnotes, featurecount,allow_broken,allow_triplets) +char dospecial(struct listx *i, int *barnotes, int *featurecount, int allow_broken, int 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; @@ -2414,8 +2333,7 @@ int allow_broken,allow_triplets; return(' '); } -int validnote(n) -int n; +int validnote(int n) /* work out a step which can be expressed as a musical time */ { int v; @@ -2435,14 +2353,11 @@ int n; return(v); } -void handletext(t, textplace, trackno) +void handletext(long t, struct tlistx **textplace, int 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; @@ -2859,9 +2774,8 @@ void printtrack_split (int trackno, int splitnum, int anacrusis) freshline(); /* [SS] 2019-06-17 */ } -void printtrack_split_voice(trackno, anacrusis) +void printtrack_split_voice(int trackno, int anacrusis) /* print out one track as abc */ -int trackno, anacrusis; { int splitnum; long now; @@ -2889,9 +2803,8 @@ int trackno, anacrusis; -void printtrack(trackno, anacrusis) +void printtrack(int trackno, int anacrusis) /* print out one track as abc */ -int trackno, anacrusis; { struct listx* i; struct tlistx* textplace; @@ -3038,8 +2951,8 @@ void remove_carriage_returns(char *str) abc file. */ char * loc; -while (loc = (char *) strchr(str,'\r')) *loc = ' '; -while (loc = (char *) strchr(str,'\n')) *loc = ' '; +while ((loc = (char *) strchr(str,'\r'))) *loc = ' '; +while ((loc = (char *) strchr(str,'\n'))) *loc = ' '; } @@ -3065,8 +2978,7 @@ void reset_back_array () for (i=0;i<256;i++) back[i] = barback[i]; } -void setupkey(sharps) -int sharps; +void setupkey(int sharps) /* set up variables related to key signature */ { char sharp[13], flat[13], shsymbol[13], flsymbol[13]; @@ -3147,10 +3059,9 @@ reset_back_array(); /* [SS] 2019-05-08 */ /* Functions for supporting the command line user interface to midi2abc. */ -int readnum(num) +int readnum(char *num) /* read a number from a string */ /* used for processing command line */ -char *num; { int t; char *p; @@ -3172,10 +3083,9 @@ char *num; } -int readnump(p) +int readnump(char **p) /* read a number from a string (subtly different) */ /* used for processing command line */ -char **p; { int t; @@ -3193,11 +3103,9 @@ char **p; } -void readsig(a, b, sig) +void readsig(int *a, int *b, char *sig) /* read time signature */ /* used for processing command line */ -int *a, *b; -char *sig; { char *p; int t; @@ -3246,11 +3154,8 @@ for (i= 0;i<8;i++) { return(0); } -int getarg(option, argc, argv) +int getarg(char *option, int argc, char *argv[]) /* extract arguments from command line */ -char *option; -char *argv[]; -int argc; { int j, place; @@ -3263,11 +3168,9 @@ int argc; return (place); } -int huntfilename(argc, argv) +int huntfilename(int argc, char *argv[]) /* look for filename argument if -f option is missing */ /* assumes filename does not begin with '-' */ -char *argv[]; -int argc; { int j, place; @@ -3289,9 +3192,7 @@ int argc; return(place); } -int process_command_line_arguments(argc,argv) -char *argv[]; -int argc; +int process_command_line_arguments(int argc, char *argv[]) { int val; int arg; @@ -3565,9 +3466,7 @@ int argc; -void midi2abc (arg, argv) -char *argv[]; -int arg; +void midi2abc (int arg, char *argv[]) { int voiceno; int accidentals; /* used for printing summary */ @@ -3764,9 +3663,7 @@ if (trackcount == 1) { fclose(outhandle); } -void midigram(argc,argv) -char *argv[]; -int argc; +void midigram(int argc, char *argv[]) { int i; int verylasttick; @@ -3783,9 +3680,7 @@ for (i=0;i<17;i++) { /*printf("%d\n",verylasttick);*/ } -void mftext(argc,argv) -char *argv[]; -int argc; +void mftext(int argc, char *argv[]) { int i; initfunc_for_mftext(); @@ -3799,11 +3694,8 @@ mfread(); -int main(argc,argv) -char *argv[]; -int argc; +int main(int argc, char *argv[]) { - FILE *efopen(); int arg; zeroBentPitches (); diff --git a/midicopy.c b/midicopy.c index 00bacba..3dc7176 100644 --- a/midicopy.c +++ b/midicopy.c @@ -66,8 +66,8 @@ /* Functions to be called while processing the MIDI file. */ -int (*Mf_arbitrary) () = NULLFUNC; -int (*Mf_seqspecific) () = NULLFUNC; +int (*Mf_arbitrary) (int, char *) = NULLFUNC; +int (*Mf_seqspecific) (int, char *) = NULLFUNC; /* Functions to implement in order to write a MIDI file */ int (*Mf_writetempotrack) () = NULLFUNC; @@ -80,10 +80,13 @@ int mf_write_meta_event (int type, char *data, int size); void mf_write_track_chunk (int which_track, FILE * fp); void mferror (char *s); int eputc (char c); -void append_to_string (); +void append_to_string (int c); void winamp_compatibility_measure (); void writechanmsg_at_0 (); void copy_noteoff (int chan, int c1, int c2); +static void write32bit(long); +static void write16bit(int); + int Mf_nomerge = 0; /* 1 => continue'ed system exclusives are */ /* not collapsed. */ @@ -121,9 +124,9 @@ int transpose = 0; /* [SS] 2024-08-11 */ long Mf_numbyteswritten = 0L; long readvarinum (); long read32bit (); -long to32bit (); +long to32bit (int,int,int,int); int read16bit (); -int to16bit (); +int to16bit (int, int); char *msg (); int seconds_to_tick (float seconds); float tick_to_seconds (int tick); @@ -135,7 +138,7 @@ void sysex (); void chanmessage (int, int, int); void msginit (); int msgleng (); -void msgadd (); +void msgadd (int); void biggermsg (); void WriteVarLen (long); @@ -389,8 +392,7 @@ copy_metatext (int type, int length, char *m) } void -midicopy_timesig (c1, c2, c3, c4) -int c1, c2, c3, c4; +midicopy_timesig (int c1, int c2, int c3, int c4) { char data[4]; data[0] = (char) c1; @@ -401,8 +403,7 @@ int c1, c2, c3, c4; } void -copy_keysig (c1, c2) -int c1, c2; +copy_keysig (int c1, int c2) { char data[2]; data[0] = (char) c1; @@ -414,8 +415,7 @@ int c1, c2; /* Metaevents */ /* 2015-11-14 [SS] */ void -copy_metaseqnum (c1, c2) -unsigned char c1,c2; +copy_metaseqnum (unsigned char c1, unsigned char c2) { char data[2]; data[0] = (char) c1; @@ -441,7 +441,6 @@ copy_metamisc (int type, int length, char *m) void copy_metaeot () { - void WriteVarLen (); WriteVarLen (10); Mf_currcopytime += 10; eputc ((char) 0xff); @@ -490,7 +489,7 @@ alloc_trackdata () if (trackdata != NULL) free (trackdata); /* double it since running status is not preserved [SS] 2013-10-08 */ -/* add another two bytes to cover winamp_compatibility +/* add another two bytes to cover winamp_compatibility */ /* for very short tracks. [SS] 2017-09-12 */ /* There is no penalty for allocating to much. */ if (Mf_toberead < 2) Mf_toberead = 64; /* to handle MIDI header */ @@ -506,8 +505,7 @@ alloc_trackdata () int -readmt (s) /* read through the "MThd" or "MTrk" header string */ - char *s; +readmt (char *s) /* read through the "MThd" or "MTrk" header string */ { int n = 0; char *p = s; @@ -935,8 +933,7 @@ get_tempo_info_from_track_1 () void -badbyte (c) - int c; +badbyte (int c) { char buff[32]; @@ -1115,8 +1112,7 @@ readvarinum () long -to32bit (c1, c2, c3, c4) - int c1, c2, c3, c4; +to32bit (int c1, int c2, int c3, int c4) { long value = 0L; @@ -1131,8 +1127,7 @@ to32bit (c1, c2, c3, c4) int -to16bit (c1, c2) - int c1, c2; +to16bit (int c1, int c2) { return ((c1 & 0xff) << 8) + (c2 & 0xff); } @@ -1283,12 +1278,9 @@ printf("\n"); */ void -build_new_midi_file (format, ntracks, division, fp) - int format, ntracks, division; - FILE *fp; +build_new_midi_file (int format, int ntracks, int division, FILE *fp) { int i,j; - void mf_write_track_chunk (); float track_time; seconds_output = 0.0; @@ -1398,9 +1390,7 @@ replace_byte_in_file (int trknum, int loc, char val, FILE * fp, int ntracks) void -mf_write_track_chunk (which_track, fp) - int which_track; - FILE *fp; +mf_write_track_chunk (int which_track, FILE *fp) /* We may not know how many tracks that we will output, so * each track is transfered to a separate string in the * array trackstr[]. At the end these strings will be @@ -1408,8 +1398,6 @@ mf_write_track_chunk (which_track, fp) */ { long trkhdr, trklength; - void write16bit (), write32bit (); - void WriteVarLen (); trkhdr = MTrk; @@ -1426,11 +1414,9 @@ mf_write_track_chunk (which_track, fp) void -mf_write_header_chunk (format, ntracks, division) - int format, ntracks, division; +mf_write_header_chunk (int format, int ntracks, int division) { long ident, length; - void write16bit (), write32bit (); ident = MThd; /* Head chunk identifier */ length = 6; /* Chunk length */ @@ -1470,7 +1456,6 @@ int mf_write_midi_event (int type, int chan, char *data, int size) { int i; - void WriteVarLen (); char c; WriteVarLen (Mf_currtime - Mf_currcopytime); @@ -1516,7 +1501,6 @@ int mf_write_meta_event (int type, char *data, int size) { int i; - void WriteVarLen (); WriteVarLen (Mf_currtime - Mf_currcopytime); if (!cut_beginning ()) @@ -1543,8 +1527,7 @@ mf_write_meta_event (int type, char *data, int size) void -mf_get_tempo_event (tempo) - long tempo; +mf_get_tempo_event (long tempo) { tempo_array[temposize].seconds = (float) (Mf_currtime - tempo_array[temposize - 1].tick) * @@ -1559,15 +1542,12 @@ mf_get_tempo_event (tempo) void -mf_write_tempo (tempo) - long tempo; +mf_write_tempo (long tempo) { /* Write tempo */ /* all tempos are written as 120 beats/minute, */ /* expressed in microseconds/quarter note */ - void WriteVarLen (); - if (Mf_currtime - Mf_currcopytime < 0) eputc (0); else @@ -1605,8 +1585,7 @@ mf_write_tempo (tempo) * Write multi-length bytes to MIDI format files */ void -WriteVarLen (value) - long value; +WriteVarLen (long value) { long buffer; @@ -1651,8 +1630,7 @@ WriteVarLen (value) * */ void -write32bit (data) - long data; +write32bit (long data) { putc ((char) ((data >> 24) & 0xff), fp); putc ((char) ((data >> 16) & 0xff), fp); @@ -1661,8 +1639,7 @@ write32bit (data) } void -write16bit (data) - int data; +write16bit (int data) { putc ((char) ((data & 0xff00) >> 8), fp); putc ((char) (data & 0xff), fp); diff --git a/midicopy.h b/midicopy.h index b4f4137..0203a8b 100644 --- a/midicopy.h +++ b/midicopy.h @@ -1,6 +1,5 @@ /* definitions for MIDI file writing code */ -float mf_ticks2sec(); -long mf_sec2ticks(); +long mf_sec2ticks(float secs, int division, long tempo); void mfwrite(); void mfread(); diff --git a/midifile.c b/midifile.c index 9b9e1b2..3d1d7eb 100644 --- a/midifile.c +++ b/midifile.c @@ -77,7 +77,7 @@ char *strcpy(), *strcat(); /* Functions to be called while processing the MIDI file. */ int (*Mf_getc)() = NULLFUNC; void (*Mf_error)() = NULLFUNC; -void (*Mf_header)() = NULLFUNC; +void (*Mf_header)(int, int, int) = NULLFUNC; void (*Mf_trackstart)() = NULLFUNC; void (*Mf_trackend)() = NULLFUNC; void (*Mf_noteon)() = NULLFUNC; @@ -88,20 +88,20 @@ void (*Mf_pitchbend)() = NULLFUNC; void (*Mf_program)() = NULLFUNC; void (*Mf_chanpressure)() = NULLFUNC; void (*Mf_sysex)() = NULLFUNC; -void (*Mf_arbitrary)() = NULLFUNC; +void (*Mf_arbitrary)(int, char *) = NULLFUNC; void (*Mf_metamisc)() = NULLFUNC; -void (*Mf_seqnum)() = NULLFUNC; +void (*Mf_seqnum)(int) = 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; +void (*Mf_smpte)(int,int,int,int,int) = NULLFUNC; +void (*Mf_tempo)(long) = NULLFUNC; +void (*Mf_timesig)(int,int,int,int) = NULLFUNC; +void (*Mf_keysig)(int, int) = NULLFUNC; +void (*Mf_seqspecific)(int, char *) = NULLFUNC; +void (*Mf_text)(int, int, char *) = NULLFUNC; /* Functions to implement in order to write a MIDI file */ -int (*Mf_putc)() = NULLFUNC; -long (*Mf_writetrack)() = NULLFUNC; +int (*Mf_putc)(char c) = NULLFUNC; +long (*Mf_writetrack)(int) = NULLFUNC; int (*Mf_writetempotrack)() = NULLFUNC; int Mf_nomerge = 0; /* 1 => continue'ed system exclusives are */ @@ -116,29 +116,29 @@ long Mf_numbyteswritten = 0L; /* linking with store.c */ static long readvarinum(); static long read32bit(); -static long to32bit(); +static long to32bit(int,int,int,int); static int read16bit(); -static int to16bit(); +static int to16bit(int, int); 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 badbyte(int); +static void metaevent(int); static void sysex(); -static void chanmessage(); +static void chanmessage(int, int, int); static void msginit(); -static void msgadd(); +static void msgadd(int); 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 void mf_write_track_chunk(int, FILE *); +static void mf_write_header_chunk(int, int, int); +static void WriteVarLen(long); +static void write32bit(long); +static void write16bit(int); static int msgleng(); -static int eputc(); +static int eputc(char c); /* end of block */ @@ -163,8 +163,7 @@ void mfread() /* The only non-static function in this file. */ } -void mfreadtrk(itrack) /* The only non-static function in this file. */ -int itrack; +void mfreadtrk(int itrack) /* The only non-static function in this file. */ { int track,ok; if ( Mf_getc == NULLFUNC ) @@ -190,8 +189,7 @@ void midifile() } static int -readmt(s) /* read through the "MThd" or "MTrk" header string */ -char *s; +readmt(char *s) /* read through the "MThd" or "MTrk" header string */ { int n = 0; char *p = s; @@ -395,8 +393,7 @@ readtrack() /* read a track chunk */ } static void -badbyte(c) -int c; +badbyte(int c) { char buff[96]; /* [SS] 2022.02.08 */ @@ -405,8 +402,7 @@ int c; } static void -metaevent(type) -int type; +metaevent(int type) { int leng; char *m; @@ -479,9 +475,7 @@ sysex() } static void -chanmessage(status,c1,c2) -int status; -int c1, c2; +chanmessage(int status, int c1, int c2) { int chan = status & 0xf; @@ -512,7 +506,7 @@ int c1, c2; break; case 0xd0: if ( Mf_chanpressure ) - (*Mf_chanpressure)(chan,c1); + (*Mf_chanpressure)(chan,c1,c2); // chan+press -> chan+pitch+press ??? break; } } @@ -539,8 +533,7 @@ readvarinum() } static long -to32bit(c1,c2,c3,c4) -int c1, c2, c3, c4; +to32bit(int c1, int c2, int c3, int c4) { long value = 0L; @@ -552,8 +545,7 @@ int c1, c2, c3, c4; } static int -to16bit(c1,c2) -int c1, c2; +to16bit(int c1, int c2) { return ((c1 & 0xff ) << 8) + (c2 & 0xff); } @@ -580,8 +572,7 @@ read16bit() } /* static */ -void mferror(s) - char *s; +void mferror(char *s) { if ( Mf_error ) { (*Mf_error)(s); @@ -620,8 +611,7 @@ msgleng() } static void -msgadd(c) -int c; +msgadd(int c) { /* If necessary, allocate larger message buffer. */ if ( Msgindex >= Msgsize ) @@ -687,9 +677,7 @@ biggermsg() * to work with Mf_putc. */ void -mfwrite(format,ntracks,division,fp) -int format,ntracks,division; -FILE *fp; +mfwrite(int format, int ntracks, int division, FILE *fp) { int i; @@ -717,10 +705,9 @@ FILE *fp; int nullpass = 0; #endif -int nullputc(c) +int nullputc(char c) /* dummy putc for abc checking option */ /* also used for FTELL work-around */ -char c; { int t; @@ -729,9 +716,7 @@ char c; } static void -mf_write_track_chunk(which_track,fp) -int which_track; -FILE *fp; +mf_write_track_chunk(int which_track, FILE *fp) { long trkhdr,trklength; long offset, place_marker; @@ -742,7 +727,7 @@ FILE *fp; #ifdef NOFTELL int (*tempfunc)() = NULLFUNC; - extern int myputc(); + extern int myputc(char c); trkhdr = MTrk; trklength = 0; @@ -842,8 +827,7 @@ printf("length = %d\n",(int) trklength); static void -mf_write_header_chunk(format,ntracks,division) -int format,ntracks,division; +mf_write_header_chunk(int format, int ntracks, int division) { long ident,length; @@ -879,11 +863,7 @@ int format,ntracks,division; * 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; +mf_write_midi_event(long delta_time, int type, int chan, char *data, int size) { int i; char c; @@ -922,11 +902,7 @@ char *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; +mf_write_meta_event(long delta_time, int type, char *data, int size) { int i; @@ -950,8 +926,7 @@ int size; } /* end mf_write_meta_event */ void -mf_write_tempo(tempo) -long tempo; +mf_write_tempo(long tempo) { /* Write tempo */ /* all tempos are written as 120 beats/minute, */ @@ -975,10 +950,7 @@ long tempo; * */ long -mf_sec2ticks(secs,division,tempo) -float secs; -int division; -long tempo; +mf_sec2ticks(float secs, int division, long tempo) { long ticks; float smpte_format, smpte_resolution; @@ -998,8 +970,7 @@ long tempo; * Write multi-length bytes to MIDI format files */ static void -WriteVarLen(value) -long value; +WriteVarLen(long value) { long buffer; @@ -1049,7 +1020,7 @@ zz = 0x7f & zz; eputc(xx); eputc(yy); eputc(zz); -eputc(247); /* 0xf7 terminates sysex command */ +eputc(0xf7); /* 0xf7 terminates sysex command */ } /* @@ -1059,10 +1030,7 @@ eputc(247); /* 0xf7 terminates sysex command */ * */ float -mf_ticks2sec(ticks,division,tempo) -int division; -long tempo; -long ticks; +mf_ticks2sec(long ticks, int division, long tempo) { float ret; float smpte_format, smpte_resolution; @@ -1090,8 +1058,7 @@ long ticks; * */ static void -write32bit(data) -long data; +write32bit(long data) { eputc((char)((data >> 24) & 0xff)); eputc((char)((data >> 16) & 0xff)); @@ -1100,16 +1067,14 @@ long data; } static void -write16bit(data) -int data; +write16bit(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; +static int eputc(char c) { int return_val; diff --git a/midifile.h b/midifile.h index 6bdb46d..0dc739d 100644 --- a/midifile.h +++ b/midifile.h @@ -4,40 +4,40 @@ 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_noteon)(int, int, int); +extern void (*Mf_noteoff)(int, int, int); +extern void (*Mf_pressure)(int, int, int); +extern void (*Mf_parameter)(int, int, int); +extern void (*Mf_pitchbend)(int, int, int); +extern void (*Mf_program)(int, int); +extern void (*Mf_chanpressure)(int, int, int); +extern void (*Mf_sysex)(int leng, char *mess); +extern void (*Mf_metamisc)(int, int, char *); 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_timesig)(int,int,int,int); +extern void (*Mf_smpte)(int,int,int,int,int); extern void (*Mf_tempo)(); -extern void (*Mf_keysig)(); +extern void (*Mf_keysig)(int, int); extern void (*Mf_arbitrary)(); -extern void (*Mf_error)(); +extern void (*Mf_error)(char *); extern long Mf_currtime; extern int Mf_nomerge; /* definitions for MIDI file writing code */ -extern int (*Mf_putc)(); +extern int (*Mf_putc)(char c); extern long (*Mf_writetrack)(); extern int (*Mf_writetempotrack)(); -float mf_ticks2sec(); -long mf_sec2ticks(); -void mfwrite(); +float mf_ticks2sec(long ticks, int division, long tempo); +long mf_sec2ticks(float secs, int division, long tempo); +void mfwrite(int format, int ntracks, int division, FILE *fp); void mfread(); -int mf_write_meta_event(); -int mf_write_midi_event(); -void mf_write_tempo(); -void mferror(); +int mf_write_meta_event(long delta_time, int type, char *data, int size); +int mf_write_midi_event (long delta_time, int type, int chan, char *data, int size); +void mf_write_tempo(long); +void mferror(char *); /* MIDI status commands most significant bit is 1 */ #define note_off 0x80 diff --git a/midistats.c b/midistats.c index 06f7c56..eafb9b4 100644 --- a/midistats.c +++ b/midistats.c @@ -313,8 +313,7 @@ int filegetc() } -void fatal_error(s) -char* s; +void fatal_error(char *s) /* fatal error encounterd - abort program */ { fprintf(stderr, "%s\n", s); @@ -322,8 +321,7 @@ char* s; } -void event_error(s) -char *s; +void event_error(char *s) /* problem encountered but OK to continue */ { char msg[256]; @@ -333,9 +331,8 @@ char *s; } -int* checkmalloc(bytes) +int* checkmalloc(int bytes) /* malloc with error checking */ -int bytes; { int *p; @@ -350,9 +347,7 @@ int bytes; FILE * -efopen(name,mode) -char *name; -char *mode; +efopen(char *name, char *mode) { FILE *f; @@ -364,16 +359,14 @@ char *mode; return(f); } -void error(s) -char *s; +void error(char *s) { fprintf(stderr,"Error: %s\n",s); } /* [SS] 2017-11-19 */ -void stats_error(s) -char *s; +void stats_error(char *s) { fprintf(stderr,"Error: %s\n",s); fprintf(stderr,"activetrack %d\n",tracknum); @@ -388,7 +381,9 @@ char *s; void no_op0() {} void no_op1(int dummy1) {} void no_op2(int dummy1, int dummy2) {} + void no_op2_is(int dummy1, char *dummy2) {} void no_op3(int dummy1, int dummy2, int dummy3) { } + void no_op3_iis(int dummy1, int dummy2, char *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) { } @@ -435,8 +430,7 @@ char* s = name; } -void pitch2drum(midipitch) -int midipitch; +void pitch2drum(int midipitch) { static char *drumpatches[] = { "Acoustic Bass Drum", "Bass Drum 1", "Side Stick", "Acoustic Snare", @@ -708,9 +702,7 @@ float histogram_entropy (int *histogram, int size) -void output_count_trkdata(data_array,name) -int data_array[]; -char *name; +void output_count_trkdata(int data_array[], char *name) { int i,sum; sum = 0; @@ -892,8 +884,7 @@ tracknm.eighthUnit = unit; -void stats_noteon(chan,pitch,vol) -int chan, pitch, vol; +void stats_noteon(int chan, int pitch, int vol) { int delta; int barnum; @@ -930,7 +921,7 @@ int chan, pitch, vol; } } - if (abs(Mf_currtime - last_on_tick[chan+1]) < chordthreshold) trkdata.chordcount[chan+1]++; + if (labs(Mf_currtime - last_on_tick[chan+1]) < chordthreshold) trkdata.chordcount[chan+1]++; else trkdata.notecount[chan+1]++; /* [SS] 2019-08-02 */ lastTick[chan*128 + pitch] = Mf_currtime; last_on_tick[chan+1] = Mf_currtime; /* [SS] 2019-08-02 */ @@ -1006,15 +997,13 @@ void stats_noteoff(int chan,int pitch,int vol) } -void stats_pitchbend(chan,lsb,msb) -int chan, lsb, msb; +void stats_pitchbend(int chan, int lsb, int msb) { trkdata.pitchbend[0]++; trkdata.pitchbend[chan+1]++; } -void stats_pressure(chan,press) -int chan, press; +void stats_pressure(int chan, int pitch, int press) { trkdata.pressure[0]++; trkdata.pressure[chan+1]++; /* [SS] 2022.04.28 */ @@ -1022,8 +1011,7 @@ trkdata.pressure[chan+1]++; /* [SS] 2022.04.28 */ -void stats_program(chan,program) -int chan, program; +void stats_program(int chan, int program) { int beatnumber; if (program <0 || program > 127) return; /* [SS] 2018-03-06 */ @@ -1041,8 +1029,7 @@ if (trkdata.program[chan+1] != 0) { -void stats_parameter(chan,control,value) -int chan, control, value; +void stats_parameter(int chan, int control, int value) { int chan1; chan1 = chan+1; @@ -1058,9 +1045,7 @@ trkdata.cntlparam[chan1]++; -void stats_metatext(type,leng,mess) -int type, leng; -char *mess; +void stats_metatext(int type, int leng, char *mess) { int i; if (type == 5) hasLyrics = 1; /* [SS] 2023-10-30 */ @@ -1074,8 +1059,7 @@ printf("\n"); /* [SS] 2018-01-02 */ -void stats_keysig(sf,mi) -int sf, mi; +void stats_keysig(int sf, int mi) { float beatnumber; static char *major[] = {"Cb", "Gb", "Db", "Ab", "Eb", "Bb", "F", @@ -1086,19 +1070,19 @@ int sf, mi; beatnumber = Mf_currtime/division; index = sf + 7; if (index < 0 || index >12) return; - if (mi) - if (noOutput == 0) + if (noOutput == 0) { + if (mi) { printf("keysig %s %d %d %6.2f\n",minor[index],sf,mi,beatnumber); - else - if (noOutput == 0) + } else { printf("keysig %s %d %d %6.2f\n",major[index],sf,mi,beatnumber); + } + } } /* [SS] 2018-01-02 */ -void stats_tempo(ltempo) -long ltempo; +void stats_tempo(long ltempo) { float beatnumber; tempo = ltempo; @@ -1110,8 +1094,7 @@ long ltempo; } -void stats_timesig(nn,dd,cc,bb) -int nn, dd, cc, bb; +void stats_timesig(int nn, int dd, int cc, int bb) { float beatnumber; int denom = 1; @@ -1174,56 +1157,56 @@ void load_header (int format, int ntrks, int ldivision) void initfunc_for_stats() { int i; - 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 = stats_eot; - 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; + 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_is; + Mf_metamisc = &no_op3_iis; + Mf_seqnum = &no_op1; + Mf_eot = &stats_eot; + 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; for (i = 0; i< 2047; i++) pulseCounter[i] = 0; } void initfunc_for_loadNoteEvents() { - Mf_error = error; - Mf_header = load_header; - Mf_trackstart = no_op0; - Mf_trackend = record_trackend; - Mf_noteon = record_noteon; - Mf_noteoff = record_noteoff; - Mf_pressure = no_op3; - Mf_parameter = no_op3; - Mf_pitchbend = no_op3; - Mf_program = no_op0; - Mf_chanpressure = no_op3; - Mf_sysex = no_op2; - Mf_metamisc = no_op3; - Mf_seqnum = no_op1; - Mf_eot = no_op0; - Mf_timesig = no_op4; - Mf_smpte = no_op5; - Mf_tempo = record_tempo; - Mf_keysig = no_op2; - Mf_seqspecific = no_op3; - Mf_text = no_op3; - Mf_arbitrary = no_op2; + Mf_error = &error; + Mf_header = &load_header; + Mf_trackstart = &no_op0; + Mf_trackend = &record_trackend; + Mf_noteon = &record_noteon; + Mf_noteoff = &record_noteoff; + Mf_pressure = &no_op3; + Mf_parameter = &no_op3; + Mf_pitchbend = &no_op3; + Mf_program = &no_op0; + Mf_chanpressure = &no_op3; + Mf_sysex = &no_op2_is; + Mf_metamisc = &no_op3_iis; + Mf_seqnum = &no_op1; + Mf_eot = &no_op0; + Mf_timesig = &no_op4; + Mf_smpte = &no_op5; + Mf_tempo = &record_tempo; + Mf_keysig = &no_op2; + Mf_seqspecific = &no_op3; + Mf_text = &no_op3; + Mf_arbitrary = &no_op2; } void dumpMidievents (int from , int to) @@ -1688,10 +1671,9 @@ printf("%d\t%d\t%d\t%d\t%d\t%d\n",lasttrack,nchannels, division,bpm,lastEvent,la -int readnum(num) +int readnum(char *num) /* read a number from a string */ /* used for processing command line */ -char *num; { int t; char *p; @@ -1713,10 +1695,9 @@ char *num; } -int readnump(p) +int readnump(char **p) /* read a number from a string (subtly different) */ /* used for processing command line */ -char **p; { int t; @@ -1734,11 +1715,8 @@ char **p; } -int getarg(option, argc, argv) +int getarg(char *option, int argc, char *argv[]) /* extract arguments from command line */ -char *option; -char *argv[]; -int argc; { int j, place; @@ -1751,11 +1729,9 @@ int argc; return (place); } -int huntfilename(argc, argv) +int huntfilename(int argc, char *argv[]) /* look for filename argument if -f option is missing */ /* assumes filename does not begin with '-' */ -char *argv[]; -int argc; { int j, place; @@ -1777,9 +1753,7 @@ int argc; return(place); } -int process_command_line_arguments(argc,argv) -char *argv[]; -int argc; +int process_command_line_arguments(int argc, char *argv[]) { int val; int arg; @@ -1913,9 +1887,7 @@ int argc; -void midistats(argc,argv) -char *argv[]; -int argc; +void midistats(int argc,char *argv[]) { initfunc_for_stats(); Mf_getc = filegetc; @@ -1971,11 +1943,8 @@ if (pitchclassanalysis) { -int main(argc,argv) -char *argv[]; -int argc; +int main(int argc, char *argv[]) { - FILE *efopen(); int arg; arg = process_command_line_arguments(argc,argv); diff --git a/parseabc.c b/parseabc.c index 46d7faf..5d28112 100755 --- a/parseabc.c +++ b/parseabc.c @@ -139,9 +139,8 @@ int modeminor[10] = { 0, 1, 1, int modekeyshift[10] = { 0, 5, 5, 5, 6, 0, 1, 2, 3, 4 }; int * -checkmalloc (bytes) +checkmalloc (int bytes) /* malloc with error checking */ - int bytes; { int *p; @@ -155,9 +154,8 @@ checkmalloc (bytes) } char * -addstring (s) +addstring (char *s) /* create space for string and store it in memory */ - char *s; { char *p; @@ -167,9 +165,7 @@ addstring (s) } /* [SS] 2014-08-16 [SDG] 2020-06-03 */ -char * concatenatestring(s1,s2) - char * s1; - char * s2; +char * concatenatestring(char * s1, char * s2) { int len = strlen(s1) + strlen(s2) + 1; char *p = (char *) checkmalloc(len); @@ -183,8 +179,7 @@ char * concatenatestring(s1,s2) void -initvstring (s) - struct vstring *s; +initvstring (struct vstring *s) /* initialize vstring (variable length string data structure) */ { s->len = 0; @@ -194,8 +189,7 @@ initvstring (s) } void -extendvstring (s) - struct vstring *s; +extendvstring (struct vstring *s) /* doubles character space available in string */ { char *p; @@ -215,9 +209,7 @@ extendvstring (s) } void -addch (ch, s) - char ch; - struct vstring *s; +addch (char ch, struct vstring *s) /* appends character to vstring structure */ { if (s->len >= s->limit) @@ -230,9 +222,7 @@ addch (ch, s) } void -addtext (text, s) - char *text; - struct vstring *s; +addtext (char *text, struct vstring *s) /* appends a string to vstring data structure */ { int newlen; @@ -247,8 +237,7 @@ addtext (text, s) } void -clearvstring (s) - struct vstring *s; +clearvstring (struct vstring *s) /* set string to empty */ /* does not deallocate memory ! */ { @@ -257,8 +246,7 @@ clearvstring (s) } void -freevstring (s) - struct vstring *s; +freevstring (struct vstring *s) /* deallocates memory allocated for string */ { if (s->st != NULL) @@ -286,8 +274,7 @@ parseroff () } /* [SS] 2017-04-12 */ -void handle_abc2midi_parser (line) -char *line; +void handle_abc2midi_parser (char *line) { char *p; p = line; @@ -301,11 +288,8 @@ if (strncasecmp(p,"%%MidiOn",8) == 0) { int -getarg (option, argc, argv) +getarg (char *option, int argc, char *argv[]) /* look for argument 'option' in command line */ - char *option; - char *argv[]; - int argc; { int j, place; @@ -321,8 +305,7 @@ getarg (option, argc, argv) } void -skipspace (p) - char **p; +skipspace (char **p) { /* skip space and tab */ while (((int) **p == ' ') || ((int) **p == TAB)) @@ -330,16 +313,14 @@ skipspace (p) } void -skiptospace (p) - char **p; +skiptospace (char **p) { while (((int) **p != ' ') && ((int) **p != TAB) && (int) **p != '\0') *p = *p + 1; } int -readnumf (num) - char *num; +readnumf (char *num) /* read integer from string without advancing character pointer */ { int t; @@ -364,8 +345,7 @@ readnumf (num) } int -readsnumf (s) - char *s; +readsnumf (char *s) /* reads signed integer from string without advancing character pointer */ { char *p; @@ -384,8 +364,7 @@ readsnumf (s) } int -readnump (p) - char **p; +readnump (char **p) /* read integer from string and advance character pointer */ { int t; @@ -405,8 +384,7 @@ readnump (p) } int -readsnump (p) - char **p; +readsnump (char **p) /* reads signed integer from string and advance character pointer */ { if (**p == '-') @@ -612,9 +590,7 @@ static void read_L_unitlen(int *num, int *denom, char **place) } void -read_microtone_value (a, b, p) - int *a, *b; - char **p; +read_microtone_value (int *a, int *b, char **p) /* read length part of a note and advance character pointer */ { int t; @@ -658,9 +634,7 @@ read_microtone_value (a, b, p) } int -ismicrotone (p, dir) - char **p; - int dir; +ismicrotone (char **p, int dir) { int a, b; char *chp; /* [HL] 2020-06-20 */ @@ -712,13 +686,11 @@ int isclef (char *s, cleftype_t * new_clef, } char * -readword (word, s) +readword (char word[], char *s) /* part of parsekey, extracts word from input line */ /* besides the space, the symbols _, ^, and = are used */ /* as separators in order to handle key signature modifiers. */ /* [SS] 2010-05-24 */ - char word[]; - char *s; { char *p; int i; @@ -743,12 +715,10 @@ readword (word, s) } char * -readword_with_ (word, s) +readword_with_ (char word[], char *s) /* This version allows ^ and _ characters to be embedded in*/ -/* the string. It is needed to parse clef=treble_8 or +/* the string. It is needed to parse clef=treble_8 or */ /* clef=treble^8 . [SS] 2024-02-23 */ - char word[]; - char *s; { char *p; int i; @@ -770,9 +740,8 @@ readword_with_ (word, s) return (p); } void -lcase (s) +lcase (char *s) /* convert word to lower case */ - char *s; { char *p; @@ -981,13 +950,14 @@ int interpret_voice_label (char *s, int num, int *is_new) int -parseclef (s, word, gotclef, clefstr, newclef, gotoctave, octave) - char **s; - char *word; - int *gotclef; - char *clefstr; /* [JA] 2020-10-19 */ - cleftype_t * newclef; - int *gotoctave, *octave; +parseclef ( + char **s, + char *word, + int *gotclef, + char *clefstr, /* [JA] 2020-10-19 */ + cleftype_t * newclef, + int *gotoctave, int *octave + ) /* extracts string clef= something */ { int successful; @@ -1024,12 +994,12 @@ parseclef (s, word, gotclef, clefstr, newclef, gotoctave, octave) int -parsetranspose (s, word, gottranspose, transpose) +parsetranspose (char **s, + char *word, + int *gottranspose, + int *transpose + ) /* parses string transpose= number */ - char **s; - char *word; - int *gottranspose; - int *transpose; { if (casecmp (word, "transpose") != 0) return 0; @@ -1048,11 +1018,7 @@ parsetranspose (s, word, gottranspose, transpose) return 1; }; -int parseSoundScore (char **s, - char *word, - int *gottranspose, - int *transpose - ) +int parseSoundScore (char **s, char *word, int *gottranspose, int *transpose) /* parses sound, score, instrument, and shift * according to Hudson Lacerda's pseudo code file * doc/hudsonshift.txt. @@ -1149,12 +1115,8 @@ if (**s != '=') int -parseoctave (s, word, gotoctave, octave) +parseoctave (char **s, char *word, int *gotoctave, int *octave) /* parses string octave= number */ - char **s; - char *word; - int *gotoctave; - int *octave; { if (casecmp (word, "octave") != 0) return 0; @@ -1227,14 +1189,10 @@ char *umlaut_build_string(char *start, struct vstring *gchord) /* Function modified JA 20 May 2022 */ int -parsename (s, gotname, namestring, maxsize) +parsename (char **s, int *gotname, char namestring[], int maxsize) /* parses string name= "string" in V: command for compatability of abc2abc with abcm2ps */ - char **s; - int *gotname; - char namestring[]; - int maxsize; { int i; @@ -1265,15 +1223,10 @@ parsename (s, gotname, namestring, maxsize) } int -parsemiddle (s, word, gotmiddle, middlestring, maxsize) +parsemiddle (char **s, char *word, int *gotmiddle, char middlestring[], int maxsize) /* parse string middle=X in V: command for abcm2ps compatibility */ - char **s; - char *word; - int *gotmiddle; - char middlestring[]; - int maxsize; { int i; i = 0; @@ -1303,13 +1256,9 @@ characters */ } int -parseother (s, word, gotother, other, maxsize) /* [SS] 2011-04-18 */ +parseother (char **s, char *word, int *gotother, char other[], int maxsize) + /* [SS] 2011-04-18 */ /* parses any left overs in V: command (eg. stafflines=1) */ - char **s; - char *word; - int *gotother; - char other[]; - int maxsize; { if (word[0] != '\0') { @@ -1395,7 +1344,7 @@ static void set_voice_from_master(int voice_num) } int -parsekey (str) +parsekey (char *str) /* parse contents of K: field */ /* this works by picking up a strings and trying to parse them */ /* returns 1 if valid key signature found, 0 otherwise */ @@ -1422,7 +1371,6 @@ parsekey (str) * All of this information is extracted from the string str from the * K: command. */ - char *str; { char *s; char word[30]; @@ -1685,8 +1633,7 @@ parsekey (str) } void -parsevoice (s) - char *s; +parsevoice (char *s) { int num; /* voice number */ struct voice_params vparams; @@ -1775,8 +1722,7 @@ parsevoice (s) void -parsenote (s) - char **s; +parsenote (char **s) /* parse abc note and advance character pointer */ { int decorators[DECSIZE]; @@ -1970,9 +1916,7 @@ parsenote (s) } char * -getrep (p, out) - char *p; - char *out; +getrep (char *p, char *out) /* look for number or list following [ | or :| */ { char *q; @@ -2026,8 +1970,7 @@ getrep (p, out) } int -checkend (s) - char *s; +checkend (char *s) /* returns 1 if we are at the end of the line 0 otherwise */ /* used when we encounter '\' '*' or other special line end characters */ { @@ -2048,10 +1991,7 @@ checkend (s) } void -readstr (out, in, limit) - char out[]; - char **in; - int limit; +readstr (char out[], char **in, int limit) /* copy across alpha string */ { int i; @@ -2068,10 +2008,7 @@ readstr (out, in, limit) /* [SS] 2015-06-01 required for parse_mididef() in store.c */ /* Just like readstr but also allows anything except white space */ -int readaln (out, in, limit) - char out[]; - char **in; - int limit; +int readaln (char out[], char **in, int limit) /* copy across alphanumeric string */ { int i; @@ -2088,8 +2025,7 @@ int readaln (out, in, limit) } void -parse_precomment (s) - char *s; +parse_precomment (char *s) /* handles a comment field */ { char package[40]; @@ -2110,8 +2046,7 @@ parse_precomment (s) } /* [SS] 2017-12-10 */ -FILE * parse_abc_include (s) - char *s; +FILE * parse_abc_include (char *s) { char includefilename[80]; FILE *includehandle; @@ -2131,8 +2066,7 @@ FILE * parse_abc_include (s) /* Function mofied for umlaut handling JA 20 May 2022 */ void -parse_tempo (place) - char *place; +parse_tempo (char *place) /* parse tempo descriptor i.e. Q: field */ { char *p; @@ -2205,9 +2139,9 @@ parse_tempo (place) void appendfield(char *); /* links with store.c and yapstree.c */ -void append_fieldcmd (key, s) /* [SS] 2014-08-15 */ -char key; -char *s; +void append_fieldcmd ( /* [SS] 2014-08-15 */ + char key, + char *s) { appendfield(s); } @@ -2379,9 +2313,7 @@ static void resolve_unitlen() } void -parsefield (key, field) - char key; - char *field; +parsefield (char key, char *field) /* top-level routine handling all lines containing a field */ { char *comment; @@ -2638,8 +2570,7 @@ parsefield (key, field) } char * -parseinlinefield (p) - char *p; +parseinlinefield (char *p) /* parse field within abc line e.g. [K:G] */ { char *q; @@ -2794,11 +2725,9 @@ static void check_and_call_bar(int bar_type, char *replist) /* [SS] 2021-10-11 */ -static int pitch2midi(note, accidental, mult, octave ) +static int pitch2midi(char note, char accidental, int mult, int octave) /* computes MIDI pitch for note. */ -char note, accidental; -int mult, octave; { int p; char acc; @@ -2951,8 +2880,7 @@ switch (**s) void -parsemusic (field) - char *field; +parsemusic (char *field) /* parse a line of abc notes */ { char *p; @@ -3447,8 +3375,7 @@ parsemusic (field) } void -parseline (line) - char *line; +parseline (char *line) /* top-level routine for handling a line in abc file */ { char *p, *q; @@ -3580,8 +3507,7 @@ parseline (line) } void -parsefile (name) - char *name; +parsefile (char *name) /* top-level routine for parsing file */ /* [SS] 2017-12-10 In order to allow including the directive "%%abc-include includefile.abc" to insert the includedfile.abc, diff --git a/parseabc.h b/parseabc.h index 6c495b8..2d604ee 100755 --- a/parseabc.h +++ b/parseabc.h @@ -9,6 +9,7 @@ #define KANDR #endif +#include #include "music_utils.h" /* the arg list to event_voice keeps growing; if we put the args into a structure @@ -166,17 +167,18 @@ extern void event_gchord(char *s); extern void event_note(int decorators[DECSIZE], cleftype_t *clef, char accidental, int mult, char note, int xoctave, int n, int m); +extern void event_ignore(); extern void event_abbreviation(char symbol, char *string, char container); extern void event_acciaccatura(); extern void event_start_extended_overlay(); extern void event_stop_extended_overlay(); extern void event_split_voice(); -extern void event_temperament(); +extern void event_temperament(char* line); extern void print_voicecodes(void); extern void init_abbreviations(); extern void free_abbreviations(); -extern void parsefile(); -extern int parsetune(); +extern void parsefile(char * name); +extern int parsetune(FILE * fp); #else extern void event_init(); extern void event_text(); diff --git a/parser2.c b/parser2.c index 3beb5d9..4b241bf 100755 --- a/parser2.c +++ b/parser2.c @@ -27,12 +27,9 @@ void event_info(char* s) } -static void splitstring(s, sep, handler) +static void splitstring(char *s, char sep, void (*handler)(char *)) /* breaks up string into fields with sep as the field separator */ /* and calls handler() for each sub-string */ -char* s; -char sep; -void (*handler)(); { char* out; char* p; @@ -53,22 +50,19 @@ void (*handler)(); }; } -void event_gchord(s) +void event_gchord(char *s) /* handles guitar chords " ... " */ -char* s; { splitstring(s, ';', event_handle_gchord); } -void event_instruction(s) +void event_instruction(char *s) /* handles a ! ... ! event in the abc */ -char* s; { splitstring(s, ';', event_handle_instruction); } -void event_slur(t) -int t; +void event_slur(int t) /* handles old 's' notation for slur on/slur off */ { if (t) { diff --git a/position.c b/position.c index ac7d3c0..d4dadcb 100644 --- a/position.c +++ b/position.c @@ -40,9 +40,7 @@ extern struct tune thetune; extern double scaledwidth; -static void addfract(f, n, m) -struct fract* f; -int n, m; +static void addfract(struct fract *f, int n, int m) /* add n/m to fraction pointed to by f */ /* like addunits(), but does not use unitlength */ { @@ -51,9 +49,7 @@ int n, m; reducef(f); } -static void mulfract(f, n, m) -struct fract* f; -int n, m; +static void mulfract(struct fract *f, int n, int m) /* multiply n/m to fraction pointed to by f */ /* like addunits(), but does not use unitlength */ { diff --git a/pslib.c b/pslib.c index aa3caed..ad6ca05 100644 --- a/pslib.c +++ b/pslib.c @@ -50,11 +50,8 @@ /* output library of PostScript routines for drawing music symbols */ -static void ps_header(f, filename, boundingbox) +static void ps_header(FILE *f, char *filename, struct bbox *boundingbox) /* create header section of PostScript file */ -FILE* f; -char* filename; -struct bbox* boundingbox; { if (eps_out) { @@ -101,8 +98,7 @@ struct bbox* boundingbox; fprintf(f,"\n"); } -static void section1(f) -FILE* f; +static void section1(FILE *f) { fprintf(f,"%% Section 1 - Fonts and String Manipulation\n"); fprintf(f,"\n"); @@ -185,8 +181,7 @@ FILE* f; fprintf(f,"\n"); } -static void section2(f) -FILE* f; +static void section2(FILE *f) { fprintf(f,"%% Section 2 - Clefs\n"); fprintf(f,"\n"); @@ -286,8 +281,7 @@ FILE* f; fprintf(f,"\n"); } -static void section3(f) -FILE* f; +static void section3(FILE *f) { fprintf(f,"%% Section 3 - Note Heads, Stems and Beams\n"); fprintf(f,"\n"); @@ -401,8 +395,7 @@ FILE* f; fprintf(f,"\n"); } -static void section4(f) -FILE* f; +static void section4(FILE *f) { fprintf(f,"%% Section 4 - Note Ornaments (Staccato, Roll, Trill etc.)\n"); fprintf(f,"\n"); @@ -488,8 +481,7 @@ FILE* f; fprintf(f,"\n"); } -static void section5(f) -FILE* f; +static void section5(FILE *f) { fprintf(f,"%% Section 5 - helper lines\n"); fprintf(f,"\n"); @@ -505,8 +497,7 @@ FILE* f; fprintf(f,"\n"); } -static void section6(f) -FILE* f; +static void section6(FILE *f) { fprintf(f,"%% Section 6 - Note tails \n"); fprintf(f,"\n"); @@ -576,8 +567,7 @@ FILE* f; fprintf(f,"\n"); } -static void section7(f) -FILE* f; +static void section7(FILE *f) { fprintf(f,"%% Section 7 - Flats, Sharps and Naturals.\n"); fprintf(f,"\n"); @@ -695,8 +685,7 @@ FILE* f; fprintf(f,"\n"); } -static void section8(f) -FILE* f; +static void section8(FILE *f) { fprintf(f,"%% Section 8 - Guitar Chords\n"); fprintf(f,"\n"); @@ -706,8 +695,7 @@ FILE* f; fprintf(f,"\n"); } -static void section9(f) -FILE* f; +static void section9(FILE *f) { fprintf(f,"%% Section 9 - Rests\n"); fprintf(f,"\n"); @@ -787,8 +775,7 @@ FILE* f; fprintf(f,"\n"); } -static void section10(f) -FILE* f; +static void section10(FILE *f) { fprintf(f,"%% Section 10 - Bar signs\n"); fprintf(f,"\n"); @@ -849,8 +836,7 @@ FILE* f; fprintf(f,"\n"); } -static void section11(f) -FILE* f; +static void section11(FILE *f) { fprintf(f,"%% Section 11 - Grace Notes\n"); fprintf(f,"\n"); @@ -924,8 +910,7 @@ FILE* f; fprintf(f,"\n"); } -static void section12(f) -FILE* f; +static void section12(FILE *f) { fprintf(f,"%% Section 12 - Time Signatures\n"); fprintf(f,"\n"); @@ -960,8 +945,7 @@ FILE* f; fprintf(f,"\n"); } -static void section13(f) -FILE* f; +static void section13(FILE *f) { fprintf(f,"%% Section 13 - Staff And Other things\n"); fprintf(f,"\n"); @@ -1059,10 +1043,7 @@ FILE* f; fprintf(f,"\n"); } -void printlib(f, filename, boundingbox) -FILE*f; -char* filename; -struct bbox* boundingbox; +void printlib(FILE *f, char *filename, struct bbox *boundingbox) { ps_header(f, filename, boundingbox); section1(f); diff --git a/queues.c b/queues.c index c121346..028e4d3 100644 --- a/queues.c +++ b/queues.c @@ -87,9 +87,7 @@ void set_control_defaults() { /* at the same as specifiedy abc standard, so the delay of the*/ /* other notes cached in the Q structure should be set to zero.*/ -void addtoQ(num, denom, pitch, chan, effect, d) -int num, denom, pitch, chan, d; -int effect; /* [SS] 2012-12-11 */ +void addtoQ(int num, int denom, int pitch, int chan, int effect, int d) { int i, done; int wait; @@ -135,8 +133,7 @@ int effect; /* [SS] 2012-12-11 */ }; } -void removefromQ(i) -int i; +void removefromQ(int i) { if (i == -1) { printQ(); @@ -192,8 +189,7 @@ void printQ() printf("\n"); } -void advanceQ(t) -int t; +void advanceQ(int t) { if (Qhead == -1) { event_error("Internal error - empty queue"); @@ -365,9 +361,8 @@ void note_effect3() { } /* [SS] 2015-07-26 */ -void note_effect4(chan) - int chan; - { +void note_effect4(int chan) +{ /* Like %%MIDI bendstring, this procedure handles %%MIDI controlstring command. The first value of controlstring indicates the controller to modify. The following values are the values to send to the @@ -404,7 +399,7 @@ void note_effect4(chan) delta_time -= delta; } midi_noteoff(delta_time, Q[Qhead].pitch, Q[Qhead].chan); - } +} /* [SS] 2015-07-30 */ @@ -448,9 +443,8 @@ void output_eventlist (struct eventstruc *list, int nsize, int chan) { } /* [SS] 2015-08-01 */ -void note_effect5(chan) - int chan; - { +void note_effect5(int chan) +{ /* This procedure merges the controlstring with the bendstring and uses it to shape the note. The control commands are prepared and stored in the eventstruc @@ -547,7 +541,7 @@ void note_effect5(chan) data[1] = (char) ((pitchbend>>7)&0x7f); write_event_with_delay(0,pitch_wheel,chan,data,2); } - } +} @@ -570,9 +564,7 @@ void note_effect5(chan) /* new: delta_time_track0 is declared in queues.h like delta_time */ -void timestep(t, atend) -int t; -int atend; +void timestep(int t, int atend) { int time; int headtime; diff --git a/store.c b/store.c index 36e3b26..470bb92 100755 --- a/store.c +++ b/store.c @@ -503,7 +503,7 @@ static void addfeature(int f,int p,int n,int d); static void replacefeature(int f, int p, int n, int d, int loc); void insertfeature(int f, int p, int n, int d, int loc); static void textfeature(int type, char *s); -extern long writetrack(); +extern long writetrack(int xtrack); void init_drum_map(); static void fix_enclosed_note_lengths(int from, int end); static int patchup_chordtie(int chordstart,int chordend); @@ -511,7 +511,7 @@ static void copymap(struct voicecontext* v); void init_stresspat(); void beat_modifier(int); void readstressfile (char * filename); -int parse_stress_params(); +extern int parse_stress_params(char *input); void calculate_stress_parameters(); extern int inbody; /* from parseabc.c [SS] 2009-12-18 */ extern int lineposition; /* from parseabc.c [SS] 2011-07-18 */ @@ -519,7 +519,7 @@ extern int beatmodel; /* from genmidi.c [SS] 2011-08-26 */ int stress_pattern_loaded; /* [SS] 2018-04-16 */ int stressmodel; -extern int nullputc(); +extern int nullputc(char c); void dumpfeat (int from, int to); /* defined in genmidi.c */ char * concatenatestring(char * s1,char * s2); /* defined in parseabc.c */ void read_custom_stress_file (char *filename); /* defined in stresspat.c */ @@ -527,9 +527,8 @@ void read_custom_stress_file (char *filename); /* defined in stresspat.c */ extern long Mf_numbyteswritten; /* linking with midifile.c [SS] 2019-03-23 */ -static struct voicecontext* newvoice(n) +static struct voicecontext* newvoice(int n) /* allocate and initialize the data for a new voice */ -int n; { struct voicecontext *s; int i,j; @@ -586,9 +585,8 @@ int n; return(s); } -static struct voicecontext* getvoicecontext(n) +static struct voicecontext* getvoicecontext(int n) /* find the data structure for a given voice number */ -int n; { struct voicecontext *p; struct voicecontext *q; @@ -747,9 +745,8 @@ static void clearvoicecontexts() -static int getchordnumber(s) +static int getchordnumber(char *s) /* looks through list of known chords for chord name given in s */ -char *s; { int i; int chordnumber; @@ -766,11 +763,8 @@ char *s; return(chordnumber); } -static void addchordname(s, len, notes) +static void addchordname(char *s, int len, int notes[]) /* adds chord name and note set to list of known chords */ -char *s; -int notes[]; -int len; { int i, j, done; @@ -880,16 +874,13 @@ static void setup_chordnames() addchordname("5", 2, list_5); } -void event_init(argc, argv, filename) +void event_init(int argc, char *argv[], char **filename) /* this routine is called first by parseabc.c */ -int argc; -char* argv[]; -char **filename; { int j; int arg,m,n; float afreq,semitone_shift; /* [SS] 2012-04-01 */ - double log10(); + extern double log10(double); /* look for code checking option */ if (getarg("-c", argc, argv) != -1) { @@ -1158,9 +1149,8 @@ outbase = addstring(argv[1]); /* [RM] 2010-11-21 */ } -void event_text(s) +void event_text(char *s) /* text found in abc file */ -char *s; { char msg[200]; @@ -1174,9 +1164,8 @@ char *s; if (quiet == -1) event_warning(msg); /* [JM] 2018-02-22 */ } -void event_x_reserved(p) +void event_x_reserved(char p) /* reserved character H-Z found in abc file */ -char p; { char msg[200]; @@ -1184,11 +1173,8 @@ char p; if (quiet == -1) event_warning(msg); /* [JM] 2018-02-22 */ } -void event_abbreviation(symbol, string, container) +void event_abbreviation(char symbol, char *string, char container) /* abbreviation encountered - this is handled within the parser */ -char symbol; -char *string; -char container; { } @@ -1526,23 +1512,20 @@ while (v != NULL) { -void event_tex(s) +void event_tex(char *s) /* TeX command found - ignore it */ -char *s; { } -void event_fatal_error(s) +void event_fatal_error(char *s) /* print error message and halt */ -char *s; { event_error(s); exit(1); } -void event_error(s) +void event_error(char *s) /* generic error handler */ -char *s; { #ifdef NOFTELL extern int nullpass; @@ -1555,9 +1538,8 @@ char *s; #endif } -void event_warning(s) +void event_warning(char *s) /* generic warning handler - for flagging possible errors */ -char *s; { #ifdef NOFTELL extern int nullpass; @@ -1570,9 +1552,8 @@ char *s; #endif } -static int autoextend(maxnotes) +static int autoextend(int maxnotes) /* increase the number of abc elements the program can cope with */ -int maxnotes; { int newlimit; int *ptr,*ptr2,*ptr3,*ptr4,*ptr5; @@ -1639,11 +1620,9 @@ int maxnotes; return(newlimit); } -static int textextend(maxstrings, stringarray) +static int textextend(int maxstrings, char ***stringarray) /* resize an array of pointers to strings */ /* used with arrays words and atext */ -int maxstrings; -char*** stringarray; { int i, newlimit; char** ptr; @@ -1661,9 +1640,8 @@ char*** stringarray; return(newlimit); } -static void addfeature(f, p, n, d) +static void addfeature(int f, int p, int n, int d) /* place feature in internal table */ -int f, p, n, d; { feature[notes] = f; pitch[notes] = p; @@ -1679,8 +1657,7 @@ int f, p, n, d; }; } -static void replacefeature(f, p, n, d, loc) -int f, p, n, d, loc; +static void replacefeature(int f, int p, int n, int d, int loc) { feature[loc] = f; pitch[loc] = p; @@ -1689,9 +1666,8 @@ int f, p, n, d, loc; } -void insertfeature(f, p, n, d, loc) +void insertfeature(int f, int p, int n, int d, int loc) /* insert feature in internal table */ -int f,p,n,d,loc; { int i; notes = notes + 1; if (notes >= maxnotes) { @@ -1717,8 +1693,7 @@ int f,p,n,d,loc; decotype[i] = 0; } -static void removefeature(loc) -int loc; +static void removefeature(int loc) { int i; for (i=loc;i 0) { skipspace(&p); - j = readaln(&name,&p,31); + j = readaln(name,&p,31); if (j < 1) break; for (i=0; i 0) { } /* [SS] 2020-07-17 ; [HL] 2020-07-24 */ -float compute_fifth_size (octave_size, ndiv) -float octave_size; /* in cents */ -int ndiv; +float compute_fifth_size ( + float octave_size, /* in cents */ + int ndiv +) /* rather than compute the fifth_size in cents directly * we subtract the octave from the third harmonic. * We do it this way instead of the proportion 3/2 because the @@ -1926,11 +1896,10 @@ return w; /* in cents */ /* [SS] 2015-08-11 */ -void event_midi(s) +void event_midi(char *s) /* Handles %%MIDI commands. It was originally part of event_specific. */ -char *s; { int ch; char command[40]; @@ -2531,10 +2500,9 @@ int default_fermata_fixed = 0; int default_ratio_a = 2; int default_ratio_b = 6; -void event_specific_in_header(package, s) +void event_specific_in_header(char *package, char *s) /* package-specific command found i.e. %%NAME */ /* only %%MIDI commands are actually handled */ -char *package, *s; { char command[40]; char *p; @@ -2689,11 +2657,9 @@ void extract_filename(char *f) got_titlename = 1; } -void event_field(k, f) +void event_field(char k, char *f) /* Handles R: T: and any other field not handled elsewhere */ /* Added code to handle C: field. */ -char k; -char *f; { if (dotune) { switch (k) { @@ -2740,11 +2706,8 @@ char *f; } /* [JA] 2022.06.14 */ -void event_words(p, append, continuation) +void event_words(char *p, int append, int continuation) /* handles a w: field in the abc */ -char* p; -int append; -int continuation; { karaoke = 1; @@ -2769,8 +2732,7 @@ int continuation; } /* [SS] 2014-08-16 */ -void append_words (morewords) -char *morewords; +void append_words (char *morewords) { char *p; p = concatenatestring(words[wcount-1],morewords); @@ -2778,8 +2740,7 @@ words[wcount-1] = p; } /* [SS] 2014-08-16 */ -void appendfield (morewords) -char *morewords; +void appendfield (char *morewords) { append_words (morewords); } @@ -2804,10 +2765,8 @@ static void checkbreak() }; } -static void char_out(part, ch) +static void char_out(struct vstring* part, char ch) /* routine for building up part list */ -struct vstring* part; -char ch; { /* if (*out - list >= MAXPARTS) { @@ -2822,7 +2781,7 @@ char ch; parts = parts + 1; } -static void read_spec(spec, part) +static void read_spec(char spec[], struct vstring* part) /* converts a P: field to a list of part labels */ /* e.g. P:A(AB)3(CD)2 becomes P:AABABABCDCD */ @@ -2832,8 +2791,6 @@ static void read_spec(spec, part) /* are ignored and only repeats implied by the part order statement */ /* are played). */ -char spec[]; -struct vstring* part; { char* in; int i, j, k, spec_length; @@ -2928,9 +2885,8 @@ struct vstring* part; }; } -void event_part(s) +void event_part(char *s) /* handles a P: field in the abc */ -char* s; { char* p; @@ -2969,11 +2925,8 @@ char* s; }; } -void event_voice(n, s, vp) +void event_voice(int n, char *s, struct voice_params *vp) /* handles a V: field in the abc */ -int n; -char *s; -struct voice_params *vp; { if (!voicesused && bodystarted) {event_warning("First V: field occurs past body; will combine this body with this voice."); bodystarted = 0; @@ -3002,9 +2955,8 @@ struct voice_params *vp; }; } -void event_length(n) +void event_length(int n) /* handles an L: field in the abc */ -int n; { if (pastheader) { v->default_length = n; @@ -3013,15 +2965,13 @@ int n; }; } -void event_default_length (n) +void event_default_length (int n) /* handles a missing L: field in the abc */ - int n; { } -static void tempounits(t_num, t_denom) +static void tempounits(int *t_num, int *t_denom) /* interprets Q: once default length is known */ -int *t_num, *t_denom; { /* calculate unit for tempo */ if (tempo_num == 0) { @@ -3038,8 +2988,7 @@ int *t_num, *t_denom; }; } -int get_tempo_from_name (s) /* [SS] 2010-12-07 */ -char *s; +int get_tempo_from_name (char *s) /* [SS] 2010-12-07 */ { int i,n; if (s == NULL) return 0; /* [SS] 2010-12-10 */ @@ -3052,8 +3001,7 @@ for (i=0;i<19;i++) { return 0; } -int is_abcm2ps_option (s) /* [SS] 2018-12-17 */ -char *s; +int is_abcm2ps_option (char *s) /* [SS] 2018-12-17 */ { int i; if (s == NULL) return 0; @@ -3065,13 +3013,9 @@ return 0; } -void event_tempo(n, a, b, rel, pre, post) +void event_tempo(int n, int a, int b, int rel, char *pre, char *post) /* handles a Q: field e.g. Q: a/b = n or Q: Ca/b = n */ /* strings before and after are ignored */ -int n; -int a, b, rel; -char *pre; -char *post; { int t_num, t_denom; int new_div; @@ -3105,9 +3049,8 @@ char *post; }; } -void event_timesig (timesig) +void event_timesig (timesig_details_t *timesig) /* handles an M: field M:n/m */ - timesig_details_t *timesig; { int dochecking; @@ -3143,11 +3086,9 @@ void event_timesig (timesig) }; } -void event_octave(num, local) +void event_octave(int num, int local) /* used internally by other routines when octave=N is encountered */ /* in I: or K: fields */ -int num; -int local; { if (dotune) { if (pastheader || local) { @@ -3160,9 +3101,8 @@ int local; /* deleted event_info_key(key,value). It is now in parser2.c [JA] 2024-04-30 */ -static void stack_broken(v) +static void stack_broken(struct voicecontext *v) /* store away broken rhythm context on encountering grace notes */ -struct voicecontext* v; { v->broken_stack[0] = v->laststart; v->broken_stack[1] = v->lastend; @@ -3178,9 +3118,8 @@ struct voicecontext* v; v->brokenpending = -1; } -static void restore_broken(v) +static void restore_broken(struct voicecontext *v) /* remember any broken rhythm context after grace notes */ -struct voicecontext* v; { if (v->brokenpending != -1) { event_error("Unresolved broken rhythm in grace notes"); @@ -3225,8 +3164,7 @@ void event_graceoff() } -void event_playonrep(s) -char* s; +void event_playonrep(char *s) /* [X in the abc, where X is a list of numbers */ { int num, converted; @@ -3246,9 +3184,8 @@ char* s; -void event_sluron(t) +void event_sluron(int t) /* called when ( is encountered in the abc */ -int t; { if (v->inslur) event_warning("Slur within slur"); else { @@ -3257,9 +3194,8 @@ int t; } } -void event_sluroff(t) +void event_sluroff(int t) /* called when ) is encountered */ -int t; { if (v->inslur) { addfeature(SLUR_OFF, 0, 0, 0); @@ -3288,17 +3224,14 @@ void event_space() /* printf("Space event\n"); */ } -void event_lineend(ch, n) +void event_lineend(char ch, int n) /* called when \ or ! or * or ** is encountered at the end of a line */ -char ch; -int n; { /* ignore */ } -void event_broken(type, mult) +void event_broken(int type, int mult) /* handles > >> >>> < << <<< in the abc */ -int type, mult; { if (v->inchord) { event_error("Broken rhythm not allowed in chord"); @@ -3318,9 +3251,8 @@ int type, mult; }; } -void event_tuple(n, q, r) +void event_tuple(int n, int q, int r) /* handles triplets (3 and general tuplets (n:q:r in the abc */ -int n, q, r; { if (tuplecount > 0) { event_error("nested tuples"); @@ -3373,9 +3305,8 @@ void event_chord() void event_ignore () { }; /* [SS] 2018-12-21 */ -static void lenmul(n, a, b) +static void lenmul(int n, int a, int b) /* multiply note length by a/b */ -int n, a, b; { if ((feature[n] == NOTE) || (feature[n] == REST) || (feature[n] == CHORDOFF) @@ -3479,15 +3410,12 @@ static void marknote() } /* just a stub to ignore 'y' */ -void event_spacing(n, m) -int n,m; +void event_spacing(int n, int m) { } -void event_rest(decorators,n,m,type) +void event_rest(int decorators[DECSIZE], int n, int m, int type) /* rest of n/m in the abc */ -int n, m,type; -int decorators[DECSIZE]; { int num, denom; @@ -3532,11 +3460,10 @@ int decorators[DECSIZE]; }; } -void event_mrest(n,m,c) +void event_mrest(int n, int m, char c) /* multiple bar rest of n/m in the abc */ /* we check for m == 1 in the parser */ -int n, m; -char c; /* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ +//char c; /* [SS] 2017-04-19 to distinguish X from Z in abc2abc */ { int i; int decorators[DECSIZE]; @@ -3625,22 +3552,18 @@ void event_chordoff(int chord_n, int chord_m) }; } -void event_finger(p) +void event_finger(char *p) /* a 1, 2, 3, 4 or 5 has been found in a guitar chord field */ -char *p; { /* does nothing */ } -static int pitchof(note, accidental, mult, octave, propagate_accs) +static int pitchof(char note, char accidental, int mult, int octave, int propagate_accs) /* This code is used for handling gchords */ /* finds MIDI pitch value for note */ /* if propagate_accs is 1, apply any accidental to all instances of */ /* that note in the bar. If propagate_accs is 0, accidental does not */ /* apply to other notes */ -char note, accidental; -int mult, octave; -int propagate_accs; { int p; char acc; @@ -3670,12 +3593,10 @@ int propagate_accs; return p + 12*octave + middle_c; } -static int barepitch(note, accidental, mult, octave) +static int barepitch(char note, char accidental, int mult, int octave) /* Computes MIDI pitch ignoring any key signature. * Required for drum track */ -char note, accidental; -int mult, octave; { int p,pitch; int accidental_size = 1; @@ -3689,7 +3610,7 @@ pitch = p + 12*octave + middle_c; return pitch; } -static int pitchof_b(note, accidental, mult, octave, propagate_accs,pitchbend) +static int pitchof_b(char note, char accidental, int mult, int octave, int propagate_accs, int *pitchbend) /* computes MIDI pitch for note. If global temperament is set, it will apply a linear temperament and return a pitchbend. If propagate_accs == 2, apply any accidental to all @@ -3699,10 +3620,6 @@ static int pitchof_b(note, accidental, mult, octave, propagate_accs,pitchbend) If propagate_accs = 0, do not apply the accidental to other notes in the bar. */ -char note, accidental; -int mult, octave; -int propagate_accs; -int *pitchbend; { int p; char acc; @@ -3887,11 +3804,8 @@ bendvalue = c53midi - (float) *midipitch; -static void doroll(note, octave, n, m, pitch) +static void doroll(char note, int octave, int n, int m, int pitch) /* applies a roll to a note */ -char note; -int octave, n, m; -int pitch; { char up, down; int t; @@ -3925,10 +3839,7 @@ int pitch; /* [SS] 2012-06-30 */ -static void doroll_setup(note,octave,n,m,pitch) -char note; -int octave, n, m; -int pitch; +static void doroll_setup(char note, int octave, int n, int m, int pitch) { char up, down; int t; @@ -3962,8 +3873,7 @@ int pitch; if (notesdefined < 1000) notesdefined++; } -static void doroll_output(i) -int i; +static void doroll_output(int i) { int deco_index; int pitch,pitchup,pitchdown,bend_up,bend_down; @@ -4004,11 +3914,8 @@ bentpitch[i] = active_pitchbend; /* dotrill is nolonger used [SDG] 2020-06-03 */ #if 0 -static void dotrill(note, octave, n, m, pitch) +static void dotrill(char note, int octave, int n, int m, int pitch) /* applies a trill to a note */ -char note; -int octave, n, m; -int pitch; { char up; int i, t; @@ -4048,10 +3955,7 @@ int pitch; } #endif -static void dotrill_setup(note, octave, n, m, pitch) -char note; -int octave, n, m; -int pitch; +static void dotrill_setup(char note, int octave, int n, int m, int pitch) { char up; int t; @@ -4080,8 +3984,7 @@ int pitch; if (notesdefined < 1000) notesdefined++; } -static void dotrill_output(i) -int i; +static void dotrill_output(int i) { int deco_index; int pitch,pitchup,pitchdown; @@ -4153,8 +4056,7 @@ for (i=1;idefault_length); } -void makeharproll (pitch, bend,n,m) /* [JS] 2011-04-29 */ -int pitch,bend,n,m; +void makeharproll (int pitch, int bend, int n, int m) /* [JS] 2011-04-29 */ { bentpitch[notes] = bend; addfeature(NOTE, pitch, 4*n/2,m*2*v->default_length); @@ -4175,8 +4076,7 @@ bentpitch[notes] = bend; addfeature(NOTE, pitch, 4*n/2,m*v->default_length); } -void makeharproll3 (pitch, bend,n,m) /* [JS] 2011-04-29 */ -int pitch,bend,n,m; +void makeharproll3 (int pitch, int bend, int n, int m) /* [JS] 2011-04-29 */ { int a=n-1; bentpitch[notes] = bend; @@ -4188,11 +4088,8 @@ addfeature(NOTE, pitch, 4*(n/2+1),m*v->default_length); } -static void doornament(note, octave, n, m, pitch) +static void doornament(char note, int octave, int n, int m, int pitch) /* applies a roll to a note */ -char note; -int octave, n, m; -int pitch; { char up, down; int t; @@ -4258,10 +4155,9 @@ int pitch; -static void hornp(num, denom) +static void hornp(int num, int denom) /* If we have used R:hornpipe, this routine modifies the rhythm by */ /* applying appropriate broken rhythm */ -int num, denom; { if ((hornpipe) && (notes > 0) && (feature[notes-1] != GT)) { if ((num*last_denom == last_num*denom) && (num == 1) && @@ -4279,13 +4175,8 @@ int num, denom; }; } -void event_note(decorators, clef, accidental, mult, note, xoctave, n, m) +void event_note(int decorators[DECSIZE], cleftype_t *clef, char accidental, int mult, char note, int xoctave, int n, int m) /* handles a note in the abc */ -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int mult; -char accidental, note; -int xoctave, n, m; { int num, denom; int octave; @@ -4474,10 +4365,11 @@ void event_normal_tone() microtone = 0; } -char *get_accidental(place, accidental) -/* read in accidental - used by event_handle_gchord() */ -char *place; /* place in string being parsed */ -char *accidental; /* pointer to char variable */ +char *get_accidental( + /* read in accidental - used by event_handle_gchord() */ + char *place, /* place in string being parsed */ + char *accidental /* pointer to char variable */ + ) { char *p; @@ -4494,9 +4386,8 @@ char *accidental; /* pointer to char variable */ return(p); } -void event_handle_gchord(s) +void event_handle_gchord(char *s) /* handler for the guitar chords */ -char* s; { int basepitch; char accidental, accidental2, note; /* [SS] 2021-12-05 */ @@ -4586,11 +4477,10 @@ char* s; addfeature(GCHORD, basepitch, inversion, chordno); } -void event_handle_instruction(s) +void event_handle_instruction(char *s) /* handler for ! ! instructions */ /* does ppp pp p mp mf f ff fff */ /* also does !drum! and !nodrum! */ -char* s; { char buff[MAXLINE]; char* p; @@ -4771,11 +4661,12 @@ if (nofnop == 0) { }; } -static void setmap(sf, map, mult) +static void setmap( /* 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 sf, /* number of sharps in key signature -7 to +7 */ + char map[7], + int mult[7] + ) { int j; @@ -4799,12 +4690,8 @@ int mult[7]; if (sf <= -7) map['f'-'a'] = '_'; } -static void altermap(v, modmap, modmul,modmic) +static void altermap(struct voicecontext* v, char modmap[7], int modmul[7], struct fraction modmic[7]) /* apply modifiers to a set of accidentals */ -struct voicecontext* v; -char modmap[7]; -int modmul[7]; -struct fraction modmic[7]; { int i; @@ -4818,9 +4705,8 @@ struct fraction modmic[7]; }; } -static void copymap(v) +static void copymap(struct voicecontext* v) /* sets up working map at the start of each bar */ -struct voicecontext* v; { int i,j; @@ -4838,8 +4724,7 @@ struct voicecontext* v; /* workaround for problems with PCC compiler */ /* data may be written to an internal buffer */ -int myputc(c) -char c; +int myputc(char c) { return (putc(c,fp)); } @@ -4853,10 +4738,7 @@ void addfract(int *xnum, int *xdenom, int a, int b) reduce(xnum, xdenom); } -void nondestructive_readstr(out, in, limit) -char out[]; -char **in; -int limit; +void nondestructive_readstr(char out[], char **in, int limit) /* copy across alphanumeric string */ { int i; @@ -4869,11 +4751,10 @@ int limit; } -static void dotie(j, xinchord,voiceno) +static void dotie(int j, int xinchord, int voiceno) /* called in preprocessing stage to handle ties */ /* we need the voiceno in case a tie is broken by a */ /* voice switch. */ -int j, xinchord,voiceno; { int tienote, place; int tietodo, done; @@ -5134,8 +5015,7 @@ if (verbose >3) printf("tiefix finished\n"); static void applygrace_orig(int); static void applygrace_new(int); -static void applygrace(place) -int place; +static void applygrace(int place) { if (gfact_method) applygrace_orig(place); else applygrace_new(place); @@ -5146,8 +5026,7 @@ removefeatures(start,end); } /* [SS] 2021-01-24 */ -static void applygrace_orig(place) -int place; +static void applygrace_orig(int place) /* assign lengths to grace notes before generating MIDI */ /* This version adjusts the length of the grace notes * based on the length of the following note, the @@ -5257,8 +5136,7 @@ int place; }; } -static void applygrace_new(place) -int place; +static void applygrace_new(int place) /* assign lengths to grace notes before generating MIDI */ /* In this version each grace note has a predetermined * length, eg, (1/64 th note) and the total length of @@ -5438,13 +5316,11 @@ static void zerobar() bar_denom = 1; } -void event_bar(type, replist) +void event_bar(int type, char *replist) /* handles bar lines of various types in the abc */ /* This function was reorganized on 2013-12-02 [SS] to handle play on repeats when there are split voices. */ -int type; -char* replist; { int newtype; int depth; @@ -5494,9 +5370,8 @@ char* replist; -static void placeendrep(j) +static void placeendrep(int j) /* patch up missing repeat */ -int j; { if (quiet == -1) event_warning("Assuming repeat"); switch(feature[j]) { @@ -5516,9 +5391,8 @@ int j; }; } -static void placestartrep(j) +static void placestartrep(int j) /* patch up missing repeat */ -int j; { if (quiet == -1) event_warning("Assuming repeat"); switch(feature[j]) { @@ -5946,20 +5820,24 @@ static void headerprocess() voicesused = 0; } -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, gotkey, gotclef, clefname, clef, - octave, transpose, gotoctave, gottranspose, explict) +void event_key( /* handles a K: field */ -int sharps; /* sharps is number of sharps in key signature */ -char *s; /* original string following K: */ -int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ -char modmap[7]; /* array of accidentals to be applied */ -int modmul[7]; /* array giving multiplicity of each accent (1 or 2) */ -struct fraction modmicrotone[7]; /* [SS] 2014-01-06 */ -int gotkey, gotclef; -char* clefname; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int octave, transpose, gotoctave, gottranspose; -int explict; + int sharps, /* sharps is number of sharps in key signature */ + char *s, /* original string following K: */ + int modeindex, /* 0 major, 1,2,3 minor, 4 locrian, etc. */ + char modmap[7], /* array of accidentals to be applied */ + int modmul[7], /* array giving multiplicity of each accent (1 or 2) */ + struct fraction modmicrotone[7], /* [SS] 2014-01-06 */ + int gotkey, + int gotclef, + char* clefname, + cleftype_t *clef, /* [JA] 2020-10-19 */ + int octave, + int transpose, + int gotoctave, + int gottranspose, + int explict + ) { int minor; minor =0; @@ -5988,7 +5866,7 @@ int explict; ***headerprocess(); ***v = getvoicecontext(1); - ***if (!inbody) v1index = notes; /* save position in case of split voice */ + ***if (!inbody) v1index = notes;***/ /* save position in case of split voice */ if (gotclef) { @@ -6251,7 +6129,7 @@ static void finishfile() event_fatal_error("File open failed"); }; if (!silent) printf("writing MIDI file %s\n", outname); - Mf_putc = myputc; + Mf_putc = &myputc; Mf_writetrack = writetrack; header_time_num = time_num; header_time_denom = time_denom; @@ -6289,9 +6167,8 @@ void event_blankline() }; } -void event_refno(n) +void event_refno(int n) /* handles an X: field (which indicates the start of a tune) */ -int n; { char numstr[23]; /* Big enough for a 64-bit int! */ char newname[256]; @@ -6365,9 +6242,7 @@ void event_eof() void set_control_defaults(); /* from queues.c */ -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { char *filename; int i; diff --git a/toabc.c b/toabc.c index 02ca992..2e705d2 100755 --- a/toabc.c +++ b/toabc.c @@ -157,8 +157,7 @@ void transpose_note(char xaccidental,int xmult,char xnote,int xoctave,int transp char* accidental, int* mult, char* note, int* octave); -static int purgespace(p) -char* p; +static int purgespace(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) */ @@ -178,19 +177,15 @@ char* p; return(blank); } -int zero_barcount(foundbar) +int zero_barcount(int *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; +int new_barcount(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) */ @@ -209,8 +204,7 @@ int oldcount; } -static void setline(t) -enum linestattype t; +static void setline(enum linestattype t) /* generates newline, or continuation, or nothing at all */ /* part of new linebreak option (-n) */ { @@ -223,9 +217,7 @@ enum linestattype t; linestat = t; } -static int flush_abctext(bars, termination) -int bars; -enum linestattype termination; +static int flush_abctext(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 */ @@ -324,11 +316,10 @@ enum linestattype termination; return(count); } -void complete_bars(v) +void complete_bars(struct voicetype *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; @@ -345,9 +336,7 @@ struct voicetype *v; }; } -void complete_all(v, termination) -struct voicetype *v; -enum linestattype termination; +void complete_all(struct voicetype *v, enum linestattype termination) /* output all remaining music and fields */ /* part of new linebreak option (-n) */ { @@ -365,8 +354,7 @@ enum linestattype termination; voice[this_voice].currentline = NULL; } -static struct abctext* newabctext(t) -enum abctype t; +static struct abctext* newabctext(enum abctype t) /* called at newlines and barlines */ /* adds current output text to linked list structure */ /* part of new linebreak option (-n) */ @@ -446,8 +434,7 @@ static int nextnotes() } #endif -static void reduce(a, b) -int *a, *b; +static void reduce(int *a, int *b) { int t, n, m; @@ -481,8 +468,7 @@ int *a, *b; * 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; +static void addunits(int n, int m) /* add fraction n/m to count */ { if (inchord) { /* [PHDM] 2013-03-10 */ @@ -501,8 +487,7 @@ int n, m; reduce(&count.num, &count.denom); } -void parse_voices_selection(voices_string) /* [PHDM] 2013-03-08 */ -char *voices_string; +void parse_voices_selection(char *voices_string) /* [PHDM] 2013-03-08 */ { char *s = voices_string; @@ -515,16 +500,12 @@ char *voices_string; } while (*s++); } -int must_emit_voice(n) /* [PHDM] 2013-03-08 */ -int n; +int must_emit_voice(int n) /* [PHDM] 2013-03-08 */ { return selected_voices & (1 << n); } -void event_init(argc, argv, filename) -int argc; -char* argv[]; -char** filename; +void event_init(int argc, char *argv[], char **filename) /* routine called on program start-up */ { int targ, narg; @@ -717,8 +698,7 @@ char** filename; totalnotes = 0; } -void emit_string(s) -char *s; +void emit_string(char *s) /* output string */ { if (output_on) { @@ -726,8 +706,7 @@ char *s; }; } -void emit_char(ch) -char ch; +void emit_char(char ch) /* output single character */ { char *place; @@ -739,8 +718,7 @@ char ch; }; } -void emit_int(n) -int n; +void emit_int(int n) /* output integer */ { if (output_on) { @@ -748,9 +726,7 @@ int n; }; } -void emit_string_sprintf(s1, s2) -char *s1; -char *s2; +void emit_string_sprintf(char *s1, char *s2) /* output string containing string expression %s */ { if (output_on) { @@ -758,9 +734,7 @@ char *s2; }; } -void emit_int_sprintf(s, n) -char *s; -int n; +void emit_int_sprintf(char *s, int n) /* output string containing int expression %d */ { if (output_on) { @@ -813,22 +787,19 @@ void event_blankline() blankline = 1; } -void event_text(p) -char *p; +void event_text(char *p) { emit_string_sprintf("%%%s", p); inmusic = 0; } -void event_reserved(p) -char p; +void event_reserved(char p) { emit_char(p); inmusic = 0; } -void event_tex(s) -char *s; +void event_tex(char *s) { emit_string(s); inmusic = 0; @@ -872,30 +843,26 @@ void event_startmusicline() complete_bars(&voice[this_voice]); } -void event_endmusicline(endchar) -char endchar; +void event_endmusicline(char endchar) /* encountered the end of a line of notes */ { } -void event_error(s) -char *s; +void event_error(char *s) { if (echeck && output_on) { /* [SS] 2011-04-14 */ printf("\n%%Error : %s\n", s); }; } -void event_warning(s) -char *s; +void event_warning(char *s) { if (echeck && output_on) { /* [SS] 2011-04-14 */ printf("\n%%Warning : %s\n", s); }; } -void event_comment(s) -char *s; +void event_comment(char *s) { if (newbreaks && (!purgespace(tmp))) { if (inmusic) { @@ -938,18 +905,15 @@ void event_specific(char *package, char *s, int in_I) /* printf("event_specific: next_voice = %d\n",next_voice); */ } -void event_info(f) +void event_info(char *f) /* handles info field I: */ -char *f; { emit_string_sprintf("I:%s", f); inmusic = 0; } -void event_field(k, f) -char k; -char *f; +void event_field(char k, char *f) { emit_char(k); emit_char(':'); @@ -958,8 +922,7 @@ char *f; inmusic = 0; } -struct abctext* getbar(place) -struct abctext *place; +struct abctext* getbar(struct abctext *place) /* find first element in list which is a bar of music */ { struct abctext *newplace; @@ -973,8 +936,7 @@ struct abctext *place; return(newplace); } -struct abctext* getnextbar(place) -struct abctext *place; +struct abctext* getnextbar(struct abctext *place) /* find next element in list which is a bar of music */ { struct abctext *newplace; @@ -986,9 +948,7 @@ struct abctext *place; return(newplace); }; -void append_lyrics(place, newwords) -struct abctext *place; -char *newwords; +void append_lyrics(struct abctext *place, char *newwords) /* add lyrics to end of lyric list associated with bar */ { struct lyricwords* new_words; @@ -1014,12 +974,8 @@ char *newwords; }; } -struct abctext* apply_bar(syll, place, notesleft, barwords) +struct abctext* apply_bar(char *syll, struct abctext *place, int *notesleft, struct vstring *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; @@ -1038,12 +994,8 @@ struct vstring *barwords; return(new_place); } -struct abctext* apply_syllable(syll, place, notesleft, barwords) +struct abctext* apply_syllable(char *syll, struct abctext *place, int *notesleft, struct vstring *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]; @@ -1068,8 +1020,7 @@ struct vstring *barwords; return(new_place); } -void parse_words(p) -char* p; +void parse_words(char *p) /* Break up a line of lyrics (w: ) into component syllables */ { struct vstring syll; @@ -1169,10 +1120,7 @@ char* p; } /* [JA] 2022.06.14 */ -void event_words(p, append, continuation) -char* p; -int append; -int continuation; +void event_words(char *p, int append, int continuation) /* a w: field has been encountered */ { struct vstring afield; @@ -1199,16 +1147,14 @@ int continuation; } /* [SS] 2014-09-07 */ -void appendfield (morewords) -char *morewords; +void appendfield (char *morewords) { emit_string("+: "); emit_string(morewords); } -void event_part(s) -char* s; +void event_part(char *s) { if (xinbody) { complete_bars(&voice[this_voice]); @@ -1241,8 +1187,7 @@ static void init_voice(int voice_index, int num) } } -int setvoice(num) -int num; +int setvoice(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 */ { @@ -1269,10 +1214,7 @@ int num; return(voice_index); } -void event_voice(n, s, vp) -int n; -char *s; -struct voice_params *vp; +void event_voice(int n, char *s, struct voice_params *vp) { char output[300]; /* [SS] 2017-10-09 2017-10-11 2018-12-27*/ if (xinbody) { @@ -1319,8 +1261,7 @@ struct voice_params *vp; this_voice = n - 1; /* [SS] 2018-12-01 */ } -void event_length(n) -int n; +void event_length(int n) { struct fract newunit; @@ -1334,15 +1275,13 @@ int n; inmusic = 0; } -void event_default_length(n) - int n; +void event_default_length(int n) { unitlen.num = 1; unitlen.denom = n; } -void event_refno(n) -int n; +void event_refno(int n) { /* [SS] 2017-07-10 */ if (xmatch == n || xmatch == -1) parseron(); @@ -1368,11 +1307,7 @@ int n; inmusic = 0; } -void event_tempo(n, a, b, relative, pre, post) -int n, a, b; -int relative; -char *pre; -char *post; +void event_tempo(int n, int a, int b, int relative, char *pre, char *post) { struct fract newlen; @@ -1438,8 +1373,7 @@ static void set_complex_barpoint(timesig_details_t *timesig, /* M: field in the source. Support M:none, M:C and M:C| as well as * normal M:n/m */ -void event_timesig (timesig) - timesig_details_t *timesig; +void event_timesig (timesig_details_t *timesig) { have_spacing_scheme = 0; /* default to no new spacing */ emit_string ( "M:"); @@ -1524,9 +1458,7 @@ void event_timesig (timesig) inmusic = 0; } -static void setmap(sf, map) -int sf; -int map[7]; +static void setmap(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 @@ -1632,20 +1564,9 @@ return 0; /* end of [SS] 2011-02-15 */ -void event_key(sharps, s, modeindex, modmap, modmul, modmicrotone, - gotkey, gotclef, clefname, new_clef, - 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; -cleftype_t *new_clef; /* [JA] 2020-10-19 */ -int octave, xtranspose, gotoctave, gottranspose; -int explict; +void event_key(int sharps, char *s, int modeindex, char modmap[7], int modmul[7], struct fraction modmicrotone[7], + int gotkey, int gotclef, char *clefname, cleftype_t *new_clef, + int octave, int xtranspose, int gotoctave, int gottranspose, int explict) { static char* keys[12] = {"Db", "Ab", "Eb", "Bb", "F", "C", "G", "D", "A", "E", "B", "F#"}; @@ -1766,8 +1687,7 @@ int explict; } -static void printlen(a, b) -int a, b; +static void printlen(int a, int b) { if (a != 1) { emit_int(a); @@ -1781,17 +1701,14 @@ int a, b; } } -void event_spacing(n, m) -int n, m; +void event_spacing(int n, int m) { emit_string("y"); printlen(n, m); } -void event_rest(decorators,n,m,type) -int n, m, type; -int decorators[DECSIZE]; +void event_rest(int decorators[DECSIZE], int n, int m, int type) { struct fract newlen; @@ -1814,9 +1731,7 @@ int decorators[DECSIZE]; }; } -void event_mrest(n,m,c) -int n, m; -char c; /* [SS] 2017-04-19 to distinguish X from Z */ +void event_mrest(int n, int m, char c) { inmusic = 1; emit_char(c); /* [SS] 2017-04-19 */ @@ -1829,9 +1744,7 @@ char c; /* [SS] 2017-04-19 to distinguish X from Z */ }; } -void event_bar(type, replist) -int type; -char* replist; +void event_bar(int type, char *replist) { char msg[40]; @@ -1931,14 +1844,12 @@ void event_rep2() emit_string(" [2"); } -void event_playonrep(s) -char*s; +void event_playonrep(char *s) { emit_string_sprintf(" [%s", s); } -void event_broken(type, n) -int type, n; +void event_broken(int type, int n) { int i; @@ -1953,8 +1864,7 @@ int type, n; }; } -void event_tuple(n, q, r) -int n, q, r; +void event_tuple(int n, int q, int r) { if (tuplenotes != 0) { event_error("tuple within tuple not allowed"); @@ -2063,10 +1973,7 @@ void event_chordoff(int chord_n, int chord_m) void event_ignore () { }; /* [SS] 2018-12-21 */ -static void splitstring(s, sep, handler) -char* s; -char sep; -void (*handler)(); +static void splitstring(char *s, char sep, void (*handler)(char *)) /* this routine splits the string into fields using semi-colon */ /* and calls handler for each sub-string */ { @@ -2089,10 +1996,9 @@ void (*handler)(); }; } -void event_handle_gchord(s) +void event_handle_gchord(char *s) /* deals with an accompaniment (guitar) chord */ /* either copies it straight out or transposes it */ -char* s; { char newchord[50]; static int offset[7] = {9, 11, 0, 2, 4, 5, 7}; @@ -2257,21 +2163,18 @@ char* s; }; } -void event_gchord(s) -char* s; +void event_gchord(char *s) { splitstring(s, ';', event_handle_gchord); } -void event_instruction(s) -char* s; +void event_instruction(char *s) { if (oldchordconvention || noplus) emit_string_sprintf("!%s!", s); else emit_string_sprintf("+%s+", s); } -void event_slur(t) -int t; +void event_slur(int t) { if (cleanup) { if (t) { @@ -2284,14 +2187,12 @@ int t; }; } -void event_sluron(t) -int t; +void event_sluron(int t) { emit_string("("); } -void event_sluroff(t) -int t; +void event_sluroff(int t) { emit_string(")"); } @@ -2301,9 +2202,7 @@ void event_tie() emit_string("-"); } -void event_lineend(ch, n) -char ch; -int n; +void event_lineend(char ch, int n) { int i; @@ -2318,13 +2217,8 @@ int n; /* [SS] 2016-05-05 */ /* This function is used to transpose the key signature modifiers. */ /* The code was borrowed from event_note1(). */ -void transpose_note(xaccidental,xmult, xnote, xoctave, transpose, - accidental, mult, note, octave) -char xaccidental, xnote; -int xoctave, transpose; -int xmult; /* 2017-07-11 */ -char *accidental, *note; -int *octave, *mult; +void transpose_note(char xaccidental, int xmult, char xnote, int xoctave, int transpose, + char *accidental, int *mult, char *note, int *octave) { *mult = 0; if (transpose == 0 || drumchan) { @@ -2424,12 +2318,7 @@ static void consider_break_after_note(int previous_tuplenotes) } } -void event_note1(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int xmult; -char xaccidental, xnote; -int xoctave, n, m; +void event_note1(int decorators[DECSIZE], cleftype_t *clef, char xaccidental, int xmult, char xnote, int xoctave, int n, int m) { int t; struct fract barpoint; @@ -2574,13 +2463,8 @@ int accidental_to_code (char xaccidental) } -void event_note2(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) +void event_note2(int decorators[DECSIZE], cleftype_t *clef, char xaccidental, int xmult, char xnote, int xoctave, int n, int m) /* this function is called if flag nokey is set */ -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int xmult; -char xaccidental, xnote; -int xoctave, n, m; { int t; struct fract barpoint; @@ -2636,12 +2520,7 @@ int xoctave, n, m; } -void event_note(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m) -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int xmult; -char xaccidental, xnote; -int xoctave, n, m; +void event_note(int decorators[DECSIZE], cleftype_t *clef, char xaccidental, int xmult, char xnote, int xoctave, int n, int m) { if (nokey) event_note2(decorators, clef, xaccidental, xmult, xnote, xoctave, n, m); @@ -2837,9 +2716,7 @@ while (p < MIDDLE - 12) { } -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { char *filename; diff --git a/yapstree.c b/yapstree.c index febc353..af515d2 100755 --- a/yapstree.c +++ b/yapstree.c @@ -48,7 +48,7 @@ char* strchr(); #include "drawtune.h" extern void setscaling(char *s); -extern void font_command(); +extern void font_command(char *p, char *s); extern void setup_fonts(); extern void printtune(struct tune *t); extern void set_keysig(struct key *k, struct key *newval); @@ -86,17 +86,14 @@ enum linestattype linestat; int dummydecorator[DECSIZE]; /* used in event_chord */ -void setfract(f, a, b) -struct fract* f; -int a, b; +void setfract(struct fract *f, int a, int b) /* assign value to fraction */ { f->num = a; f->denom = b; } -void reducef(f) -struct fract* f; +void reducef(struct fract *f) /* reducef fraction to smallest terms */ { int t, n, m; @@ -712,14 +709,8 @@ static char* decstring(int decorators[]) }; } -static struct note* newnote(decorators, clef, xaccidental, xmult, xnote, xoctave, - a, b) -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int xmult; -char xaccidental, xnote; -int xoctave; -int a, b; +static struct note* newnote(int decorators[DECSIZE], cleftype_t *clef, char xaccidental, int xmult, char xnote, int xoctave, + int a, int b) /* create and set up the fields for a note structure */ { struct note* n; @@ -785,9 +776,7 @@ static struct rest* newrest(int a, int b, int multi) return(n); } -static void addunits(f, n, m) -struct fract* f; -int n, m; +static void addunits(struct fract *f, int n, int m) /* add n/m to fraction pointed to by f */ { f->num = n*f->denom*(cv->unitlen.num) + f->num*(m*cv->unitlen.denom); @@ -795,9 +784,7 @@ int n, m; reducef(f); } -static void addfractions(f,n,m) -struct fract* f; -int n,m; +static void addfractions(struct fract *f, int n, int m) { f->num = n*f->denom + f->num*m; f->denom = m*f->denom; @@ -1110,10 +1097,7 @@ static int checkmatch(int refno) return(select); } -void event_init(argc, argv, filename) -int argc; -char* argv[]; -char** filename; +void event_init(int argc, char *argv[], char **filename) /* initialization routine - called once at the start of the program */ /* interprets the parameters in argv */ { @@ -1346,22 +1330,17 @@ void event_blankline() parseroff(); } -void event_text(p) +void event_text(char *p) /* Text outside an abc tune has been encountered */ -char *p; { } -void event_x_reserved(p) -char p; +void event_x_reserved(char p) { } -void event_abbreviation(symbol, string, container) +void event_abbreviation(char symbol, char *string, char container) /* abbreviation declaratiion - handled by parser. Ignore it here */ -char symbol; -char *string; -char container; { } @@ -1389,8 +1368,7 @@ addnumberfeature(SPLITVOICE, lineno); event_error("voice split not implemented in yaps"); } -void event_tex(s) -char *s; +void event_tex(char *s) /* A TeX command has been found in the abc */ { } @@ -1482,8 +1460,7 @@ void event_score_linebreak (char ch) } } -void event_endmusicline(endchar) -char endchar; +void event_endmusicline(char endchar) /* We are at the end of a line of abc notes */ { cv->lineend = addnumberfeature(MUSICSTOP, 0); @@ -1494,22 +1471,19 @@ char endchar; }; } -void event_error(s) -char *s; +void event_error(char *s) /* report any error message */ { printf("Error in line %d : %s\n", lineno, s); } -void event_warning(s) -char *s; +void event_warning(char *s) /* report any warning message */ { printf("Warning in line %d : %s\n", lineno, s); } -void event_comment(s) -char *s; +void event_comment(char *s) /* A comment has been encountered in the input */ { } @@ -1597,9 +1571,7 @@ void event_specific(char *p, char *str, int in_I) font_command(p, s); } -void event_field(k, f) -char k; -char *f; +void event_field(char k, char *f) /* A field line has been encountered in the input abc */ { switch (k) { @@ -1713,10 +1685,7 @@ struct feature* apply_syll(char* s, struct feature* wordplace, int* errors) } /* [JA] 2022.06.14 */ -void event_words(p, append, continuation) -char* p; -int append; -int continuation; +void event_words(char *p, int append, int continuation) /* A line of lyrics (w: ) has been encountered in the abc */ { struct vstring syll; @@ -1818,14 +1787,12 @@ int continuation; } /* [SS] 2014-08-16 */ -void appendfield (morewords) -char *morewords; +void appendfield (char *morewords) { printf("appendfield not implemented here\n"); } -void event_part(s) -char* s; +void event_part(char *s) /* A part field (P: ) has been encountered in the abc */ { char label[200]; /* [SS] 2010-12-12 */ @@ -1848,10 +1815,7 @@ char* s; }; } -void event_voice(n, s, vp) -int n; -char *s; -struct voice_params *vp; +void event_voice(int n, char *s, struct voice_params *vp) /* A voice field (V: ) has been encountered */ { if (xinbody) { @@ -1869,8 +1833,7 @@ struct voice_params *vp; }; } -void event_length(n) -int n; +void event_length(int n) /* A length field (L: ) has been encountered */ { if (xinhead) { @@ -1886,15 +1849,13 @@ int n; }; } -void event_default_length (n) - int n; +void event_default_length (int n) /* Handles a missing L: field */ { event_length(n); } -void event_refno(n) -int n; +void event_refno(int n) /* A reference field (X: ) has been encountered. This indicates the start */ /* of a new tune */ { @@ -1924,11 +1885,9 @@ int n; }; } -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 */ +void event_tempo(int n, int a, int b, int relative, char *pre, char *post) +//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 */ @@ -1952,8 +1911,7 @@ char *post; /* text after tempo */ }; } -void event_timesig (timesig) - timesig_details_t *timesig; +void event_timesig (timesig_details_t *timesig) /* A time signature (M: ) has been encountered in the abc */ { int checkbars; @@ -2000,11 +1958,9 @@ void event_clef(char* clefstr, cleftype_t * new_clef) }; } -void setmap(sf, map, mult) +void setmap(int sf, char map[7], int mult[7]) /* 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 sf; /* number of sharps in key signature -7 to +7 */ { int j; @@ -2028,10 +1984,8 @@ int mult[7]; if (sf <= -7) map['f'-'a'] = '_'; } -void altermap(basemap, basemul, modmap, modmul) +void altermap(char basemap[7], int basemul[7], char modmap[7], int modmul[7]) /* apply modifiers to a set of accidentals */ -char basemap[7], modmap[7]; -int basemul[7], modmul[7]; { int i; @@ -2073,12 +2027,8 @@ static void start_body() }; } -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]; +void event_true_key(int sharps, char *s, int modeindex, char modmap[7], int modmul[7]) +//int modeindex; /* 0 major, 1,2,3 minor, 4 locrian, etc. */ /* key detected in K: field */ { char basemap[7]; @@ -2119,20 +2069,9 @@ void event_octave(int num, int local) }; } -void event_key(sharps, s, minor, modmap, modmul, modmicrotone, gotkey, - gotclef, clefstr, new_clef, - 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; /* [JA] 2020-10-19 */ -cleftype_t * new_clef; -int octave, transpose, gotoctave, gottranspose; -int explict; +void event_key(int sharps, char *s, int minor, char modmap[7], int modmul[7], struct fraction modmicrotone[7], int gotkey, + int gotclef, char *clefstr, cleftype_t *new_clef, + int octave, int transpose, int gotoctave, int gottranspose, int explict) /* A key field (K: ) has been encountered */ { if (xinhead || xinbody) { @@ -2189,9 +2128,7 @@ static void checkbar(int type) }; } -void event_bar(type, playonrep_list) -int type; -char* playonrep_list; +void event_bar(int type, char *playonrep_list) /* A bar has been encountered in the abc */ { if (cv->inchord) { @@ -2259,16 +2196,14 @@ void event_rep2() addfeature(REP2, NULL); } -void event_playonrep(s) -char* s; +void event_playonrep(char *s) /* play on repeat(s) X - where X can be a list */ { addfeature(PLAY_ON_REP, addstring(s)); } -void event_broken(type, mult) +void event_broken(int type, int mult) /* handles > >> >>> < << <<< in the abc */ -int type, mult; { if (cv->inchord) { event_error("Broken rhythm not allowed in chord"); @@ -2283,8 +2218,7 @@ int type, mult; }; } -void event_tuple(n, q, r) -int n, q, r; +void event_tuple(int n, int q, int 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 */ @@ -2327,8 +2261,7 @@ void event_closeinline() { } -void event_handle_gchord(s) -char* s; +void event_handle_gchord(char *s) /* Guitar/Accompaniment chord placed in linked list for association */ /* with next suitable note */ { @@ -2345,8 +2278,7 @@ char* s; }; } -void event_handle_instruction(s) -char* s; +void event_handle_instruction(char *s) /* An instruction (! !) has been encountered */ { char* inst; @@ -2442,8 +2374,7 @@ static void startslurs(struct feature* firstnote) }; } -void event_sluron(t) -int t; +void event_sluron(int t) /* start of slur */ { struct slurtie* s; @@ -2459,8 +2390,7 @@ int t; }; } -void event_sluroff(t) -int t; +void event_sluroff(int t) /* end of slur */ { struct slurtie* s; @@ -2542,17 +2472,13 @@ void event_tie() }; } -void event_lineend(ch, n) -char ch; -int n; +void event_lineend(char ch, int n) /* Line ending with n copies of special character ch */ { } -static void lenmul(n, a, b) +static void lenmul(struct feature *n, int a, int b) /* multiply note length by a/b */ -struct feature* n; -int a, b; { struct note *anote; struct rest* arest; @@ -2818,13 +2744,11 @@ void event_chordoff(int chord_n, int chord_m) } /* just a stub to ignore 'y' */ -void event_spacing(n, m) -int n,m; +void event_spacing(int n, int m) { } -void xevent_rest(n, m, multi) -int n, m, multi; +void xevent_rest(int n, int m, int multi) /* A rest has been encountered in the abc */ /* multi is 0 for ordinary rests or count for multibar rests */ { @@ -2870,28 +2794,20 @@ int n, m, multi; }; } -void event_rest(decorators,n,m,type) -int n, m,type; -int decorators[DECSIZE]; +void event_rest(int decorators[DECSIZE], int n, int m, int type) /* 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 */ +void event_mrest(int n, int m, char c) +//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, clef, xaccidental, xmult, xnote, xoctave, n, m) -int decorators[DECSIZE]; -cleftype_t *clef; /* [JA] 2020-10-19 */ -int xmult; -char xaccidental, xnote; -int xoctave, n, m; +void event_note(int decorators[DECSIZE], cleftype_t *clef, char xaccidental, int xmult, char xnote, int xoctave, int n, int m) /* note found in abc */ { struct note* nt; @@ -2962,9 +2878,7 @@ void event_normal_tone() -void event_info_key(key, value) -char* key; -char* value; +void event_info_key(char *key, char *value) /* handles a (key,value) pair found in an I: field */ { int num; @@ -2989,9 +2903,7 @@ char* value; } -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc,char *argv[]) { char *filename; int i;