Module Name:    src
Committed By:   martin
Date:           Sat May 12 10:40:25 UTC 2018

Modified Files:
        src/usr.bin/midiplay [netbsd-8]: midiplay.1 midiplay.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #820):

        usr.bin/midiplay/midiplay.1: revision 1.20
        usr.bin/midiplay/midiplay.1: revision 1.21
        usr.bin/midiplay/midiplay.c: revision 1.31
        usr.bin/midiplay/midiplay.c: revision 1.32

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.

Merge options without arguments in synopsis.

Sync usage with manpage.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.38.1 src/usr.bin/midiplay/midiplay.1
cvs rdiff -u -r1.30 -r1.30.8.1 src/usr.bin/midiplay/midiplay.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/midiplay/midiplay.1
diff -u src/usr.bin/midiplay/midiplay.1:1.19 src/usr.bin/midiplay/midiplay.1:1.19.38.1
--- src/usr.bin/midiplay/midiplay.1:1.19	Sat Jan 16 08:50:29 2010
+++ src/usr.bin/midiplay/midiplay.1	Sat May 12 10:40:25 2018
@@ -1,4 +1,5 @@
-.\" $NetBSD: midiplay.1,v 1.19 2010/01/16 08:50:29 mbalmer Exp $
+.\" $NetBSD: midiplay.1,v 1.19.38.1 2018/05/12 10:40:25 martin 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
@@ -33,15 +34,11 @@
 .Nd play MIDI and RMID files
 .Sh SYNOPSIS
 .Nm
+.Op Fl lmqsvx
 .Op Fl d Ar devno
 .Op Fl f Ar file
-.Op Fl l
-.Op Fl m
 .Op Fl p Ar pgm
-.Op Fl q
 .Op Fl t Ar tempo
-.Op Fl v
-.Op Fl x
 .Op Ar file ...
 .Sh DESCRIPTION
 The
@@ -86,6 +83,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 +125,8 @@ It may take a long while before playing 
 .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.

Index: src/usr.bin/midiplay/midiplay.c
diff -u src/usr.bin/midiplay/midiplay.c:1.30 src/usr.bin/midiplay/midiplay.c:1.30.8.1
--- src/usr.bin/midiplay/midiplay.c:1.30	Sun Mar 22 22:47:43 2015
+++ src/usr.bin/midiplay/midiplay.c	Sat May 12 10:40:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: midiplay.c,v 1.30 2015/03/22 22:47:43 mrg Exp $	*/
+/*	$NetBSD: midiplay.c,v 1.30.8.1 2018/05/12 10:40:25 martin 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.30.8.1 2018/05/12 10:40:25 martin 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
@@ -148,8 +155,8 @@ static u_char sample[] = {
 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",
+	fprintf(stderr, "usage: %s [-lmqsvx] [-d devno] [-f file] "
+		"[-p pgm] [-t tempo] [file ...]\n",
 		getprogname());
 	exit(1);
 }
@@ -408,9 +415,12 @@ playdata(u_char *buf, u_int tot, const c
 		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

Reply via email to