From owner-freebsd-multimedia@FreeBSD.ORG Wed Nov 9 13:47:05 2005 Return-Path: X-Original-To: freebsd-multimedia@freebsd.org Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A2E916A420 for ; Wed, 9 Nov 2005 13:47:05 +0000 (GMT) (envelope-from CQG00620@nifty.ne.jp) Received: from mail.asahi-net.or.jp (mail1.asahi-net.or.jp [202.224.39.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id BA0B743D49 for ; Wed, 9 Nov 2005 13:47:02 +0000 (GMT) (envelope-from CQG00620@nifty.ne.jp) Received: from asahi-net.jp (h204195.ppp.asahi-net.or.jp [61.114.204.195]) by mail.asahi-net.or.jp (Postfix) with ESMTP id EF5FF25916 for ; Wed, 9 Nov 2005 22:47:00 +0900 (JST) Date: Wed, 09 Nov 2005 22:48:27 +0900 From: Watanabe Kazuhiro To: freebsd-multimedia In-Reply-To: <20051109002013.4dcf3c0d.skywizard@MyBSD.org.my> <20051108165955.ge235sro0848csok@netchild.homeip.net> References: <20051109002013.4dcf3c0d.skywizard@MyBSD.org.my> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 Emacs/20.7 (i386--freebsd) MULE/4.0 (HANANOEN) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Message-Id: <20051109134700.EF5FF25916@mail.asahi-net.or.jp> Subject: Re: [patch] stereo input is mixed to monaural via SoundBlaster16 recording mixer X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2005 13:47:05 -0000 At Tue, 08 Nov 2005 16:59:55 +0100, Alexander Leidinger wrote: > Watanabe Kazuhiro 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)