Doing equal power panning in the stereo mixer
Doing equal power panning in the stereo mixer
- Subject: Doing equal power panning in the stereo mixer
- From: "Timothy J. Wood" <email@hidden>
- Date: Mon, 21 Oct 2002 11:12:40 -0700
Since I'm unable to use the 3D mixer (due to non configurable power
falloff and high frequency absorption discussed in mid Sep), I'm using
the 2D mixer and doing my own spatialization.
The first issue is that the 2D mixer uses amplitude scaling to
implement volume (at least I gather this from the headers and from the
sounds). That is, if you supply a volume of 0.5, this gets multiplied
by the samples, thus halving the amplitude of the waveform.
This is all find and good. The sound library I'm emulating wants a
power linear volume curve whereas amplitude scaling gives a power
quadratic curve. Simple enough -- use sqrt(volume) instead of volume
(where volume is in 0..1).
But this doesn't account for panning. If I want to pan w/o changing
the total power, I'm not sure what to do. I'm assuming that the 2D
mixer does something like:
leftOutputSample = (1.0 - pan) * volume * inputSample
rightOutputSample = pan * volume * inputSample
If I've adjusted the 'volume' parameter to provide a linear power
scale I have:
leftOutputSample = (1.0 - pan) * sqrt(volume) * inputSample
rightOutputSample = pan * sqrt(volume) * inputSample
This isn't going to preserve power, though... If pan is 0.5, then
both channels will have:
0.5 * sqrt(volume) * inputSample
which will result in each channel getting 0.25 of the power (ending
in a total of 0.5 of the desired power).
It looks like I need to have the pan factors add up to something >
1.0, or I need to be able to set the amplitude multiplier directly on
the left/right channels instead of setting a pan value and a single
amplitude multiplier.
Is there some way I can do this -- I don't see it from the
headers/docs. kStereoMixerParam_Volume as an input applies to the
whole mono input while as an output applies to the whole output (all
the mixed inputs).
The only thing I can think of right now is to have every input sent
into the 2D mixer TWICE, once with a pan of 0.0 and once with a pan of
1.0 and then I can control the volume directly on each channel. This
seems like a really lame solution, but failing anything better....
-tim
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.