Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jan 2006 22:41:19 +0200 (EET)
From:      Juha-Matti Tilli <juhis@nallukka.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/92512: [sound] distorted mono output with emu10k1
Message-ID:  <20060129204119.5A2791707B@tykki.juhis.ath.cx>
Resent-Message-ID: <200601292050.k0TKo2KG039294@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         92512
>Category:       kern
>Synopsis:       [sound] distorted mono output with emu10k1
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 29 20:50:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Juha-Matti Tilli
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD tykki.juhis.ath.cx 6.0-STABLE FreeBSD 6.0-STABLE #4: Sun Jan 1 01:53:04 EET 2006 juhis@tykki:/usr/obj/usr/src/sys/TYKKI i386

% cat /dev/sndstat
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: <Creative EMU10K1> at io 0xc400 irq 5 kld snd_emu10k1 (4p/2r/0v channels duplex default)

% dmesg|grep pcm0
pcm0: <Creative EMU10K1> port 0xc400-0xc41f irq 5 at device 13.0 on pci0
pcm0: <TriTech TR28023 AC97 Codec>


>Description:

The playback of mono audio with emu10k1 causes distortion. When the same
sound is played back using 2 channels, the problem disappears. It seems
that samples are multiplied by 2 during mono playback.

>How-To-Repeat:


#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	int fd, format, channels, rate, i;

  /* 450 Hz sine wave on both channels */
  unsigned char samples2[] = { 0, 0, 0, 0, 94, 16, 94, 16, 120, 32, 120, 32, 9,
    48, 9, 48, 208, 62, 208, 62, 143, 76, 143, 76, 12, 89, 12, 89, 19, 100, 19,
    100, 117, 109, 117, 109, 11, 117, 11, 117, 182, 122, 182, 122, 92, 126, 92,
    126, 239, 127, 239, 127, 105, 127, 105, 127, 202, 124, 202, 124, 32, 120,
    32, 120, 124, 113, 124, 113, 251, 104, 251, 104, 193, 94, 193, 94, 249, 82,
    249, 82, 212, 69, 212, 69, 138, 55, 138, 55, 85, 40, 85, 40, 120, 24, 120,
    24, 51, 8, 51, 8, 205, 247, 205, 247, 136, 231, 136, 231, 171, 215, 171,
    215, 118, 200, 118, 200, 44, 186, 44, 186, 7, 173, 7, 173, 63, 161, 63,
    161, 5, 151, 5, 151, 132, 142, 132, 142, 224, 135, 224, 135, 54, 131, 54,
    131, 151, 128, 151, 128, 17, 128, 17, 128, 164, 129, 164, 129, 74, 133, 74,
    133, 245, 138, 245, 138, 139, 146, 139, 146, 237, 155, 237, 155, 244, 166,
    244, 166, 113, 179, 113, 179, 48, 193, 48, 193, 247, 207, 247, 207, 136,
    223, 136, 223, 162, 239, 162, 239};

  /* 450 Hz sine wave */
  unsigned char samples1[] = { 0, 0, 94, 16, 120, 32, 9, 48, 208, 62, 143, 76,
    12, 89, 19, 100, 117, 109, 11, 117, 182, 122, 92, 126, 239, 127, 105, 127,
    202, 124, 32, 120, 124, 113, 251, 104, 193, 94, 249, 82, 212, 69, 138, 55,
    85, 40, 120, 24, 51, 8, 205, 247, 136, 231, 171, 215, 118, 200, 44, 186, 7,
    173, 63, 161, 5, 151, 132, 142, 224, 135, 54, 131, 151, 128, 17, 128, 164,
    129, 74, 133, 245, 138, 139, 146, 237, 155, 244, 166, 113, 179, 48, 193,
    247, 207, 136, 223, 162, 239};

  fd = open("/dev/dsp", O_WRONLY);
  format = AFMT_S16_LE;
  channels = 2;
  rate = 22050;
  ioctl(fd, SNDCTL_DSP_SETFMT,&format);
  ioctl(fd, SNDCTL_DSP_CHANNELS,&channels);
  ioctl(fd, SNDCTL_DSP_SPEED,&rate);
  for(i=0;i<500;i++)
    write(fd, &samples2, sizeof(samples2)); /* not distorted */

  close(fd);
  sleep(1);

  fd = open("/dev/dsp", O_WRONLY);
  format = AFMT_S16_LE;
  channels = 1;
  rate = 22050;
  ioctl(fd, SNDCTL_DSP_SETFMT,&format);
  ioctl(fd, SNDCTL_DSP_CHANNELS,&channels);
  ioctl(fd, SNDCTL_DSP_SPEED,&rate);
  for(i=0;i<500;i++)
    write(fd, &samples1, sizeof(samples1)); /* distorted */

  return 0;
}

>Fix:

Not known.
>Release-Note:
>Audit-Trail:
>Unformatted:



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