[haiku-development] Re: Considering the audio Mixer formats

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 06 Feb 2016 15:29:27 +0000

Provided that this problem can be solved on the API side, I don't think the 
game_kit needs should
have anything to do with media_kit ones.

What's your plan for mixing the output of the game kit with the output from the 
media kit then? That sounds like a job for the system mixer to me, and the 
system mixer is a media node.


We should definitely keep support for that, if only because in the future we 
may want to support
even more formats (5.1 channel, long double floats, or whatever), both on 
input and output sides
(the output to the soundcard is usually not floats).

But, from a real time audio perspective it's a bottleneck. For professional 
uses, a developer will
need to supply an it's own mixer. The risk here using the system one is that 
one format from the
soup will decrease performances thus not allowing us to get 0 latency audio. 
The problem persists,
how can I ensure a certain processing quality/latency with the format soup we 
have?

Have you looked at the current mixer code? Precisely because it does 1-pass 
format conversion and resampling, there is not any added latency when compared 
to just resampling.
Also, floating point math is slower than integer math, so the float formats 
would be the ones slowing everyone down. But that would be noticeable only on a 
very old 133MHz machine, unless you are dealing with hundreds of media nodes in 
realtime?


The mixer definitely should be able to handle all kind of input formats. 
Internally, this can be
implemented as a 3-step process (whatever to float, resampling using floats, 
then floats to
soundcard output format), knowing that it will need more memory and add more 
latency than what we
use now (all 3 done in a single step).

I'm just wondering if letting the audio to be in floating point and having 
every app (or API) to
face out with this in a autonomous way will make things simple. Anyway, like 
things are now I doubt
the Mixer will be ever used seriously in something more complex than looking 
a Video or playing
Doom.

The Mixer is already used by all and every sounds produced in the Media Kit. 
Playing Doom, watching a Video with MediaPlayer, composing music in Sawteeth or 
Sequitur + SynC Modular are things I've already done with it. I'm sure Peete 
Goodeve can show you what he does with the Music Weaver as well.

The Mixer also has a plug-in system where you can replace the resampling 
algorithm. A few years ago, I added the linear interpolation we currently use 
as default, and there is still the older (and faster) drop/repeat sample one 
(with a very noticeable quality drop when you use it). There are of course even 
better algorithms available, with the drawback that they increase latency a 
little more (but we are talking maybe a dozen of samples or so). It's easy to 
add more resampling algorithms without having to remove support for different 
input and output formats, as the format conversion is already a solved problem.

-- 
Adrien.

Other related posts: