mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +02:00
Merge pull request #238 from birarda/off-axis
exaggerate the off-axis effect, fix double variable declaration
This commit is contained in:
commit
106dd3c6d2
1 changed files with 16 additions and 14 deletions
|
@ -60,7 +60,7 @@ 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 MAX_OFF_AXIS_ATTENUATION = 0.2f;
|
||||||
const float OFF_AXIS_ATTENUATION_FORMULA_STEP = (1 - MAX_OFF_AXIS_ATTENUATION) / 2.0f;
|
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) {
|
||||||
|
@ -111,7 +111,6 @@ void *sendBuffer(void *args) {
|
||||||
|
|
||||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
AudioRingBuffer* agentRingBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
AudioRingBuffer* agentRingBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||||
float agentBearing = agentRingBuffer->getBearing();
|
|
||||||
|
|
||||||
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
||||||
|
|
||||||
|
@ -151,7 +150,7 @@ void *sendBuffer(void *args) {
|
||||||
float triangleAngle = atan2f(fabsf(agentPosition[2] - otherAgentPosition[2]),
|
float triangleAngle = atan2f(fabsf(agentPosition[2] - otherAgentPosition[2]),
|
||||||
fabsf(agentPosition[0] - otherAgentPosition[0])) * (180 / M_PI);
|
fabsf(agentPosition[0] - otherAgentPosition[0])) * (180 / M_PI);
|
||||||
float absoluteAngleToSource = 0;
|
float absoluteAngleToSource = 0;
|
||||||
float bearingRelativeAngleToSource = 0;
|
bearingRelativeAngleToSource = 0;
|
||||||
|
|
||||||
// find the angle we need for calculation based on the orientation of the triangle
|
// find the angle we need for calculation based on the orientation of the triangle
|
||||||
if (otherAgentPosition[0] > agentPosition[0]) {
|
if (otherAgentPosition[0] > agentPosition[0]) {
|
||||||
|
@ -168,18 +167,19 @@ void *sendBuffer(void *args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (absoluteAngleToSource > 180) {
|
bearingRelativeAngleToSource = absoluteAngleToSource - agentRingBuffer->getBearing();
|
||||||
absoluteAngleToSource -= 360;
|
|
||||||
} else if (absoluteAngleToSource < -180) {
|
|
||||||
absoluteAngleToSource += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
bearingRelativeAngleToSource = absoluteAngleToSource - agentBearing;
|
if (bearingRelativeAngleToSource > 180) {
|
||||||
bearingRelativeAngleToSource *= (M_PI / 180);
|
bearingRelativeAngleToSource -= 360;
|
||||||
|
} else if (bearingRelativeAngleToSource < -180) {
|
||||||
|
bearingRelativeAngleToSource += 360;
|
||||||
|
}
|
||||||
|
|
||||||
float angleOfDelivery = absoluteAngleToSource - otherAgentBuffer->getBearing();
|
float angleOfDelivery = absoluteAngleToSource - otherAgentBuffer->getBearing();
|
||||||
|
|
||||||
if (angleOfDelivery < -180) {
|
if (angleOfDelivery > 180) {
|
||||||
|
angleOfDelivery -= 360;
|
||||||
|
} else if (angleOfDelivery < -180) {
|
||||||
angleOfDelivery += 360;
|
angleOfDelivery += 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,13 +190,15 @@ void *sendBuffer(void *args) {
|
||||||
* otherAgentBuffer->getAttenuationRatio()
|
* otherAgentBuffer->getAttenuationRatio()
|
||||||
* offAxisCoefficient;
|
* offAxisCoefficient;
|
||||||
|
|
||||||
|
bearingRelativeAngleToSource *= (M_PI / 180);
|
||||||
|
|
||||||
float sinRatio = fabsf(sinf(bearingRelativeAngleToSource));
|
float sinRatio = fabsf(sinf(bearingRelativeAngleToSource));
|
||||||
numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
||||||
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t* goodChannel = bearingRelativeAngleToSource > 0 ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
||||||
int16_t* delayedChannel = bearingRelativeAngleToSource > 0 ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||||
|
|
||||||
int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer()
|
int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer()
|
||||||
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
|
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
|
||||||
|
|
Loading…
Reference in a new issue