Date: Tue, 1 Feb 2000 21:25:23 -0600 From: Dan Nelson <dnelson@emsphone.com> To: "Alexey N. Dokuchaev" <danfe@inet.ssc.nsu.ru> Cc: FreeBSD-Questions@FreeBSD.ORG Subject: Re: How to use pca0 PS-Speaker sound driver in FreeBSD? Message-ID: <20000201212523.A87242@dan.emsphone.com> In-Reply-To: <Pine.LNX.4.10.10002020853450.4699-100000@inet.ssc.nsu.ru>; from "Alexey N. Dokuchaev" on Wed Feb 2 08:56:29 GMT 2000 References: <20000120002155.D70698@cc942873-a.ewndsr1.nj.home.com> <Pine.LNX.4.10.10002020853450.4699-100000@inet.ssc.nsu.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <machine/soundcard.h>
#include <machine/pcaudioio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000201212523.A87242>
