mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +02:00
latest pass, improved distance calulations, added menu item to remove original source
This commit is contained in:
parent
23e5452a89
commit
98f0fe8619
6 changed files with 243 additions and 178 deletions
|
@ -611,7 +611,7 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
||||||
if (_audioOutput) {
|
if (_audioOutput) {
|
||||||
// Audio output must exist and be correctly set up if we're going to process received audio
|
// Audio output must exist and be correctly set up if we're going to process received audio
|
||||||
_ringBuffer.parseData(audioByteArray);
|
_ringBuffer.parseData(audioByteArray);
|
||||||
processReceivedAudio(_spatialAudioStart, _ringBuffer);
|
processReceivedAudio(_ringBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO).updateValue(audioByteArray.size());
|
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO).updateValue(audioByteArray.size());
|
||||||
|
@ -711,7 +711,7 @@ void Audio::toggleAudioNoiseReduction() {
|
||||||
_noiseGateEnabled = !_noiseGateEnabled;
|
_noiseGateEnabled = !_noiseGateEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::processReceivedAudio(unsigned int sampleTime, AudioRingBuffer& ringBuffer) {
|
void Audio::processReceivedAudio(AudioRingBuffer& ringBuffer) {
|
||||||
|
|
||||||
float networkOutputToOutputRatio = (_desiredOutputFormat.sampleRate() / (float) _outputFormat.sampleRate())
|
float networkOutputToOutputRatio = (_desiredOutputFormat.sampleRate() / (float) _outputFormat.sampleRate())
|
||||||
* (_desiredOutputFormat.channelCount() / (float) _outputFormat.channelCount());
|
* (_desiredOutputFormat.channelCount() / (float) _outputFormat.channelCount());
|
||||||
|
@ -751,8 +751,9 @@ void Audio::processReceivedAudio(unsigned int sampleTime, AudioRingBuffer& ringB
|
||||||
|
|
||||||
ringBuffer.readSamples((int16_t*)buffer.data(), numNetworkOutputSamples);
|
ringBuffer.readSamples((int16_t*)buffer.data(), numNetworkOutputSamples);
|
||||||
// Accumulate direct transmission of audio from sender to receiver
|
// Accumulate direct transmission of audio from sender to receiver
|
||||||
addSpatialAudioToBuffer(sampleTime, buffer, numNetworkOutputSamples);
|
if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncudeOriginal)) {
|
||||||
//addSpatialAudioToBuffer(sampleTime + 48000, buffer, numNetworkOutputSamples);
|
addSpatialAudioToBuffer(sampleTime, buffer, numNetworkOutputSamples);
|
||||||
|
}
|
||||||
|
|
||||||
// Send audio off for spatial processing
|
// Send audio off for spatial processing
|
||||||
emit processSpatialAudio(sampleTime, buffer, _desiredOutputFormat);
|
emit processSpatialAudio(sampleTime, buffer, _desiredOutputFormat);
|
||||||
|
|
|
@ -74,6 +74,8 @@ public:
|
||||||
int getNetworkSampleRate() { return SAMPLE_RATE; }
|
int getNetworkSampleRate() { return SAMPLE_RATE; }
|
||||||
int getNetworkBufferLengthSamplesPerChannel() { return NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; }
|
int getNetworkBufferLengthSamplesPerChannel() { return NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; }
|
||||||
|
|
||||||
|
bool getProcessSpatialAudio() const { return _processSpatialAudio; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
@ -186,7 +188,7 @@ private:
|
||||||
void addProceduralSounds(int16_t* monoInput, int numSamples);
|
void addProceduralSounds(int16_t* monoInput, int numSamples);
|
||||||
|
|
||||||
// Process received audio
|
// Process received audio
|
||||||
void processReceivedAudio(unsigned int sampleTime, AudioRingBuffer& ringBuffer);
|
void processReceivedAudio(AudioRingBuffer& ringBuffer);
|
||||||
|
|
||||||
bool switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo);
|
bool switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo);
|
||||||
bool switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo);
|
bool switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo);
|
||||||
|
|
|
@ -13,17 +13,9 @@ void AudioReflector::render() {
|
||||||
return; // exit early if not set up correctly
|
return; // exit early if not set up correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_audio->getProcessSpatialAudio()) {
|
||||||
/*
|
drawRays();
|
||||||
glm::vec3 position = _myAvatar->getHead()->getPosition();
|
}
|
||||||
const float radius = 0.25f;
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(position.x, position.y, position.z);
|
|
||||||
glutWireSphere(radius, 15, 15);
|
|
||||||
glPopMatrix();
|
|
||||||
*/
|
|
||||||
|
|
||||||
drawRays();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +31,13 @@ int getDelayFromDistance(float distance) {
|
||||||
|
|
||||||
const float BOUNCE_ATTENUATION_FACTOR = 0.125f;
|
const float BOUNCE_ATTENUATION_FACTOR = 0.125f;
|
||||||
|
|
||||||
|
// each bounce we adjust our attenuation by this factor, the result is an asymptotically decreasing attenuation...
|
||||||
|
// 0.125, 0.25, 0.5, ...
|
||||||
|
const float PER_BOUNCE_ATTENUATION_ADJUSTMENT = 2.0f;
|
||||||
|
|
||||||
|
// we don't grow larger than this, which means by the 4th bounce we don't get that much less quiet
|
||||||
|
const float MAX_BOUNCE_ATTENUATION = 0.9f;
|
||||||
|
|
||||||
float getDistanceAttenuationCoefficient(float distance) {
|
float getDistanceAttenuationCoefficient(float distance) {
|
||||||
const float DISTANCE_SCALE = 2.5f;
|
const float DISTANCE_SCALE = 2.5f;
|
||||||
const float GEOMETRIC_AMPLITUDE_SCALAR = 0.3f;
|
const float GEOMETRIC_AMPLITUDE_SCALAR = 0.3f;
|
||||||
|
@ -97,7 +96,7 @@ QVector<glm::vec3> AudioReflector::calculateReflections(const glm::vec3& origin,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AudioReflector::newDrawReflections(const glm::vec3& origin, const glm::vec3& originalColor, const QVector<glm::vec3>& reflections) {
|
void AudioReflector::drawReflections(const glm::vec3& origin, const glm::vec3& originalColor, const QVector<glm::vec3>& reflections) {
|
||||||
|
|
||||||
glm::vec3 start = origin;
|
glm::vec3 start = origin;
|
||||||
glm::vec3 color = originalColor;
|
glm::vec3 color = originalColor;
|
||||||
|
@ -110,33 +109,94 @@ void AudioReflector::newDrawReflections(const glm::vec3& origin, const glm::vec3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioReflector::drawReflections(const glm::vec3& origin, const glm::vec3& originalDirection,
|
|
||||||
int bounces, const glm::vec3& originalColor) {
|
|
||||||
|
|
||||||
glm::vec3 start = origin;
|
|
||||||
glm::vec3 direction = originalDirection;
|
|
||||||
glm::vec3 color = originalColor;
|
|
||||||
OctreeElement* elementHit;
|
|
||||||
float distance;
|
|
||||||
BoxFace face;
|
|
||||||
const float SLIGHTLY_SHORT = 0.999f; // slightly inside the distance so we're on the inside of the reflection point
|
|
||||||
const float COLOR_ADJUST_PER_BOUNCE = 0.75f;
|
|
||||||
|
|
||||||
for (int i = 0; i < bounces; i++) {
|
|
||||||
if (_voxels->findRayIntersection(start, direction, elementHit, distance, face)) {
|
|
||||||
glm::vec3 end = start + (direction * (distance * SLIGHTLY_SHORT));
|
|
||||||
drawVector(start, end, color);
|
|
||||||
|
|
||||||
glm::vec3 faceNormal = getFaceNormal(face);
|
|
||||||
direction = glm::normalize(glm::reflect(direction,faceNormal));
|
|
||||||
start = end;
|
|
||||||
color = color * COLOR_ADJUST_PER_BOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// set up our buffers for our attenuated and delayed samples
|
// set up our buffers for our attenuated and delayed samples
|
||||||
const int NUMBER_OF_CHANNELS = 2;
|
const int NUMBER_OF_CHANNELS = 2;
|
||||||
void AudioReflector::echoReflections(const glm::vec3& origin, const glm::vec3& originalDirection,
|
|
||||||
|
|
||||||
|
void AudioReflector::echoReflections(const glm::vec3& origin, const QVector<glm::vec3>& reflections, const QByteArray& samples,
|
||||||
|
unsigned int sampleTime, int sampleRate) {
|
||||||
|
|
||||||
|
glm::vec3 rightEarPosition = _myAvatar->getHead()->getRightEarPosition();
|
||||||
|
glm::vec3 leftEarPosition = _myAvatar->getHead()->getLeftEarPosition();
|
||||||
|
glm::vec3 start = origin;
|
||||||
|
|
||||||
|
int totalNumberOfSamples = samples.size() / sizeof(int16_t);
|
||||||
|
int totalNumberOfStereoSamples = samples.size() / (sizeof(int16_t) * NUMBER_OF_CHANNELS);
|
||||||
|
|
||||||
|
const int16_t* originalSamplesData = (const int16_t*)samples.constData();
|
||||||
|
QByteArray attenuatedLeftSamples;
|
||||||
|
QByteArray attenuatedRightSamples;
|
||||||
|
attenuatedLeftSamples.resize(samples.size());
|
||||||
|
attenuatedRightSamples.resize(samples.size());
|
||||||
|
|
||||||
|
int16_t* attenuatedLeftSamplesData = (int16_t*)attenuatedLeftSamples.data();
|
||||||
|
int16_t* attenuatedRightSamplesData = (int16_t*)attenuatedRightSamples.data();
|
||||||
|
|
||||||
|
float rightDistance = 0;
|
||||||
|
float leftDistance = 0;
|
||||||
|
float bounceAttenuation = BOUNCE_ATTENUATION_FACTOR;
|
||||||
|
|
||||||
|
foreach (glm::vec3 end, reflections) {
|
||||||
|
|
||||||
|
rightDistance += glm::distance(start, end);
|
||||||
|
leftDistance += glm::distance(start, end);
|
||||||
|
|
||||||
|
// calculate the distance to the ears
|
||||||
|
float rightEarDistance = glm::distance(end, rightEarPosition);
|
||||||
|
float leftEarDistance = glm::distance(end, leftEarPosition);
|
||||||
|
|
||||||
|
float rightTotalDistance = rightEarDistance + rightDistance;
|
||||||
|
float leftTotalDistance = leftEarDistance + leftDistance;
|
||||||
|
|
||||||
|
int rightEarDelayMsecs = getDelayFromDistance(rightTotalDistance);
|
||||||
|
int leftEarDelayMsecs = getDelayFromDistance(leftTotalDistance);
|
||||||
|
int rightEarDelay = rightEarDelayMsecs * sampleRate / MSECS_PER_SECOND;
|
||||||
|
int leftEarDelay = leftEarDelayMsecs * sampleRate / MSECS_PER_SECOND;
|
||||||
|
|
||||||
|
//qDebug() << "leftTotalDistance=" << leftTotalDistance << "rightTotalDistance=" << rightTotalDistance;
|
||||||
|
//qDebug() << "leftEarDelay=" << leftEarDelay << "rightEarDelay=" << rightEarDelay;
|
||||||
|
|
||||||
|
float rightEarAttenuation = getDistanceAttenuationCoefficient(rightTotalDistance) * bounceAttenuation;
|
||||||
|
float leftEarAttenuation = getDistanceAttenuationCoefficient(leftTotalDistance) * bounceAttenuation;
|
||||||
|
|
||||||
|
//qDebug() << "leftEarAttenuation=" << leftEarAttenuation << "rightEarAttenuation=" << rightEarAttenuation;
|
||||||
|
|
||||||
|
|
||||||
|
bounceAttenuation = std::min(MAX_BOUNCE_ATTENUATION, bounceAttenuation * PER_BOUNCE_ATTENUATION_ADJUSTMENT);
|
||||||
|
|
||||||
|
// run through the samples, and attenuate them
|
||||||
|
for (int sample = 0; sample < totalNumberOfStereoSamples; sample++) {
|
||||||
|
int16_t leftSample = originalSamplesData[sample * NUMBER_OF_CHANNELS];
|
||||||
|
int16_t rightSample = originalSamplesData[(sample * NUMBER_OF_CHANNELS) + 1];
|
||||||
|
|
||||||
|
//qDebug() << "leftSample=" << leftSample << "rightSample=" << rightSample;
|
||||||
|
|
||||||
|
attenuatedLeftSamplesData[sample * NUMBER_OF_CHANNELS] = leftSample * leftEarAttenuation;
|
||||||
|
attenuatedLeftSamplesData[sample * NUMBER_OF_CHANNELS + 1] = 0;
|
||||||
|
|
||||||
|
attenuatedRightSamplesData[sample * NUMBER_OF_CHANNELS] = 0;
|
||||||
|
attenuatedRightSamplesData[sample * NUMBER_OF_CHANNELS + 1] = rightSample * rightEarAttenuation;
|
||||||
|
|
||||||
|
//qDebug() << "attenuated... leftSample=" << (leftSample * leftEarAttenuation) << "rightSample=" << (rightSample * rightEarAttenuation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now inject the attenuated array with the appropriate delay
|
||||||
|
|
||||||
|
unsigned int sampleTimeLeft = sampleTime + leftEarDelay;
|
||||||
|
unsigned int sampleTimeRight = sampleTime + rightEarDelay;
|
||||||
|
|
||||||
|
//qDebug() << "sampleTimeLeft=" << sampleTimeLeft << "sampleTimeRight=" << sampleTimeRight;
|
||||||
|
|
||||||
|
_audio->addSpatialAudioToBuffer(sampleTimeLeft, attenuatedLeftSamples, totalNumberOfSamples);
|
||||||
|
_audio->addSpatialAudioToBuffer(sampleTimeRight, attenuatedRightSamples, totalNumberOfSamples);
|
||||||
|
|
||||||
|
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AudioReflector::oldEchoReflections(const glm::vec3& origin, const glm::vec3& originalDirection,
|
||||||
int bounces, const QByteArray& originalSamples,
|
int bounces, const QByteArray& originalSamples,
|
||||||
unsigned int sampleTime, int sampleRate) {
|
unsigned int sampleTime, int sampleRate) {
|
||||||
|
|
||||||
|
@ -225,7 +285,7 @@ void AudioReflector::processSpatialAudio(unsigned int sampleTime, const QByteArr
|
||||||
_audio->addSpatialAudioToBuffer(sampleTime + 12000, samples, totalNumberOfSamples);
|
_audio->addSpatialAudioToBuffer(sampleTime + 12000, samples, totalNumberOfSamples);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
quint64 start = usecTimestampNow();
|
//quint64 start = usecTimestampNow();
|
||||||
|
|
||||||
glm::vec3 origin = _myAvatar->getHead()->getPosition();
|
glm::vec3 origin = _myAvatar->getHead()->getPosition();
|
||||||
|
|
||||||
|
@ -247,22 +307,37 @@ void AudioReflector::processSpatialAudio(unsigned int sampleTime, const QByteArr
|
||||||
|
|
||||||
const int BOUNCE_COUNT = 5;
|
const int BOUNCE_COUNT = 5;
|
||||||
|
|
||||||
echoReflections(origin, frontRightUp, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> frontRightUpReflections = calculateReflections(origin, frontRightUp, BOUNCE_COUNT);
|
||||||
echoReflections(origin, frontLeftUp, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> frontLeftUpReflections = calculateReflections(origin, frontLeftUp, BOUNCE_COUNT);
|
||||||
echoReflections(origin, backRightUp, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> backRightUpReflections = calculateReflections(origin, backRightUp, BOUNCE_COUNT);
|
||||||
echoReflections(origin, backLeftUp, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> backLeftUpReflections = calculateReflections(origin, backLeftUp, BOUNCE_COUNT);
|
||||||
echoReflections(origin, frontRightDown, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> frontRightDownReflections = calculateReflections(origin, frontRightDown, BOUNCE_COUNT);
|
||||||
echoReflections(origin, frontLeftDown, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> frontLeftDownReflections = calculateReflections(origin, frontLeftDown, BOUNCE_COUNT);
|
||||||
echoReflections(origin, backRightDown, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> backRightDownReflections = calculateReflections(origin, backRightDown, BOUNCE_COUNT);
|
||||||
echoReflections(origin, backLeftDown, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
QVector<glm::vec3> backLeftDownReflections = calculateReflections(origin, backLeftDown, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> frontReflections = calculateReflections(origin, front, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backReflections = calculateReflections(origin, back, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> leftReflections = calculateReflections(origin, left, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> rightReflections = calculateReflections(origin, right, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> upReflections = calculateReflections(origin, up, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> downReflections = calculateReflections(origin, down, BOUNCE_COUNT);
|
||||||
|
|
||||||
echoReflections(origin, front, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, frontRightUpReflections, samples, sampleTime, format.sampleRate());
|
||||||
echoReflections(origin, back, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, frontLeftUpReflections, samples, sampleTime, format.sampleRate());
|
||||||
echoReflections(origin, left, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, backRightUpReflections, samples, sampleTime, format.sampleRate());
|
||||||
echoReflections(origin, right, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, backLeftUpReflections, samples, sampleTime, format.sampleRate());
|
||||||
echoReflections(origin, up, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, frontRightDownReflections, samples, sampleTime, format.sampleRate());
|
||||||
echoReflections(origin, down, BOUNCE_COUNT, samples, sampleTime, format.sampleRate());
|
echoReflections(origin, frontLeftDownReflections, samples, sampleTime, format.sampleRate());
|
||||||
quint64 end = usecTimestampNow();
|
echoReflections(origin, backRightDownReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, backLeftDownReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
|
||||||
|
echoReflections(origin, frontReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, backReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, leftReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, rightReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, upReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
echoReflections(origin, downReflections, samples, sampleTime, format.sampleRate());
|
||||||
|
//quint64 end = usecTimestampNow();
|
||||||
|
|
||||||
//qDebug() << "AudioReflector::addSamples()... elapsed=" << (end - start);
|
//qDebug() << "AudioReflector::addSamples()... elapsed=" << (end - start);
|
||||||
}
|
}
|
||||||
|
@ -307,130 +382,109 @@ void AudioReflector::drawRays() {
|
||||||
|
|
||||||
const int BOUNCE_COUNT = 5;
|
const int BOUNCE_COUNT = 5;
|
||||||
|
|
||||||
bool oldWay = false;
|
QVector<glm::vec3> frontRightUpReflections = calculateReflections(origin, frontRightUp, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> frontLeftUpReflections = calculateReflections(origin, frontLeftUp, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backRightUpReflections = calculateReflections(origin, backRightUp, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backLeftUpReflections = calculateReflections(origin, backLeftUp, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> frontRightDownReflections = calculateReflections(origin, frontRightDown, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> frontLeftDownReflections = calculateReflections(origin, frontLeftDown, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backRightDownReflections = calculateReflections(origin, backRightDown, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backLeftDownReflections = calculateReflections(origin, backLeftDown, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> frontReflections = calculateReflections(origin, front, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> backReflections = calculateReflections(origin, back, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> leftReflections = calculateReflections(origin, left, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> rightReflections = calculateReflections(origin, right, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> upReflections = calculateReflections(origin, up, BOUNCE_COUNT);
|
||||||
|
QVector<glm::vec3> downReflections = calculateReflections(origin, down, BOUNCE_COUNT);
|
||||||
|
|
||||||
|
glm::vec3 frontRightUpColor = RED;
|
||||||
|
glm::vec3 frontLeftUpColor = GREEN;
|
||||||
|
glm::vec3 backRightUpColor = BLUE;
|
||||||
|
glm::vec3 backLeftUpColor = CYAN;
|
||||||
|
glm::vec3 frontRightDownColor = PURPLE;
|
||||||
|
glm::vec3 frontLeftDownColor = YELLOW;
|
||||||
|
glm::vec3 backRightDownColor = WHITE;
|
||||||
|
glm::vec3 backLeftDownColor = DARK_RED;
|
||||||
|
glm::vec3 frontColor = GRAY;
|
||||||
|
glm::vec3 backColor = DARK_GREEN;
|
||||||
|
glm::vec3 leftColor = DARK_BLUE;
|
||||||
|
glm::vec3 rightColor = DARK_CYAN;
|
||||||
|
glm::vec3 upColor = DARK_PURPLE;
|
||||||
|
glm::vec3 downColor = DARK_YELLOW;
|
||||||
|
|
||||||
if (oldWay) {
|
// attempt to determine insidness/outsideness based on number of directional rays that reflect
|
||||||
drawReflections(origin, frontRightUp, BOUNCE_COUNT, RED);
|
bool inside = false;
|
||||||
drawReflections(origin, frontLeftUp, BOUNCE_COUNT, GREEN);
|
|
||||||
drawReflections(origin, backRightUp, BOUNCE_COUNT, BLUE);
|
bool blockedUp = (frontRightUpReflections.size() > 0) &&
|
||||||
drawReflections(origin, backLeftUp, BOUNCE_COUNT, CYAN);
|
(frontLeftUpReflections.size() > 0) &&
|
||||||
drawReflections(origin, frontRightDown, BOUNCE_COUNT, PURPLE);
|
(backRightUpReflections.size() > 0) &&
|
||||||
drawReflections(origin, frontLeftDown, BOUNCE_COUNT, YELLOW);
|
(backLeftUpReflections.size() > 0) &&
|
||||||
drawReflections(origin, backRightDown, BOUNCE_COUNT, WHITE);
|
(upReflections.size() > 0);
|
||||||
drawReflections(origin, backLeftDown, BOUNCE_COUNT, DARK_RED);
|
|
||||||
|
|
||||||
drawReflections(origin, front, BOUNCE_COUNT, DARK_GREEN);
|
bool blockedDown = (frontRightDownReflections.size() > 0) &&
|
||||||
drawReflections(origin, back, BOUNCE_COUNT, DARK_BLUE);
|
(frontLeftDownReflections.size() > 0) &&
|
||||||
drawReflections(origin, left, BOUNCE_COUNT, DARK_CYAN);
|
(backRightDownReflections.size() > 0) &&
|
||||||
drawReflections(origin, right, BOUNCE_COUNT, DARK_PURPLE);
|
(backLeftDownReflections.size() > 0) &&
|
||||||
drawReflections(origin, up, BOUNCE_COUNT, DARK_YELLOW);
|
(downReflections.size() > 0);
|
||||||
drawReflections(origin, down, BOUNCE_COUNT, GRAY);
|
|
||||||
} else {
|
|
||||||
QVector<glm::vec3> frontRightUpReflections = calculateReflections(origin, frontRightUp, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> frontLeftUpReflections = calculateReflections(origin, frontLeftUp, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> backRightUpReflections = calculateReflections(origin, backRightUp, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> backLeftUpReflections = calculateReflections(origin, backLeftUp, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> frontRightDownReflections = calculateReflections(origin, frontRightDown, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> frontLeftDownReflections = calculateReflections(origin, frontLeftDown, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> backRightDownReflections = calculateReflections(origin, backRightDown, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> backLeftDownReflections = calculateReflections(origin, backLeftDown, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> frontReflections = calculateReflections(origin, front, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> backReflections = calculateReflections(origin, back, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> leftReflections = calculateReflections(origin, left, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> rightReflections = calculateReflections(origin, right, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> upReflections = calculateReflections(origin, up, BOUNCE_COUNT);
|
|
||||||
QVector<glm::vec3> downReflections = calculateReflections(origin, down, BOUNCE_COUNT);
|
|
||||||
|
|
||||||
glm::vec3 frontRightUpColor = RED;
|
bool blockedFront = (frontRightUpReflections.size() > 0) &&
|
||||||
glm::vec3 frontLeftUpColor = GREEN;
|
(frontLeftUpReflections.size() > 0) &&
|
||||||
glm::vec3 backRightUpColor = BLUE;
|
(frontRightDownReflections.size() > 0) &&
|
||||||
glm::vec3 backLeftUpColor = CYAN;
|
(frontLeftDownReflections.size() > 0) &&
|
||||||
glm::vec3 frontRightDownColor = PURPLE;
|
(frontReflections.size() > 0);
|
||||||
glm::vec3 frontLeftDownColor = YELLOW;
|
|
||||||
glm::vec3 backRightDownColor = WHITE;
|
|
||||||
glm::vec3 backLeftDownColor = DARK_RED;
|
|
||||||
glm::vec3 frontColor = GRAY;
|
|
||||||
glm::vec3 backColor = DARK_GREEN;
|
|
||||||
glm::vec3 leftColor = DARK_BLUE;
|
|
||||||
glm::vec3 rightColor = DARK_CYAN;
|
|
||||||
glm::vec3 upColor = DARK_PURPLE;
|
|
||||||
glm::vec3 downColor = DARK_YELLOW;
|
|
||||||
|
|
||||||
// attempt to determine insidness/outsideness based on number of directional rays that reflect
|
|
||||||
bool inside = false;
|
|
||||||
|
|
||||||
bool blockedUp = (frontRightUpReflections.size() > 0) &&
|
|
||||||
(frontLeftUpReflections.size() > 0) &&
|
|
||||||
(backRightUpReflections.size() > 0) &&
|
|
||||||
(backLeftUpReflections.size() > 0) &&
|
|
||||||
(upReflections.size() > 0);
|
|
||||||
|
|
||||||
bool blockedDown = (frontRightDownReflections.size() > 0) &&
|
bool blockedBack = (backRightUpReflections.size() > 0) &&
|
||||||
(frontLeftDownReflections.size() > 0) &&
|
(backLeftUpReflections.size() > 0) &&
|
||||||
(backRightDownReflections.size() > 0) &&
|
(backRightDownReflections.size() > 0) &&
|
||||||
(backLeftDownReflections.size() > 0) &&
|
(backLeftDownReflections.size() > 0) &&
|
||||||
(downReflections.size() > 0);
|
(backReflections.size() > 0);
|
||||||
|
|
||||||
|
bool blockedLeft = (frontLeftUpReflections.size() > 0) &&
|
||||||
|
(backLeftUpReflections.size() > 0) &&
|
||||||
|
(frontLeftDownReflections.size() > 0) &&
|
||||||
|
(backLeftDownReflections.size() > 0) &&
|
||||||
|
(leftReflections.size() > 0);
|
||||||
|
|
||||||
bool blockedFront = (frontRightUpReflections.size() > 0) &&
|
bool blockedRight = (frontRightUpReflections.size() > 0) &&
|
||||||
(frontLeftUpReflections.size() > 0) &&
|
(backRightUpReflections.size() > 0) &&
|
||||||
(frontRightDownReflections.size() > 0) &&
|
(frontRightDownReflections.size() > 0) &&
|
||||||
(frontLeftDownReflections.size() > 0) &&
|
(backRightDownReflections.size() > 0) &&
|
||||||
(frontReflections.size() > 0);
|
(rightReflections.size() > 0);
|
||||||
|
|
||||||
bool blockedBack = (backRightUpReflections.size() > 0) &&
|
|
||||||
(backLeftUpReflections.size() > 0) &&
|
|
||||||
(backRightDownReflections.size() > 0) &&
|
|
||||||
(backLeftDownReflections.size() > 0) &&
|
|
||||||
(backReflections.size() > 0);
|
|
||||||
|
|
||||||
bool blockedLeft = (frontLeftUpReflections.size() > 0) &&
|
|
||||||
(backLeftUpReflections.size() > 0) &&
|
|
||||||
(frontLeftDownReflections.size() > 0) &&
|
|
||||||
(backLeftDownReflections.size() > 0) &&
|
|
||||||
(leftReflections.size() > 0);
|
|
||||||
|
|
||||||
bool blockedRight = (frontRightUpReflections.size() > 0) &&
|
|
||||||
(backRightUpReflections.size() > 0) &&
|
|
||||||
(frontRightDownReflections.size() > 0) &&
|
|
||||||
(backRightDownReflections.size() > 0) &&
|
|
||||||
(rightReflections.size() > 0);
|
|
||||||
|
|
||||||
inside = blockedUp && blockedDown && blockedFront && blockedBack && blockedLeft && blockedRight;
|
|
||||||
|
|
||||||
if (inside) {
|
|
||||||
frontRightUpColor = RED;
|
|
||||||
frontLeftUpColor = RED;
|
|
||||||
backRightUpColor = RED;
|
|
||||||
backLeftUpColor = RED;
|
|
||||||
frontRightDownColor = RED;
|
|
||||||
frontLeftDownColor = RED;
|
|
||||||
backRightDownColor = RED;
|
|
||||||
backLeftDownColor = RED;
|
|
||||||
frontColor = RED;
|
|
||||||
backColor = RED;
|
|
||||||
leftColor = RED;
|
|
||||||
rightColor = RED;
|
|
||||||
upColor = RED;
|
|
||||||
downColor = RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
newDrawReflections(origin, frontRightUpColor, frontRightUpReflections);
|
|
||||||
newDrawReflections(origin, frontLeftUpColor, frontLeftUpReflections);
|
|
||||||
newDrawReflections(origin, backRightUpColor, backRightUpReflections);
|
|
||||||
newDrawReflections(origin, backLeftUpColor, backLeftUpReflections);
|
|
||||||
newDrawReflections(origin, frontRightDownColor, frontRightDownReflections);
|
|
||||||
newDrawReflections(origin, frontLeftDownColor, frontLeftDownReflections);
|
|
||||||
newDrawReflections(origin, backRightDownColor, backRightDownReflections);
|
|
||||||
newDrawReflections(origin, backLeftDownColor, backLeftDownReflections);
|
|
||||||
|
|
||||||
newDrawReflections(origin, frontColor, frontReflections);
|
|
||||||
newDrawReflections(origin, backColor, backReflections);
|
|
||||||
newDrawReflections(origin, leftColor, leftReflections);
|
|
||||||
newDrawReflections(origin, rightColor, rightReflections);
|
|
||||||
newDrawReflections(origin, upColor, upReflections);
|
|
||||||
newDrawReflections(origin, downColor, downReflections);
|
|
||||||
|
|
||||||
|
inside = blockedUp && blockedDown && blockedFront && blockedBack && blockedLeft && blockedRight;
|
||||||
|
|
||||||
|
if (inside) {
|
||||||
|
frontRightUpColor = RED;
|
||||||
|
frontLeftUpColor = RED;
|
||||||
|
backRightUpColor = RED;
|
||||||
|
backLeftUpColor = RED;
|
||||||
|
frontRightDownColor = RED;
|
||||||
|
frontLeftDownColor = RED;
|
||||||
|
backRightDownColor = RED;
|
||||||
|
backLeftDownColor = RED;
|
||||||
|
frontColor = RED;
|
||||||
|
backColor = RED;
|
||||||
|
leftColor = RED;
|
||||||
|
rightColor = RED;
|
||||||
|
upColor = RED;
|
||||||
|
downColor = RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawReflections(origin, frontRightUpColor, frontRightUpReflections);
|
||||||
|
drawReflections(origin, frontLeftUpColor, frontLeftUpReflections);
|
||||||
|
drawReflections(origin, backRightUpColor, backRightUpReflections);
|
||||||
|
drawReflections(origin, backLeftUpColor, backLeftUpReflections);
|
||||||
|
drawReflections(origin, frontRightDownColor, frontRightDownReflections);
|
||||||
|
drawReflections(origin, frontLeftDownColor, frontLeftDownReflections);
|
||||||
|
drawReflections(origin, backRightDownColor, backRightDownReflections);
|
||||||
|
drawReflections(origin, backLeftDownColor, backLeftDownReflections);
|
||||||
|
|
||||||
|
drawReflections(origin, frontColor, frontReflections);
|
||||||
|
drawReflections(origin, backColor, backReflections);
|
||||||
|
drawReflections(origin, leftColor, leftReflections);
|
||||||
|
drawReflections(origin, rightColor, rightReflections);
|
||||||
|
drawReflections(origin, upColor, upReflections);
|
||||||
|
drawReflections(origin, downColor, downReflections);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioReflector::drawVector(const glm::vec3& start, const glm::vec3& end, const glm::vec3& color) {
|
void AudioReflector::drawVector(const glm::vec3& start, const glm::vec3& end, const glm::vec3& color) {
|
||||||
|
|
|
@ -37,13 +37,15 @@ private:
|
||||||
|
|
||||||
void drawRays();
|
void drawRays();
|
||||||
void drawVector(const glm::vec3& start, const glm::vec3& end, const glm::vec3& color);
|
void drawVector(const glm::vec3& start, const glm::vec3& end, const glm::vec3& color);
|
||||||
void drawReflections(const glm::vec3& origin, const glm::vec3& direction, int bounces, const glm::vec3& color);
|
void oldEchoReflections(const glm::vec3& origin, const glm::vec3& originalDirection,
|
||||||
void echoReflections(const glm::vec3& origin, const glm::vec3& originalDirection,
|
|
||||||
int bounces, const QByteArray& samples,
|
int bounces, const QByteArray& samples,
|
||||||
unsigned int sampleTime, int sampleRate);
|
unsigned int sampleTime, int sampleRate);
|
||||||
|
|
||||||
|
void echoReflections(const glm::vec3& origin, const QVector<glm::vec3>& reflections, const QByteArray& samples,
|
||||||
|
unsigned int sampleTime, int sampleRate);
|
||||||
|
|
||||||
QVector<glm::vec3> calculateReflections(const glm::vec3& origin, const glm::vec3& originalDirection, int maxBounces);
|
QVector<glm::vec3> calculateReflections(const glm::vec3& origin, const glm::vec3& originalDirection, int maxBounces);
|
||||||
void newDrawReflections(const glm::vec3& origin, const glm::vec3& originalColor, const QVector<glm::vec3>& reflections);
|
void drawReflections(const glm::vec3& origin, const glm::vec3& originalColor, const QVector<glm::vec3>& reflections);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -371,6 +371,11 @@ Menu::Menu() :
|
||||||
false,
|
false,
|
||||||
appInstance->getAudio(),
|
appInstance->getAudio(),
|
||||||
SLOT(toggleAudioSpatialProcessing()));
|
SLOT(toggleAudioSpatialProcessing()));
|
||||||
|
|
||||||
|
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioSpatialProcessingIncudeOriginal,
|
||||||
|
Qt::CTRL | Qt::SHIFT | Qt::Key_O,
|
||||||
|
true);
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::LowPassFilter,
|
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::LowPassFilter,
|
||||||
Qt::CTRL | Qt::SHIFT | Qt::Key_F,
|
Qt::CTRL | Qt::SHIFT | Qt::Key_F,
|
||||||
false);
|
false);
|
||||||
|
|
|
@ -244,6 +244,7 @@ namespace MenuOption {
|
||||||
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
||||||
const QString AudioToneInjection = "Inject Test Tone";
|
const QString AudioToneInjection = "Inject Test Tone";
|
||||||
const QString AudioSpatialProcessing = "Audio Spatial Processing";
|
const QString AudioSpatialProcessing = "Audio Spatial Processing";
|
||||||
|
const QString AudioSpatialProcessingIncudeOriginal = "Audio Spatial Processing includes Original";
|
||||||
const QString EchoServerAudio = "Echo Server Audio";
|
const QString EchoServerAudio = "Echo Server Audio";
|
||||||
const QString EchoLocalAudio = "Echo Local Audio";
|
const QString EchoLocalAudio = "Echo Local Audio";
|
||||||
const QString MuteAudio = "Mute Microphone";
|
const QString MuteAudio = "Mute Microphone";
|
||||||
|
|
Loading…
Reference in a new issue