All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: dmix plugin
@ 2003-02-17 10:04 Jaroslaw Sobierski
  2003-02-17 10:15 ` Jaroslav Kysela
  2003-02-17 10:32 ` tomasz motylewski
  0 siblings, 2 replies; 21+ messages in thread
From: Jaroslaw Sobierski @ 2003-02-17 10:04 UTC (permalink / raw)
  To: alsa-devel

> > b) sum overflow: we can lower volume of samples before sum; I think that
> >    hardware works in this way, too
> 
> Here I don't understand you. Suppose we have 3 samples to mix:
> a = 0x7500
> b = 0x7400
> c = 0x8300
> 
> If you do a + b + c (in this order) you obtain:
> d=0
> d += a -> 7500
> d += b -> 0xe900 -> 0x7fff
> d += c -> 0x02ff
> 
> while the correct result is 0x6c00. You see?

AFAIK most hardware does not mix by reducing volume before the sum. On the
contrary, it is usually summed "as is" to a wider register, and often even so
used. For example, a sound card able to mix 16 chanels of 16 bits would have
a 16+4 bits or 24 bit register were the channels are added and no saturation
can occur. In good hardware this would not even be downscaled back to 16 bits,
but a 24 bit D/A converter would be used instead. In older times (Gravis Ultra
Sound and I think older SB AWE) this could easily be spotted by the difference
in supported "hardware" channels and "software" channels. A card with a 32 bit
sum register and 24 bit DA could support (as above) 16 hardware channels and 
for example 64 software channels (mixed together in quadrouplets to the 16 hw).

In our case, such "solution" would have to affect the whole buffer, meaning 
we would need 3 (or better yet 4) bytes per sample, which would eventually get
reduced back to 2 bytes on the way out to the sound card. This seems neither
elegant nor memory efficient but would work, and also solves the "a)" problem
because we don't need to saturate so an atomic add can be performed on each
sample. 

--------------
Fycio (J.Sobierski)
 fycio@gucio.com


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: dmix plugin
@ 2003-02-13 10:28 Marc Titinger
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Titinger @ 2003-02-13 10:28 UTC (permalink / raw)
  To: ALSA development

> well, route (or plug) has the capability for software mix (in a
> certain meaning), but not for separate pcm streams.  you can downmix
> the multi-channels in a stream via route plugin if the channels is
> given.
> 
> but it's defenitely different from what dmix plugin does, and perhaps
> it's different from what Marc wants, too...

You got my point : route may looks like soft mix, but actually is downmix with the possibility of setting gains. I guess gains are what makes sense using the asoundrc configuration instead of leaving the downmix to the plughw (I assume plughw would downmix a stereo stream to a mono hw pcm, even if nothing is asoundrc-configured).
 
 
> > Some cards with multiple open hardware acceleration doesn't 
> need this 
> > default. Also, the dmix plugin has some limited things so I 
> don't prefer 
> > to select it as default.
> 
> agreed here, although i feel it's also nice to set it as default for a
> consumer card which has no hardware mix function.
> 
> please note that you can re-define the default in asoundrc.
> if you want to set up dmix as the system default, you can define it in
> /etc/asound.conf, too.
>
 
