From owner-freebsd-questions Sat Dec 7 10:27:21 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id KAA03561 for questions-outgoing; Sat, 7 Dec 1996 10:27:21 -0800 (PST) Received: from sergio.lenzi ([200.247.23.105]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id KAA03555 for ; Sat, 7 Dec 1996 10:27:10 -0800 (PST) Received: (from lenzi@localhost) by sergio.lenzi (8.7.5/8.7.3) id PAA06793; Sat, 7 Dec 1996 15:14:20 GMT Date: Sat, 7 Dec 1996 15:14:19 +0000 () From: "Lenzi, Sergio" X-Sender: lenzi@sergio To: S.Brandenburg@tu-bs.de cc: Lady Ada , freebsd-questions@FreeBSD.ORG Subject: Re: O si o [sound question] In-Reply-To: <32A8740C.41C67EA6@algieba.ts.rz.tu-bs.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I have the same problem with the .au files. even with some "samples". I have written 2 programs (record) and (play) that records music or other whings from the dsp. this programs work great... use record [sample rate] < /dev/dsp > file --------------------------record program----------- #include #include #include #include #include #include #include static int tot = 0; static float k; #define BUFFSZ 4096 static void closeall(int x) { fprintf(stderr, "End ok total bytes:%d, [%6.2 Kbps]\n", tot,k); exit(0); } main(int ac, char **av) { int r, h, n, t1, t2; char *dev; char area[BUFFSZ]; h = fileno(stdin); if (ac < 2) r=18000; else r = atoi(av[1]); if (ioctl(h, SOUND_PCM_WRITE_RATE, &r) < 0) { perror("set ioctl"); exit(1); } if (ioctl(h, SOUND_PCM_READ_RATE, &r) < 0) { perror("read ioctl"); exit(1); } fprintf(stderr, "dsp rate:%d\n", r); signal(SIGINT, closeall); t1 = time(NULL); fwrite(&r, sizeof(r), 1, stdout); while ((n = fread(area, 1, BUFFSZ, stdin)) > 0) { tot += n; fwrite(area, 1, n, stdout); t2 = time(NULL); k = t2 - t1; if (k == 0) k = 1; k *= 1000.0; fprintf(stderr, "%6.2f bps\r", (float) tot / k); } return (0); } -----------------------play program use play < file > /dev/dsp------- #include #include #include #include #include #include #include #define BUFFSZ 8192 static int tot = 0; static float k=0; static void closeall(int x) { fprintf(stderr, "End ok total bytes:%d [%6.2f Kbps]\n", tot,k); exit(0); } main(int ac, char **av) { int r, h, n, k, t1, t2; char *dev; char area[BUFFSZ]; h = fileno(stdout); fread(&r, sizeof(r), 1, stdin); if (ioctl(h, SOUND_PCM_WRITE_RATE, &r) < 0) { perror("set ioctl"); exit(1); } if (ioctl(h, SOUND_PCM_READ_RATE, &r) < 0) { perror("read ioctl"); exit(1); } fprintf(stderr, "dsp rate:%d\n", r); signal(SIGINT, closeall); t1 = time(NULL); while ((n = fread(area, 1, BUFFSZ, stdin))) { tot += n; fwrite(area, 1, n, stdout); fflush(stdout); t2 = time(NULL); k = t2 - t1; if (k == 0) k = 1; k *= 1000; fprintf(stderr, "%.8d [%6.2f]\r", tot, (float)tot / k); } fprintf(stderr, "End ok total bytes:%d\n", tot); return (0); } Sergio Lenzi. Unix consult.