mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 07:36:36 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
07eba1ae88
2 changed files with 114 additions and 109 deletions
|
@ -86,7 +86,7 @@ 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* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||||
|
|
||||||
if (agentBuffer != NULL && agentBuffer->getEndOfLastWrite() != NULL) {
|
if (agentBuffer && agentBuffer->getEndOfLastWrite() != NULL) {
|
||||||
|
|
||||||
if (!agentBuffer->isStarted()
|
if (!agentBuffer->isStarted()
|
||||||
&& agentBuffer->diffLastWriteNextOutput() <= BUFFER_LENGTH_SAMPLES_PER_CHANNEL + JITTER_BUFFER_SAMPLES) {
|
&& agentBuffer->diffLastWriteNextOutput() <= BUFFER_LENGTH_SAMPLES_PER_CHANNEL + JITTER_BUFFER_SAMPLES) {
|
||||||
|
@ -111,6 +111,7 @@ 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();
|
||||||
|
|
||||||
|
if (agentRingBuffer) {
|
||||||
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
||||||
|
|
||||||
for (AgentList::iterator otherAgent = agentList->begin(); otherAgent != agentList->end(); otherAgent++) {
|
for (AgentList::iterator otherAgent = agentList->begin(); otherAgent != agentList->end(); otherAgent++) {
|
||||||
|
@ -140,7 +141,8 @@ void *sendBuffer(void *args) {
|
||||||
powf(agentPosition[2] - otherAgentPosition[2], 2));
|
powf(agentPosition[2] - otherAgentPosition[2], 2));
|
||||||
|
|
||||||
float minCoefficient = std::min(1.0f,
|
float minCoefficient = std::min(1.0f,
|
||||||
powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1));
|
powf(0.5,
|
||||||
|
(logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1));
|
||||||
distanceCoefficients[lowAgentIndex][highAgentIndex] = minCoefficient;
|
distanceCoefficients[lowAgentIndex][highAgentIndex] = minCoefficient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +198,12 @@ void *sendBuffer(void *args) {
|
||||||
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f
|
||||||
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
|
||||||
|
: clientMix;
|
||||||
|
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
|
||||||
|
@ -225,10 +231,11 @@ void *sendBuffer(void *args) {
|
||||||
|
|
||||||
agentList->getAgentSocket().send(agent->getPublicSocket(), clientMix, BUFFER_LENGTH_BYTES);
|
agentList->getAgentSocket().send(agent->getPublicSocket(), clientMix, BUFFER_LENGTH_BYTES);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||||
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||||
if (agentBuffer->shouldBeAddedToMix()) {
|
if (agentBuffer && agentBuffer->shouldBeAddedToMix()) {
|
||||||
agentBuffer->setNextOutput(agentBuffer->getNextOutput() + BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
agentBuffer->setNextOutput(agentBuffer->getNextOutput() + BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
if (agentBuffer->getNextOutput() >= agentBuffer->getBuffer() + RING_BUFFER_SAMPLES) {
|
if (agentBuffer->getNextOutput() >= agentBuffer->getBuffer() + RING_BUFFER_SAMPLES) {
|
||||||
|
|
|
@ -9,15 +9,13 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "AudioRingBuffer.h"
|
#include "AudioRingBuffer.h"
|
||||||
|
|
||||||
AudioRingBuffer::AudioRingBuffer(int ringSamples, int bufferSamples) {
|
AudioRingBuffer::AudioRingBuffer(int ringSamples, int bufferSamples) :
|
||||||
ringBufferLengthSamples = ringSamples;
|
ringBufferLengthSamples(ringSamples),
|
||||||
bufferLengthSamples = bufferSamples;
|
bufferLengthSamples(bufferSamples),
|
||||||
|
endOfLastWrite(NULL),
|
||||||
started = false;
|
started(false),
|
||||||
_shouldBeAddedToMix = false;
|
_shouldBeAddedToMix(false),
|
||||||
|
_shouldLoopbackForAgent(false) {
|
||||||
endOfLastWrite = NULL;
|
|
||||||
|
|
||||||
buffer = new int16_t[ringBufferLengthSamples];
|
buffer = new int16_t[ringBufferLengthSamples];
|
||||||
nextOutput = buffer;
|
nextOutput = buffer;
|
||||||
};
|
};
|
||||||
|
@ -27,6 +25,7 @@ AudioRingBuffer::AudioRingBuffer(const AudioRingBuffer &otherRingBuffer) {
|
||||||
bufferLengthSamples = otherRingBuffer.bufferLengthSamples;
|
bufferLengthSamples = otherRingBuffer.bufferLengthSamples;
|
||||||
started = otherRingBuffer.started;
|
started = otherRingBuffer.started;
|
||||||
_shouldBeAddedToMix = otherRingBuffer._shouldBeAddedToMix;
|
_shouldBeAddedToMix = otherRingBuffer._shouldBeAddedToMix;
|
||||||
|
_shouldLoopbackForAgent = otherRingBuffer._shouldLoopbackForAgent;
|
||||||
|
|
||||||
buffer = new int16_t[ringBufferLengthSamples];
|
buffer = new int16_t[ringBufferLengthSamples];
|
||||||
memcpy(buffer, otherRingBuffer.buffer, sizeof(int16_t) * ringBufferLengthSamples);
|
memcpy(buffer, otherRingBuffer.buffer, sizeof(int16_t) * ringBufferLengthSamples);
|
||||||
|
@ -149,8 +148,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
return numBytes;
|
return numBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
short AudioRingBuffer::diffLastWriteNextOutput()
|
short AudioRingBuffer::diffLastWriteNextOutput() {
|
||||||
{
|
|
||||||
if (endOfLastWrite == NULL) {
|
if (endOfLastWrite == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue