mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +02:00
send full quaternion orientation instead of just bearing to audio-mixer
This commit is contained in:
parent
7ea9bb4b92
commit
0f70c9c06b
1 changed files with 9 additions and 20 deletions
|
@ -133,7 +133,10 @@ int audioCallback (const void* inputBuffer,
|
||||||
Agent* audioMixer = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER);
|
Agent* audioMixer = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER);
|
||||||
|
|
||||||
if (audioMixer) {
|
if (audioMixer) {
|
||||||
int leadingBytes = 2 + (sizeof(float) * 4);
|
glm::vec3 headPosition = interfaceAvatar->getHeadJointPosition();
|
||||||
|
glm::quat headOrientation = interfaceAvatar->getHead().getOrientation();
|
||||||
|
|
||||||
|
int leadingBytes = 1 + sizeof(headPosition) + sizeof(headOrientation) + sizeof(unsigned char);
|
||||||
|
|
||||||
// we need the amount of bytes in the buffer + 1 for type
|
// we need the amount of bytes in the buffer + 1 for type
|
||||||
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
||||||
|
@ -143,29 +146,15 @@ int audioCallback (const void* inputBuffer,
|
||||||
unsigned char *currentPacketPtr = dataPacket + 1;
|
unsigned char *currentPacketPtr = dataPacket + 1;
|
||||||
|
|
||||||
// memcpy the three float positions
|
// memcpy the three float positions
|
||||||
memcpy(currentPacketPtr, &interfaceAvatar->getHeadJointPosition(), sizeof(float) * 3);
|
memcpy(currentPacketPtr, &headPosition, sizeof(headPosition));
|
||||||
currentPacketPtr += (sizeof(float) * 3);
|
currentPacketPtr += (sizeof(headPosition));
|
||||||
|
|
||||||
// tell the mixer not to add additional attenuation to our source
|
// tell the mixer not to add additional attenuation to our source
|
||||||
*(currentPacketPtr++) = 255;
|
*(currentPacketPtr++) = 255;
|
||||||
|
|
||||||
// memcpy the corrected render yaw
|
// memcpy our orientation
|
||||||
float correctedYaw = fmodf(-1 * interfaceAvatar->getAbsoluteHeadYaw(), 360);
|
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
|
||||||
|
currentPacketPtr += sizeof(headOrientation);
|
||||||
if (correctedYaw > 180) {
|
|
||||||
correctedYaw -= 360;
|
|
||||||
} else if (correctedYaw < -180) {
|
|
||||||
correctedYaw += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Application::getInstance()->shouldEchoAudio()) {
|
|
||||||
correctedYaw = correctedYaw > 0
|
|
||||||
? correctedYaw + AGENT_LOOPBACK_MODIFIER
|
|
||||||
: correctedYaw - AGENT_LOOPBACK_MODIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(currentPacketPtr, &correctedYaw, sizeof(float));
|
|
||||||
currentPacketPtr += sizeof(float);
|
|
||||||
|
|
||||||
// copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet
|
// copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet
|
||||||
memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES);
|
memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES);
|
||||||
|
|
Loading…
Reference in a new issue