From: Takashi Iwai Subject: Re: Re: Alsa mix in HW Date: Mon, 22 Aug 2005 18:41:06 +0200 Message-ID: References: <42EBAE72.9090608@e4a.it> <4306EA27.7060000@netvigator.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <4306EA27.7060000@netvigator.com> 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: Raymond Cc: Dino Puller , alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Sat, 20 Aug 2005 16:30:31 +0800, Raymond wrote: > > Manuel Jander wrote: > > On Wed, 2005-08-17 at 19:25 +0200, Takashi Iwai wrote: > > > >>At Wed, 17 Aug 2005 12:42:26 -0400, > >>Lee Revell wrote: > >> > >>>On Wed, 2005-08-17 at 20:42 +0800, Raymond wrote: > >>> > >>>>Do anyone have a list of the sound cards ( alsa driver ) which > >>>>support the above features ? > >>> > >>>Vortex and emu10k1/2 at least... > >> > >>You can count ymfpci and trident, too. > > > > > > ESS Maestro. The 3D HRTF pipelines does not seem to be clear how they > > can be used, but AFAIK the hardware mixing and pitch programming > > should be possible. > > > > Since ALSA support multiple sound cards, it is possible to use onboard > sound chip as capturing device. > > Is it feasible to use one or more sound cards for playback ? (e.g. > on-board sound chip with dmix is capable of playing stereo background > music, or you have two sound cards which support hardware mixing) It's feasible via alsa-lib multi plugin. > Refer to 4.3.2 Source Attributes > > Get/Set Offset > > AL_SEC_OFFSET - the playback position expressed in seconds. > ... > This value is based on byte position, so a pitch-shifted source will > have an exaggerated playback speed. For example you can be 0.500 seconds > into a buffer having taken only 0.250 seconds to get there if the pitch > is set to 2.0 > > AL_SAMPLE_OFFSET - the playback position expressed in samples > > AL_BYTE_OFFSET - the playback position, expressed in bytes. > > > Do "SNDRV_PCM_RATE_CONTINUOUS" in snd_hardware_t mean that sample rate > can be any integer between .rate_min and .rate_max ? Basically, yes. A driver might add another restriction but in such a case it should use RATE_KNOT instead. > Since changing sample rate while playing is not offically supported by > ALSA. The audio are usually play in LOOP, is it feasible to change the > sample rate at the start of each loop if doppler effect is required ? Changing the rate during the DMA is running is not officially supported. This reads: you have to stop the stream once to change the parameter. This isn't what you want, I guess. > Refer to src/alc_device.c > > #define _ALC_DEF_FREQ 44100 > #define _ALC_NUM_PERIODS 2 > #define _ALC_BUFFER_SIZE 4096 > > > if (snd_pcm_hw_params_set_channels(src->handle, hw_params, 2)) > return ALC_FALSE; > > src->freq = dev->freq; > if (snd_pcm_hw_params_set_rate_near(src->handle, hw_params, &src->freq, 0)) > return ALC_FALSE; > > src->periods = _ALC_NUM_PERIODS; > if (snd_pcm_hw_params_set_periods_near(src->handle, hw_params, > &src->periods,0)) > return ALC_FALSE; > > > size = _ALC_BUFFER_SIZE; > if (snd_pcm_hw_params_set_buffer_size_near(src->handle, hw_params, &size)) > return ALC_FALSE; > > > 1) most of the audio are mono except those stereo backgroud music. > 2) is there any special reason to use _near() function to set rate, > period_size and buffer_size in that order ? The requested rate isn't supported always. The order of hw_params calls may influence the resultant parameters. Especially, the parameters for period and buffer sizes are very sensitive. Usually, the order of period_size -> buffer_size is more stable than buffer_size -> period_size. Takashi ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf