From 0f70c9c06bbffd2206d5fe1b9b7f2e80c9c379a2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 4 Jun 2013 12:52:09 -0700 Subject: [PATCH] send full quaternion orientation instead of just bearing to audio-mixer --- interface/src/Audio.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index bf100d733b..16ac7fa4f7 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -133,7 +133,10 @@ int audioCallback (const void* inputBuffer, Agent* audioMixer = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER); 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 // + 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; // memcpy the three float positions - memcpy(currentPacketPtr, &interfaceAvatar->getHeadJointPosition(), sizeof(float) * 3); - currentPacketPtr += (sizeof(float) * 3); + memcpy(currentPacketPtr, &headPosition, sizeof(headPosition)); + currentPacketPtr += (sizeof(headPosition)); // tell the mixer not to add additional attenuation to our source *(currentPacketPtr++) = 255; - // memcpy the corrected render yaw - float correctedYaw = fmodf(-1 * interfaceAvatar->getAbsoluteHeadYaw(), 360); - - 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); + // memcpy our orientation + memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation)); + currentPacketPtr += sizeof(headOrientation); // copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES);