Commit 1def346b authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

dsound: Support downmixing quadraphonic to stereo.

parent 88dd3b4f
......@@ -252,6 +252,33 @@ void put_surround512stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD c
}
}
void put_quad2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
{
/* based on pulseaudio's downmix algorithm */
switch(channel){
case 2: /* back left */
value *= 0.1f; /* (1/9) / (sum of left volumes) */
dsb->put_aux(dsb, pos, 0, value);
break;
case 0: /* front left */
value *= 0.9f; /* 1 / (sum of left volumes) */
dsb->put_aux(dsb, pos, 0, value);
break;
case 3: /* back right */
value *= 0.1f; /* (1/9) / (sum of right volumes) */
dsb->put_aux(dsb, pos, 1, value);
break;
case 1: /* front right */
value *= 0.9f; /* 1 / (sum of right volumes) */
dsb->put_aux(dsb, pos, 1, value);
break;
}
}
void mixieee32(float *src, float *dst, unsigned samples)
{
TRACE("%p - %p %d\n", src, dst, samples);
......
......@@ -179,6 +179,7 @@ void put_stereo2quad(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel
void put_mono2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_stereo2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_surround512stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_quad2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *dsbd,
IDirectSoundBuffer **buffer) DECLSPEC_HIDDEN;
......
......@@ -179,6 +179,12 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
dsb->put = put_surround512stereo;
dsb->put_aux = putieee32_sum;
}
else if (ichannels == 4 && ochannels == 2)
{
dsb->mix_channels = 4;
dsb->put = put_quad2stereo;
dsb->put_aux = putieee32_sum;
}
else
{
if (ichannels > 2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment