Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/usr.bin/midiplay Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/e72e3b7d6f2d
branches:  netbsd-8
changeset: 434988:e72e3b7d6f2d
user:      martin <martin%NetBSD.org@localhost>
date:      Sat May 12 10:40:25 2018 +0000

description:
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.

diffstat:

 usr.bin/midiplay/midiplay.1 |  21 ++++++++++++++-------
 usr.bin/midiplay/midiplay.c |  34 ++++++++++++++++++++++++++--------
 2 files changed, 40 insertions(+), 15 deletions(-)

diffs (154 lines):

diff -r d492672d4728 -r e72e3b7d6f2d usr.bin/midiplay/midiplay.1
--- a/usr.bin/midiplay/midiplay.1       Sat May 12 10:35:45 2018 +0000
+++ b/usr.bin/midiplay/midiplay.1       Sat May 12 10:40:25 2018 +0000
@@ -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 @@
 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 @@
 .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 -r d492672d4728 -r e72e3b7d6f2d usr.bin/midiplay/midiplay.c
--- a/usr.bin/midiplay/midiplay.c       Sat May 12 10:35:45 2018 +0000
+++ b/usr.bin/midiplay/midiplay.c       Sat May 12 10:40:25 2018 +0000
@@ -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 @@
 #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 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 @@
                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 @@
        int ch;
        int listdevs = 0;
        int example = 0;
+       int silence = 0;
        int nmidi;
        const char *file = DEVMUSIC;
        const char *sunit;
@@ -725,7 +736,7 @@
        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 @@
                case 'q':
                        play = 0;
                        break;
+               case 's':
+                       silence++;
+                       break;
                case 't':
                        ttempo = atoi(optarg);
                        break;
@@ -785,6 +799,10 @@
        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



Home | Main Index | Thread Index | Old Index