Skip to content

Commit

Permalink
add -s option to rec for stereo
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/svn/nwr/trunk@32 103c2249-d0a5-da11-ade6-0050bffea3d9
  • Loading branch information
greg committed Mar 17, 2003
1 parent 98d7b3e commit ceefe39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

./rec - | ./squelch 10 | ./splitter ./streamer './decode -' './log /public/greg/nwr'
./rec -s - | ./demux "./splitter ./streamer './decode -' './log /public/greg/nwr/wxk27'" "cat >/dev/null"
5 changes: 4 additions & 1 deletion rec.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SH NAME
rec \- record from audio device
.SH SYNOPSIS
.B rec
.B rec [-s]
.I file
.SH DESCRIPTION
.B rec
Expand All @@ -11,6 +11,9 @@ opens an audio device and writes sample data to
If
.I file
is \-, then write to stdout.
.SH OPTIONS
.IP -s
Record both left and right stereo channels.
.SH FILES
.I /dev/dsp
.RS
Expand Down
23 changes: 18 additions & 5 deletions rec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@

int main(int argc, char *argv[])
{
bool stereo = false;
int a = 1;
while (a < argc && argv[a][0] == '-' && argv[a][1] != 0) {
switch (argv[a][1]) {
case 's':
stereo = true;
break;
default:
fprintf(stderr, "%s: unknown option %c\n", argv[0], argv[a][1]);
exit(1);
}
a++;
}
FILE *f;
if (strcmp(argv[1], "-") == 0) {
if (strcmp(argv[a], "-") == 0) {
f = stdout;
} else {
f = fopen(argv[1], "wb");
f = fopen(argv[a], "wb");
if (f == NULL) {
perror("fopen");
exit(1);
Expand All @@ -31,13 +44,13 @@ int main(int argc, char *argv[])
perror("ioctl: SNDCTL_DSP_SETFMT");
exit(1);
}
sndparam = 0;
sndparam = stereo;
if (ioctl(fd, SNDCTL_DSP_STEREO, &sndparam) == -1) {
perror("ioctl: SNDCTL_DSP_STEREO");
exit(1);
}
if (sndparam != 0) {
fprintf(stderr, "gen: Error, cannot set the channel number to 0\n");
if (sndparam != stereo) {
fprintf(stderr, "rec: Error, cannot set the channel number to %d\n", stereo);
exit(1);
}
int sample_rate = 11025;
Expand Down

0 comments on commit ceefe39

Please sign in to comment.