home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
app
/
mtools
/
mw.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-21
|
2KB
|
117 lines
/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sundev/midi.h>
usage()
{
printf("usage: mw b1 [ b2 b3 ... ]\n");
exit(1);
}
w(fd, p)
int fd;
struct midi_msg *p;
{
int cc;
cc = write(fd, (caddr_t)p, sizeof(*p));
if (cc < 0) {
perror("write");
exit(1);
}
printf("wrote %d bytes\n", cc);
}
xm(fd, t, c, v)
{
struct midi_msg mm;
mm.mm_time = t;
mm.mm_data[0] = c;
mm.mm_data[1] = v;
mm.mm_data[2] = 0x20;
w(fd, &mm);
}
on(fd, t, v)
{
xm(fd, t, 0x90, v);
}
off(fd, t, v)
{
xm(fd, t, 0x80, v);
}
mute(fd, t)
{
int i, cc;
struct midi_msg m;
m.mm_time = t;
for (i = 0; i < 16; ++i) {
m.mm_data[0] = 0xb0 | i;
w(fd, &m);
}
}
extern char *optarg;
main(argc, argv)
int argc;
char **argv;
{
int fd, c;
int port = 1;
u_long t;
char *dev = "/dev/midi0";
while ((c = getopt(argc, argv, "p:")) != -1) {
switch(c) {
case 'p':
port = atoi(optarg);
break;
default:
usage();
}
}
fd = midi_open(O_WRONLY, port);
on(fd, 100, 0x3c);
off(fd, 1100, 0x3c);
#ifdef notdef
if (ioctl(fd, BMDPAUSE, 0) < 0) {
perror("BMDPAUSE");
exit(1);
}
#endif
mute(fd, 1500);
#ifdef notdef
(void)ioctl(fd, BMDRESUME, 0);
#endif
close(fd);
exit(0);
}