mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
Merge pull request #231 from birarda/master
fix loopback from audio mixer
This commit is contained in:
commit
68ead2f309
2 changed files with 68 additions and 64 deletions
|
@ -120,6 +120,11 @@ void *sendBuffer(void *args) {
|
||||||
AudioRingBuffer* otherAgentBuffer = (AudioRingBuffer*) otherAgent->getLinkedData();
|
AudioRingBuffer* otherAgentBuffer = (AudioRingBuffer*) otherAgent->getLinkedData();
|
||||||
|
|
||||||
if (otherAgentBuffer->shouldBeAddedToMix()) {
|
if (otherAgentBuffer->shouldBeAddedToMix()) {
|
||||||
|
|
||||||
|
float bearingRelativeAngleToSource = 0.f;
|
||||||
|
float attenuationCoefficient = 1.f;
|
||||||
|
|
||||||
|
if (otherAgent != agent) {
|
||||||
float *agentPosition = agentRingBuffer->getPosition();
|
float *agentPosition = agentRingBuffer->getPosition();
|
||||||
float *otherAgentPosition = otherAgentBuffer->getPosition();
|
float *otherAgentPosition = otherAgentBuffer->getPosition();
|
||||||
|
|
||||||
|
@ -146,7 +151,6 @@ void *sendBuffer(void *args) {
|
||||||
float absoluteAngleToSource = 0;
|
float absoluteAngleToSource = 0;
|
||||||
float bearingRelativeAngleToSource = 0;
|
float 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]) {
|
||||||
if (otherAgentPosition[2] > agentPosition[2]) {
|
if (otherAgentPosition[2] > agentPosition[2]) {
|
||||||
|
@ -180,13 +184,14 @@ void *sendBuffer(void *args) {
|
||||||
float offAxisCoefficient = MAX_OFF_AXIS_ATTENUATION +
|
float offAxisCoefficient = MAX_OFF_AXIS_ATTENUATION +
|
||||||
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (fabsf(angleOfDelivery) / 90.0f));
|
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (fabsf(angleOfDelivery) / 90.0f));
|
||||||
|
|
||||||
float attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex]
|
attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex]
|
||||||
* otherAgentBuffer->getAttenuationRatio()
|
* otherAgentBuffer->getAttenuationRatio()
|
||||||
* offAxisCoefficient;
|
* 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;
|
||||||
float weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
float 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 ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
||||||
int16_t* delayedChannel = bearingRelativeAngleToSource > 0 ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
int16_t* delayedChannel = bearingRelativeAngleToSource > 0 ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||||
|
|
|
@ -113,6 +113,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
attenuationRatio = attenuationByte / 255.0f;
|
attenuationRatio = attenuationByte / 255.0f;
|
||||||
|
|
||||||
memcpy(&bearing, dataPtr, sizeof(float));
|
memcpy(&bearing, dataPtr, sizeof(float));
|
||||||
|
dataPtr += sizeof(bearing);
|
||||||
|
|
||||||
if (bearing > 180 || bearing < -180) {
|
if (bearing > 180 || bearing < -180) {
|
||||||
// we were passed an invalid bearing because this agent wants loopback (pressed the H key)
|
// we were passed an invalid bearing because this agent wants loopback (pressed the H key)
|
||||||
|
@ -126,8 +127,6 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
_shouldLoopbackForAgent = false;
|
_shouldLoopbackForAgent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataPtr += sizeof(float);
|
|
||||||
|
|
||||||
sourceBuffer = dataPtr;
|
sourceBuffer = dataPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue