Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/midiplay if just parsing don't try to r...



details:   https://anonhg.NetBSD.org/src/rev/33eabd527ebf
branches:  trunk
changeset: 318668:33eabd527ebf
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu May 03 01:12:57 2018 +0000
description:
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:

 usr.bin/midiplay/midiplay.1 |  16 ++++++++++++++--
 usr.bin/midiplay/midiplay.c |  32 +++++++++++++++++++++++++-------
 2 files changed, 39 insertions(+), 9 deletions(-)

diffs (143 lines):

diff -r c5d16f3fb087 -r 33eabd527ebf usr.bin/midiplay/midiplay.1
--- a/usr.bin/midiplay/midiplay.1       Thu May 03 01:12:26 2018 +0000
+++ b/usr.bin/midiplay/midiplay.1       Thu May 03 01:12:57 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.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 @@
 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 @@
 .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 c5d16f3fb087 -r 33eabd527ebf usr.bin/midiplay/midiplay.c
--- a/usr.bin/midiplay/midiplay.c       Thu May 03 01:12:26 2018 +0000
+++ b/usr.bin/midiplay/midiplay.c       Thu May 03 01:12:57 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.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 @@
 #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 @@
 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 @@
                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