mirror of
https://github.com/overte-org/overte.git
synced 2025-06-16 14:20:20 +02:00
add a way to disble muted warning from audio panel.
fix positioning of warning. hide warning when removing timer.
This commit is contained in:
parent
d54d0280c2
commit
3ecd86caee
6 changed files with 155 additions and 56 deletions
|
@ -159,6 +159,19 @@ Rectangle {
|
||||||
onXChanged: rightMostInputLevelPos = x + width
|
onXChanged: rightMostInputLevelPos = x + width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: muteMic.spacing*2;
|
||||||
|
AudioControls.CheckBox {
|
||||||
|
spacing: muteMic.spacing
|
||||||
|
text: qsTr("Warn when muted");
|
||||||
|
checked: AudioScriptingInterface.warnWhenMuted;
|
||||||
|
onClicked: {
|
||||||
|
AudioScriptingInterface.warnWhenMuted = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.warnWhenMuted; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {}
|
Separator {}
|
||||||
|
|
|
@ -25,6 +25,7 @@ QString Audio::DESKTOP { "Desktop" };
|
||||||
QString Audio::HMD { "VR" };
|
QString Audio::HMD { "VR" };
|
||||||
|
|
||||||
Setting::Handle<bool> enableNoiseReductionSetting { QStringList { Audio::AUDIO, "NoiseReduction" }, true };
|
Setting::Handle<bool> enableNoiseReductionSetting { QStringList { Audio::AUDIO, "NoiseReduction" }, true };
|
||||||
|
Setting::Handle<bool> enableWarnWhenMutedSetting { QStringList { Audio::AUDIO, "WarnWhenMuted" }, true };
|
||||||
Setting::Handle<bool> mutedSetting { QStringList{ Audio::AUDIO, "MuteMicrophone" }, false };
|
Setting::Handle<bool> mutedSetting { QStringList{ Audio::AUDIO, "MuteMicrophone" }, false };
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,10 +40,12 @@ Audio::Audio() : _devices(_contextIsHMD) {
|
||||||
auto client = DependencyManager::get<AudioClient>().data();
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
connect(client, &AudioClient::muteToggled, this, &Audio::setMuted);
|
connect(client, &AudioClient::muteToggled, this, &Audio::setMuted);
|
||||||
connect(client, &AudioClient::noiseReductionChanged, this, &Audio::enableNoiseReduction);
|
connect(client, &AudioClient::noiseReductionChanged, this, &Audio::enableNoiseReduction);
|
||||||
|
connect(client, &AudioClient::warnWhenMutedChanged, this, &Audio::enableWarnWhenMuted);
|
||||||
connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged);
|
connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged);
|
||||||
connect(client, &AudioClient::inputVolumeChanged, this, &Audio::setInputVolume);
|
connect(client, &AudioClient::inputVolumeChanged, this, &Audio::setInputVolume);
|
||||||
connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged);
|
connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged);
|
||||||
enableNoiseReduction(enableNoiseReductionSetting.get());
|
enableNoiseReduction(enableNoiseReductionSetting.get());
|
||||||
|
enableWarnWhenMuted(enableWarnWhenMutedSetting.get());
|
||||||
onContextChanged();
|
onContextChanged();
|
||||||
setMuted(mutedSetting.get());
|
setMuted(mutedSetting.get());
|
||||||
}
|
}
|
||||||
|
@ -109,6 +112,28 @@ void Audio::enableNoiseReduction(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Audio::warnWhenMutedEnabled() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _enableWarnWhenMuted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::enableWarnWhenMuted(bool enable) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_enableWarnWhenMuted != enable) {
|
||||||
|
_enableWarnWhenMuted = enable;
|
||||||
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
|
QMetaObject::invokeMethod(client, "setWarnWhenMuted", Q_ARG(bool, enable), Q_ARG(bool, false));
|
||||||
|
enableWarnWhenMutedSetting.set(enable);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (changed) {
|
||||||
|
emit warnWhenMutedChanged(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float Audio::getInputVolume() const {
|
float Audio::getInputVolume() const {
|
||||||
return resultWithReadLock<bool>([&] {
|
return resultWithReadLock<bool>([&] {
|
||||||
return _inputVolume;
|
return _inputVolume;
|
||||||
|
|
|
@ -58,6 +58,7 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
||||||
|
|
||||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||||
Q_PROPERTY(bool noiseReduction READ noiseReductionEnabled WRITE enableNoiseReduction NOTIFY noiseReductionChanged)
|
Q_PROPERTY(bool noiseReduction READ noiseReductionEnabled WRITE enableNoiseReduction NOTIFY noiseReductionChanged)
|
||||||
|
Q_PROPERTY(bool warnWhenMuted READ warnWhenMutedEnabled WRITE enableWarnWhenMuted NOTIFY warnWhenMutedChanged)
|
||||||
Q_PROPERTY(float inputVolume READ getInputVolume WRITE setInputVolume NOTIFY inputVolumeChanged)
|
Q_PROPERTY(float inputVolume READ getInputVolume WRITE setInputVolume NOTIFY inputVolumeChanged)
|
||||||
Q_PROPERTY(float inputLevel READ getInputLevel NOTIFY inputLevelChanged)
|
Q_PROPERTY(float inputLevel READ getInputLevel NOTIFY inputLevelChanged)
|
||||||
Q_PROPERTY(bool clipping READ isClipping NOTIFY clippingChanged)
|
Q_PROPERTY(bool clipping READ isClipping NOTIFY clippingChanged)
|
||||||
|
@ -75,6 +76,7 @@ public:
|
||||||
|
|
||||||
bool isMuted() const;
|
bool isMuted() const;
|
||||||
bool noiseReductionEnabled() const;
|
bool noiseReductionEnabled() const;
|
||||||
|
bool warnWhenMutedEnabled() const;
|
||||||
float getInputVolume() const;
|
float getInputVolume() const;
|
||||||
float getInputLevel() const;
|
float getInputLevel() const;
|
||||||
bool isClipping() const;
|
bool isClipping() const;
|
||||||
|
@ -201,6 +203,14 @@ signals:
|
||||||
*/
|
*/
|
||||||
void noiseReductionChanged(bool isEnabled);
|
void noiseReductionChanged(bool isEnabled);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when "warn when muted" is enabled or disabled.
|
||||||
|
* @function Audio.warnWhenMutedChanged
|
||||||
|
* @param {boolean} isEnabled - <code>true</code> if "warn when muted" is enabled, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void warnWhenMutedChanged(bool isEnabled);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the input audio volume changes.
|
* Triggered when the input audio volume changes.
|
||||||
* @function Audio.inputVolumeChanged
|
* @function Audio.inputVolumeChanged
|
||||||
|
@ -248,6 +258,7 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void setMuted(bool muted);
|
void setMuted(bool muted);
|
||||||
void enableNoiseReduction(bool enable);
|
void enableNoiseReduction(bool enable);
|
||||||
|
void enableWarnWhenMuted(bool enable);
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
void onInputLoudnessChanged(float loudness, bool isClipping);
|
void onInputLoudnessChanged(float loudness, bool isClipping);
|
||||||
|
|
||||||
|
@ -262,6 +273,7 @@ private:
|
||||||
bool _isClipping { false };
|
bool _isClipping { false };
|
||||||
bool _isMuted { false };
|
bool _isMuted { false };
|
||||||
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
|
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
|
||||||
|
bool _enableWarnWhenMuted { true };
|
||||||
bool _contextIsHMD { false };
|
bool _contextIsHMD { false };
|
||||||
AudioDevices* getDevices() { return &_devices; }
|
AudioDevices* getDevices() { return &_devices; }
|
||||||
AudioDevices _devices;
|
AudioDevices _devices;
|
||||||
|
|
|
@ -1531,6 +1531,14 @@ void AudioClient::setNoiseReduction(bool enable, bool emitSignal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioClient::setWarnWhenMuted(bool enable, bool emitSignal) {
|
||||||
|
if (_warnWhenMuted != enable) {
|
||||||
|
_warnWhenMuted = enable;
|
||||||
|
if (emitSignal) {
|
||||||
|
emit warnWhenMutedChanged(_warnWhenMuted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AudioClient::setIsStereoInput(bool isStereoInput) {
|
bool AudioClient::setIsStereoInput(bool isStereoInput) {
|
||||||
bool stereoInputChanged = false;
|
bool stereoInputChanged = false;
|
||||||
|
|
|
@ -210,6 +210,9 @@ public slots:
|
||||||
void setNoiseReduction(bool isNoiseGateEnabled, bool emitSignal = true);
|
void setNoiseReduction(bool isNoiseGateEnabled, bool emitSignal = true);
|
||||||
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }
|
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }
|
||||||
|
|
||||||
|
void setWarnWhenMuted(bool isNoiseGateEnabled, bool emitSignal = true);
|
||||||
|
bool isWarnWhenMutedEnabled() const { return _warnWhenMuted; }
|
||||||
|
|
||||||
bool getLocalEcho() { return _shouldEchoLocally; }
|
bool getLocalEcho() { return _shouldEchoLocally; }
|
||||||
void setLocalEcho(bool localEcho) { _shouldEchoLocally = localEcho; }
|
void setLocalEcho(bool localEcho) { _shouldEchoLocally = localEcho; }
|
||||||
void toggleLocalEcho() { _shouldEchoLocally = !_shouldEchoLocally; }
|
void toggleLocalEcho() { _shouldEchoLocally = !_shouldEchoLocally; }
|
||||||
|
@ -246,6 +249,7 @@ signals:
|
||||||
void inputVolumeChanged(float volume);
|
void inputVolumeChanged(float volume);
|
||||||
void muteToggled(bool muted);
|
void muteToggled(bool muted);
|
||||||
void noiseReductionChanged(bool noiseReductionEnabled);
|
void noiseReductionChanged(bool noiseReductionEnabled);
|
||||||
|
void warnWhenMutedChanged(bool warnWhenMutedEnabled);
|
||||||
void mutedByMixer();
|
void mutedByMixer();
|
||||||
void inputReceived(const QByteArray& inputSamples);
|
void inputReceived(const QByteArray& inputSamples);
|
||||||
void inputLoudnessChanged(float loudness, bool isClipping);
|
void inputLoudnessChanged(float loudness, bool isClipping);
|
||||||
|
@ -365,6 +369,7 @@ private:
|
||||||
bool _shouldEchoLocally;
|
bool _shouldEchoLocally;
|
||||||
bool _shouldEchoToServer;
|
bool _shouldEchoToServer;
|
||||||
bool _isNoiseGateEnabled;
|
bool _isNoiseGateEnabled;
|
||||||
|
bool _warnWhenMuted;
|
||||||
|
|
||||||
bool _reverb;
|
bool _reverb;
|
||||||
AudioEffectOptions _scriptReverbOptions;
|
AudioEffectOptions _scriptReverbOptions;
|
||||||
|
|
|
@ -19,33 +19,44 @@
|
||||||
|
|
||||||
var lastInputLoudness = 0.0;
|
var lastInputLoudness = 0.0;
|
||||||
var sampleRate = 8.0; // Hz
|
var sampleRate = 8.0; // Hz
|
||||||
var attackTC = Math.exp(-1.0 / (sampleRate * 0.500)) // 500 milliseconds attack
|
var attackTC = Math.exp(-1.0 / (sampleRate * 0.500)); // 500 milliseconds attack
|
||||||
var releaseTC = Math.exp(-1.0 / (sampleRate * 1.000)) // 1000 milliseconds release
|
var releaseTC = Math.exp(-1.0 / (sampleRate * 1.000)); // 1000 milliseconds release
|
||||||
var holdReset = 2.0 * sampleRate; // 2 seconds hold
|
var holdReset = 2.0 * sampleRate; // 2 seconds hold
|
||||||
var holdCount = 0;
|
var holdCount = 0;
|
||||||
var warningOverlayID = null;
|
var warningOverlayID = null;
|
||||||
|
var pollInterval = null;
|
||||||
|
var warningText = "Muted";
|
||||||
|
var textDimensions = { x: 100, y: 50 };
|
||||||
|
|
||||||
function showWarning() {
|
function showWarning() {
|
||||||
if (warningOverlayID) {
|
if (warningOverlayID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
warningOverlayID = Overlays.addOverlay("text3d", {
|
|
||||||
|
var windowWidth;
|
||||||
|
var windowHeight;
|
||||||
|
if (HMD.active) {
|
||||||
|
var viewportDimension = Controller.getViewportDimensions();
|
||||||
|
windowWidth = viewportDimension.x;
|
||||||
|
windowHeight = viewportDimension.y;
|
||||||
|
} else {
|
||||||
|
windowWidth = Window.innerWidth;
|
||||||
|
windowHeight = Window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
warningOverlayID = Overlays.addOverlay("text", {
|
||||||
name: "Muted-Warning",
|
name: "Muted-Warning",
|
||||||
localPosition: { x: 0.2, y: -0.35, z: -1.0 },
|
font: { size: 36 },
|
||||||
localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 0.0, z: 0.0, w: 1.0 }),
|
text: warningText,
|
||||||
text: "Warning: you are muted",
|
x: windowWidth / 2 - textDimensions.x / 2,
|
||||||
textAlpha: 1,
|
y: windowHeight / 2 - textDimensions.y / 2,
|
||||||
color: { red: 226, green: 51, blue: 77 },
|
width: textDimensions.x,
|
||||||
|
height: textDimensions.y,
|
||||||
|
textColor: { red: 226, green: 51, blue: 77 },
|
||||||
backgroundAlpha: 0,
|
backgroundAlpha: 0,
|
||||||
lineHeight: 0.042,
|
visible: true
|
||||||
visible: true,
|
|
||||||
ignoreRayIntersection: true,
|
|
||||||
drawInFront: true,
|
|
||||||
grabbable: false,
|
|
||||||
parentID: MyAvatar.SELF_ID,
|
|
||||||
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX")
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
function hideWarning() {
|
function hideWarning() {
|
||||||
if (!warningOverlayID) {
|
if (!warningOverlayID) {
|
||||||
|
@ -55,20 +66,17 @@
|
||||||
warningOverlayID = null;
|
warningOverlayID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function startPoll() {
|
||||||
Overlays.deleteOverlay(warningOverlayID);
|
if (pollInterval) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
pollInterval = Script.setInterval(function() {
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
||||||
|
|
||||||
Script.setInterval(function() {
|
|
||||||
|
|
||||||
var inputLoudness = Audio.inputLevel;
|
var inputLoudness = Audio.inputLevel;
|
||||||
var tc = (inputLoudness > lastInputLoudness) ? attackTC : releaseTC;
|
var tc = (inputLoudness > lastInputLoudness) ? attackTC : releaseTC;
|
||||||
inputLoudness += tc * (lastInputLoudness - inputLoudness);
|
inputLoudness += tc * (lastInputLoudness - inputLoudness);
|
||||||
lastInputLoudness = inputLoudness;
|
lastInputLoudness = inputLoudness;
|
||||||
|
|
||||||
if (Audio.muted && inputLoudness > 0.3) {
|
if (inputLoudness > 0.1) {
|
||||||
holdCount = holdReset;
|
holdCount = holdReset;
|
||||||
} else {
|
} else {
|
||||||
holdCount = Math.max(holdCount - 1, 0);
|
holdCount = Math.max(holdCount - 1, 0);
|
||||||
|
@ -80,5 +88,33 @@
|
||||||
hideWarning();
|
hideWarning();
|
||||||
}
|
}
|
||||||
}, 1000.0 / sampleRate);
|
}, 1000.0 / sampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopPoll() {
|
||||||
|
if (!pollInterval) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Script.clearInterval(pollInterval);
|
||||||
|
pollInterval = null;
|
||||||
|
hideWarning();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startOrStopPoll() {
|
||||||
|
if (Audio.warnWhenMuted && Audio.muted) {
|
||||||
|
startPoll();
|
||||||
|
} else {
|
||||||
|
stopPoll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
stopPoll();
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
|
startOrStopPoll();
|
||||||
|
Audio.mutedChanged.connect(startOrStopPoll);
|
||||||
|
Audio.warnWhenMutedChanged.connect(startOrStopPoll);
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue