Bug 92512 - [sound] distorted mono output with emu10k1
Summary: [sound] distorted mono output with emu10k1
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 6.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-multimedia (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-29 20:50 UTC by Juha-Matti Tilli
Modified: 2017-06-29 01:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juha-Matti Tilli 2006-01-29 20:50:01 UTC
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.

Fix: 

Not known.
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;
}
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-01-29 23:14:52 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-multimedia

Over to maintainer(s).