sticky mic meter / noise reduction

This commit is contained in:
Zach Pomerantz 2017-06-12 18:41:32 -04:00
parent 8dac83d3fe
commit b5dab39f83
3 changed files with 32 additions and 22 deletions

View file

@ -721,10 +721,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
}
});
auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>();
connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
audioThread->start();
auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>();
connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);
connect(audioIO.data(), &AudioClient::disconnected, audioScriptingInterface.data(), &AudioScriptingInterface::disconnected);
@ -743,8 +745,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(this, &Application::activeDisplayPluginChanged,
reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onChangedContext);
audioThread->start();
ResourceManager::init();
// Make sure we don't time out during slow operations at startup
updateHeartbeat();
@ -1932,6 +1932,7 @@ void Application::initializeUi() {
auto audio = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
connect(ai, &AvatarInputs::showAudioToolsChanged, audio, &scripting::Audio::onChangedMicMeter);
connect(audio, &scripting::Audio::changedMicMeter, ai, &AvatarInputs::setShowAudioTools);
ai->setShowAudioTools(audio->micMeterShown());
}
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {

View file

@ -20,14 +20,18 @@ using namespace scripting;
static const QString DESKTOP_CONTEXT { "Desktop" };
static const QString HMD_CONTEXT { "VR" };
static const QString AUDIO { "Audio" };
Setting::Handle<bool> enableNoiseReductionSetting { QStringList(AUDIO) << "NoiseReduction", true };
Setting::Handle<bool> showMicMeterSetting { QStringList(AUDIO) << "MicMeter", false };
Audio::Audio() {
auto client = DependencyManager::get<AudioClient>();
connect(client.data(), &AudioClient::muteToggled, this, &Audio::onChangedMuted);
connect(&_devices._inputs, &AudioDeviceList::deviceChanged, this, &Audio::onInputChanged);
// TODO: make noise reduction sticky
// TODO: make mic meter sticky (need to reinitialize in AvatarInputs)
enableNoiseReduction(enableNoiseReductionSetting.get());
_showMicMeter = showMicMeterSetting.get();
}
void Audio::setReverb(bool enable) {
@ -73,11 +77,14 @@ void Audio::setMuted(bool isMuted) {
}
void Audio::enableNoiseReduction(bool enable) {
auto client = DependencyManager::get<AudioClient>().data();
QMetaObject::invokeMethod(client, "setNoiseReduction", Qt::BlockingQueuedConnection, Q_ARG(bool, enable));
if (_enableNoiseReduction != enable) {
auto client = DependencyManager::get<AudioClient>().data();
QMetaObject::invokeMethod(client, "setNoiseReduction", Qt::BlockingQueuedConnection, Q_ARG(bool, enable));
_enableNoiseReduction = enable;
emit changedNoiseReduction(enable);
enableNoiseReductionSetting.set(enable);
_enableNoiseReduction = enable;
emit changedNoiseReduction(enable);
}
}
void Audio::onChangedMicMeter(bool show) {
@ -86,6 +93,7 @@ void Audio::onChangedMicMeter(bool show) {
void Audio::showMicMeter(bool show) {
if (_showMicMeter != show) {
showMicMeterSetting.set(show);
_showMicMeter = show;
emit changedMicMeter(show);
}

View file

@ -15,6 +15,7 @@
#include "AudioScriptingInterface.h"
#include "AudioDevices.h"
#include "AudioEffectOptions.h"
#include "SettingHandle.h"
namespace scripting {
@ -32,6 +33,17 @@ class Audio : public AudioScriptingInterface {
public:
virtual ~Audio() {}
bool isMuted() const { return _isMuted; }
bool noiseReductionEnabled() const { return _enableNoiseReduction; }
bool micMeterShown() const { return _showMicMeter; }
float getInputVolume() const { return _inputVolume; }
QString getContext() const;
void setMuted(bool muted);
void enableNoiseReduction(bool enable);
void showMicMeter(bool show);
void setInputVolume(float volume);
Q_INVOKABLE void setReverb(bool enable);
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
@ -53,21 +65,10 @@ protected:
Audio();
private:
bool isMuted() const { return _isMuted; }
bool noiseReductionEnabled() const { return _enableNoiseReduction; }
bool micMeterShown() const { return _showMicMeter; }
float getInputVolume() const { return _inputVolume; }
QString getContext() const;
void setMuted(bool muted);
void enableNoiseReduction(bool enable);
void showMicMeter(bool show);
void setInputVolume(float volume);
float _inputVolume { 1.0f };
bool _isMuted { false };
bool _enableNoiseReduction { true };
bool _showMicMeter { false };
bool _enableNoiseReduction;
bool _showMicMeter;
bool _contextIsHMD { false };
AudioDevices* getDevices() { return &_devices; }