This makes me enthousiastic about those configuration files : it's a pity that no GUI is yet available to help design complex files ; consider the fact that some hardware manufacturers spend time on developping pricy console enabled hardware, console interfaces and SDK.
A good GUI for asoundrc wouldn't be far from a console interface, especially if some settings can be automated via the sequencer : imagine a gain (or any parameter) could be dependent of a MIDI code !






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: dmix plugin
@ 2003-02-12 18:04 Marc Titinger
  2003-02-12 19:21 ` Jaroslav Kysela
  0 siblings, 1 reply; 21+ messages in thread
From: Marc Titinger @ 2003-02-12 18:04 UTC (permalink / raw)
  To: ALSA development

This looks Great !

I haven't yet experimented a lot with .asoundrc files, so please excuse me if the following questions are irrelevant or OTO, but:

I was wondering if one could define a plug pcm, that offers two stereo pairs routed with policy "average" to a single-stereo "hw" slave.

My understanding is that until this dmix pcm, there was no "official" means supported by alsalib to achieve software mix of streams comming from differents apps.

Could I have one app open the first pair of my hypothetic plug pcm, and another app open the second pair ?
I guess this would be managed like a concurrent access to a pcm, and block or fail the second open() call. 

Would'nt it be nice to create a dmix pcm "behind"  a such plug pcm, to provide mix in a transparent way ?

thanks for your light over this 
Marc.



> -----Original Message-----
> From: Jaroslav Kysela [mailto:perex@suse.cz]
> Sent: mercredi 12 février 2003 10:46
> To: ALSA development
> Subject: [Alsa-devel] dmix plugin
> 
> 
> Hi all,
> 
> 	a next step to get the lowlatency sharing of exclusive 
> PCM devices 
> is in ALSA CVS - the dmix (direct mixing) plugin..
> 	How it works? Basically, the playback in driver runs forewer
> without any xrun detection. The ring buffer (only just played 
> areas) is
> also silenced in each interrupt. Then we have multiple clients and a
> process (server) which passes the file descriptor of playback 
> devices to
> them. The server also takes care about freeing of used shm memory and
> semaphore.
> 	The big step forward is that we share one mmaped ring buffer
> accross many processes and each process can add samples into 
> it without
> any process<->kernel swaps. Also, each processes are independant, thus
> failing of one doesn't break others. It's not multithreaded, 
> we don't need
> this mechanism.
> 
> Here is an .asoundrc example configuration (plugin defaults 
> are 48kHz, 
> stereo, signed 16-bit little endian):
> 
> pcm.dmix {
> 	type dmix
> 	ipc_key 1234	# must be unique for all dmix plugins!!!!
> 	slave {
> 		pcm "hw:0,0"
> 	}
> }
> 
> 	Then try: 'aplay -Dplug:dmix <filename>' on multiple consoles.
> 
> 	Note that it's still alpha code and there are some not correctly
> implemented functions (like drain, rewind and more). Note 
> that you'll need
> also the latest ALSA driver from CVS, because the silence settings was
> enhanced a bit and bug in the timer code will crash your machine.
> 
> 					Enjoy it!
> 						Jaroslav
> 
> -----
> Jaroslav Kysela <perex@suse.cz>
> Linux Kernel Sound Maintainer
> ALSA Project, SuSE Labs
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/alsa-devel
> 


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <20030212125323.C75F059D34D@kerberos.suse.cz>]
* dmix plugin
@ 2003-02-12  9:45 Jaroslav Kysela
  2003-02-12 12:18 ` Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Jaroslav Kysela @ 2003-02-12  9:45 UTC (permalink / raw)
  To: ALSA development

Hi all,

	a next step to get the lowlatency sharing of exclusive PCM devices 
is in ALSA CVS - the dmix (direct mixing) plugin..
	How it works? Basically, the playback in driver runs forewer
without any xrun detection. The ring buffer (only just played areas) is
also silenced in each interrupt. Then we have multiple clients and a
process (server) which passes the file descriptor of playback devices to
them. The server also takes care about freeing of used shm memory and
semaphore.
	The big step forward is that we share one mmaped ring buffer
accross many processes and each process can add samples into it without
any process<->kernel swaps. Also, each processes are independant, thus
failing of one doesn't break others. It's not multithreaded, we don't need
this mechanism.

Here is an .asoundrc example configuration (plugin defaults are 48kHz, 
stereo, signed 16-bit little endian):

pcm.dmix {
	type dmix
	ipc_key 1234	# must be unique for all dmix plugins!!!!
	slave {
		pcm "hw:0,0"
	}
}

	Then try: 'aplay -Dplug:dmix <filename>' on multiple consoles.

	Note that it's still alpha code and there are some not correctly
implemented functions (like drain, rewind and more). Note that you'll need
also the latest ALSA driver from CVS, because the silence settings was
enhanced a bit and bug in the timer code will crash your machine.

					Enjoy it!
						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2003-02-17 15:21 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-17 10:04 dmix plugin Jaroslaw Sobierski
2003-02-17 10:15 ` Jaroslav Kysela
2003-02-17 12:15   ` Abramo Bagnara
2003-02-17 13:12     ` Jaroslav Kysela
2003-02-17 13:29       ` Abramo Bagnara
2003-02-17 15:00         ` Jaroslav Kysela
2003-02-17 15:21           ` Abramo Bagnara
2003-02-17 10:32 ` tomasz motylewski
  -- strict thread matches above, loose matches on Subject: below --
2003-02-13 10:28 Marc Titinger
2003-02-12 18:04 Marc Titinger
2003-02-12 19:21 ` Jaroslav Kysela
2003-02-13  9:51   ` Takashi Iwai
2003-02-13 16:30     ` Jaroslav Kysela
     [not found] <20030212125323.C75F059D34D@kerberos.suse.cz>
2003-02-12 13:32 ` Jaroslav Kysela
2003-02-12  9:45 Jaroslav Kysela
2003-02-12 12:18 ` Takashi Iwai
2003-02-12 13:55   ` Jaroslav Kysela
2003-02-12 12:57 ` Paul Davis
2003-02-13 13:10 ` Abramo Bagnara
2003-02-16 13:27   ` Jaroslav Kysela
2003-02-16 18:00     ` Abramo Bagnara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.