From owner-freebsd-multimedia@FreeBSD.ORG Sat Jan 28 11:37:04 2012 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A0351065670 for ; Sat, 28 Jan 2012 11:37:04 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id B0FBF8FC08 for ; Sat, 28 Jan 2012 11:37:03 +0000 (UTC) Received: by eekb47 with SMTP id b47so978304eek.13 for ; Sat, 28 Jan 2012 03:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=kOdAKWSuI2iU4LB4ssL1WS1AvJDa31ZRa+swJvecqWs=; b=NwvDtgFDGEo7rj9ZlFVnRor6dwulxwGv9sUVvREXk5ZYc8jExyKkyHcHGUD089RHm4 GGX6duH5ISNsAM5XKJAgmAQSfvmn9bqnwkVYphYRJLz1vNz236W/1/TCa7z/PnYC+by+ roFTprFCID4g5ZlkPvlHGL5wpL56i2600SJ+Y= Received: by 10.14.51.198 with SMTP id b46mr3348828eec.111.1327750622517; Sat, 28 Jan 2012 03:37:02 -0800 (PST) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id s16sm42453256eef.2.2012.01.28.03.37.00 (version=SSLv3 cipher=OTHER); Sat, 28 Jan 2012 03:37:01 -0800 (PST) Sender: Alexander Motin Message-ID: <4F23DDD2.7000804@FreeBSD.org> Date: Sat, 28 Jan 2012 13:36:50 +0200 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120116 Thunderbird/9.0 MIME-Version: 1.0 To: Ruslan Bukin References: <4F1ADDC8.90104@FreeBSD.org> <20120122163828.GA18783@jail.io> <20120128102235.GA39995@jail.io> In-Reply-To: <20120128102235.GA39995@jail.io> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-multimedia@FreeBSD.org Subject: Re: multi-mono-channel sound card 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: Sat, 28 Jan 2012 11:37:04 -0000 On 28.01.2012 12:22, Ruslan Bukin wrote: > On Sun, Jan 22, 2012 at 08:38:28PM +0400, Ruslan Bukin wrote: >> On Sat, Jan 21, 2012 at 05:46:16PM +0200, Alexander Motin wrote: >>> On 01/21/12 16:12, Ruslan Bukin wrote: >>>> My multichannel sound card (RME HDSPe AIO) is support >>>> SND_FORMAT(AFMT_S32_LE, 1, 0) only. >>>> >>>> I call pcm_addchan(..), which triggers chan_init(..,*snd_dbuf,..) >>>> Addr of snd_dbuf I write to card in slot N. >>>> In result I have /dev/dsp0.pN devices (one device per each mono channel) >>>> >>>> Works perfectly, sounds great, but in mono mode. >>>> >>>> I'm interested, what is the right way to implement >>>> stereo pair of channels per one device file like in OSS? >>> >>> pcm_addchan() registers set of equal playback/record channels that >>> are supposed to be mixed into the same signal. It is hardware >>> equivalent of vchans. It has nothing common with multiple speakers. >>> >>> Multichannel audio is always multiplexed and AFAIk there is no >>> demultiplexing in sound(4). Sound(4) can upmix/downmix channels, >>> change their order, format, rate, but not demultiplex. >>> >>> I see only two ways: >>> - implement demultiplexing in driver -- that is not easy, but I >>> believe it should be possible; >>> - export each input/output connector as separate PCM device and let >>> some user level software to do demultiplexing -- that is easy and >>> that is what snd_emu10kx does. snd_emu10kx(4) recommends to use >>> pulseaudio for demultiplexing. >> >> Thanks. I have implemented demultiplexing. Works great. >> I will release the driver soon. >> > > Not great, actually. Demultiplexing need some time, > but seems that PCMTRIG_EMLDMAWR event trigger is not the > moment where we have it. > > If I just copy buffer (memcpy) on PCMTRIG_EMLDMAWR no problem at all, > card generates 12k IRQ/s. > > but simple demultiplex (for loop) on each IRQ reduce speed to 6-10k IRQ/s > and causes producing high-pitched sound goes from some chip > on card or may be motherboard (its difficult to identify source) It can be CPU power converter, when power consumption jumps up and down when CPU is woken up by interrupt. > it happens only on small period sizes, like 32 samples > (choices are 32,64,..4096). > > samples - IRQ/s > 32 - 12k > 64 - 6k > 128 - 3k > 256 - 1.5k > 512 - 0.6k > 1024 - 0.3k > 2048 - 0.15k > 4096 - 0.08k > > card bufsize is 64k bytes (16k samples) Interrupt rate depends on what fragment size you are setting on the card. The smaller fragment size is, the lower I/O latency, but higher interrupt rate. sound(4) has mechanism to set fragment size depending on current format to control latency, but you can change it if your card has some limitations. > so we have only 1/12k = 0.0000833s to demultiplex, > but it is not possible, right? Yes, you have 1/12ks to do it in worst case, but you only need to handle data for 1/12k of second from the last tick. So this should be not so difficult. -- Alexander Motin