@@ -963,6 +963,8 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {
963963
964964 } else if (_numChannels == 2 ) {
965965
966+ __m128 d8 = _mm_set1_ps (8 .0f );
967+ __m128 m7 = _mm_set1_ps (7 .0f / 8 .0f );
966968 int i = 0 ;
967969 for (; i < numFrames - 3 ; i += 4 ) {
968970 __m128 f0 = _mm_mul_ps (_mm_loadu_ps (&inputs[0 ][i]), scale);
@@ -972,6 +974,10 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {
972974 f0 = _mm_add_ps (f0, d0);
973975 f1 = _mm_add_ps (f1, d0);
974976
977+ // blend left and right slightly to make headphones less painful to use
978+ f0 = _mm_add_ps (_mm_mul_ps (f0, m7), _mm_div_ps (f1, d8));
979+ f1 = _mm_add_ps (_mm_mul_ps (f1, m7), _mm_div_ps (f0, d8));
980+
975981 // round and saturate
976982 __m128i a0 = _mm_cvtps_epi32 (f0);
977983 __m128i a1 = _mm_cvtps_epi32 (f1);
@@ -1243,6 +1249,10 @@ void AudioSRC::convertOutput(float** inputs, int16_t* output, int numFrames) {
12431249 f0 += d;
12441250 f1 += d;
12451251
1252+ // blend left and right slightly to make headphones less painful to use
1253+ f0 = f0 * (7 .0f / 8 .0f ) + f1 / 8 .0f ;
1254+ f1 = f1 * (7 .0f / 8 .0f ) + f0 / 8 .0f ;
1255+
12461256 // round and saturate
12471257 f0 += (f0 < 0 .0f ? -0 .5f : +0 .5f );
12481258 f1 += (f1 < 0 .0f ? -0 .5f : +0 .5f );
0 commit comments