Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/midiplay Add a -p flag to set the MIDI program. Fro...



details:   https://anonhg.NetBSD.org/src/rev/44dc89a0d393
branches:  trunk
changeset: 482659:44dc89a0d393
user:      augustss <augustss%NetBSD.org@localhost>
date:      Fri Feb 18 23:03:05 2000 +0000

description:
Add a -p flag to set the MIDI program.  From lindroos%nls.fi@localhost.

diffstat:

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

diffs (104 lines):

diff -r f5c5c64fe9e3 -r 44dc89a0d393 usr.bin/midiplay/midiplay.1
--- a/usr.bin/midiplay/midiplay.1       Fri Feb 18 20:52:15 2000 +0000
+++ b/usr.bin/midiplay/midiplay.1       Fri Feb 18 23:03:05 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: midiplay.1,v 1.6 1999/09/30 13:47:57 soren Exp $
+.\" $NetBSD: midiplay.1,v 1.7 2000/02/18 23:03:05 augustss Exp $
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
@@ -44,6 +44,8 @@
 .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
@@ -68,6 +70,8 @@
 list the possible devices without playing anything.
 .It Fl m
 show MIDI file meta events (copyright, lyrics, etc).
+.It Fl p Ar pgm
+use only this program (range 1-128) for all channels.
 .It Fl q
 specifies that the MIDI file should not be played, just parsed.
 .It Fl t Ar tempo
diff -r f5c5c64fe9e3 -r 44dc89a0d393 usr.bin/midiplay/midiplay.c
--- a/usr.bin/midiplay/midiplay.c       Fri Feb 18 20:52:15 2000 +0000
+++ b/usr.bin/midiplay/midiplay.c       Fri Feb 18 23:03:05 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midiplay.c,v 1.9 1999/10/11 12:52:10 augustss Exp $    */
+/*     $NetBSD: midiplay.c,v 1.10 2000/02/18 23:03:05 augustss Exp $   */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -129,7 +129,7 @@
 void
 usage()
 {
-       printf("Usage: %s [-d unit] [-f file] [-l] [-m] [-q] [-t tempo] [-v] [-x] [file ...]\n",
+       printf("Usage: %s [-d unit] [-f file] [-l] [-m] [-p pgm] [-q] [-t tempo] [-v] [-x] [file ...]\n",
                __progname);
        exit(1);
 }
@@ -142,6 +142,7 @@
 int unit = 0;
 int play = 1;
 int fd;
+int sameprogram = 0;
 
 void
 send_event(ev)
@@ -322,7 +323,7 @@
                printf("format=%d ntrks=%d divfmt=%x ticks=%d\n",
                       format, ntrks, divfmt, ticks);
        if (format != 0 && format != 1) {
-               warnx("Cannnot play MIDI file of type %d\n", format);
+               warnx("Cannot play MIDI file of type %d\n", format);
                return;
        }
        if (ntrks == 0)
@@ -353,7 +354,13 @@
         * Play MIDI events by selecting the track track with the lowest
         * curtime.  Execute the event, update the curtime and repeat.
         */
-
+       if(sameprogram) {
+               for(t=0;t<16;t++) {
+                       SEQ_MK_CHN_COMMON(&event, unit, MIDI_PGM_CHANGE, t,
+                               sameprogram+1, 0, 0);
+                       send_event(&event);
+               }
+       }
        /*
         * The ticks variable is the number of ticks that make up a quarter
         * note and is used as a reference value for the delays between
@@ -434,6 +441,7 @@
                                send_event(&event);
                                break;
                        case MIDI_PGM_CHANGE:
+                               if(sameprogram) break;
                        case MIDI_CHN_PRESSURE:
                                SEQ_MK_CHN_COMMON(&event, unit, status, chan, 
                                                  msg[0], 0, 0);
@@ -486,7 +494,7 @@
        struct synth_info info;
        FILE *f;
 
-       while ((ch = getopt(argc, argv, "?d:f:lmqt:vx")) != -1) {
+       while ((ch = getopt(argc, argv, "?d:f:lmp:qt:vx")) != -1) {
                switch(ch) {
                case 'd':
                        unit = atoi(optarg);
@@ -500,6 +508,9 @@
                case 'm':
                        showmeta++;
                        break;
+               case 'p':
+                       sameprogram = atoi(optarg);
+                       break;
                case 'q':
                        play = 0;
                        break;



Home | Main Index | Thread Index | Old Index