version 1.34, 2008/11/09 16:26:07 |
version 1.35, 2008/11/10 23:25:37 |
|
|
fprintf(stderr, |
fprintf(stderr, |
"usage: %s [-lu] [-b nsamples] [-C min:max] [-c min:max] [-e enc] " |
"usage: %s [-lu] [-b nsamples] [-C min:max] [-c min:max] [-e enc] " |
"[-f device]\n" |
"[-f device]\n" |
"\t[-h fmt] [-i file] [-o file] [-r rate] [-x policy]\n", |
"\t[-h fmt] [-i file] [-o file] [-r rate] [-v volume] " |
|
"[-x policy]\n", |
__progname); |
__progname); |
} |
} |
|
|
|
|
{ |
{ |
if (sscanf(optarg, "%u:%u", &par->cmin, &par->cmax) != 2 || |
if (sscanf(optarg, "%u:%u", &par->cmin, &par->cmax) != 2 || |
par->cmax < par->cmin || par->cmax > NCHAN_MAX - 1) |
par->cmax < par->cmin || par->cmax > NCHAN_MAX - 1) |
err(1, "%s: bad channel range", optarg); |
errx(1, "%s: bad channel range", optarg); |
} |
} |
|
|
void |
void |
|
|
{ |
{ |
if (sscanf(optarg, "%u", &par->rate) != 1 || |
if (sscanf(optarg, "%u", &par->rate) != 1 || |
par->rate < RATE_MIN || par->rate > RATE_MAX) |
par->rate < RATE_MIN || par->rate > RATE_MAX) |
err(1, "%s: bad sample rate", optarg); |
errx(1, "%s: bad sample rate", optarg); |
} |
} |
|
|
void |
void |
|
opt_vol(unsigned *vol) |
|
{ |
|
if (sscanf(optarg, "%u", vol) != 1 || |
|
*vol > MIDI_MAXCTL) |
|
errx(1, "%s: bad volume", optarg); |
|
} |
|
|
|
void |
opt_enc(struct aparams *par) |
opt_enc(struct aparams *par) |
{ |
{ |
int len; |
int len; |
|
|
return HDR_RAW; |
return HDR_RAW; |
if (strcmp("wav", optarg) == 0) |
if (strcmp("wav", optarg) == 0) |
return HDR_WAV; |
return HDR_WAV; |
err(1, "%s: bad header specification", optarg); |
errx(1, "%s: bad header specification", optarg); |
} |
} |
|
|
int |
int |
|
|
aproc_setout(proc, buf); |
aproc_setout(proc, buf); |
abuf_fill(buf); /* XXX: move this in dev_attach() ? */ |
abuf_fill(buf); /* XXX: move this in dev_attach() ? */ |
dev_attach(fa->name, buf, &fa->par, fa->xrun, NULL, NULL, 0); |
dev_attach(fa->name, buf, &fa->par, fa->xrun, NULL, NULL, 0); |
|
dev_setvol(buf, MIDI_TO_ADATA(fa->vol)); |
} |
} |
|
|
/* |
/* |
|
|
struct farglist ifiles, ofiles; |
struct farglist ifiles, ofiles; |
struct aparams ipar, opar, dipar, dopar; |
struct aparams ipar, opar, dipar, dopar; |
struct sigaction sa; |
struct sigaction sa; |
unsigned ivol, ovol, bufsz; |
unsigned ivol, bufsz; |
char *devpath, *dbgenv, *listenpath; |
char *devpath, *dbgenv, *listenpath; |
const char *errstr; |
const char *errstr; |
extern char *malloc_options; |
extern char *malloc_options; |
|
|
SLIST_INIT(&ofiles); |
SLIST_INIT(&ofiles); |
hdr = HDR_AUTO; |
hdr = HDR_AUTO; |
xrun = XRUN_IGNORE; |
xrun = XRUN_IGNORE; |
ivol = ovol = MIDI_TO_ADATA(127); |
ivol = MIDI_MAXCTL; |
bufsz = 44100 * 4 / 15; /* XXX: use milliseconds, not frames */ |
bufsz = 44100 * 4 / 15; /* XXX: use milliseconds, not frames */ |
|
|
while ((c = getopt(argc, argv, "b:c:C:e:r:h:x:i:o:f:lu")) != -1) { |
while ((c = getopt(argc, argv, "b:c:C:e:r:h:x:v:i:o:f:lu")) != -1) { |
switch (c) { |
switch (c) { |
case 'h': |
case 'h': |
hdr = opt_hdr(); |
hdr = opt_hdr(); |
|
|
opt_rate(&ipar); |
opt_rate(&ipar); |
opar.rate = ipar.rate; |
opar.rate = ipar.rate; |
break; |
break; |
|
case 'v': |
|
opt_vol(&ivol); |
|
break; |
case 'i': |
case 'i': |
opt_file(&ifiles, &ipar, 127, hdr, xrun, optarg); |
opt_file(&ifiles, &ipar, ivol, hdr, xrun, optarg); |
break; |
break; |
case 'o': |
case 'o': |
opt_file(&ofiles, &opar, 127, hdr, xrun, optarg); |
opt_file(&ofiles, &opar, 127, hdr, xrun, optarg); |