From 8fab184ed106ac0c99193d79e614ebb790f5164d Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Oct 2014 11:10:11 -0700 Subject: [PATCH 01/11] Remove audio settings from advanced --- .../resources/describe-settings.json | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 818ba62370..46eb86a5ac 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -152,72 +152,63 @@ "type": "checkbox", "label": "Dynamic Jitter Buffers", "help": "dynamically buffer client audio based on perceived jitter in packet receipt timing", - "default": false, - "advanced": true + "default": false }, { "name": "static_desired_jitter_buffer_frames", "label": "Static Desired Jitter Buffer Frames", "help": "If dynamic jitter buffers is disabled, this determines the target number of frames maintained by the AudioMixer's jitter buffers", "placeholder": "1", - "default": "1", - "advanced": true + "default": "1" }, { "name": "max_frames_over_desired", "label": "Max Frames Over Desired", "help": "The highest number of frames an AudioMixer's ringbuffer can exceed the desired jitter buffer frames by", "placeholder": "10", - "default": "10", - "advanced": true + "default": "10" }, { "name": "use_stdev_for_desired_calc", "type": "checkbox", "label": "Use Stdev for Desired Jitter Frames Calc:", "help": "use Philip's method (stdev of timegaps) to calculate desired jitter frames (otherwise Fred's max timegap method is used)", - "default": false, - "advanced": true + "default": false }, { "name": "window_starve_threshold", "label": "Window Starve Threshold", "help": "If this many starves occur in an N-second window (N is the number in the next field), then the desired jitter frames will be re-evaluated using Window A.", "placeholder": "3", - "default": "3", - "advanced": true + "default": "3" }, { "name": "window_seconds_for_desired_calc_on_too_many_starves", "label": "Timegaps Window (A) Seconds:", "help": "Window A contains a history of timegaps. Its max timegap is used to re-evaluate the desired jitter frames when too many starves occur within it.", "placeholder": "50", - "default": "50", - "advanced": true + "default": "50" }, { "name": "window_seconds_for_desired_reduction", "label": "Timegaps Window (B) Seconds:", "help": "Window B contains a history of timegaps. Its max timegap is used as a ceiling for the desired jitter frames value.", "placeholder": "10", - "default": "10", - "advanced": true + "default": "10" }, { "name": "repetition_with_fade", "type": "checkbox", "label": "Repetition with Fade:", "help": "dropped frames and mixing during starves repeat the last frame, eventually fading to silence", - "default": false, - "advanced": true + "default": false }, { "name": "print_stream_stats", "type": "checkbox", "label": "Print Stream Stats:", "help": "audio upstream and downstream stats of each agent printed to audio-mixer stdout", - "default": false, - "advanced": true + "default": false } ] } From 6d03590c00c771fe92c3c677d0575fcc00b03a83 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Oct 2014 11:10:37 -0700 Subject: [PATCH 02/11] If no advanced settings, don't show button --- domain-server/resources/web/settings/index.shtml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/domain-server/resources/web/settings/index.shtml b/domain-server/resources/web/settings/index.shtml index 9bc8d4bf8f..bdbfdd02ad 100644 --- a/domain-server/resources/web/settings/index.shtml +++ b/domain-server/resources/web/settings/index.shtml @@ -22,7 +22,7 @@ - + @@ -42,10 +42,13 @@ <%= getFormGroup(group.name, setting, values, false, (_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %> <% }); %> - <% _.each(split_settings[1], function(setting) { %> - <%= getFormGroup(group.name, setting, values, true, - (_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %> - <% }); %> + <% if (!_.isEmpty(split_settings[1])) { %> + <% $("#advanced-toggle-button").show() %> + <% _.each(split_settings[1], function(setting) { %> + <%= getFormGroup(group.name, setting, values, true, + (_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %> + <% }); %> + <% }%> <% }); %> From bbd1afc55ca1275125ee85e506fe429b6aa3f95a Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Oct 2014 13:50:06 -0700 Subject: [PATCH 03/11] Switch hash to an array --- assignment-client/src/audio/AudioMixer.cpp | 37 ++++++++-------------- assignment-client/src/audio/AudioMixer.h | 8 ++++- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 42ea8a7341..dda4e8bc35 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -197,20 +197,12 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(AudioMixerClientData* l attenuationCoefficient *= offAxisCoefficient; } - - bool wantBreak = false; + float attenuationPerDoublingInDistance = _attenuationPerDoublingInDistance; - foreach (const QString& source, _attenuationCoefficients.keys()) { - if (_audioZones[source].contains(streamToAdd->getPosition())) { - foreach (const QString& listener, _attenuationCoefficients[source].keys()) { - if (_audioZones[listener].contains(listeningNodeStream->getPosition())) { - attenuationPerDoublingInDistance = _attenuationCoefficients[source][listener]; - wantBreak = true; - break; - } - } - } - if (wantBreak) { + for (int i = 0; i < _zonesSettings.length(); ++i) { + if (_audioZones[_zonesSettings[i].source].contains(streamToAdd->getPosition()) && + _audioZones[_zonesSettings[i].listener].contains(listeningNodeStream->getPosition())) { + attenuationPerDoublingInDistance = _zonesSettings[i].coefficient; break; } } @@ -1028,21 +1020,18 @@ void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) { coefficientObject.contains(LISTENER) && coefficientObject.contains(COEFFICIENT)) { + ZonesSettings settings; + bool ok; - QString source = coefficientObject.value(SOURCE).toString(); - QString listener = coefficientObject.value(LISTENER).toString(); - float coefficient = coefficientObject.value(COEFFICIENT).toString().toFloat(&ok); + settings.source = coefficientObject.value(SOURCE).toString(); + settings.listener = coefficientObject.value(LISTENER).toString(); + settings.coefficient = coefficientObject.value(COEFFICIENT).toString().toFloat(&ok); if (ok && coefficient >= 0.0f && coefficient <= 1.0f && - _audioZones.contains(source) && _audioZones.contains(listener)) { + _audioZones.contains(settings.source) && _audioZones.contains(settings.listener)) { - if (!_attenuationCoefficients.contains(source)) { - _attenuationCoefficients.insert(source, QHash()); - } - if (!_attenuationCoefficients[source].contains(listener)) { - _attenuationCoefficients[source].insert(listener, coefficient); - qDebug() << "Added Coefficient:" << source << listener << coefficient; - } + _zonesSettings.push_back(settings); + qDebug() << "Added Coefficient:" << settings.source << settings.listener << settings.coefficient; } } } diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 7f07c846a4..3cfa5443a8 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -74,8 +74,14 @@ private: int _numStatFrames; int _sumListeners; int _sumMixes; + QHash _audioZones; - QHash > _attenuationCoefficients; + struct ZonesSettings { + QString source; + QString listener; + float coefficient; + }; + QVector _zonesSettings; static InboundAudioStream::Settings _streamSettings; From edea8da18ffe336a2c68fcdc79c6f91af3cd235b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Oct 2014 12:13:34 -0700 Subject: [PATCH 04/11] Move array rows --- .../resources/describe-settings.json | 3 +- domain-server/resources/web/css/style.css | 10 ++++ domain-server/resources/web/js/settings.js | 58 ++++++++++++++++++- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 46eb86a5ac..ffb4ae5c66 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -118,7 +118,8 @@ "type": "table", "label": "Attenuation Coefficients", "help": "In this table you can set custom attenuation coefficients between audio zones", - "numbered": false, + "numbered": true, + "can_order": true, "columns": [ { "name": "source", diff --git a/domain-server/resources/web/css/style.css b/domain-server/resources/web/css/style.css index ad889274d4..249d08bc0e 100644 --- a/domain-server/resources/web/css/style.css +++ b/domain-server/resources/web/css/style.css @@ -85,6 +85,16 @@ td.buttons .glyphicon { font-size: 12px; } +td.edit-buttons { + width: 14px; +} + +td.edit-buttons .glyphicon { + display: block; + text-align: center; + font-size: 12px; +} + tr.new-row { color: #3c763d; background-color: #dff0d8; diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 2b8b42d029..57fbf8c326 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -8,6 +8,10 @@ var Settings = { ADD_ROW_SPAN_CLASSES: 'glyphicon glyphicon-plus add-row', DEL_ROW_BUTTON_CLASS: 'del-row', DEL_ROW_SPAN_CLASSES: 'glyphicon glyphicon-remove del-row', + MOVE_UP_BUTTON_CLASS: 'move-up', + MOVE_UP_SPAN_CLASSES: 'glyphicon glyphicon-chevron-up move-up', + MOVE_DOWN_BUTTON_CLASS: 'move-down', + MOVE_DOWN_SPAN_CLASSES: 'glyphicon glyphicon-chevron-down move-down', TABLE_BUTTONS_CLASS: 'buttons', NEW_ROW_CLASS: 'new-row' }; @@ -110,6 +114,14 @@ $(document).ready(function(){ $('#settings-form').on('click', '.' + Settings.DEL_ROW_BUTTON_CLASS, function(){ deleteTableRow(this); }) + + $('#settings-form').on('click', '.' + Settings.MOVE_UP_BUTTON_CLASS, function(){ + moveTableRow(this, true); + }) + + $('#settings-form').on('click', '.' + Settings.MOVE_DOWN_BUTTON_CLASS, function(){ + moveTableRow(this, false); + }) $('#settings-form').on('keypress', 'table input', function(e){ if (e.keyCode == 13) { @@ -239,6 +251,10 @@ $('body').on('click', '.save-button', function(e){ function makeTable(setting, setting_name, setting_value) { var isArray = !_.has(setting, 'key') + if (!isArray && setting.can_order) { + setting.can_order = false; + } + var html = (setting.label) ? "" : "" html += "" + setting.help + "" html += "" + col.label + "" // Data }) + if (setting.can_order) { + html += ""; + } html += "" // populate rows in the table from existing values @@ -293,6 +312,10 @@ function makeTable(setting, setting_name, setting_value) { html += "" }) + if (setting.can_order) { + html += "" + } html += "" html += "" @@ -324,7 +347,10 @@ function makeTableInputs(setting) { \ " }) - + + if (setting.can_order) { + html += "" + } html += "" html += "" @@ -447,6 +473,9 @@ function addTableRow(add_glyphicon) { input.attr("data-changed", "true") $(element).append(input.val()) + } else if ($(element).hasClass("edit-buttons")) { + $(element).html("") } else { console.log("Unknown table element") } @@ -499,7 +528,32 @@ function deleteTableRow(delete_glyphicon) { // we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated badgeSidebarForDifferences($(table)) -} +} + +function moveTableRow(move_glyphicon, move_up) { + var row = $(move_glyphicon).closest('tr') + + var table = $(row).closest('table') + var isArray = table.data('setting-type') === 'array' + if (!isArray) { + return; + } + + if (move_up) { + var prev_row = row.prev() + if (prev_row.hasClass(Settings.DATA_ROW_CLASS)) { + prev_row.before(row) + } + } else { + var next_row = row.next() + if (next_row.hasClass(Settings.DATA_ROW_CLASS)) { + next_row.after(row) + } + } + + // we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated + badgeSidebarForDifferences($(table)) +} function updateDataChangedForSiblingRows(row, forceTrue) { // anytime a new row is added to an array we need to set data-changed for all sibling row inputs to true From 2edc2eed6d56960d595083f0aeef969d27e06239 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Oct 2014 12:31:17 -0700 Subject: [PATCH 05/11] Changed arrows style --- domain-server/resources/web/css/style.css | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/domain-server/resources/web/css/style.css b/domain-server/resources/web/css/style.css index 249d08bc0e..1576413d91 100644 --- a/domain-server/resources/web/css/style.css +++ b/domain-server/resources/web/css/style.css @@ -75,7 +75,7 @@ span.port { margin-bottom: 15px; } -td.buttons { +td.buttons td.edit-buttons { width: 14px; } @@ -85,12 +85,8 @@ td.buttons .glyphicon { font-size: 12px; } -td.edit-buttons { - width: 14px; -} - td.edit-buttons .glyphicon { - display: block; + display: inherit; text-align: center; font-size: 12px; } From b22701451048e6dae1b9a99d1ecde2cf54df523f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 14 Oct 2014 14:14:59 -0700 Subject: [PATCH 06/11] Stupid mistake --- assignment-client/src/audio/AudioMixer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index dda4e8bc35..21b699540c 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -1027,7 +1027,7 @@ void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) { settings.listener = coefficientObject.value(LISTENER).toString(); settings.coefficient = coefficientObject.value(COEFFICIENT).toString().toFloat(&ok); - if (ok && coefficient >= 0.0f && coefficient <= 1.0f && + if (ok && settings.coefficient >= 0.0f && settings.coefficient <= 1.0f && _audioZones.contains(settings.source) && _audioZones.contains(settings.listener)) { _zonesSettings.push_back(settings); From 0688379b74a5d1c0bbef4a2613f1b5819cb1eea8 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Oct 2014 15:15:19 -0700 Subject: [PATCH 07/11] changed buttons class names --- domain-server/resources/web/css/style.css | 6 ++-- domain-server/resources/web/js/settings.js | 33 ++++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/domain-server/resources/web/css/style.css b/domain-server/resources/web/css/style.css index 1576413d91..702b5ad8ed 100644 --- a/domain-server/resources/web/css/style.css +++ b/domain-server/resources/web/css/style.css @@ -75,17 +75,17 @@ span.port { margin-bottom: 15px; } -td.buttons td.edit-buttons { +td.buttons { width: 14px; } -td.buttons .glyphicon { +td.add-del-buttons .glyphicon { display: block; text-align: center; font-size: 12px; } -td.edit-buttons .glyphicon { +td.reorder-buttons .glyphicon { display: inherit; text-align: center; font-size: 12px; diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 57fbf8c326..0275f7d55c 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -13,6 +13,10 @@ var Settings = { MOVE_DOWN_BUTTON_CLASS: 'move-down', MOVE_DOWN_SPAN_CLASSES: 'glyphicon glyphicon-chevron-down move-down', TABLE_BUTTONS_CLASS: 'buttons', + ADD_DEL_BUTTONS_CLASS: 'add-del-buttons', + ADD_DEL_BUTTONS_CLASSES: 'buttons add-del-buttons', + REORDER_BUTTONS_CLASS: 'reorder-buttons', + REORDER_BUTTONS_CLASSES: 'buttons reorder-buttons', NEW_ROW_CLASS: 'new-row' }; @@ -132,7 +136,7 @@ $(document).ready(function(){ if (sibling.hasClass(Settings.DATA_COL_CLASS)) { // set focus to next input sibling.find('input').focus() - } else if (sibling.hasClass(Settings.TABLE_BUTTONS_CLASS)) { + } else if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) { sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click() // set focus to the first input in the new row @@ -276,9 +280,11 @@ function makeTable(setting, setting_name, setting_value) { }) if (setting.can_order) { - html += ""; + html += ""; } - html += "" + html += "" // populate rows in the table from existing values var row_num = 1 @@ -313,10 +319,12 @@ function makeTable(setting, setting_name, setting_value) { }) if (setting.can_order) { - html += "" + html += "" } - html += "" + html += "" html += "" row_num++ @@ -349,9 +357,10 @@ function makeTableInputs(setting) { }) if (setting.can_order) { - html += "" + html += "" } - html += "" + html += "" html += "" return html @@ -444,7 +453,10 @@ function addTableRow(add_glyphicon) { } else { $(element).html(1) } - } else if ($(element).hasClass("buttons")) { + } else if ($(element).hasClass(Settings.REORDER_BUTTONS_CLASS)) { + $(element).html("") + } else if ($(element).hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) { // Change buttons var span = $(element).children("span") span.removeClass(Settings.ADD_ROW_SPAN_CLASSES) @@ -473,9 +485,6 @@ function addTableRow(add_glyphicon) { input.attr("data-changed", "true") $(element).append(input.val()) - } else if ($(element).hasClass("edit-buttons")) { - $(element).html("") } else { console.log("Unknown table element") } From 0cf4483c5a26b453e7ca8ea610355f1753615899 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Oct 2014 15:52:59 -0700 Subject: [PATCH 08/11] factor text-align and font-size --- domain-server/resources/web/css/style.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domain-server/resources/web/css/style.css b/domain-server/resources/web/css/style.css index 702b5ad8ed..1aab383a7d 100644 --- a/domain-server/resources/web/css/style.css +++ b/domain-server/resources/web/css/style.css @@ -79,16 +79,17 @@ td.buttons { width: 14px; } -td.add-del-buttons .glyphicon { - display: block; +td .glyphicon { text-align: center; font-size: 12px; } +td.add-del-buttons .glyphicon { + display: block; +} + td.reorder-buttons .glyphicon { display: inherit; - text-align: center; - font-size: 12px; } tr.new-row { From ad48009ecd453929df7f0b091a0b5b9ba56d6d27 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Oct 2014 17:08:45 -0700 Subject: [PATCH 09/11] Switch buffers back to advanced --- .../resources/describe-settings.json | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index eabe4fe078..3cee490bd0 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -153,63 +153,72 @@ "type": "checkbox", "label": "Dynamic Jitter Buffers", "help": "dynamically buffer client audio based on perceived jitter in packet receipt timing", - "default": false + "default": false, + "advanced": true }, { "name": "static_desired_jitter_buffer_frames", "label": "Static Desired Jitter Buffer Frames", "help": "If dynamic jitter buffers is disabled, this determines the target number of frames maintained by the AudioMixer's jitter buffers", "placeholder": "1", - "default": "1" + "default": "1", + "advanced": true }, { "name": "max_frames_over_desired", "label": "Max Frames Over Desired", "help": "The highest number of frames an AudioMixer's ringbuffer can exceed the desired jitter buffer frames by", "placeholder": "10", - "default": "10" + "default": "10", + "advanced": true }, { "name": "use_stdev_for_desired_calc", "type": "checkbox", "label": "Use Stdev for Desired Jitter Frames Calc:", "help": "use Philip's method (stdev of timegaps) to calculate desired jitter frames (otherwise Fred's max timegap method is used)", - "default": false + "default": false, + "advanced": true }, { "name": "window_starve_threshold", "label": "Window Starve Threshold", "help": "If this many starves occur in an N-second window (N is the number in the next field), then the desired jitter frames will be re-evaluated using Window A.", "placeholder": "3", - "default": "3" + "default": "3", + "advanced": true }, { "name": "window_seconds_for_desired_calc_on_too_many_starves", "label": "Timegaps Window (A) Seconds:", "help": "Window A contains a history of timegaps. Its max timegap is used to re-evaluate the desired jitter frames when too many starves occur within it.", "placeholder": "50", - "default": "50" + "default": "50", + "advanced": true }, { "name": "window_seconds_for_desired_reduction", "label": "Timegaps Window (B) Seconds:", "help": "Window B contains a history of timegaps. Its max timegap is used as a ceiling for the desired jitter frames value.", "placeholder": "10", - "default": "10" + "default": "10", + "advanced": true }, { "name": "repetition_with_fade", "type": "checkbox", "label": "Repetition with Fade:", "help": "dropped frames and mixing during starves repeat the last frame, eventually fading to silence", - "default": false + "default": false, + "advanced": true }, { "name": "print_stream_stats", "type": "checkbox", "label": "Print Stream Stats:", "help": "audio upstream and downstream stats of each agent printed to audio-mixer stdout", - "default": false + "default": false, + "advanced": true } ] } From 3f67f6fae7563e849b8d190df805e6a0babeb95f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Oct 2014 17:09:10 -0700 Subject: [PATCH 10/11] hide panels if only advanced settings --- domain-server/resources/web/settings/index.shtml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/domain-server/resources/web/settings/index.shtml b/domain-server/resources/web/settings/index.shtml index bdbfdd02ad..598f137285 100644 --- a/domain-server/resources/web/settings/index.shtml +++ b/domain-server/resources/web/settings/index.shtml @@ -32,12 +32,16 @@ - +
From 0ae4392d0a266c3e505132a61a329e3256692abf Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Oct 2014 17:11:24 -0700 Subject: [PATCH 11/11] missing 's' --- domain-server/resources/describe-settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 3cee490bd0..1e3dc6321e 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -145,7 +145,7 @@ }, { "name": "audio_buffer", - "label": "Audio Buffer", + "label": "Audio Buffers", "assignment-types": [0], "settings": [ {
+/-
+/-
+/-