mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
merge branch qt5 with upstream/master
This commit is contained in:
commit
08b94d731f
12 changed files with 367 additions and 160 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include <Node.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "PositionalAudioRingBuffer.h"
|
||||
|
@ -16,25 +17,81 @@ PositionalAudioRingBuffer::PositionalAudioRingBuffer() :
|
|||
AudioRingBuffer(false),
|
||||
_position(0.0f, 0.0f, 0.0f),
|
||||
_orientation(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
_willBeAddedToMix(false)
|
||||
_willBeAddedToMix(false),
|
||||
_listenMode(AudioRingBuffer::NORMAL),
|
||||
_listenRadius(0.0f)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PositionalAudioRingBuffer::~PositionalAudioRingBuffer() {
|
||||
}
|
||||
|
||||
bool PositionalAudioRingBuffer::isListeningToNode(Node& other) const {
|
||||
switch (_listenMode) {
|
||||
default:
|
||||
case AudioRingBuffer::NORMAL:
|
||||
return true;
|
||||
break;
|
||||
|
||||
case AudioRingBuffer::OMNI_DIRECTIONAL_POINT: {
|
||||
PositionalAudioRingBuffer* otherNodeBuffer = (PositionalAudioRingBuffer*) other.getLinkedData();
|
||||
float distance = glm::distance(_position, otherNodeBuffer->_position);
|
||||
return distance <= _listenRadius;
|
||||
break;
|
||||
}
|
||||
case AudioRingBuffer::SELECTED_SOURCES:
|
||||
for (int i = 0; i < _listenSources.size(); i++) {
|
||||
if (other.getNodeID() == _listenSources[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int PositionalAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
unsigned char* currentBuffer = sourceBuffer + numBytesForPacketHeader(sourceBuffer);
|
||||
currentBuffer += sizeof(uint16_t); // the source ID
|
||||
currentBuffer += parseListenModeData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
|
||||
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
|
||||
currentBuffer += parseAudioSamples(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
|
||||
|
||||
return currentBuffer - sourceBuffer;
|
||||
}
|
||||
|
||||
int PositionalAudioRingBuffer::parseListenModeData(unsigned char* sourceBuffer, int numBytes) {
|
||||
unsigned char* currentBuffer = sourceBuffer;
|
||||
|
||||
memcpy(&_listenMode, currentBuffer, sizeof(_listenMode));
|
||||
currentBuffer += sizeof(_listenMode);
|
||||
|
||||
if (_listenMode == AudioRingBuffer::OMNI_DIRECTIONAL_POINT) {
|
||||
memcpy(&_listenRadius, currentBuffer, sizeof(_listenRadius));
|
||||
currentBuffer += sizeof(_listenRadius);
|
||||
} else if (_listenMode == AudioRingBuffer::SELECTED_SOURCES) {
|
||||
int listenSourcesCount;
|
||||
memcpy(&listenSourcesCount, currentBuffer, sizeof(listenSourcesCount));
|
||||
currentBuffer += sizeof(listenSourcesCount);
|
||||
for (int i = 0; i < listenSourcesCount; i++) {
|
||||
int sourceID;
|
||||
memcpy(&sourceID, currentBuffer, sizeof(sourceID));
|
||||
currentBuffer += sizeof(sourceID);
|
||||
_listenSources.push_back(sourceID);
|
||||
}
|
||||
}
|
||||
|
||||
return currentBuffer - sourceBuffer;
|
||||
}
|
||||
|
||||
int PositionalAudioRingBuffer::parsePositionalData(unsigned char* sourceBuffer, int numBytes) {
|
||||
unsigned char* currentBuffer = sourceBuffer;
|
||||
|
||||
memcpy(&_position, currentBuffer, sizeof(_position));
|
||||
currentBuffer += sizeof(_position);
|
||||
|
||||
|
||||
memcpy(&_orientation, currentBuffer, sizeof(_orientation));
|
||||
currentBuffer += sizeof(_orientation);
|
||||
|
||||
|
@ -63,6 +120,6 @@ bool PositionalAudioRingBuffer::shouldBeAddedToMix(int numJitterBufferSamples) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
printf("packet mismatch...\n");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef __hifi__PositionalAudioRingBuffer__
|
||||
#define __hifi__PositionalAudioRingBuffer__
|
||||
|
||||
#include <vector>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <AudioRingBuffer.h>
|
||||
|
@ -16,9 +17,11 @@
|
|||
class PositionalAudioRingBuffer : public AudioRingBuffer {
|
||||
public:
|
||||
PositionalAudioRingBuffer();
|
||||
~PositionalAudioRingBuffer();
|
||||
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
int parsePositionalData(unsigned char* sourceBuffer, int numBytes);
|
||||
int parseListenModeData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
||||
bool shouldBeAddedToMix(int numJitterBufferSamples);
|
||||
|
||||
|
@ -27,6 +30,9 @@ public:
|
|||
|
||||
const glm::vec3& getPosition() const { return _position; }
|
||||
const glm::quat& getOrientation() const { return _orientation; }
|
||||
|
||||
bool isListeningToNode(Node& other) const;
|
||||
ListenMode getListeningMode() const { return _listenMode; }
|
||||
|
||||
protected:
|
||||
// disallow copying of PositionalAudioRingBuffer objects
|
||||
|
@ -36,6 +42,10 @@ protected:
|
|||
glm::vec3 _position;
|
||||
glm::quat _orientation;
|
||||
bool _willBeAddedToMix;
|
||||
|
||||
ListenMode _listenMode;
|
||||
float _listenRadius;
|
||||
std::vector<int> _listenSources;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__PositionalAudioRingBuffer__) */
|
||||
|
|
|
@ -141,7 +141,6 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||
PositionalAudioRingBuffer* positionalRingBuffer = (PositionalAudioRingBuffer*) node->getLinkedData();
|
||||
|
||||
if (positionalRingBuffer && positionalRingBuffer->shouldBeAddedToMix(JITTER_BUFFER_SAMPLES)) {
|
||||
// this is a ring buffer that is ready to go
|
||||
// set its flag so we know to push its buffer when all is said and done
|
||||
|
@ -159,168 +158,171 @@ int main(int argc, const char* argv[]) {
|
|||
// zero out the client mix for this node
|
||||
memset(clientSamples, 0, sizeof(clientSamples));
|
||||
|
||||
// loop through all other nodes that have sufficient audio to mix
|
||||
for (NodeList::iterator otherNode = nodeList->begin(); otherNode != nodeList->end(); otherNode++) {
|
||||
if (((PositionalAudioRingBuffer*) otherNode->getLinkedData())->willBeAddedToMix()
|
||||
&& (otherNode != node || (otherNode == node && nodeRingBuffer->shouldLoopbackForNode()))) {
|
||||
|
||||
PositionalAudioRingBuffer* otherNodeBuffer = (PositionalAudioRingBuffer*) otherNode->getLinkedData();
|
||||
// based on our listen mode we will do this mixing...
|
||||
if (nodeRingBuffer->isListeningToNode(*otherNode)) {
|
||||
float bearingRelativeAngleToSource = 0.0f;
|
||||
float attenuationCoefficient = 1.0f;
|
||||
int numSamplesDelay = 0;
|
||||
float weakChannelAmplitudeRatio = 1.0f;
|
||||
|
||||
float bearingRelativeAngleToSource = 0.0f;
|
||||
float attenuationCoefficient = 1.0f;
|
||||
int numSamplesDelay = 0;
|
||||
float weakChannelAmplitudeRatio = 1.0f;
|
||||
stk::TwoPole* otherNodeTwoPole = NULL;
|
||||
|
||||
stk::TwoPole* otherNodeTwoPole = NULL;
|
||||
|
||||
if (otherNode != node) {
|
||||
// only do axis/distance attenuation when in normal mode
|
||||
if (otherNode != node && nodeRingBuffer->getListeningMode() == AudioRingBuffer::NORMAL) {
|
||||
|
||||
glm::vec3 listenerPosition = nodeRingBuffer->getPosition();
|
||||
glm::vec3 relativePosition = otherNodeBuffer->getPosition() - nodeRingBuffer->getPosition();
|
||||
glm::quat inverseOrientation = glm::inverse(nodeRingBuffer->getOrientation());
|
||||
glm::vec3 listenerPosition = nodeRingBuffer->getPosition();
|
||||
glm::vec3 relativePosition = otherNodeBuffer->getPosition() - nodeRingBuffer->getPosition();
|
||||
glm::quat inverseOrientation = glm::inverse(nodeRingBuffer->getOrientation());
|
||||
|
||||
float distanceSquareToSource = glm::dot(relativePosition, relativePosition);
|
||||
float radius = 0.0f;
|
||||
float distanceSquareToSource = glm::dot(relativePosition, relativePosition);
|
||||
float radius = 0.0f;
|
||||
|
||||
if (otherNode->getType() == NODE_TYPE_AUDIO_INJECTOR) {
|
||||
InjectedAudioRingBuffer* injectedBuffer = (InjectedAudioRingBuffer*) otherNodeBuffer;
|
||||
radius = injectedBuffer->getRadius();
|
||||
attenuationCoefficient *= injectedBuffer->getAttenuationRatio();
|
||||
}
|
||||
if (otherNode->getType() == NODE_TYPE_AUDIO_INJECTOR) {
|
||||
InjectedAudioRingBuffer* injectedBuffer = (InjectedAudioRingBuffer*) otherNodeBuffer;
|
||||
radius = injectedBuffer->getRadius();
|
||||
attenuationCoefficient *= injectedBuffer->getAttenuationRatio();
|
||||
}
|
||||
|
||||
if (radius == 0 || (distanceSquareToSource > radius * radius)) {
|
||||
// this is either not a spherical source, or the listener is outside the sphere
|
||||
if (radius == 0 || (distanceSquareToSource > radius * radius)) {
|
||||
// this is either not a spherical source, or the listener is outside the sphere
|
||||
|
||||
if (radius > 0) {
|
||||
// this is a spherical source - the distance used for the coefficient
|
||||
// needs to be the closest point on the boundary to the source
|
||||
if (radius > 0) {
|
||||
// this is a spherical source - the distance used for the coefficient
|
||||
// needs to be the closest point on the boundary to the source
|
||||
|
||||
// ovveride the distance to the node with the distance to the point on the
|
||||
// boundary of the sphere
|
||||
distanceSquareToSource -= (radius * radius);
|
||||
// ovveride the distance to the node with the distance to the point on the
|
||||
// boundary of the sphere
|
||||
distanceSquareToSource -= (radius * radius);
|
||||
|
||||
} else {
|
||||
// calculate the angle delivery for off-axis attenuation
|
||||
glm::vec3 rotatedListenerPosition = glm::inverse(otherNodeBuffer->getOrientation())
|
||||
* relativePosition;
|
||||
} else {
|
||||
// calculate the angle delivery for off-axis attenuation
|
||||
glm::vec3 rotatedListenerPosition = glm::inverse(otherNodeBuffer->getOrientation())
|
||||
* relativePosition;
|
||||
|
||||
float angleOfDelivery = glm::angle(glm::vec3(0.0f, 0.0f, -1.0f),
|
||||
glm::normalize(rotatedListenerPosition));
|
||||
float angleOfDelivery = glm::angle(glm::vec3(0.0f, 0.0f, -1.0f),
|
||||
glm::normalize(rotatedListenerPosition));
|
||||
|
||||
const float MAX_OFF_AXIS_ATTENUATION = 0.2f;
|
||||
const float OFF_AXIS_ATTENUATION_FORMULA_STEP = (1 - MAX_OFF_AXIS_ATTENUATION) / 2.0f;
|
||||
const float MAX_OFF_AXIS_ATTENUATION = 0.2f;
|
||||
const float OFF_AXIS_ATTENUATION_FORMULA_STEP = (1 - MAX_OFF_AXIS_ATTENUATION) / 2.0f;
|
||||
|
||||
float offAxisCoefficient = MAX_OFF_AXIS_ATTENUATION +
|
||||
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (angleOfDelivery / 90.0f));
|
||||
float offAxisCoefficient = MAX_OFF_AXIS_ATTENUATION +
|
||||
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (angleOfDelivery / 90.0f));
|
||||
|
||||
// multiply the current attenuation coefficient by the calculated off axis coefficient
|
||||
attenuationCoefficient *= offAxisCoefficient;
|
||||
// multiply the current attenuation coefficient by the calculated off axis coefficient
|
||||
attenuationCoefficient *= offAxisCoefficient;
|
||||
}
|
||||
|
||||
glm::vec3 rotatedSourcePosition = inverseOrientation * relativePosition;
|
||||
|
||||
const float DISTANCE_SCALE = 2.5f;
|
||||
const float GEOMETRIC_AMPLITUDE_SCALAR = 0.3f;
|
||||
const float DISTANCE_LOG_BASE = 2.5f;
|
||||
const float DISTANCE_SCALE_LOG = logf(DISTANCE_SCALE) / logf(DISTANCE_LOG_BASE);
|
||||
|
||||
// calculate the distance coefficient using the distance to this node
|
||||
float distanceCoefficient = powf(GEOMETRIC_AMPLITUDE_SCALAR,
|
||||
DISTANCE_SCALE_LOG +
|
||||
(0.5f * logf(distanceSquareToSource) / logf(DISTANCE_LOG_BASE)) - 1);
|
||||
distanceCoefficient = std::min(1.0f, distanceCoefficient);
|
||||
|
||||
// multiply the current attenuation coefficient by the distance coefficient
|
||||
attenuationCoefficient *= distanceCoefficient;
|
||||
|
||||
// project the rotated source position vector onto the XZ plane
|
||||
rotatedSourcePosition.y = 0.0f;
|
||||
|
||||
// produce an oriented angle about the y-axis
|
||||
bearingRelativeAngleToSource = glm::orientedAngle(glm::vec3(0.0f, 0.0f, -1.0f),
|
||||
glm::normalize(rotatedSourcePosition),
|
||||
glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
const float PHASE_AMPLITUDE_RATIO_AT_90 = 0.5;
|
||||
|
||||
// figure out the number of samples of delay and the ratio of the amplitude
|
||||
// in the weak channel for audio spatialization
|
||||
float sinRatio = fabsf(sinf(glm::radians(bearingRelativeAngleToSource)));
|
||||
numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
||||
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||
|
||||
// grab the TwoPole object for this source, add it if it doesn't exist
|
||||
TwoPoleNodeMap& nodeTwoPoles = nodeRingBuffer->getTwoPoles();
|
||||
TwoPoleNodeMap::iterator twoPoleIterator = nodeTwoPoles.find(otherNode->getNodeID());
|
||||
|
||||
if (twoPoleIterator == nodeTwoPoles.end()) {
|
||||
// setup the freeVerb effect for this source for this client
|
||||
otherNodeTwoPole = nodeTwoPoles[otherNode->getNodeID()] = new stk::TwoPole;
|
||||
} else {
|
||||
otherNodeTwoPole = twoPoleIterator->second;
|
||||
}
|
||||
|
||||
// calculate the reasonance for this TwoPole based on angle to source
|
||||
float TWO_POLE_CUT_OFF_FREQUENCY = 800.0f;
|
||||
float TWO_POLE_MAX_FILTER_STRENGTH = 0.4f;
|
||||
|
||||
otherNodeTwoPole->setResonance(TWO_POLE_CUT_OFF_FREQUENCY,
|
||||
TWO_POLE_MAX_FILTER_STRENGTH
|
||||
* fabsf(bearingRelativeAngleToSource) / 180.0f,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
int16_t* sourceBuffer = otherNodeBuffer->getNextOutput();
|
||||
|
||||
int16_t* goodChannel = (bearingRelativeAngleToSource > 0.0f)
|
||||
? clientSamples
|
||||
: clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||
int16_t* delayedChannel = (bearingRelativeAngleToSource > 0.0f)
|
||||
? clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
|
||||
: clientSamples;
|
||||
|
||||
int16_t* delaySamplePointer = otherNodeBuffer->getNextOutput() == otherNodeBuffer->getBuffer()
|
||||
? otherNodeBuffer->getBuffer() + RING_BUFFER_LENGTH_SAMPLES - numSamplesDelay
|
||||
: otherNodeBuffer->getNextOutput() - numSamplesDelay;
|
||||
|
||||
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||
// load up the stkFrameBuffer with this source's samples
|
||||
stkFrameBuffer[s] = (stk::StkFloat) sourceBuffer[s];
|
||||
}
|
||||
|
||||
// perform the TwoPole effect on the stkFrameBuffer
|
||||
if (otherNodeTwoPole) {
|
||||
otherNodeTwoPole->tick(stkFrameBuffer);
|
||||
}
|
||||
|
||||
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||
if (s < numSamplesDelay) {
|
||||
// pull the earlier sample for the delayed channel
|
||||
int earlierSample = delaySamplePointer[s] * attenuationCoefficient * weakChannelAmplitudeRatio;
|
||||
|
||||
glm::vec3 rotatedSourcePosition = inverseOrientation * relativePosition;
|
||||
|
||||
const float DISTANCE_SCALE = 2.5f;
|
||||
const float GEOMETRIC_AMPLITUDE_SCALAR = 0.3f;
|
||||
const float DISTANCE_LOG_BASE = 2.5f;
|
||||
const float DISTANCE_SCALE_LOG = logf(DISTANCE_SCALE) / logf(DISTANCE_LOG_BASE);
|
||||
|
||||
// calculate the distance coefficient using the distance to this node
|
||||
float distanceCoefficient = powf(GEOMETRIC_AMPLITUDE_SCALAR,
|
||||
DISTANCE_SCALE_LOG +
|
||||
(0.5f * logf(distanceSquareToSource) / logf(DISTANCE_LOG_BASE)) - 1);
|
||||
distanceCoefficient = std::min(1.0f, distanceCoefficient);
|
||||
|
||||
// multiply the current attenuation coefficient by the distance coefficient
|
||||
attenuationCoefficient *= distanceCoefficient;
|
||||
|
||||
// project the rotated source position vector onto the XZ plane
|
||||
rotatedSourcePosition.y = 0.0f;
|
||||
|
||||
// produce an oriented angle about the y-axis
|
||||
bearingRelativeAngleToSource = glm::orientedAngle(glm::vec3(0.0f, 0.0f, -1.0f),
|
||||
glm::normalize(rotatedSourcePosition),
|
||||
glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
const float PHASE_AMPLITUDE_RATIO_AT_90 = 0.5;
|
||||
|
||||
// figure out the number of samples of delay and the ratio of the amplitude
|
||||
// in the weak channel for audio spatialization
|
||||
float sinRatio = fabsf(sinf(glm::radians(bearingRelativeAngleToSource)));
|
||||
numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
|
||||
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||
|
||||
// grab the TwoPole object for this source, add it if it doesn't exist
|
||||
TwoPoleNodeMap& nodeTwoPoles = nodeRingBuffer->getTwoPoles();
|
||||
TwoPoleNodeMap::iterator twoPoleIterator = nodeTwoPoles.find(otherNode->getNodeID());
|
||||
|
||||
if (twoPoleIterator == nodeTwoPoles.end()) {
|
||||
// setup the freeVerb effect for this source for this client
|
||||
otherNodeTwoPole = nodeTwoPoles[otherNode->getNodeID()] = new stk::TwoPole;
|
||||
} else {
|
||||
otherNodeTwoPole = twoPoleIterator->second;
|
||||
delayedChannel[s] = glm::clamp(delayedChannel[s] + earlierSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
}
|
||||
|
||||
// calculate the reasonance for this TwoPole based on angle to source
|
||||
float TWO_POLE_CUT_OFF_FREQUENCY = 800.0f;
|
||||
float TWO_POLE_MAX_FILTER_STRENGTH = 0.4f;
|
||||
|
||||
otherNodeTwoPole->setResonance(TWO_POLE_CUT_OFF_FREQUENCY,
|
||||
TWO_POLE_MAX_FILTER_STRENGTH
|
||||
* fabsf(bearingRelativeAngleToSource) / 180.0f,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
int16_t* sourceBuffer = otherNodeBuffer->getNextOutput();
|
||||
|
||||
int16_t* goodChannel = (bearingRelativeAngleToSource > 0.0f)
|
||||
? clientSamples
|
||||
: clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||
int16_t* delayedChannel = (bearingRelativeAngleToSource > 0.0f)
|
||||
? clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
|
||||
: clientSamples;
|
||||
|
||||
int16_t* delaySamplePointer = otherNodeBuffer->getNextOutput() == otherNodeBuffer->getBuffer()
|
||||
? otherNodeBuffer->getBuffer() + RING_BUFFER_LENGTH_SAMPLES - numSamplesDelay
|
||||
: otherNodeBuffer->getNextOutput() - numSamplesDelay;
|
||||
|
||||
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||
// load up the stkFrameBuffer with this source's samples
|
||||
stkFrameBuffer[s] = (stk::StkFloat) sourceBuffer[s];
|
||||
}
|
||||
|
||||
// perform the TwoPole effect on the stkFrameBuffer
|
||||
if (otherNodeTwoPole) {
|
||||
otherNodeTwoPole->tick(stkFrameBuffer);
|
||||
}
|
||||
|
||||
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||
if (s < numSamplesDelay) {
|
||||
// pull the earlier sample for the delayed channel
|
||||
int earlierSample = delaySamplePointer[s] * attenuationCoefficient * weakChannelAmplitudeRatio;
|
||||
|
||||
delayedChannel[s] = glm::clamp(delayedChannel[s] + earlierSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
}
|
||||
|
||||
int16_t currentSample = stkFrameBuffer[s] * attenuationCoefficient;
|
||||
int16_t currentSample = stkFrameBuffer[s] * attenuationCoefficient;
|
||||
|
||||
goodChannel[s] = glm::clamp(goodChannel[s] + currentSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
goodChannel[s] = glm::clamp(goodChannel[s] + currentSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
|
||||
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
|
||||
int sumSample = delayedChannel[s + numSamplesDelay]
|
||||
+ (currentSample * weakChannelAmplitudeRatio);
|
||||
delayedChannel[s + numSamplesDelay] = glm::clamp(sumSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
}
|
||||
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
|
||||
int sumSample = delayedChannel[s + numSamplesDelay]
|
||||
+ (currentSample * weakChannelAmplitudeRatio);
|
||||
delayedChannel[s + numSamplesDelay] = glm::clamp(sumSample,
|
||||
MIN_SAMPLE_VALUE,
|
||||
MAX_SAMPLE_VALUE);
|
||||
}
|
||||
|
||||
if (s >= BUFFER_LENGTH_SAMPLES_PER_CHANNEL - PHASE_DELAY_AT_90) {
|
||||
// this could be a delayed sample on the next pass
|
||||
// so store the affected back in the ARB
|
||||
otherNodeBuffer->getNextOutput()[s] = (int16_t) stkFrameBuffer[s];
|
||||
if (s >= BUFFER_LENGTH_SAMPLES_PER_CHANNEL - PHASE_DELAY_AT_90) {
|
||||
// this could be a delayed sample on the next pass
|
||||
// so store the affected back in the ARB
|
||||
otherNodeBuffer->getNextOutput()[s] = (int16_t) stkFrameBuffer[s];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +342,6 @@ int main(int argc, const char* argv[]) {
|
|||
if (nodeBuffer->getNextOutput() >= nodeBuffer->getBuffer() + RING_BUFFER_LENGTH_SAMPLES) {
|
||||
nodeBuffer->setNextOutput(nodeBuffer->getBuffer());
|
||||
}
|
||||
|
||||
nodeBuffer->setWillBeAddedToMix(false);
|
||||
}
|
||||
}
|
||||
|
@ -350,14 +351,15 @@ int main(int argc, const char* argv[]) {
|
|||
packetVersionMatch(packetData)) {
|
||||
if (packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO ||
|
||||
packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO) {
|
||||
|
||||
unsigned char* currentBuffer = packetData + numBytesForPacketHeader(packetData);
|
||||
uint16_t sourceID;
|
||||
memcpy(&sourceID, currentBuffer, sizeof(sourceID));
|
||||
|
||||
Node* avatarNode = nodeList->addOrUpdateNode(nodeAddress,
|
||||
nodeAddress,
|
||||
NODE_TYPE_AGENT,
|
||||
nodeList->getLastNodeID());
|
||||
|
||||
if (avatarNode->getNodeID() == nodeList->getLastNodeID()) {
|
||||
nodeList->increaseNodeID();
|
||||
}
|
||||
sourceID);
|
||||
|
||||
nodeList->updateNodeWithData(nodeAddress, packetData, receivedBytes);
|
||||
|
||||
|
|
|
@ -40,11 +40,13 @@ bool hasInjectedAudioOnce = false;
|
|||
float sleepIntervalMin = 1.00;
|
||||
float sleepIntervalMax = 2.00;
|
||||
char *sourceAudioFile = NULL;
|
||||
const char *allowedParameters = ":sc::a::f::t::r:";
|
||||
const char *allowedParameters = ":sc::a::f::t::r:l";
|
||||
float floatArguments[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
unsigned char volume = DEFAULT_INJECTOR_VOLUME;
|
||||
float triggerDistance = 0.0f;
|
||||
float radius = 0.0f;
|
||||
bool wantsLocalDomain = false;
|
||||
|
||||
|
||||
void usage(void) {
|
||||
std::cout << "High Fidelity - Interface audio injector" << std::endl;
|
||||
|
@ -54,6 +56,7 @@ void usage(void) {
|
|||
std::cout << " -f FILENAME Name of audio source file. Required - RAW format, 22050hz 16bit signed mono" << std::endl;
|
||||
std::cout << " -t FLOAT Trigger distance for injection. If not specified will loop constantly" << std::endl;
|
||||
std::cout << " -r FLOAT Radius for spherical source. If not specified injected audio is point source" << std::endl;
|
||||
std::cout << " -l Local domain mode." << std::endl;
|
||||
}
|
||||
|
||||
bool processParameters(int parameterCount, char* parameterData[]) {
|
||||
|
@ -96,6 +99,9 @@ bool processParameters(int parameterCount, char* parameterData[]) {
|
|||
::radius = atof(optarg);
|
||||
std::cout << "[DEBUG] Injector radius: " << optarg << std::endl;
|
||||
break;
|
||||
case 'l':
|
||||
::wantsLocalDomain = true;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
return false;
|
||||
|
@ -111,6 +117,7 @@ void createAvatarDataForNode(Node* node) {
|
|||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
// new seed for random audio sleep times
|
||||
srand(time(0));
|
||||
|
||||
|
@ -126,6 +133,11 @@ int main(int argc, char* argv[]) {
|
|||
// create an NodeList instance to handle communication with other nodes
|
||||
NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AUDIO_INJECTOR, AUDIO_UDP_SEND_PORT);
|
||||
|
||||
if (::wantsLocalDomain) {
|
||||
printf("Local Domain MODE!\n");
|
||||
nodeList->setDomainIPToLocalhost();
|
||||
}
|
||||
|
||||
// start the node list thread that will kill off nodes when they stop talking
|
||||
nodeList->startSilentNodeRemovalThread();
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_mouseVoxelScale(1.0f / 1024.0f),
|
||||
_justEditedVoxel(false),
|
||||
_isLookingAtOtherAvatar(false),
|
||||
_lookatIndicatorScale(1.0f),
|
||||
_paintOn(false),
|
||||
_dominantColor(0),
|
||||
_perfStatsOn(false),
|
||||
|
@ -1854,6 +1855,11 @@ void Application::initMenu() {
|
|||
(_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true);
|
||||
(_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true);
|
||||
|
||||
QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools");
|
||||
audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1);
|
||||
audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2);
|
||||
audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3);
|
||||
|
||||
QMenu* settingsMenu = menuBar->addMenu("Settings");
|
||||
(_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true);
|
||||
_settingsAutosave->setChecked(true);
|
||||
|
@ -1865,6 +1871,30 @@ void Application::initMenu() {
|
|||
_networkAccessManager = new QNetworkAccessManager(this);
|
||||
}
|
||||
|
||||
void Application::setListenModeNormal() {
|
||||
_audio.setListenMode(AudioRingBuffer::NORMAL);
|
||||
}
|
||||
|
||||
void Application::setListenModePoint() {
|
||||
_audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT);
|
||||
_audio.setListenRadius(1.0);
|
||||
}
|
||||
|
||||
void Application::setListenModeSingleSource() {
|
||||
_audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES);
|
||||
_audio.clearListenSources();
|
||||
|
||||
glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin();
|
||||
glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection();
|
||||
glm::vec3 eyePositionIgnored;
|
||||
uint16_t nodeID;
|
||||
|
||||
if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
|
||||
_audio.addListenSource(nodeID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Application::updateFrustumRenderModeAction() {
|
||||
switch (_frustumDrawingMode) {
|
||||
default:
|
||||
|
@ -1953,7 +1983,13 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
|||
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
||||
const float HEAD_SPHERE_RADIUS = 0.07;
|
||||
|
||||
bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) {
|
||||
|
||||
static uint16_t DEFAULT_NODE_ID_REF = 1;
|
||||
|
||||
|
||||
bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||
|
@ -1961,7 +1997,9 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m
|
|||
glm::vec3 headPosition = avatar->getHead().getPosition();
|
||||
if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {
|
||||
eyePosition = avatar->getHead().getEyeLevelPosition();
|
||||
_lookatIndicatorScale = avatar->getScale();
|
||||
_lookatOtherPosition = headPosition;
|
||||
nodeID = avatar->getOwningNode()->getNodeID();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1971,11 +2009,13 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m
|
|||
|
||||
void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {
|
||||
|
||||
const float DISTANCE_FROM_HEAD_SPHERE = 0.1f;
|
||||
const float DISTANCE_FROM_HEAD_SPHERE = 0.1f * _lookatIndicatorScale;
|
||||
const float INDICATOR_RADIUS = 0.1f * _lookatIndicatorScale;
|
||||
const float YELLOW[] = { 1.0f, 1.0f, 0.0f };
|
||||
const int NUM_SEGMENTS = 30;
|
||||
glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z);
|
||||
glColor3f(YELLOW[0], YELLOW[1], YELLOW[2]);
|
||||
renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30);
|
||||
renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
|
||||
}
|
||||
|
||||
void Application::update(float deltaTime) {
|
||||
|
@ -2005,7 +2045,9 @@ void Application::update(float deltaTime) {
|
|||
|
||||
// Set where I am looking based on my mouse ray (so that other people can see)
|
||||
glm::vec3 eyePosition;
|
||||
if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition))) {
|
||||
|
||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition);
|
||||
if (_isLookingAtOtherAvatar) {
|
||||
// If the mouse is over another avatar's head...
|
||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||
|
@ -2022,7 +2064,7 @@ void Application::update(float deltaTime) {
|
|||
glm::vec3 front = orientation * IDENTITY_FRONT;
|
||||
glm::vec3 up = orientation * IDENTITY_UP;
|
||||
glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging)
|
||||
- _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne
|
||||
- _myAvatar.getCameraPosition();
|
||||
towardVoxel = front * glm::length(towardVoxel);
|
||||
glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel);
|
||||
_voxelThrust = glm::vec3(0, 0, 0);
|
||||
|
@ -2270,7 +2312,9 @@ void Application::updateAvatar(float deltaTime) {
|
|||
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
|
||||
|
||||
glm::vec3 eyePosition;
|
||||
if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition))) {
|
||||
|
||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||
if (_isLookingAtOtherAvatar) {
|
||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||
}
|
||||
|
@ -2298,7 +2342,7 @@ void Application::updateAvatar(float deltaTime) {
|
|||
// actually need to calculate the view frustum planes to send these details
|
||||
// to the server.
|
||||
loadViewFrustum(_myCamera, _viewFrustum);
|
||||
_myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne
|
||||
_myAvatar.setCameraPosition(_viewFrustum.getPosition());
|
||||
_myAvatar.setCameraOrientation(_viewFrustum.getOrientation());
|
||||
_myAvatar.setCameraFov(_viewFrustum.getFieldOfView());
|
||||
_myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio());
|
||||
|
|
|
@ -174,6 +174,10 @@ private slots:
|
|||
void copyVoxels();
|
||||
void pasteVoxels();
|
||||
void runTests();
|
||||
void setListenModeNormal();
|
||||
void setListenModePoint();
|
||||
void setListenModeSingleSource();
|
||||
|
||||
|
||||
void renderCoverageMap();
|
||||
void renderCoverageMapsRecursively(CoverageMap* map);
|
||||
|
@ -203,7 +207,9 @@ private:
|
|||
void init();
|
||||
|
||||
void update(float deltaTime);
|
||||
bool isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition);
|
||||
bool isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID);
|
||||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera);
|
||||
void updateAvatar(float deltaTime);
|
||||
void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
|
||||
|
@ -378,6 +384,7 @@ private:
|
|||
|
||||
bool _isLookingAtOtherAvatar;
|
||||
glm::vec3 _lookatOtherPosition;
|
||||
float _lookatIndicatorScale;
|
||||
|
||||
bool _paintOn; // Whether to paint voxels as you fly around
|
||||
unsigned char _dominantColor; // The dominant color of the voxel we're painting
|
||||
|
|
|
@ -112,7 +112,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
|
|||
|
||||
// we need the amount of bytes in the buffer + 1 for type
|
||||
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
||||
unsigned char dataPacket[BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes];
|
||||
unsigned char dataPacket[MAX_PACKET_SIZE];
|
||||
|
||||
PACKET_TYPE packetType = (Application::getInstance()->shouldEchoAudio())
|
||||
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO
|
||||
|
@ -120,6 +120,33 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
|
|||
|
||||
unsigned char* currentPacketPtr = dataPacket + populateTypeAndVersion(dataPacket, packetType);
|
||||
|
||||
// pack Source Data
|
||||
uint16_t ownerID = NodeList::getInstance()->getOwnerID();
|
||||
memcpy(currentPacketPtr, &ownerID, sizeof(ownerID));
|
||||
currentPacketPtr += (sizeof(ownerID));
|
||||
leadingBytes += (sizeof(ownerID));
|
||||
|
||||
// pack Listen Mode Data
|
||||
memcpy(currentPacketPtr, &_listenMode, sizeof(_listenMode));
|
||||
currentPacketPtr += (sizeof(_listenMode));
|
||||
leadingBytes += (sizeof(_listenMode));
|
||||
|
||||
if (_listenMode == AudioRingBuffer::OMNI_DIRECTIONAL_POINT) {
|
||||
memcpy(currentPacketPtr, &_listenRadius, sizeof(_listenRadius));
|
||||
currentPacketPtr += (sizeof(_listenRadius));
|
||||
leadingBytes += (sizeof(_listenRadius));
|
||||
} else if (_listenMode == AudioRingBuffer::SELECTED_SOURCES) {
|
||||
int listenSourceCount = _listenSources.size();
|
||||
memcpy(currentPacketPtr, &listenSourceCount, sizeof(listenSourceCount));
|
||||
currentPacketPtr += (sizeof(listenSourceCount));
|
||||
leadingBytes += (sizeof(listenSourceCount));
|
||||
for (int i = 0; i < listenSourceCount; i++) {
|
||||
memcpy(currentPacketPtr, &_listenSources[i], sizeof(_listenSources[i]));
|
||||
currentPacketPtr += sizeof(_listenSources[i]);
|
||||
leadingBytes += sizeof(_listenSources[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// memcpy the three float positions
|
||||
memcpy(currentPacketPtr, &headPosition, sizeof(headPosition));
|
||||
currentPacketPtr += (sizeof(headPosition));
|
||||
|
@ -309,6 +336,24 @@ void Audio::reset() {
|
|||
_ringBuffer.reset();
|
||||
}
|
||||
|
||||
void Audio::addListenSource(int sourceID) {
|
||||
_listenSources.push_back(sourceID);
|
||||
}
|
||||
|
||||
void Audio::clearListenSources() {
|
||||
_listenSources.clear();
|
||||
}
|
||||
|
||||
void Audio::removeListenSource(int sourceID) {
|
||||
for (int i = 0; i < _listenSources.size(); i++) {
|
||||
if (_listenSources[i] == sourceID) {
|
||||
_listenSources.erase(_listenSources.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
|
||||
_stream(NULL),
|
||||
_ringBuffer(true),
|
||||
|
@ -338,7 +383,9 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
|
|||
_collisionSoundNoise(0.0f),
|
||||
_collisionSoundDuration(0.0f),
|
||||
_proceduralEffectSample(0),
|
||||
_heartbeatMagnitude(0.0f)
|
||||
_heartbeatMagnitude(0.0f),
|
||||
_listenMode(AudioRingBuffer::NORMAL),
|
||||
_listenRadius(0.0f)
|
||||
{
|
||||
outputPortAudioError(Pa_Initialize());
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef __interface__Audio__
|
||||
#define __interface__Audio__
|
||||
|
||||
#include <vector>
|
||||
#include <portaudio.h>
|
||||
#include <AudioRingBuffer.h>
|
||||
#include <StdDev.h>
|
||||
|
@ -54,6 +55,11 @@ public:
|
|||
// The results of the analysis are written to the log.
|
||||
bool eventuallyAnalyzePing();
|
||||
|
||||
void setListenMode(AudioRingBuffer::ListenMode mode) { _listenMode = mode; };
|
||||
void setListenRadius(float radius) { _listenRadius = radius; };
|
||||
void addListenSource(int sourceID);
|
||||
void removeListenSource(int sourceID);
|
||||
void clearListenSources();
|
||||
|
||||
private:
|
||||
PaStream* _stream;
|
||||
|
@ -90,6 +96,10 @@ private:
|
|||
float _collisionSoundDuration;
|
||||
int _proceduralEffectSample;
|
||||
float _heartbeatMagnitude;
|
||||
|
||||
AudioRingBuffer::ListenMode _listenMode;
|
||||
float _listenRadius;
|
||||
std::vector<int> _listenSources;
|
||||
|
||||
// Audio callback in class context.
|
||||
inline void performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* outputRight);
|
||||
|
|
|
@ -164,6 +164,10 @@ public:
|
|||
glm::quat getOrientation () const;
|
||||
glm::quat getWorldAlignedOrientation() const;
|
||||
|
||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||
|
||||
|
||||
glm::vec3 getGravity () const { return _gravity; }
|
||||
|
||||
glm::vec3 getUprightHeadPosition() const;
|
||||
|
|
|
@ -272,7 +272,7 @@ void Head::calculateGeometry() {
|
|||
+ up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET
|
||||
+ front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET;
|
||||
|
||||
_eyeLevelPosition = _position + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET;
|
||||
_eyeLevelPosition = _rightEyePosition - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET;
|
||||
|
||||
//calculate the eyebrow positions
|
||||
_leftEyeBrowPosition = _leftEyePosition;
|
||||
|
|
|
@ -27,6 +27,14 @@ const short RING_BUFFER_LENGTH_SAMPLES = RING_BUFFER_LENGTH_FRAMES * BUFFER_LENG
|
|||
|
||||
class AudioRingBuffer : public NodeData {
|
||||
public:
|
||||
|
||||
static int const DEFAULT_LISTEN_LIST_SIZE = 100;
|
||||
typedef enum {
|
||||
NORMAL,
|
||||
OMNI_DIRECTIONAL_POINT,
|
||||
SELECTED_SOURCES
|
||||
} ListenMode;
|
||||
|
||||
AudioRingBuffer(bool isStereo);
|
||||
~AudioRingBuffer();
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
|
||||
PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
|
||||
switch (type) {
|
||||
|
||||
case PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO:
|
||||
case PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case PACKET_TYPE_HEAD_DATA:
|
||||
return 2;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue