Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 1996 09:05:04 -0600 (CST)
From:      Jim Lowe <james@miller.cs.uwm.edu>
To:        CSP1DWD@MVS.OAC.UCLA.EDU, dwhite@resnet.uoregon.edu
Cc:        multimedia@freebsd.org
Subject:   Re: GUS & Mbone: more updates
Message-ID:  <199612101505.JAA17184@miller.cs.uwm.edu>

next in thread | raw e-mail | index | archive | help
> From: Denis DeLaRoca (310) 825-4580        <CSP1DWD@MVS.OAC.UCLA.EDU>
> Subject: Re: GUS & Mbone: more updates
> Cc: multimedia@freebsd.org
> 
> I've never seen these with my PAS16 card. What I keep seeing very
> freuqntly is
> 
>      aud write: resource temporarily busy
> 
> which is a result of a pwrite("aud write") in vat's audio-voxware.cc
> when its write() to the audio device fails. I haven't figured out what
> activity on the system interferes with /dev/audio to trigger the above
> failures.

This is beacuse the audio output of the PAS-16 doesn't run at 8khz.  When
you set the frequency at 8khz, it actually runs around 7.5khz. 

> 
> The sound quality I am getting in half-duplex mode with a ProAudio
> Spectrum 16 card is quite good, not as splendid as with the GUS card
> mind you, but quite acceptable -- the only minor problem is that
> vat's clocking of audio output is slightly amiss and every so often
> a couple of audio samples overlap on output as the playback buffer
> is reset.
> 

It will need to reset the play buffer since the actual clocking rate
is slower than vat is anticipating.  I think you can change this by
setting the rate to something a little faster.  I beleive (I don't
remember offhand) if you set the PAS-16 card to 8062hz, that it will
actually run around 8011hz.  This should make the error stop.  Actually,
the rate to run at 8011hz might mean setting the card to 8116hz.
I don't remember which frequency to use.

Here is a little program that can be used to measure the frequency of
incoming packets.  You will want to tune your audio card to run as
close as possible to 8khz.  Anything within 5% should make vat happy.

Depending on which version of the sound driver you are running you
might have to -DBROKEN_SELECT when you compile.  In some versions
of the sound driver, you have to kick-start the audio.

	-Jim
---
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/file.h>
#include <errno.h>
#include <machine/soundcard.h>
/* #define BROKEN_SELECT /* */

char	*dev="/dev/dsp0";
int	blocksize = 160;

main(int ac, char **av)
{
        struct timeval  tv, start;
        int             fd;
        fd_set          rfd;
        int 		cc;
        int 		i;
	int		freq;
        double		 u;

	if(ac>1) {
		freq = atoi(av[1]);
	} else
		freq = 8000;

        if((fd=open(dev, O_RDONLY)) < 0) {
                perror("open failed\n");
                exit(-1);
        }
	if(ioctl(fd, SNDCTL_DSP_SETBLKSIZE, &blocksize) < 0) {
		printf("Setting blocksize failed: %s\n", strerror(errno));
	}
	if(ioctl(fd, SNDCTL_DSP_SPEED, &freq) < 0) {
		printf("Setting speed failed: %s\n", strerror(errno));
	}
#ifdef BROKEN_SELECT
	read(fd, dev, 1);
#endif

        gettimeofday(&start, 0);

        cc = 0;
        i = 0;
        FD_ZERO(&rfd);
        while (1) {
                int n;
                char buf[blocksize];
                FD_SET(fd, &rfd);
                select(fd+1, &rfd, 0, 0, 0);
                n = read(fd, buf, blocksize);
                if (n < 0) {
                        perror("read");
                        exit(1);
                }
		if(n!=blocksize) printf("read %d, wanted blocksize\n", n);
                cc += n;
                if (++i >= 50) {
                        i = 0;
                        gettimeofday(&tv, 0);
                        u = tv.tv_sec - start.tv_sec;
                        u += 1e-6 * (tv.tv_usec - start.tv_usec);
                        printf("%d %lg %lg\n", cc, u,
                               (double)cc / u);
			fflush(stdout);
                }
        }
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612101505.JAA17184>