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

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 7 Feb 2016 08:56:21 +0100

On Sat, Feb 06, 2016 at 06:16:09PM -0800, Pete Goodeve wrote:

On Sat, Feb 06, 2016 at 03:29:27PM +0000, Adrien Destugues wrote:

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.

[I think you have an extra 'e' in there... (:-))  (Fair's fair, as a few weeks
ago you corrected my extra '9'!)]

Sorry!


I'm sorry to say that I've never used the mixer for *anything* but driving
HDA audio output.  Simply because I've never been ABLE to!

Maybe I'm missing something basic, but I've never, for instance, been
able to connect the mixer output to anything *but* HDA.  I can use
Cortex to disconnect it from that and (apparently) reconnect it to,
say, SoundRecorder, but when I try to run I just get a "busy" error
message.

Yes, doing this from Cortex is not working currently. You could,
however, instanciate a separate mixer node from a C++ app. The Game Kit
used to do that, in order to mix its own sources and provide a single
output per app to the media kit. I removed this some years ago because
of problems with hybrid builds (instanciating a gcc2 mixer from a gcc4
compiled app didn't quite work).

What is your process for mixing then? Which other tools should we be
looking at for inspiration?

So IMO, the audio chain is badly in need of an overhaul!  Not sure
what my opinion on float-only is.  I can see that if you need wildly
different fader settings, float might have better characteristics,
but as it has to be integer for the soundcard, I'm not sure there'd
really be a  gain.  I should say, though, that the sources I mostly use
-- Csound and fluidsynth -- both generate float values.

A plain float has only 24-bit for the mantissa, which is less than an
int32. It makes some math simpler as you don't have to worry about
overflows/clipping: just do a bunch of operations, and when you're done,
normalize to fit the required -1:1 range.

But if what you're after is "wildly different fader settings", you would
get results just as good (or possibly even better) with int32 and making
good use of the extra 8 least significant bits.

So, the only thing floats gives us is some simplification in avoiding
clipping/overflows. I can see this making some of the processing simpler
to code, but I'm not sure it makes it faster (there will be less
instructions for the CPU, but I think current CPUs are still slower at
floating point math than integers, especially if you don't use modern
instructions (we're still using gcc2 and generating Pentium MMX
compatible code) and optimizations such as gcc's -ffast-math (which
sacrifices some accuracy in edge cases to going with whatever the CPU
hardware generates).

-- 
Adrien.

Other related posts: