From 18656188be561b98357eb7267789ef02c85a03f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=81SHIN?= Date: Mon, 1 Jan 2018 13:12:35 +0100 Subject: [PATCH] Do not include zero-length delays in output This would cause lockup in ATtiny-playtune and output can be significantly shorter without zero-length delays. See http://www.mariopiano.com/Mario-Sheet-Music-Overworld-Main-Theme.mid --- miditones.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/miditones.c b/miditones.c index 2efca15..870fc88 100644 --- a/miditones.c +++ b/miditones.c @@ -1225,18 +1225,20 @@ This is not unlike multiway merging used for tape sorting algoritms in the 50's! unsigned long long temp; temp = ((unsigned long long) delta_time * tempo) / ticks_per_beat; delta_msec = temp / 1000; // get around LCC compiler bug - if (loggen) - fprintf (logfile, "->Delay %ld msec (%ld ticks)\n", delta_msec, delta_time); - if (delta_msec > 0x7fff) - midi_error ("INTERNAL: time delta too big", trk->trkptr); - /* output a 15-bit delay in big-endian format */ - if (binaryoutput) { - putc ((unsigned char) (delta_msec >> 8), outfile); - putc ((unsigned char) (delta_msec & 0xff), outfile); - outfile_bytecount += 2; - } else { - fprintf (outfile, "%ld,%ld, ", delta_msec >> 8, delta_msec & 0xff); - outfile_items (2); + if (delta_msec) { + if (loggen) + fprintf (logfile, "->Delay %ld msec (%ld ticks)\n", delta_msec, delta_time); + if (delta_msec > 0x7fff) + midi_error ("INTERNAL: time delta too big", trk->trkptr); + /* output a 15-bit delay in big-endian format */ + if (binaryoutput) { + putc ((unsigned char) (delta_msec >> 8), outfile); + putc ((unsigned char) (delta_msec & 0xff), outfile); + outfile_bytecount += 2; + } else { + fprintf (outfile, "%ld,%ld, ", delta_msec >> 8, delta_msec & 0xff); + outfile_items (2); + } } } timenow = earliest_time;