diff --git a/midi2tones.c b/midi2tones.c index 76a7fd8..109a31e 100644 --- a/midi2tones.c +++ b/midi2tones.c @@ -58,6 +58,7 @@ * * midi2tones chopin * +* * It will create a file in the same directory called "chopin.c" which contains * the C-language statement to intiialize an array called "score" with the bytestream. * @@ -72,6 +73,9 @@ * The is the base name, without an extension, for the input and * output files. It can contain directory path information, or not. * +* If the provided by the user ends in .mid, that will be stripped off +* before being used. +* * The input file is .mid The output filename(s) * are the base file name with .c, .bin, and/or .log extensions. * @@ -239,6 +243,7 @@ * The MIT License (MIT) * Original work Copyright (c) 2011,2013,2015,2016, Len Shustek * Modified work Copyright (c) 2016, Scott Allen +* Modified work Copyright (c) 2020, Ben Combee * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -325,8 +330,11 @@ * -Prevent unnecessary "note off" commands from being generated by delaying * them until we see if a "note on" is generated before the next wait. * Ported from MIDITONES V1.14 +* 17 October 2020, Ben Combee, V1.1.0 +* -Support user providing full name of MIDI file on command line by stripping +* off the .mid suffix if provided */ -#define VERSION "1.0.0" +#define VERSION "1.1.0" /*-------------------------------------------------------------------------------------------- @@ -1176,13 +1184,14 @@ int main (int argc, char *argv[]) { char *filebasename; #define MAXPATH 120 char filename[MAXPATH]; + int filenamelen; int tracknum; int earliest_tracknum; unsigned long earliest_time; int notes_skipped = 0; char *text; - printf ("MIDI2TONES V%s\n(C) 2011-2016 Len Shustek\n(C) 2016 Scott Allen\n", VERSION); + printf ("MIDI2TONES V%s\n(C) 2011-2016 Len Shustek\n(C) 2016 Scott Allen\n(C) 2020 Ben Combee\n", VERSION); if (argc == 1) { /* no arguments */ SayUsage (argv[0]); return 1; @@ -1198,6 +1207,15 @@ int main (int argc, char *argv[]) { } filebasename = argv[argno]; +/* strip off trailing .mid or .MID extension if provided by user */ + + filenamelen = strlength(filebasename); + if (filenamelen > 4 && + (charcmp(filebasename + filenamelen - 4, ".mid") || + charcmp(filebasename + filenamelen - 4, ".MID"))) { + filebasename[filenamelen - 4] = 0; + } + /* if alternate output format, overide options with required values */ if (alt_out) { num_tonegens = 1;