From 87e4055514d54dda96c78c3e76179152a8c54518 Mon Sep 17 00:00:00 2001 From: angel Date: Sun, 19 Jun 2005 10:50:48 +0000 Subject: [PATCH] Time skipping capabilities have been added to MIDI playing (Closes: #1085). git-svn-id: file:///home/angel/tmp/svn-triptico/ahxm/trunk@698 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- TODO | 6 +++++- midi_song.c | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 0e4eb69..054863e 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,6 @@ Release Critical Bugs * 1060: Add ss_tempo_from_wave to language. * 1067: Fill the extended commands document. * 1079: Move midiin.c functionality to main.c. - * 1085: Add skip_secs capability to MIDI output. * 1086: MIDI output is still done to stdout (file descriptor 2). Open Bugs @@ -29,6 +28,9 @@ Open Bugs * 1056: Note printing in midiin.c should also print chords. * 1070: Portamento support is still uncertain. * 1022: Add file name to compiler errors. + * 1087: When skipping time, MIDI should still write program changes + (and probably other messages) to the output device; that is, only + notes and time sleeping should be skipped. Pending Enhancements -------------------- @@ -201,5 +203,7 @@ Closed another block, a syntax error is generated (Thu, 16 Jun 2005 18:32:54 +0200). * 1071: Add the posibility to start a song from a given measure or time (Sun, 19 Jun 2005 10:56:11 +0200). + * 1085: Add skip_secs capability to MIDI output + (Sun, 19 Jun 2005 12:48:51 +0200). Email bugs to angel@triptico.com diff --git a/midi_song.c b/midi_song.c index 7b8636e..6f5cba7 100644 --- a/midi_song.c +++ b/midi_song.c @@ -374,20 +374,23 @@ int midi_song_play(int skip_secs) if(!go) break; - /* if there are pending messages, write them */ - if(mi) - write(midi_fd, midimsg, mi); - /* get time of next event */ msecs_p=msecs; msecs=e->generic.msecs; msecs_d=msecs - msecs_p; - /* calculate the time to sleep */ - ts.tv_sec=(time_t) msecs_d / 1000; - ts.tv_nsec=(long) ((msecs_d * 1000000) % 1000000000); + if(msecs >= skip_msecs) + { + /* if there are pending messages, write them */ + if(mi) + write(midi_fd, midimsg, mi); + + /* calculate the time to sleep */ + ts.tv_sec=(time_t) msecs_d / 1000; + ts.tv_nsec=(long) ((msecs_d * 1000000) % 1000000000); - nanosleep(&ts, NULL); + nanosleep(&ts, NULL); + } } return(0); -- 2.11.4.GIT