From owner-freebsd-current Thu Feb 17 2:12:37 2000 Delivered-To: freebsd-current@freebsd.org Received: from mail.hcisp.net (StarGate.hcisp.net [208.60.89.1]) by hub.freebsd.org (Postfix) with SMTP id 79EFF37B586 for ; Thu, 17 Feb 2000 02:12:34 -0800 (PST) (envelope-from tim@mysql.com) Received: (qmail 7756 invoked from network); 17 Feb 2000 10:17:56 -0000 Received: from modem2.hcsip.net (HELO threads.polyesthetic.msg) (208.60.89.68) by stargate.hcisp.net with SMTP; 17 Feb 2000 10:17:56 -0000 Received: (qmail 4959 invoked by uid 1001); 17 Feb 2000 10:11:51 -0000 From: "Thimble Smith" Date: Thu, 17 Feb 2000 05:11:51 -0500 To: current@freebsd.org Subject: ViBRA16X and /dev/dsp Message-ID: <20000217051151.T2611@threads.polyesthetic.msg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi. I'm still trying to figure out why /dev/dsp isn't working with my ViBRA16X card. I wrote a little program to test the device. The trouble is, I don't know what I'm doing and have not found much in the way of documentation. I'm hoping someone can give me a hint, so I can figure out what's going wrong. If I'm way off topic and just annoying everyone, please let me know and I'll just shut up until either I learn more or someone else deals with it. :) Being optimistic, here's my program: #include #include #include #include #include #include #include #define BUFSZ 1024 int main() { int audio_fd; unsigned char audio_buf[BUFSZ]; int format = AFMT_U8; int speed = 8000; ssize_t written; if ((audio_fd = open("/dev/dsp", O_WRONLY, 0)) == -1) { perror("/dev/dsp"); exit(EXIT_FAILURE); } if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1) { perror("SETFMT"); exit(EXIT_FAILURE); } if (format != AFMT_U8) { fprintf(stderr, "AFMT_U8 is unsupported (try 0x%02x)\n", format); exit(EXIT_FAILURE); } if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1) { perror("SPEED"); exit(EXIT_FAILURE); } if (speed != 8000) fprintf(stderr, "warning: speed == %d\n", speed); /* let's give this a shot! */ /* OK, so this doesn't seem to be doing what I want - I'm trying to just play some tone - anything - to test if the thing is working or not. I was hoping this simple thing might be close enough to a sound file that it would play something. But obviously I'm being naive. What should I put into the buffer to get it to play? Do I need to write the buffer many times to the device in order to hear anything? */ memset(audio_buf, 0xaa, BUFSZ); fprintf(stderr, "getting ready to write to the device\n"); written = write(audio_fd, audio_buf, BUFSZ); if (written != BUFSZ) fprintf(stderr, "only wrote %d of %d bytes\n", written, BUFSZ); fprintf(stderr, "getting ready to close the device\n"); close(audio_fd); fprintf(stderr, "Done.\n"); return EXIT_SUCCESS; } When I run the program, I hear a pop; just as if I'd done $ echo "foo" > /dev/dsp; but I hear nothing that sounds like a tone. There are no warnings printed, though. Thanks for any help, Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message