mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
add off axis attenuation to audio-mixer
This commit is contained in:
parent
81fade33dc
commit
04b223a020
1 changed files with 10 additions and 2 deletions
|
@ -60,6 +60,9 @@ const float DISTANCE_RATIO = 3.0f / 0.3f;
|
||||||
const float PHASE_AMPLITUDE_RATIO_AT_90 = 0.5;
|
const float PHASE_AMPLITUDE_RATIO_AT_90 = 0.5;
|
||||||
const int PHASE_DELAY_AT_90 = 20;
|
const int PHASE_DELAY_AT_90 = 20;
|
||||||
|
|
||||||
|
const float MAX_OFF_AXIS_ATTENUATION = 0.5f;
|
||||||
|
const float OFF_AXIS_ATTENUATION_FORMULA_STEP = (1 - MAX_OFF_AXIS_ATTENUATION) / 2.0f;
|
||||||
|
|
||||||
void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
|
void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
|
||||||
long sumSample = sampleToAdd + mixSample;
|
long sumSample = sampleToAdd + mixSample;
|
||||||
|
|
||||||
|
@ -168,8 +171,13 @@ void *sendBuffer(void *args) {
|
||||||
bearingRelativeAngleToSource = absoluteAngleToSource - agentBearing;
|
bearingRelativeAngleToSource = absoluteAngleToSource - agentBearing;
|
||||||
bearingRelativeAngleToSource *= (M_PI / 180);
|
bearingRelativeAngleToSource *= (M_PI / 180);
|
||||||
|
|
||||||
float attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex] *
|
float angleOfDelivery = absoluteAngleToSource - otherAgentBuffer->getBearing();
|
||||||
otherAgentBuffer->getAttenuationRatio();
|
float offAxisCoefficient = MAX_OFF_AXIS_ATTENUATION +
|
||||||
|
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (fabsf(angleOfDelivery) / 90.0f));
|
||||||
|
|
||||||
|
float attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex]
|
||||||
|
* otherAgentBuffer->getAttenuationRatio()
|
||||||
|
* offAxisCoefficient;
|
||||||
|
|
||||||
float sinRatio = fabsf(sinf(bearingRelativeAngleToSource));
|
float sinRatio = fabsf(sinf(bearingRelativeAngleToSource));
|
||||||
int numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
int numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
||||||
|
|
Loading…
Reference in a new issue