Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libraries/audio/src/AudioSRC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {

} else if (_numChannels == 2) {

__m128 d8 = _mm_set1_ps(8.0f);
__m128 m7 = _mm_set1_ps(7.0f / 8.0f);
int i = 0;
for (; i < numFrames - 3; i += 4) {
__m128 f0 = _mm_mul_ps(_mm_loadu_ps(&inputs[0][i]), scale);
Expand All @@ -972,6 +974,10 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {
f0 = _mm_add_ps(f0, d0);
f1 = _mm_add_ps(f1, d0);

// blend left and right slightly to make headphones less painful to use
f0 = _mm_add_ps(_mm_mul_ps(f0, m7), _mm_div_ps(f1, d8));
f1 = _mm_add_ps(_mm_mul_ps(f1, m7), _mm_div_ps(f0, d8));

// round and saturate
__m128i a0 = _mm_cvtps_epi32(f0);
__m128i a1 = _mm_cvtps_epi32(f1);
Expand Down Expand Up @@ -1243,6 +1249,10 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {
f0 += d;
f1 += d;

// blend left and right slightly to make headphones less painful to use
f0 = f0 * (7.0f / 8.0f) + f1 / 8.0f;
f1 = f1 * (7.0f / 8.0f) + f0 / 8.0f;

// round and saturate
f0 += (f0 < 0.0f ? -0.5f : +0.5f);
f1 += (f1 < 0.0f ? -0.5f : +0.5f);
Expand Down