From owner-freebsd-questions Tue Feb 1 19:26: 1 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by builder.freebsd.org (Postfix) with ESMTP id 979B43FD0 for ; Tue, 1 Feb 2000 19:25:54 -0800 (PST) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id VAA89207; Tue, 1 Feb 2000 21:25:23 -0600 (CST) (envelope-from dan) Date: Tue, 1 Feb 2000 21:25:23 -0600 From: Dan Nelson To: "Alexey N. Dokuchaev" Cc: FreeBSD-Questions@FreeBSD.ORG Subject: Re: How to use pca0 PS-Speaker sound driver in FreeBSD? Message-ID: <20000201212523.A87242@dan.emsphone.com> References: <20000120002155.D70698@cc942873-a.ewndsr1.nj.home.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" X-Mailer: Mutt 1.0.1i In-Reply-To: ; from "Alexey N. Dokuchaev" on Wed Feb 2 08:56:29 GMT 2000 X-OS: FreeBSD 4.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii In the last episode (Feb 02), Alexey N. Dokuchaev said: > I was undable to set up my sound card (must be very weird), so I > decided to try that pca driver just for fun. But, even with snd0 > entries in /dev, I can't hear eanything by cating into /dev/audio or > /dev/dsp. The pca device is accessed through /dev/pcaudio; the easiest way to use it is to cat .au soundfiles into it. Attached is a little C program which will let you pipe unsigned 8-bit samples into it as well. Use it with sox to play other file formats like this: sox file.wav -r 8000 -t ub -c 1 - | play -s -r 8000 -- Dan Nelson dnelson@emsphone.com --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="play.c" #include #include #include #include #include #include main(int argc, char *argv[]) { int fd; int rate = 8012; int bits = 8; int speaker = 0; int channels = 1; int c; int len; char buf[1024]; while ((c = getopt(argc, argv, "r:b:c:s")) != EOF) { switch (c) { case 's': speaker = 1; break; case 'r': rate = atoi(optarg); break; case 'c': channels = atoi(optarg); break; case 'b': bits = atoi(optarg); break; case '?': case 'h': printf ("play [-s] [-c channels] [-r rate] [-b bits]\n"); exit(1); break; } } if (speaker) { audio_info_t ait; ait.play.sample_rate = rate; ait.play.encoding = AUDIO_ENCODING_RAW; ait.play.gain = 150; ait.play.pause = -1; fd = open("/dev/pcaudio", O_WRONLY); ioctl(fd, AUDIO_SETINFO, &ait); } else { fd = open("/dev/dsp", O_WRONLY); ioctl(fd, SNDCTL_DSP_SETFMT, &bits); ioctl(fd, SOUND_PCM_WRITE_RATE, &rate); ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &channels); } while ((len = read(fileno(stdin), buf, sizeof(buf))) > 0) write(fd, buf, len); } --3V7upXqbjpZ4EhLz-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message