Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Oct 2000 13:46:08 +0200
From:      Khamba Staring <purrcat@edoropolis.org>
To:        freebsd-questions@freebsd.org
Subject:   ViBRA16C 16bit recording problems
Message-ID:  <200010251146.e9PBk9j06626@francine.edoropolis.org>

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

I'm trying to record some music using a SoundBlaster ViBRA16C soundcard.
I can record at various speeds (8000/22050/44100 etc Hz) both stereo and
mono, but when I set the depth to 16 bits instead of 8, all I get is
static. I used DAP for this and thought it was a DAP problem until I wrote
a little record program myself (DAP can't record long plays; my code
just reads /dev/dsp and puts the output directly in a file) but I got
the same result (all speeds, mono/stereo recording works, but not with
16bits).

dmesg outputs:
--
sbc1: <Creative ViBRA16C> at port 0x220-0x22f,0x330-0x331,0x388-0x38b irq 5 drq 1,5 on isa0
sbc1: setting card to irq 5, drq 1, 5
pcm0: <SB DSP 4.13> on sbc1
--

IRQ 5, DRQ 1 and 5 are not used by any other device.

As far as I can see all devices are properly linked:
--
lrwxrwxrwx  1 root  wheel         4 Oct 25 12:33 dsp -> dsp0
crw-rw-rw-  1 root  wheel   30,   3 Oct 25 12:33 dsp0
lrwxrwxrwx  1 root  wheel         5 Oct 25 12:33 dspW -> dspW0
crw-rw-rw-  1 root  wheel   30,   5 Oct 25 12:33 dspW0
--

This is what my relevant code looks like:
--
  if((snddev = open(sd, O_RDONLY, 0)) == -1) {
    printf("error opening sound device %s: %s\n", sd, strerror(errno));
    exit(-1);
  }

  if(s_depth == 16) {
    format = AFMT_U16_LE;
    printf("Setting device to 16 bits: ");
    if(ioctl(snddev, SNDCTL_DSP_SETFMT, &format) == -1) {
      printf("not succeeded: %s\n", strerror(errno));
      exit(-1);
    } else
      printf("succeeded\n");
    if(format != AFMT_U16_LE) {
      printf("not succeeded; format: %d\n", format);
      exit(-1);
    }
  }

  if(s_size == 2) {
    printf("Setting device to stereo: ");
    if(ioctl(snddev, SNDCTL_DSP_STEREO, &true) == -1) {
      printf("not succeeded: %s\n", strerror(errno));
      exit(-1);
    } else
      printf("succeeded: %d\n", s_size);
  }

  printf("Setting speed to %d: ", s_rate);
  if(ioctl(snddev, SNDCTL_DSP_SPEED, &s_rate) == -1) {
    printf("not succeeded: %s\n", strerror(errno));
    exit(-1);
  } else
    printf("succeeded: %d\n", s_rate);

  for(;;) {
    if((dev_read = read(snddev, sndbuf, bufsize)) == -1) {
      printf("error reading sound device file %s: %s\n", sd, strerror(errno));
      sigint();
    }
    if((file_written = fwrite(sndbuf, 1, dev_read, sndfile)) == 0) {
      printf("error writing to file %s\n", sf);
      sigint();
    }
  }
--
Of course I also opened the output file (sndfile), I used a 1024 bytes
(bufsize) buffer (sndbuf).

SIGINT is used to stop the recording; sigint() just closes the files and
quits. The output looks like this:
--
Setting device to 16 bits: succeeded
Setting device to stereo: succeeded: 2
Setting speed to 44100: succeeded: 44100
--


Has anyone had the same problem? Or does anyone know where I should start
looking for it?

I also tried the Network Audio System, but wasn't able to produce a playable
audio file (?!). Also, playing 16bit 44100 stereo audio streams works like
a charm.. I don't understand it.


Kind regards,

-- Khamba Staring

Ps: I'm not on the freebsd-questions mailing list. If you've got an answer,
please also mail it to me..


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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