mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-30 08:51:08 +00:00
Mixer function fixups from H266
git-svn-id: https://svn.eduke32.com/eduke32@7120 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1c007c56c5
commit
6d226cf0da
3 changed files with 88 additions and 90 deletions
|
@ -36,10 +36,12 @@ void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32
|
|||
|
||||
while (length--)
|
||||
{
|
||||
int const sample0 = MV_VOLUME(source[position >> 16]);
|
||||
uint8_t const usample0 = MV_VOLUME(source[position >> 16], volume);
|
||||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[sample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[usample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -55,12 +57,14 @@ void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint
|
|||
|
||||
while (length--)
|
||||
{
|
||||
int const sample0 = MV_VOLUME(source[position >> 16]);
|
||||
uint8_t const usample0 = MV_VOLUME(source[position >> 16], volume);
|
||||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[sample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[usample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
= (int16_t)clamp(MV_RightVolume[sample0] + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
= (int16_t)clamp(MV_RightVolume[usample0] + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -71,25 +75,18 @@ void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint
|
|||
// 16-bit mono source, 16-bit mono output
|
||||
void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length, float volume)
|
||||
{
|
||||
auto const source = (uint16_t const *)start;
|
||||
auto const source = (int16_t const *)start;
|
||||
int16_t * dest = (int16_t *)MV_MixDestination;
|
||||
|
||||
while (length--)
|
||||
{
|
||||
int const sample0 = MV_VOLUME(source[position >> 16]);
|
||||
#ifdef BIGENDIAN
|
||||
int sample0l = sample0 >> 8;
|
||||
int sample0h = (sample0 & 255) ^ 128;
|
||||
#else
|
||||
int sample0l = sample0 & 255;
|
||||
int sample0h = (sample0 >> 8) ^ 128;
|
||||
#endif
|
||||
int16_t const isample0 = B_LITTLE16(source[position >> 16]);
|
||||
split16_t const usample0{MV_FLIP_SIGNEDNESS(MV_VOLUME(isample0, volume))};
|
||||
|
||||
position += rate;
|
||||
|
||||
sample0l = MV_LeftVolume[sample0l] >> 8;
|
||||
sample0h = MV_LeftVolume[sample0h];
|
||||
|
||||
*dest = (int16_t)clamp(sample0l + sample0h + 128 + *dest, INT16_MIN, INT16_MAX);
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
*dest = (int16_t)clamp(sample0 + *dest, INT16_MIN, INT16_MAX);
|
||||
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
@ -101,31 +98,21 @@ void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint
|
|||
// 16-bit mono source, 16-bit stereo output
|
||||
void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length, float volume)
|
||||
{
|
||||
auto const source = (uint16_t const *)start;
|
||||
auto const source = (int16_t const *)start;
|
||||
int16_t * dest = (int16_t *)MV_MixDestination;
|
||||
|
||||
while (length--)
|
||||
{
|
||||
int const sample0 = MV_VOLUME(source[position >> 16]);
|
||||
int16_t const isample0 = B_LITTLE16(source[position >> 16]);
|
||||
split16_t const usample0{MV_FLIP_SIGNEDNESS(MV_VOLUME(isample0, volume))};
|
||||
|
||||
position += rate;
|
||||
|
||||
#ifdef BIGENDIAN
|
||||
int sample0l = sample0 >> 8;
|
||||
int sample0h = (sample0 & 255) ^ 128;
|
||||
#else
|
||||
int sample0l = sample0 & 255;
|
||||
int sample0h = (sample0 >> 8) ^ 128;
|
||||
#endif
|
||||
|
||||
int const sample1l = MV_RightVolume[sample0l] >> 8;
|
||||
int const sample1h = MV_RightVolume[sample0h];
|
||||
|
||||
sample0l = MV_LeftVolume[sample0l] >> 8;
|
||||
sample0h = MV_LeftVolume[sample0h];
|
||||
|
||||
*dest = (int16_t)clamp(sample0l + sample0h + 128 + *dest, INT16_MIN, INT16_MAX);
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
int32_t const sample1 = (MV_RightVolume[usample0.l()] >> 8) + MV_RightVolume[usample0.h()] + 128;
|
||||
*dest = (int16_t)clamp(sample0 + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
= (int16_t)clamp(sample1l + sample1h + 128 + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
= (int16_t)clamp(sample1 + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue