From 195186f72688749501445f6f6d0949f32aa5ff15 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 9 Oct 2014 11:48:41 -0700 Subject: [PATCH 01/15] Removed redundant TREE_SCALE declaration --- libraries/voxels/src/VoxelDetail.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/voxels/src/VoxelDetail.h b/libraries/voxels/src/VoxelDetail.h index b94601392b..5ef7f0ff4e 100644 --- a/libraries/voxels/src/VoxelDetail.h +++ b/libraries/voxels/src/VoxelDetail.h @@ -15,6 +15,7 @@ #include #include +#include #include #include "VoxelConstants.h" @@ -53,8 +54,6 @@ void rayToVoxelIntersectionResultFromScriptValue(const QScriptValue& object, Ray inline QDebug operator<<(QDebug debug, const VoxelDetail& details) { - const int TREE_SCALE = 16384; // ~10 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe - debug << "VoxelDetail[ (" << details.x * (float)TREE_SCALE << "," << details.y * (float)TREE_SCALE << "," << details.z * (float)TREE_SCALE << " ) to (" From 981666cb385908757a6edf0413aa104858616359 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 9 Oct 2014 11:49:55 -0700 Subject: [PATCH 02/15] Moved audioMixer setting parsing to its own function --- assignment-client/src/audio/AudioMixer.cpp | 271 ++++++++++++--------- assignment-client/src/audio/AudioMixer.h | 3 + 2 files changed, 162 insertions(+), 112 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 37d89f3790..d5fa108fe3 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ const float LOUDNESS_TO_DISTANCE_RATIO = 0.00001f; const float DEFAULT_ATTENUATION_PER_DOUBLING_IN_DISTANCE = 0.18; const QString AUDIO_MIXER_LOGGING_TARGET_NAME = "audio-mixer"; +const QString AUDIO_GROUP_KEY = "audio"; void attachNewNodeDataToNode(Node *newNode) { if (!newNode->getLinkedData()) { @@ -637,119 +639,8 @@ void AudioMixer::run() { const QJsonObject& settingsObject = domainHandler.getSettingsObject(); // check the settings object to see if we have anything we can parse out - const QString AUDIO_GROUP_KEY = "audio"; - if (settingsObject.contains(AUDIO_GROUP_KEY)) { - QJsonObject audioGroupObject = settingsObject[AUDIO_GROUP_KEY].toObject(); - - // check the payload to see if we have asked for dynamicJitterBuffer support - const QString DYNAMIC_JITTER_BUFFER_JSON_KEY = "dynamic_jitter_buffer"; - _streamSettings._dynamicJitterBuffers = audioGroupObject[DYNAMIC_JITTER_BUFFER_JSON_KEY].toBool(); - if (_streamSettings._dynamicJitterBuffers) { - qDebug() << "Enable dynamic jitter buffers."; - } else { - qDebug() << "Dynamic jitter buffers disabled."; - } - - bool ok; - const QString DESIRED_JITTER_BUFFER_FRAMES_KEY = "static_desired_jitter_buffer_frames"; - _streamSettings._staticDesiredJitterBufferFrames = audioGroupObject[DESIRED_JITTER_BUFFER_FRAMES_KEY].toString().toInt(&ok); - if (!ok) { - _streamSettings._staticDesiredJitterBufferFrames = DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES; - } - qDebug() << "Static desired jitter buffer frames:" << _streamSettings._staticDesiredJitterBufferFrames; - - const QString MAX_FRAMES_OVER_DESIRED_JSON_KEY = "max_frames_over_desired"; - _streamSettings._maxFramesOverDesired = audioGroupObject[MAX_FRAMES_OVER_DESIRED_JSON_KEY].toString().toInt(&ok); - if (!ok) { - _streamSettings._maxFramesOverDesired = DEFAULT_MAX_FRAMES_OVER_DESIRED; - } - qDebug() << "Max frames over desired:" << _streamSettings._maxFramesOverDesired; - - const QString USE_STDEV_FOR_DESIRED_CALC_JSON_KEY = "use_stdev_for_desired_calc"; - _streamSettings._useStDevForJitterCalc = audioGroupObject[USE_STDEV_FOR_DESIRED_CALC_JSON_KEY].toBool(); - if (_streamSettings._useStDevForJitterCalc) { - qDebug() << "Using Philip's stdev method for jitter calc if dynamic jitter buffers enabled"; - } else { - qDebug() << "Using Fred's max-gap method for jitter calc if dynamic jitter buffers enabled"; - } - - const QString WINDOW_STARVE_THRESHOLD_JSON_KEY = "window_starve_threshold"; - _streamSettings._windowStarveThreshold = audioGroupObject[WINDOW_STARVE_THRESHOLD_JSON_KEY].toString().toInt(&ok); - if (!ok) { - _streamSettings._windowStarveThreshold = DEFAULT_WINDOW_STARVE_THRESHOLD; - } - qDebug() << "Window A starve threshold:" << _streamSettings._windowStarveThreshold; - - const QString WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY = "window_seconds_for_desired_calc_on_too_many_starves"; - _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY].toString().toInt(&ok); - if (!ok) { - _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES; - } - qDebug() << "Window A length:" << _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves << "seconds"; - - const QString WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY = "window_seconds_for_desired_reduction"; - _streamSettings._windowSecondsForDesiredReduction = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY].toString().toInt(&ok); - if (!ok) { - _streamSettings._windowSecondsForDesiredReduction = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION; - } - qDebug() << "Window B length:" << _streamSettings._windowSecondsForDesiredReduction << "seconds"; - - const QString REPETITION_WITH_FADE_JSON_KEY = "repetition_with_fade"; - _streamSettings._repetitionWithFade = audioGroupObject[REPETITION_WITH_FADE_JSON_KEY].toBool(); - if (_streamSettings._repetitionWithFade) { - qDebug() << "Repetition with fade enabled"; - } else { - qDebug() << "Repetition with fade disabled"; - } - - const QString PRINT_STREAM_STATS_JSON_KEY = "print_stream_stats"; - _printStreamStats = audioGroupObject[PRINT_STREAM_STATS_JSON_KEY].toBool(); - if (_printStreamStats) { - qDebug() << "Stream stats will be printed to stdout"; - } - - const QString FILTER_KEY = "enable_filter"; - if (audioGroupObject[FILTER_KEY].isBool()) { - _enableFilter = audioGroupObject[FILTER_KEY].toBool(); - } - if (_enableFilter) { - qDebug() << "Filter enabled"; - } - - const QString UNATTENUATED_ZONE_KEY = "unattenuated_zone"; - - QString unattenuatedZoneString = audioGroupObject[UNATTENUATED_ZONE_KEY].toString(); - if (!unattenuatedZoneString.isEmpty()) { - QStringList zoneStringList = unattenuatedZoneString.split(','); - - glm::vec3 sourceCorner(zoneStringList[0].toFloat(), zoneStringList[1].toFloat(), zoneStringList[2].toFloat()); - glm::vec3 sourceDimensions(zoneStringList[3].toFloat(), zoneStringList[4].toFloat(), zoneStringList[5].toFloat()); - - glm::vec3 listenerCorner(zoneStringList[6].toFloat(), zoneStringList[7].toFloat(), zoneStringList[8].toFloat()); - glm::vec3 listenerDimensions(zoneStringList[9].toFloat(), zoneStringList[10].toFloat(), zoneStringList[11].toFloat()); - - _sourceUnattenuatedZone = new AABox(sourceCorner, sourceDimensions); - _listenerUnattenuatedZone = new AABox(listenerCorner, listenerDimensions); - - glm::vec3 sourceCenter = _sourceUnattenuatedZone->calcCenter(); - glm::vec3 destinationCenter = _listenerUnattenuatedZone->calcCenter(); - - qDebug() << "There is an unattenuated zone with source center at" - << QString("%1, %2, %3").arg(sourceCenter.x).arg(sourceCenter.y).arg(sourceCenter.z); - qDebug() << "Buffers inside this zone will not be attenuated inside a box with center at" - << QString("%1, %2, %3").arg(destinationCenter.x).arg(destinationCenter.y).arg(destinationCenter.z); - } - - const QString ATTENATION_PER_DOULING_IN_DISTANCE = "attenuation_per_doubling_in_distance"; - if (audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].isString()) { - bool ok = false; - float attenuation = audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].toString().toFloat(&ok); - if (ok) { - _attenuationPerDoublingInDistance = attenuation; - qDebug() << "Attenuation per doubling in distance changed to" << _attenuationPerDoublingInDistance; - } - } + parseSettingsObject(settingsObject); } int nextFrame = 0; @@ -982,3 +873,159 @@ QString AudioMixer::getReadPendingDatagramsHashMatchTimeStatsString() const { + " prct_time_in_hashmatch_1s: " + QString::number(_timeSpentPerHashMatchCallStats.getLastCompleteIntervalStats().getSum() / USECS_PER_SECOND * 100.0, 'f', 6) + "%"; return result; } + +void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) { + QJsonObject audioGroupObject = settingsObject[AUDIO_GROUP_KEY].toObject(); + + // check the payload to see if we have asked for dynamicJitterBuffer support + const QString DYNAMIC_JITTER_BUFFER_JSON_KEY = "dynamic_jitter_buffer"; + _streamSettings._dynamicJitterBuffers = audioGroupObject[DYNAMIC_JITTER_BUFFER_JSON_KEY].toBool(); + if (_streamSettings._dynamicJitterBuffers) { + qDebug() << "Enable dynamic jitter buffers."; + } else { + qDebug() << "Dynamic jitter buffers disabled."; + } + + bool ok; + const QString DESIRED_JITTER_BUFFER_FRAMES_KEY = "static_desired_jitter_buffer_frames"; + _streamSettings._staticDesiredJitterBufferFrames = audioGroupObject[DESIRED_JITTER_BUFFER_FRAMES_KEY].toString().toInt(&ok); + if (!ok) { + _streamSettings._staticDesiredJitterBufferFrames = DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES; + } + qDebug() << "Static desired jitter buffer frames:" << _streamSettings._staticDesiredJitterBufferFrames; + + const QString MAX_FRAMES_OVER_DESIRED_JSON_KEY = "max_frames_over_desired"; + _streamSettings._maxFramesOverDesired = audioGroupObject[MAX_FRAMES_OVER_DESIRED_JSON_KEY].toString().toInt(&ok); + if (!ok) { + _streamSettings._maxFramesOverDesired = DEFAULT_MAX_FRAMES_OVER_DESIRED; + } + qDebug() << "Max frames over desired:" << _streamSettings._maxFramesOverDesired; + + const QString USE_STDEV_FOR_DESIRED_CALC_JSON_KEY = "use_stdev_for_desired_calc"; + _streamSettings._useStDevForJitterCalc = audioGroupObject[USE_STDEV_FOR_DESIRED_CALC_JSON_KEY].toBool(); + if (_streamSettings._useStDevForJitterCalc) { + qDebug() << "Using Philip's stdev method for jitter calc if dynamic jitter buffers enabled"; + } else { + qDebug() << "Using Fred's max-gap method for jitter calc if dynamic jitter buffers enabled"; + } + + const QString WINDOW_STARVE_THRESHOLD_JSON_KEY = "window_starve_threshold"; + _streamSettings._windowStarveThreshold = audioGroupObject[WINDOW_STARVE_THRESHOLD_JSON_KEY].toString().toInt(&ok); + if (!ok) { + _streamSettings._windowStarveThreshold = DEFAULT_WINDOW_STARVE_THRESHOLD; + } + qDebug() << "Window A starve threshold:" << _streamSettings._windowStarveThreshold; + + const QString WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY = "window_seconds_for_desired_calc_on_too_many_starves"; + _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY].toString().toInt(&ok); + if (!ok) { + _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES; + } + qDebug() << "Window A length:" << _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves << "seconds"; + + const QString WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY = "window_seconds_for_desired_reduction"; + _streamSettings._windowSecondsForDesiredReduction = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY].toString().toInt(&ok); + if (!ok) { + _streamSettings._windowSecondsForDesiredReduction = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION; + } + qDebug() << "Window B length:" << _streamSettings._windowSecondsForDesiredReduction << "seconds"; + + const QString REPETITION_WITH_FADE_JSON_KEY = "repetition_with_fade"; + _streamSettings._repetitionWithFade = audioGroupObject[REPETITION_WITH_FADE_JSON_KEY].toBool(); + if (_streamSettings._repetitionWithFade) { + qDebug() << "Repetition with fade enabled"; + } else { + qDebug() << "Repetition with fade disabled"; + } + + const QString PRINT_STREAM_STATS_JSON_KEY = "print_stream_stats"; + _printStreamStats = audioGroupObject[PRINT_STREAM_STATS_JSON_KEY].toBool(); + if (_printStreamStats) { + qDebug() << "Stream stats will be printed to stdout"; + } + + const QString FILTER_KEY = "enable_filter"; + if (audioGroupObject[FILTER_KEY].isBool()) { + _enableFilter = audioGroupObject[FILTER_KEY].toBool(); + } + if (_enableFilter) { + qDebug() << "Filter enabled"; + } + + const QString UNATTENUATED_ZONE_KEY = "unattenuated_zone"; + + QString unattenuatedZoneString = audioGroupObject[UNATTENUATED_ZONE_KEY].toString(); + if (!unattenuatedZoneString.isEmpty()) { + QStringList zoneStringList = unattenuatedZoneString.split(','); + + glm::vec3 sourceCorner(zoneStringList[0].toFloat(), zoneStringList[1].toFloat(), zoneStringList[2].toFloat()); + glm::vec3 sourceDimensions(zoneStringList[3].toFloat(), zoneStringList[4].toFloat(), zoneStringList[5].toFloat()); + + glm::vec3 listenerCorner(zoneStringList[6].toFloat(), zoneStringList[7].toFloat(), zoneStringList[8].toFloat()); + glm::vec3 listenerDimensions(zoneStringList[9].toFloat(), zoneStringList[10].toFloat(), zoneStringList[11].toFloat()); + + _sourceUnattenuatedZone = new AABox(sourceCorner, sourceDimensions); + _listenerUnattenuatedZone = new AABox(listenerCorner, listenerDimensions); + + glm::vec3 sourceCenter = _sourceUnattenuatedZone->calcCenter(); + glm::vec3 destinationCenter = _listenerUnattenuatedZone->calcCenter(); + + qDebug() << "There is an unattenuated zone with source center at" + << QString("%1, %2, %3").arg(sourceCenter.x).arg(sourceCenter.y).arg(sourceCenter.z); + qDebug() << "Buffers inside this zone will not be attenuated inside a box with center at" + << QString("%1, %2, %3").arg(destinationCenter.x).arg(destinationCenter.y).arg(destinationCenter.z); + } + + const QString ATTENATION_PER_DOULING_IN_DISTANCE = "attenuation_per_doubling_in_distance"; + if (audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].isString()) { + bool ok = false; + float attenuation = audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].toString().toFloat(&ok); + if (ok) { + _attenuationPerDoublingInDistance = attenuation; + qDebug() << "Attenuation per doubling in distance changed to" << _attenuationPerDoublingInDistance; + } + } + + const QString AUDIO_ZONES = "zones"; + if (audioGroupObject[AUDIO_ZONES].isObject()) { + const QJsonObject& zones = audioGroupObject[AUDIO_ZONES].toObject(); + + const QString X_RANGE = "x_range"; + const QString Y_RANGE = "y_range"; + const QString Z_RANGE = "z_range"; + foreach (const QString& zone, zones.keys()) { + QJsonObject zoneObject = zones[zone].toObject(); + + if (zoneObject.contains(X_RANGE) && zoneObject.contains(Y_RANGE) && zoneObject.contains(Z_RANGE)) { + QStringList xRange = zoneObject.value(X_RANGE).toString().split("-", QString::SkipEmptyParts); + QStringList yRange = zoneObject.value(Y_RANGE).toString().split("-", QString::SkipEmptyParts); + QStringList zRange = zoneObject.value(Z_RANGE).toString().split("-", QString::SkipEmptyParts); + + if (xRange.size() == 2 && yRange.size() == 2 && zRange.size() == 2) { + float xMin, xMax, yMin, yMax, zMin, zMax; + bool ok, allOk = true; + xMin = xRange[0].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + xMax = xRange[1].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + yMin = yRange[0].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + yMax = yRange[1].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + zMin = zRange[0].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + zMax = zRange[1].toFloat(&ok) / (float)TREE_SCALE; + allOk &= ok; + + if (allOk) { + glm::vec3 corner(xMin, yMin, zMin); + glm::vec3 dimension(xMax - xMin, yMax - yMin, zMax - zMin); + AABox zoneAABox(corner, dimension); + _audioZones.insert(zone, zoneAABox); + qDebug() << "Added zone:" << zoneAABox; + } + } + } + } + } +} diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 4d08d480f8..ca1b610051 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -66,6 +66,8 @@ private: QString getReadPendingDatagramsTimeStatsString() const; QString getReadPendingDatagramsHashMatchTimeStatsString() const; + void parseSettingsObject(const QJsonObject& settingsObject); + float _trailingSleepRatio; float _minAudibilityThreshold; float _performanceThrottlingRatio; @@ -75,6 +77,7 @@ private: int _sumMixes; AABox* _sourceUnattenuatedZone; AABox* _listenerUnattenuatedZone; + QHash _audioZones; static InboundAudioStream::Settings _streamSettings; From e7ecf1cd6fb3abd9c9e8603d2fd6c264927fd565 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 9 Oct 2014 12:38:07 -0700 Subject: [PATCH 03/15] Optional labels --- domain-server/resources/web/js/settings.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 130000fc9c..4a4f882d99 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -25,7 +25,9 @@ var viewHelpers = { + " trigger-change' data-short-name='" + setting.name + "' name='" + setting_name + "' " if (setting.type === 'checkbox') { - form_group += "" + if (setting.label) { + form_group += "" + } form_group += "
" form_group += "