From: Takashi Iwai Subject: Re: Doubt on implementing .readi and .readn methods Date: Wed, 17 May 2006 15:37:55 +0200 Message-ID: References: <4464E1B7.6070601@instant.com.br> <446A415A.5070505@instant.com.br> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <446A415A.5070505@instant.com.br> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Juan Carlos Castro y Castro Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 16 May 2006 18:17:14 -0300, Juan Carlos Castro y Castro wrote: > > Takashi Iwai wrote: > > >"area" refers to snd_pcm_channel_area_t. It's an exported struct > >defined in pcm.h: > > > >/** PCM area specification */ > >typedef struct _snd_pcm_channel_area { > > /** base address of channel samples */ > > void *addr; > > /** offset to first sample in bits */ > > unsigned int first; > > /** samples distance in bits */ > > unsigned int step; > >} snd_pcm_channel_area_t; > > > >An area array is used for a stream with multiple channels. Each > >element of the array contains the area information for one channel. > >For example, in the case of 16bit 4-channel interleaved format, > > > > area[*].addr = base_addr > > area[0].first = 0 > > area[1].first = 16 > > area[2].first = 32 > > area[3].first = 48 > > area[*].step = 64 > > > >"frame" is the unit of samples, and 1 frame = sample-width * chanenels. > >e.g. for 16bit 4-channel format, 1 frame = 2 * 4 = 8 bytes. > > > > > OK, let me see if I get this straight. My main concern here is how I > have to do the implementation of _readn(). Let's suppose the raw file > has the following 16-bit words in it: A, B, C, D, E, F, G, H, I... > > After performing the _readn(), the memory ponted to by buf[0] to buf[3] > (four channels) will have to contain the following 16-bit words: > > buf[0] -> A, E, I, ... > buf[1] -> B, F, J, ... > buf[2] -> C, G, K, ... > buf[3] -> D, H, L, ... No, the non-interleaved format is a kind of bundled mono streams. Suppose you have a buffer with N * B samples, where N is the number of channels. Then the whole buffer consists of N times of mono-streams each of which has B samples: <-- B --> <-- B --> <-- B --> ... <- B -> |000000...|1111.....|2222.....|...|(N-1)...| Then, area array is set up like below (assume S16 format): area[0].addr = buf_addr area[1].addr = buf_addr + B * 2 area[2].addr = buf_addr + B * 4 ... area[N-1].addr = buf_addr + B * 2 * (N-1) area[*].first = 0; area[*].step = 16; /* 16bit format */ Takashi ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642