mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 05:51:07 +02:00
have the mixer additionally attenuate sources based on extra byte
This commit is contained in:
parent
0711539fc6
commit
896047d2aa
4 changed files with 24 additions and 7 deletions
|
@ -158,6 +158,9 @@ int audioCallback (const void *inputBuffer,
|
|||
currentPacketPtr += sizeof(float);
|
||||
}
|
||||
|
||||
// tell the mixer not to add additional attenuation to our source
|
||||
*(currentPacketPtr++) = 255;
|
||||
|
||||
// memcpy the corrected render yaw
|
||||
float correctedYaw = fmodf(data->linkedHead->getRenderYaw(), 360);
|
||||
|
||||
|
|
|
@ -147,9 +147,6 @@ void *sendBuffer(void *args)
|
|||
float triangleAngle = atan2f(fabsf(agentPosition[2] - otherAgentPosition[2]), fabsf(agentPosition[0] - otherAgentPosition[0])) * (180 / M_PI);
|
||||
float angleToSource;
|
||||
|
||||
if (agentWantsLoopback) {
|
||||
|
||||
}
|
||||
|
||||
// find the angle we need for calculation based on the orientation of the triangle
|
||||
if (otherAgentPosition[0] > agentPosition[0]) {
|
||||
|
@ -178,8 +175,6 @@ void *sendBuffer(void *args)
|
|||
int numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
||||
float weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||
|
||||
printf("The weak channel AR is %f\n", weakChannelAmplitudeRatio);
|
||||
|
||||
int16_t *goodChannel = angleToSource > 0 ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
||||
int16_t *delayedChannel = angleToSource > 0 ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||
|
||||
|
@ -193,11 +188,16 @@ void *sendBuffer(void *args)
|
|||
if (s < numSamplesDelay) {
|
||||
// pull the earlier sample for the delayed channel
|
||||
|
||||
int earlierSample = delaySamplePointer[s] * distanceCoeffs[lowAgentIndex][highAgentIndex];
|
||||
int earlierSample = delaySamplePointer[s] *
|
||||
distanceCoeffs[lowAgentIndex][highAgentIndex] *
|
||||
otherAgentBuffer->getAttenuationRatio();
|
||||
|
||||
plateauAdditionOfSamples(delayedChannel[s], earlierSample * weakChannelAmplitudeRatio);
|
||||
}
|
||||
|
||||
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * distanceCoeffs[lowAgentIndex][highAgentIndex]);
|
||||
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] *
|
||||
distanceCoeffs[lowAgentIndex][highAgentIndex]) *
|
||||
otherAgentBuffer->getAttenuationRatio();
|
||||
plateauAdditionOfSamples(goodChannel[s], currentSample);
|
||||
|
||||
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
|
||||
|
|
|
@ -89,6 +89,14 @@ void AudioRingBuffer::setPosition(float *newPosition) {
|
|||
position[2] = newPosition[2];
|
||||
}
|
||||
|
||||
float AudioRingBuffer::getAttenuationRatio() {
|
||||
return attenuationRatio;
|
||||
}
|
||||
|
||||
void AudioRingBuffer::setAttenuationRatio(float newAttenuation) {
|
||||
attenuationRatio = newAttenuation;
|
||||
}
|
||||
|
||||
float AudioRingBuffer::getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
@ -109,6 +117,9 @@ void AudioRingBuffer::parseData(void *data, int size) {
|
|||
dataPtr += sizeof(float);
|
||||
}
|
||||
|
||||
unsigned int attenuationByte = *(dataPtr++);
|
||||
attenuationRatio = attenuationByte / 255.0f;
|
||||
|
||||
memcpy(&bearing, dataPtr, sizeof(float));
|
||||
dataPtr += sizeof(float);
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ class AudioRingBuffer : public AgentData {
|
|||
void setAddedToMix(bool added);
|
||||
float* getPosition();
|
||||
void setPosition(float newPosition[]);
|
||||
float getAttenuationRatio();
|
||||
void setAttenuationRatio(float newAttenuation);
|
||||
float getBearing();
|
||||
void setBearing(float newBearing);
|
||||
|
||||
|
@ -41,6 +43,7 @@ class AudioRingBuffer : public AgentData {
|
|||
int ringBufferLengthSamples;
|
||||
int bufferLengthSamples;
|
||||
float position[3];
|
||||
float attenuationRatio;
|
||||
float bearing;
|
||||
int16_t *nextOutput;
|
||||
int16_t *endOfLastWrite;
|
||||
|
|
Loading…
Reference in a new issue