Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions midi2tones.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -72,6 +73,9 @@
* The <basefilename> is the base name, without an extension, for the input and
* output files. It can contain directory path information, or not.
*
* If the <basefilename> provided by the user ends in .mid, that will be stripped off
* before being used.
*
* The input file is <basefilename>.mid The output filename(s)
* are the base file name with .c, .bin, and/or .log extensions.
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"

/*--------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down