|
|
@ -68,7 +68,19 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa |
|
|
|
|
|
|
|
|
|
|
|
void AudioEffectStereoPanorama::panorama(float p) |
|
|
|
void AudioEffectStereoPanorama::panorama(float p) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pan = mapfloat(p, -1.0, 1.0, 1.0, 0.0); |
|
|
|
//pan = mapfloat(p, -1.0, 1.0, 1.0, 0.0);
|
|
|
|
|
|
|
|
if (p == 0.5) |
|
|
|
|
|
|
|
pan_l = pan_r = 1.0; |
|
|
|
|
|
|
|
else if (p > 0.5) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pan_r = 0.5 - abs(0.5 - p); |
|
|
|
|
|
|
|
pan_l = 1.0 - pan_r; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pan_l = 0.5 - abs(0.5 - p); |
|
|
|
|
|
|
|
pan_r = 1.0 - p; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AudioEffectStereoPanorama::update(void) |
|
|
|
void AudioEffectStereoPanorama::update(void) |
|
|
@ -92,17 +104,16 @@ void AudioEffectStereoPanorama::update(void) |
|
|
|
arm_q15_to_float(in[0]->data, in_f[0], AUDIO_BLOCK_SAMPLES); |
|
|
|
arm_q15_to_float(in[0]->data, in_f[0], AUDIO_BLOCK_SAMPLES); |
|
|
|
arm_q15_to_float(in[1]->data, in_f[1], AUDIO_BLOCK_SAMPLES); |
|
|
|
arm_q15_to_float(in[1]->data, in_f[1], AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
|
|
|
|
float fsin = arm_sin_f32(pan * PI / 2.0); |
|
|
|
|
|
|
|
float fcos = arm_cos_f32(pan * PI / 2.0); |
|
|
|
|
|
|
|
int16_t* out_p[2] = {&out[0]->data[0], &out[1]->data[0]}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (uint16_t n = 0; n < AUDIO_BLOCK_SAMPLES; n++) |
|
|
|
for (uint16_t n = 0; n < AUDIO_BLOCK_SAMPLES; n++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
out_p[0][n] = int16_t(in_f[0][n] * _pseudo_log * fsin * SHRT_MAX); |
|
|
|
out_f[0][n] = in_f[0][n] * pan_r; |
|
|
|
out_p[1][n] = int16_t(in_f[1][n] * _pseudo_log * fcos * SHRT_MAX); |
|
|
|
out_f[0][n] += in_f[1][n] * pan_l; |
|
|
|
out_p[0][n] = int16_t(in_f[0][n] * _pseudo_log * fcos * SHRT_MAX); |
|
|
|
out_f[1][n] = in_f[1][n] * pan_r; |
|
|
|
out_p[1][n] = int16_t(in_f[1][n] * _pseudo_log * fsin * SHRT_MAX); |
|
|
|
out_f[1][n] += in_f[0][n] * pan_l; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arm_float_to_q15(out_f[0], out[0]->data, AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
arm_float_to_q15(out_f[1], out[1]->data, AUDIO_BLOCK_SAMPLES); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (in[0] != (audio_block_t*)&zeroblock) |
|
|
|
if (in[0] != (audio_block_t*)&zeroblock) |
|
|
|