[Linux] OpenAL: fix mic data

The data returned by Mic_ReadSample() must be transfered in 2 parts.
This must be done by every microphone driver.

I did test with Lunar: Dragon Song which values are considered loud,
since you can run away by screaming/blowing into the microphone. Values
from 33-223 don't trigger the escape, values from 0-32 and from 224-255
trigger an escape attempt. Thus 128 would be considered silence.
This commit is contained in:
Ingo Saitz 2021-11-17 15:56:27 +01:00
parent 0b4b58f3b4
commit 9f19d681de
1 changed files with 11 additions and 1 deletions

View File

@ -149,7 +149,17 @@ u8 Mic_ReadSample()
stats_max = ret;
if (ret < stats_min)
stats_min = ret;
Mic_BufPos += 2;
// convert to 2 bytes to transfer over SPI
if (Mic_BufPos & 0x1)
{
ret = ((ret & 0x01) << 7);
}
else
{
ret = ((ret & 0xFE) >> 1);
}
Mic_BufPos += 1;
return ret;
}