diff options
| author | mrg <mrg@NetBSD.org> | 2018-05-03 01:12:57 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2018-05-03 01:12:57 +0000 |
| commit | faf5c1eb83044671d433cd0993bfebccbc8c6720 (patch) | |
| tree | 5a53fb7414a68c84acecb682b026e8b31f46c523 /usr.bin | |
| parent | 76d74c8c1b06b62fbdf84a6de7a86be484e59d80 (diff) | |
if just parsing don't try to read the uninitialised device name,
or display the unit number.
add a "-s" option that sends an ALL_SOUNDS_OFF midi event. very
useful after an interrupted midiplay leaves notes on.
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/midiplay/midiplay.1 | 16 | ||||
| -rw-r--r-- | usr.bin/midiplay/midiplay.c | 32 |
2 files changed, 39 insertions, 9 deletions
diff --git a/usr.bin/midiplay/midiplay.1 b/usr.bin/midiplay/midiplay.1 index fa2387a353d..7aa4d37d614 100644 --- a/usr.bin/midiplay/midiplay.1 +++ b/usr.bin/midiplay/midiplay.1 @@ -1,4 +1,5 @@ -.\" $NetBSD: midiplay.1,v 1.19 2010/01/16 08:50:29 mbalmer Exp $ +.\" $NetBSD: midiplay.1,v 1.20 2018/05/03 01:12:57 mrg Exp $ +.\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -25,7 +26,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 16, 2010 +.Dd May 2, 2018 .Dt MIDIPLAY 1 .Os .Sh NAME @@ -39,6 +40,7 @@ .Op Fl m .Op Fl p Ar pgm .Op Fl q +.Op Fl s .Op Fl t Ar tempo .Op Fl v .Op Fl x @@ -86,6 +88,11 @@ There is no way at present to have selectively map channels or instruments. .It Fl q specifies that the MIDI file should not be played, just parsed. +.It Fl s +send an +.Dq ALL SOUNDS OFF +MIDI event. +Useful if an interrupted MIDI file left notes playing. .It Fl t Ar tempo-adjust specifies an adjustment (in percent) to the tempi recorded in the file. The default of 100 plays as specified in the file, 50 halves every tempo, @@ -123,3 +130,8 @@ It may take a long while before playing stops when .Nm is interrupted, as the data already buffered in the sequencer will contain timing events. +Use +.Nm +with the +.Fl s +option to silence any sounds left after an interrupted call. diff --git a/usr.bin/midiplay/midiplay.c b/usr.bin/midiplay/midiplay.c index d40e8e333b6..4089e72d652 100644 --- a/usr.bin/midiplay/midiplay.c +++ b/usr.bin/midiplay/midiplay.c @@ -1,4 +1,4 @@ -/* $NetBSD: midiplay.c,v 1.30 2015/03/22 22:47:43 mrg Exp $ */ +/* $NetBSD: midiplay.c,v 1.31 2018/05/03 01:12:57 mrg Exp $ */ /* * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: midiplay.c,v 1.30 2015/03/22 22:47:43 mrg Exp $"); +__RCSID("$NetBSD: midiplay.c,v 1.31 2018/05/03 01:12:57 mrg Exp $"); #endif @@ -128,6 +128,13 @@ static u_char sample[] = { #undef E #undef F +static u_char silence_sample[] = { + 'M', 'T', 'h', 'd', 0, 0, 0, 6, 0, 1, 0, 1, 0, 8, + 'M', 'T', 'r', 'k', 0, 0, 0, 8, + 0, 0xb0, 0x78, 0x00, + 0, 0xff, 0x2f, 0 +}; + #define MARK_HEADER "MThd" #define MARK_TRACK "MTrk" #define MARK_LEN 4 @@ -149,7 +156,7 @@ static void __attribute__((__noreturn__)) usage(void) { fprintf(stderr, "usage: %s [-d unit] [-f file] [-l] [-m] [-p pgm] [-q] " - "[-t %%tempo] [-v] [-x] [file ...]\n", + "[-t %%tempo] [-v] [-x] [-s] [file ...]\n", getprogname()); exit(1); } @@ -408,9 +415,12 @@ playdata(u_char *buf, u_int tot, const char *name) err(1, "ioctl(SEQUENCER_INFO) failed"); end = buf + tot; - if (verbose) - printf("Playing %s (%d bytes) on %s (unit %d)... \n", - name, tot, info.name, info.device); + if (verbose) { + printf("Playing %s (%d bytes)", name, tot); + if (play) + printf(" on %s (unit %d)...", info.name, info.device); + puts("\n"); + } if (tot < MARK_LEN + 4) { warnx("Not a MIDI file, too short"); @@ -716,6 +726,7 @@ main(int argc, char **argv) int ch; int listdevs = 0; int example = 0; + int silence = 0; int nmidi; const char *file = DEVMUSIC; const char *sunit; @@ -725,7 +736,7 @@ main(int argc, char **argv) if ((sunit = getenv("MIDIUNIT"))) unit = parse_unit(sunit); - while ((ch = getopt(argc, argv, "?d:f:lmp:qt:vx")) != -1) { + while ((ch = getopt(argc, argv, "?d:f:lmp:qst:vx")) != -1) { switch(ch) { case 'd': unit = parse_unit(optarg); @@ -745,6 +756,9 @@ main(int argc, char **argv) case 'q': play = 0; break; + case 's': + silence++; + break; case 't': ttempo = atoi(optarg); break; @@ -785,6 +799,10 @@ main(int argc, char **argv) if (example) while (example--) playdata(sample, sizeof sample, "<Gubben Noa>"); + else if (silence) + while (silence--) + playdata(silence_sample, sizeof silence_sample, + "<Silence>"); else if (argc == 0) playfile(stdin, "<stdin>"); else |
