Date: Wed, 09 Nov 2005 22:48:27 +0900 From: Watanabe Kazuhiro <CQG00620@nifty.ne.jp> To: freebsd-multimedia <freebsd-multimedia@freebsd.org> Subject: Re: [patch] stereo input is mixed to monaural via SoundBlaster16 recording mixer Message-ID: <20051109134700.EF5FF25916@mail.asahi-net.or.jp> In-Reply-To: <20051109002013.4dcf3c0d.skywizard@MyBSD.org.my> <20051108165955.ge235sro0848csok@netchild.homeip.net> References: <20051109002013.4dcf3c0d.skywizard@MyBSD.org.my>
next in thread | previous in thread | raw e-mail | index | archive | help
At Tue, 08 Nov 2005 16:59:55 +0100, Alexander Leidinger wrote: > Watanabe Kazuhiro <CQG00620@nifty.ne.jp> wrote: >=20 > > if (src & SOUND_MASK_MIC) > > - recdev |=3D 0x01; /* mono mic */ > > + recdev_l |=3D 0x01; /* mono mic */ > > + recdev_r |=3D 0x01; >=20 > If I understand this correctly, this feeds the monaural signal to the left > and the right channel. When we have a mono input, do we really want to ha= ve > the same input doubled? I don't do any recording, so I don't know how most > programs handle this, but IMHO it's a waste of resources and if the source > is only able to deliver a mono-signal, the recording should only be possi= ble > in mono. The function sb16mix_setrecsrc() only manipulates the analog recording mixer. So if we assign a mono input to the left and right channel, it doesn't force for us to record a two-channel digitized output. To decide a sampling format(stereo/mono, sample rate, bit length, and so on) is not the mixer's role but DSP. At Wed, 9 Nov 2005 00:20:13 +0800, Ariff Abdullah wrote: > Watanabe-san, I would suggest you to put braces along with the > conditional statement so the code become much easier tu understand. > Without it, it seems that recdev_r will always be set even if the > condition is false. Oops... your indication is right and I'm wrong. The correct patch is below. However, this patch is not perfect. After applied the patch, if I try to record an monaural output (e.g. "wavrec -M mono.wav"), only record the left channel sound. =46rom the "Hardware Programming Reference" pp74: "When recording in mono, note that samples will only be taken from the left input mixer. So, if a mono recording of a stereo source is desired, the switchs controlled by registers 0x3D and 0x3E must be manipulated to enable both channels of a stereo source to be mixed together first into the left input mixer before being sampled." I'm just going to consider the problem. Perhaps it's difficult for me to solve the problem... --- sys/dev/sound/isa/sb16.c.orig Tue Nov 8 22:01:22 2005 +++ sys/dev/sound/isa/sb16.c Wed Nov 9 12:22:29 2005 @@ -370,23 +370,32 @@ static int sb16mix_setrecsrc(struct snd_mixer *m, u_int32_t src) { struct sb_info *sb =3D mix_getdevinfo(m); - u_char recdev; + u_char recdev_l, recdev_r; =20 - recdev =3D 0; - if (src & SOUND_MASK_MIC) - recdev |=3D 0x01; /* mono mic */ + recdev_l =3D 0; + recdev_r =3D 0; + if (src & SOUND_MASK_MIC) { + recdev_l |=3D 0x01; /* mono mic */ + recdev_r |=3D 0x01; + } =20 - if (src & SOUND_MASK_CD) - recdev |=3D 0x06; /* l+r cd */ + if (src & SOUND_MASK_CD) { + recdev_l |=3D 0x04; /* l cd */ + recdev_r |=3D 0x02; /* r cd */ + } =20 - if (src & SOUND_MASK_LINE) - recdev |=3D 0x18; /* l+r line */ + if (src & SOUND_MASK_LINE) { + recdev_l |=3D 0x10; /* l line */ + recdev_r |=3D 0x08; /* r line */ + } =20 - if (src & SOUND_MASK_SYNTH) - recdev |=3D 0x60; /* l+r midi */ + if (src & SOUND_MASK_SYNTH) { + recdev_l |=3D 0x40; /* l midi */ + recdev_r |=3D 0x20; /* r midi */ + } =20 - sb_setmixer(sb, SB16_IMASK_L, recdev); - sb_setmixer(sb, SB16_IMASK_R, recdev); + sb_setmixer(sb, SB16_IMASK_L, recdev_l); + sb_setmixer(sb, SB16_IMASK_R, recdev_r); =20 /* Switch on/off FM tuner source */ if (src & SOUND_MASK_LINE1) @@ -849,7 +858,7 @@ sb16_attach(device_t dev) else status2[0] =3D '\0'; =20 - snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld%s bufsz = %ud %s", + snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld%s bufsz = %u %s", rman_get_start(sb->io_base), rman_get_start(sb->irq), rman_get_start(sb->drq1), status2, sb->bufsize, PCM_KLDSTRING(snd_sb16)); --- Watanabe Kazuhiro (CQG00620@nifty.ne.jp)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051109134700.EF5FF25916>