version 1.4, 2003/06/10 22:20:48 |
version 1.5, 2004/05/14 04:27:26 |
|
|
* POSSIBILITY OF SUCH DAMAGE. |
* POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#include <sys/types.h> |
|
#include <sys/stat.h> |
|
#include <sys/ioctl.h> |
|
#include <sys/midiio.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <limits.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <err.h> |
#include <err.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <string.h> |
#include <string.h> |
#include <sys/types.h> |
|
#include <sys/stat.h> |
|
#include <sys/ioctl.h> |
|
#include <sys/midiio.h> |
|
|
|
#define DEVMUSIC "/dev/music" |
#define DEVMUSIC "/dev/music" |
|
|
|
|
void |
void |
usage(void) |
usage(void) |
{ |
{ |
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] [-q] [-t tempo]" |
__progname); |
"[-v] [-x] [file ...]\n", __progname); |
exit(1); |
exit(1); |
} |
} |
|
|
|
|
void |
void |
playfile(FILE *f, char *name) |
playfile(FILE *f, char *name) |
{ |
{ |
u_char *buf; |
u_char *buf, *newbuf; |
u_int tot, n, size, nread; |
u_int tot, n, size, newsize, nread; |
|
|
/* |
/* |
* We need to read the whole file into memory for easy processing. |
* We need to read the whole file into memory for easy processing. |
|
|
*/ |
*/ |
size = 1000; |
size = 1000; |
buf = malloc(size); |
buf = malloc(size); |
if (buf == 0) |
if (buf == NULL) |
errx(1, "malloc() failed"); |
err(1, "malloc() failed"); |
nread = size; |
nread = size; |
tot = 0; |
tot = 0; |
for (;;) { |
for (;;) { |
|
|
break; |
break; |
/* There must be more to read. */ |
/* There must be more to read. */ |
nread = size; |
nread = size; |
size *= 2; |
newsize = size * 2; |
buf = realloc(buf, size); |
newbuf = realloc(buf, newsize); |
if (buf == NULL) |
if (newbuf == NULL) |
errx(1, "realloc() failed"); |
err(1, "realloc() failed"); |
|
buf = newbuf; |
|
size = newsize; |
} |
} |
playdata(buf, tot, name); |
playdata(buf, tot, name); |
free(buf); |
free(buf); |
|
|
return; |
return; |
tracks = malloc(ntrks * sizeof(struct track)); |
tracks = malloc(ntrks * sizeof(struct track)); |
if (tracks == NULL) |
if (tracks == NULL) |
errx(1, "malloc() tracks failed"); |
err(1, "malloc() tracks failed"); |
for (t = 0; t < ntrks; ) { |
for (t = 0; t < ntrks; ) { |
if (p >= end - MARK_LEN - SIZE_LEN) { |
if (p >= end - MARK_LEN - SIZE_LEN) { |
warnx("Cannot find track %d", t); |
warnx("Cannot find track %d", t); |
|
|
char *file = DEVMUSIC; |
char *file = DEVMUSIC; |
struct synth_info info; |
struct synth_info info; |
FILE *f; |
FILE *f; |
|
const char *errstr; |
|
|
while ((ch = getopt(argc, argv, "?d:f:lmqt:vx")) != -1) { |
while ((ch = getopt(argc, argv, "?d:f:lmqt:vx")) != -1) { |
switch(ch) { |
switch (ch) { |
case 'd': |
case 'd': |
unit = atoi(optarg); |
unit = strtonum(optarg, 0, INT_MAX, &errstr); |
|
if (errstr) |
|
errx(1, "unit is %s: %s", errstr, optarg); |
break; |
break; |
case 'f': |
case 'f': |
file = optarg; |
file = optarg; |
|
|
play = 0; |
play = 0; |
break; |
break; |
case 't': |
case 't': |
ttempo = atoi(optarg); |
ttempo = strtonum(optarg, 0, INT_MAX, &errstr); |
|
if (errstr) |
|
errx(1, "tempo is %s: %s", errstr, optarg); |
break; |
break; |
case 'v': |
case 'v': |
verbose++; |
verbose++; |