mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Update APIs and add Noise Reduction section to Audio app.
This commit is contained in:
parent
5a40007758
commit
085bf8423c
3 changed files with 195 additions and 43 deletions
|
@ -104,6 +104,11 @@ Rectangle {
|
||||||
AudioScriptingInterface.setSystemInjectorGain(sliderValue);
|
AudioScriptingInterface.setSystemInjectorGain(sliderValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function updateNoiseReductionThresholdFromQML(sliderValue) {
|
||||||
|
if (AudioScriptingInterface.getNoiseReductionThreshold() != sliderValue) {
|
||||||
|
AudioScriptingInterface.setNoiseReductionThreshold(sliderValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
enablePeakValues();
|
enablePeakValues();
|
||||||
|
@ -164,7 +169,7 @@ Rectangle {
|
||||||
x: 2 * margins.paddings;
|
x: 2 * margins.paddings;
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
// switch heights + 2 * top margins
|
// switch heights + 2 * top margins
|
||||||
height: (root.switchHeight) * 6 + 48;
|
height: (bar.currentIndex === 0) ? (root.switchHeight) * 2 + 48 : (root.switchHeight) * 4 + 48;
|
||||||
anchors.top: firstSeparator.bottom;
|
anchors.top: firstSeparator.bottom;
|
||||||
anchors.topMargin: 10;
|
anchors.topMargin: 10;
|
||||||
|
|
||||||
|
@ -175,6 +180,7 @@ Rectangle {
|
||||||
height: parent.height;
|
height: parent.height;
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
HifiControlsUit.Switch {
|
||||||
id: muteMic;
|
id: muteMic;
|
||||||
height: root.switchHeight;
|
height: root.switchHeight;
|
||||||
|
@ -193,45 +199,11 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
|
||||||
id: noiseReductionSwitch;
|
|
||||||
height: root.switchHeight;
|
|
||||||
switchWidth: root.switchWidth;
|
|
||||||
anchors.top: muteMic.bottom;
|
|
||||||
anchors.topMargin: 24
|
|
||||||
anchors.left: parent.left
|
|
||||||
labelTextOn: "Noise Reduction";
|
|
||||||
labelTextSize: 16;
|
|
||||||
backgroundOnColor: "#E3E3E3";
|
|
||||||
checked: AudioScriptingInterface.noiseReduction;
|
|
||||||
onCheckedChanged: {
|
|
||||||
AudioScriptingInterface.noiseReduction = checked;
|
|
||||||
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
|
||||||
id: acousticEchoCancellationSwitch;
|
|
||||||
height: root.switchHeight;
|
|
||||||
switchWidth: root.switchWidth;
|
|
||||||
anchors.top: noiseReductionSwitch.bottom
|
|
||||||
anchors.topMargin: 24
|
|
||||||
anchors.left: parent.left
|
|
||||||
labelTextOn: "Echo Cancellation";
|
|
||||||
labelTextSize: 16;
|
|
||||||
backgroundOnColor: "#E3E3E3";
|
|
||||||
checked: AudioScriptingInterface.acousticEchoCancellation;
|
|
||||||
onCheckedChanged: {
|
|
||||||
AudioScriptingInterface.acousticEchoCancellation = checked;
|
|
||||||
checked = Qt.binding(function() { return AudioScriptingInterface.acousticEchoCancellation; });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
HifiControlsUit.Switch {
|
||||||
id: pttSwitch
|
id: pttSwitch
|
||||||
height: root.switchHeight;
|
height: root.switchHeight;
|
||||||
switchWidth: root.switchWidth;
|
switchWidth: root.switchWidth;
|
||||||
anchors.top: acousticEchoCancellationSwitch.bottom;
|
anchors.top: muteMic.bottom;
|
||||||
anchors.topMargin: 24
|
anchors.topMargin: 24
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
labelTextOn: (bar.currentIndex === 0) ? qsTr("Push To Talk (T)") : qsTr("Push To Talk");
|
labelTextOn: (bar.currentIndex === 0) ? qsTr("Push To Talk (T)") : qsTr("Push To Talk");
|
||||||
|
@ -254,6 +226,7 @@ Rectangle {
|
||||||
height: parent.height;
|
height: parent.height;
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: switchContainer.right;
|
anchors.left: switchContainer.right;
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
HifiControlsUit.Switch {
|
||||||
id: warnMutedSwitch
|
id: warnMutedSwitch
|
||||||
height: root.switchHeight;
|
height: root.switchHeight;
|
||||||
|
@ -271,7 +244,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
HifiControlsUit.Switch {
|
||||||
id: audioLevelSwitch
|
id: audioLevelSwitch
|
||||||
height: root.switchHeight;
|
height: root.switchHeight;
|
||||||
|
@ -519,13 +491,181 @@ Rectangle {
|
||||||
anchors.top: systemInjectorGainContainer.bottom;
|
anchors.top: systemInjectorGainContainer.bottom;
|
||||||
anchors.topMargin: 10;
|
anchors.topMargin: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: noiseReductionHeader
|
||||||
|
x: margins.paddings;
|
||||||
|
width: parent.width - margins.paddings*2;
|
||||||
|
height: 36;
|
||||||
|
anchors.top: secondSeparator.bottom;
|
||||||
|
anchors.topMargin: 10;
|
||||||
|
|
||||||
|
HiFiGlyphs {
|
||||||
|
width: margins.sizeCheckBox;
|
||||||
|
text: hifi.glyphs.mic;
|
||||||
|
color: hifi.colors.white;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: -size/4; //the glyph has empty space at left about 25%
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
size: 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewayRegular {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
width: margins.sizeText + margins.sizeLevel;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: margins.sizeCheckBox;
|
||||||
|
size: 22;
|
||||||
|
color: hifi.colors.white;
|
||||||
|
text: qsTr("Noise Reduction");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: noiseReductionSwitches;
|
||||||
|
x: 2 * margins.paddings;
|
||||||
|
width: parent.width;
|
||||||
|
// switch heights + 2 * top margins
|
||||||
|
height: (root.switchHeight) * 5 + 48;
|
||||||
|
anchors.top: noiseReductionHeader.bottom;
|
||||||
|
anchors.topMargin: 0;
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: noiseReductionSwitchContainer;
|
||||||
|
x: margins.paddings;
|
||||||
|
width: parent.width / 2;
|
||||||
|
height: parent.height;
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: acousticEchoCancellationSwitch;
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
anchors.top: noiseReductionSwitchContainer.top
|
||||||
|
anchors.topMargin: 24
|
||||||
|
anchors.left: parent.left
|
||||||
|
labelTextOn: "Echo Cancellation";
|
||||||
|
labelTextSize: 16;
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AudioScriptingInterface.acousticEchoCancellation;
|
||||||
|
onCheckedChanged: {
|
||||||
|
AudioScriptingInterface.acousticEchoCancellation = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.acousticEchoCancellation; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: noiseReductionSwitch;
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
anchors.top: acousticEchoCancellationSwitch.bottom;
|
||||||
|
anchors.topMargin: 24
|
||||||
|
anchors.left: parent.left
|
||||||
|
labelTextOn: "Noise Reduction";
|
||||||
|
labelTextSize: 16;
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AudioScriptingInterface.noiseReduction;
|
||||||
|
onCheckedChanged: {
|
||||||
|
AudioScriptingInterface.noiseReduction = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: noiseReductionAutomaticSwitch;
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
anchors.top: noiseReductionSwitch.bottom;
|
||||||
|
anchors.topMargin: 24;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
labelTextOn: "Noise Reduction: Manual/Automatic";
|
||||||
|
labelTextSize: 16;
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AudioScriptingInterface.noiseReductionAutomatic;
|
||||||
|
onCheckedChanged: {
|
||||||
|
AudioScriptingInterface.noiseReductionAutomatic = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReductionAutomatic; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: noiseReductionThresholdContainer
|
||||||
|
x: margins.paddings;
|
||||||
|
anchors.top: noiseReductionSwitches.bottom;
|
||||||
|
anchors.topMargin: 16;
|
||||||
|
width: parent.width - margins.paddings*2;
|
||||||
|
height: avatarGainSliderTextMetrics.height;
|
||||||
|
visible: AudioScriptingInterface.noiseReductionAutomatic !== true;
|
||||||
|
|
||||||
|
HifiControlsUit.Slider {
|
||||||
|
id: noiseReductionThresholdSlider
|
||||||
|
anchors.right: parent.right
|
||||||
|
height: parent.height
|
||||||
|
width: 200
|
||||||
|
minimumValue: 0.0
|
||||||
|
maximumValue: 1.0
|
||||||
|
stepSize: 0.1
|
||||||
|
value: AudioScriptingInterface.getNoiseReductionThreshold()
|
||||||
|
onValueChanged: {
|
||||||
|
updateNoiseReductionThresholdFromQML(value);
|
||||||
|
}
|
||||||
|
onPressedChanged: {
|
||||||
|
if (!pressed) {
|
||||||
|
updateNoiseReductionThresholdFromQML(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
onDoubleClicked: {
|
||||||
|
noiseReductionThresholdSlider.value = 0.0
|
||||||
|
}
|
||||||
|
onPressed: {
|
||||||
|
// Pass through to Slider
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
// the above mouse.accepted seems to make this
|
||||||
|
// never get called, nonetheless...
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextMetrics {
|
||||||
|
id: noiseReductionThresholdSliderTextMetrics
|
||||||
|
text: noiseReductionThresholdSliderText.text
|
||||||
|
font: noiseReductionThresholdSliderText.font
|
||||||
|
}
|
||||||
|
RalewayRegular {
|
||||||
|
// The slider for my card is special, it controls the master gain
|
||||||
|
id: noiseReductionThresholdSliderText;
|
||||||
|
text: "Audio input threshold";
|
||||||
|
size: 16;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
color: hifi.colors.white;
|
||||||
|
horizontalAlignment: Text.AlignLeft;
|
||||||
|
verticalAlignment: Text.AlignTop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Separator {
|
||||||
|
id: thirdSeparator;
|
||||||
|
anchors.top: noiseReductionThresholdContainer.bottom;
|
||||||
|
anchors.topMargin: 14;
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: inputDeviceHeader
|
id: inputDeviceHeader
|
||||||
x: margins.paddings;
|
x: margins.paddings;
|
||||||
width: parent.width - margins.paddings*2;
|
width: parent.width - margins.paddings*2;
|
||||||
height: 36;
|
height: 36;
|
||||||
anchors.top: secondSeparator.bottom;
|
anchors.top: thirdSeparator.bottom;
|
||||||
anchors.topMargin: 10;
|
anchors.topMargin: 10;
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
|
@ -609,7 +749,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {
|
Separator {
|
||||||
id: thirdSeparator;
|
id: fourthSeparator;
|
||||||
anchors.top: inputView.bottom;
|
anchors.top: inputView.bottom;
|
||||||
anchors.topMargin: 10;
|
anchors.topMargin: 10;
|
||||||
}
|
}
|
||||||
|
@ -617,7 +757,7 @@ Rectangle {
|
||||||
Item {
|
Item {
|
||||||
id: outputDeviceHeader;
|
id: outputDeviceHeader;
|
||||||
anchors.topMargin: 10;
|
anchors.topMargin: 10;
|
||||||
anchors.top: thirdSeparator.bottom;
|
anchors.top: fourthSeparator.bottom;
|
||||||
x: margins.paddings;
|
x: margins.paddings;
|
||||||
width: parent.width - margins.paddings*2
|
width: parent.width - margins.paddings*2
|
||||||
height: 36
|
height: 36
|
||||||
|
|
|
@ -314,7 +314,7 @@ void Audio::enableNoiseReductionAutomatic(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Audio::getNoiseReductionThreshold() const {
|
float Audio::getNoiseReductionThreshold() {
|
||||||
return resultWithReadLock<float>([&] {
|
return resultWithReadLock<float>([&] {
|
||||||
return _noiseReductionThreshold;
|
return _noiseReductionThreshold;
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,7 +127,6 @@ public:
|
||||||
bool isMuted() const;
|
bool isMuted() const;
|
||||||
bool noiseReductionEnabled() const;
|
bool noiseReductionEnabled() const;
|
||||||
bool noiseReductionAutomatic() const;
|
bool noiseReductionAutomatic() const;
|
||||||
float getNoiseReductionThreshold() const;
|
|
||||||
bool warnWhenMutedEnabled() const;
|
bool warnWhenMutedEnabled() const;
|
||||||
bool acousticEchoCancellationEnabled() const;
|
bool acousticEchoCancellationEnabled() const;
|
||||||
float getInputVolume() const;
|
float getInputVolume() const;
|
||||||
|
@ -274,6 +273,20 @@ public:
|
||||||
* @returns {number} The injector gain (dB) in the client.
|
* @returns {number} The injector gain (dB) in the client.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE float getSystemInjectorGain();
|
Q_INVOKABLE float getSystemInjectorGain();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Sets the noise gate threshold before your mic audio is transmitted. (Applies only if Audio.noiseReductionAutomatic is off.)
|
||||||
|
* @function Audio.setNoiseReductionThreshold
|
||||||
|
* @param {number} threshold - The level that your input must surpass to be transmitted. (0 - 1.0)
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void setNoiseReductionThreshold(float threshold);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Gets the noise reduction threshold.
|
||||||
|
* @function Audio.getNoiseReductionThreshold
|
||||||
|
* @returns {number} The noise reduction threshold. (0 - 1.0)
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE float getNoiseReductionThreshold();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format.
|
* Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format.
|
||||||
|
@ -535,7 +548,6 @@ private slots:
|
||||||
void setMuted(bool muted);
|
void setMuted(bool muted);
|
||||||
void enableNoiseReduction(bool enable);
|
void enableNoiseReduction(bool enable);
|
||||||
void enableNoiseReductionAutomatic(bool enable);
|
void enableNoiseReductionAutomatic(bool enable);
|
||||||
void setNoiseReductionThreshold(float threshold);
|
|
||||||
void enableWarnWhenMuted(bool enable);
|
void enableWarnWhenMuted(bool enable);
|
||||||
void enableAcousticEchoCancellation(bool enable);
|
void enableAcousticEchoCancellation(bool enable);
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
|
|
Loading…
Reference in a new issue