From a253d5abecb18f9ae9b63dd76ca0033efb72918d Mon Sep 17 00:00:00 2001 From: ykeara Date: Fri, 21 Dec 2018 13:04:11 -0600 Subject: [PATCH] Added Audio Profiles --- advancedSettings.pro | 6 +- src/tabcontrollers/AudioTabController.cpp | 113 ++++++++++++++++++++-- src/tabcontrollers/AudioTabController.h | 2 - 3 files changed, 106 insertions(+), 15 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index c385302..dacff55 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -57,8 +57,7 @@ SOURCES += src/main.cpp\ src/tabcontrollers/UtilitiesTabController.cpp \ src/utils/ChaperoneUtils.cpp \ src/main.cpp \ - src/overlaycontroller.cpp \ - src/tabcontrollers/AudioProfileController.cpp + src/overlaycontroller.cpp HEADERS += src/overlaycontroller.h \ src/logging.h \ @@ -108,8 +107,7 @@ HEADERS += src/overlaycontroller.h \ third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_driver.h \ third-party/openvr/headers/openvr.h \ third-party/openvr/headers/openvr_capi.h \ - third-party/openvr/headers/openvr_driver.h \ - src/tabcontrollers/AudioProfileController.h + third-party/openvr/headers/openvr_driver.h win32 { SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \ diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 1815a0f..788abdb 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -464,7 +464,8 @@ namespace advsettings { /*AUDIO PROFILE FUNCTIONS - The functions in this section pertain to saving the Audio settings. + The following section includes the code required to save and load Audio Profiles. + Saved Settings Include: Playback Device Mirror Device @@ -475,6 +476,19 @@ namespace advsettings { */ + /* + Name: reloadAudioProfiles + + Inputs: args: none + other: Reads audioProfiles setting from file + + + Output: return:none + other:none + + Description: Clears working copy, and reloads from Settings file. + + */ void AudioTabController::reloadAudioProfiles() { audioProfiles.clear(); auto settings = OverlayController::appSettings(); @@ -488,11 +502,28 @@ namespace advsettings { entry.playbackName = settings->value("playbackName").toString().toStdString(); entry.micName = settings->value("micName").toString().toStdString(); entry.mirrorName = settings->value("mirrorName").toString().toStdString(); + entry.micMute = settings->value("micMute", false).toBool(); + entry.mirrorMute = settings->value("mirrorMute", false).toBool(); + entry.mirrorVol = settings->value("mirrorVol", 0.0).toFloat(); + entry.micVol = settings->value("micVol", 1.0).toFloat(); } settings->endArray(); settings->endGroup(); } + /* + Name: saveAudioProfile + + Inputs: args: none + other: none + + + Output: return: none + other: Writes audioProfiles setting to file + + Description: saves a copy of the audio profiles from working to Settings file. + + */ void AudioTabController::saveAudioProfiles() { auto settings = OverlayController::appSettings(); settings->beginGroup(getSettingsName()); @@ -504,6 +535,10 @@ namespace advsettings { settings->setValue("playbackName", QString::fromStdString(p.playbackName)); settings->setValue("micName", QString::fromStdString(p.micName)); settings->setValue("mirrorName", QString::fromStdString(p.mirrorName)); + settings->setValue("micMute", p.micMute); + settings->setValue("mirrorMute", p.mirrorMute); + settings->setValue("micVol", p.micVol); + settings->setValue("mirrorVol", p.mirrorVol); i++; } settings->endArray(); @@ -512,6 +547,19 @@ namespace advsettings { + /* + Name: addAudioProfile + + Inputs: args: Qstring name - the name of the audio profile + other: none + + + Output: return: none + other: audioProfile to audioProfiles array + + Description: Creates an audioProfile, and adds it to the working copy of audioProfiles[] + + */ void AudioTabController::addAudioProfile(QString name) { AudioProfile* profile = nullptr; @@ -530,26 +578,74 @@ namespace advsettings { profile->playbackName = getPlaybackDeviceName(m_playbackDeviceIndex).toStdString(); profile->mirrorName = getPlaybackDeviceName(m_mirrorDeviceIndex).toStdString(); profile->micName = getRecordingDeviceName(m_recordingDeviceIndex).toStdString(); + profile->micMute = m_micMuted; + profile->mirrorMute = m_mirrorMuted; + profile->mirrorVol = m_mirrorVolume; + profile->micVol = m_micVolume; saveAudioProfiles(); OverlayController::appSettings()->sync(); emit audioProfilesUpdated(); } - //POSSIBLE TODO MIRROR/PLAYBACK SAME ON SWTICH + + /* + Name: applyAudioProfile + + Inputs: args: index - index of audioProfile in audioProfiles[] + other: audioProfile based on index + + + Output: return: none + other: none + + Description: Applies the required logic to activate the audio profile. + + */ + //TODO Remembers Mirror Volume when switching to main volume. void AudioTabController::applyAudioProfile(unsigned index) { if (index < audioProfiles.size()) { auto& profile = audioProfiles[index]; - setMirrorDeviceIndex(getMirrorIndex(profile.mirrorName), true); - setPlaybackDeviceIndex(getPlaybackIndex(profile.playbackName), true); + int mInd = getMirrorIndex(profile.mirrorName); + int pInd = getPlaybackIndex(profile.playbackName); + + //Needed to keep remembering when swtiching from mirror/main etc. + setMicMuted(false, false); + setMirrorMuted(false, false); + + if ((m_playbackDeviceIndex == mInd) && (m_mirrorDeviceIndex == pInd)) { + setMirrorDeviceIndex(-1, true); + } + if (m_playbackDeviceIndex == mInd) { + setPlaybackDeviceIndex(pInd, true); + setMirrorDeviceIndex(mInd, true); + } + else { + setMirrorDeviceIndex(mInd, true); + setPlaybackDeviceIndex(pInd, true); + } setMicDeviceIndex(getRecordingIndex(profile.micName), true); - //TODO apply logic here - //setPttShowNotification(profile.showNotification); - //reloadAudioProfiles(); + setMicMuted(profile.micMute, true); + setMirrorMuted(profile.mirrorMute, true); + setMicVolume(profile.micVol, true); + setMirrorVolume(profile.mirrorVol, true); } } + /* + Name: deleteAudioProfile + + Inputs: args: index - index of audioProfile in audioProfiles[] + other: audioProfile based on index + + + Output: return: none + other: none + + Description: Removes selected Audio Profile + + */ void AudioTabController::deleteAudioProfile(unsigned index) { if (index < audioProfiles.size()) { auto pos = audioProfiles.begin() + index; @@ -561,7 +657,6 @@ namespace advsettings { } - unsigned AudioTabController::getAudioProfileCount() { return (unsigned)audioProfiles.size(); } @@ -574,7 +669,7 @@ namespace advsettings { } /* - Function getPlaybackIndex, getRecordingIndex, and getMirrorIndex + Name: getPlaybackIndex, getRecordingIndex, and getMirrorIndex input: string, of microphone/playback device name output: integer for use In: setMicDeviceIndex(int,bool), setMirrorDeviceIndex(int,bool) setPlayBackDeviceIndex(int,bool) diff --git a/src/tabcontrollers/AudioTabController.h b/src/tabcontrollers/AudioTabController.h index 59d2cc6..acad6fa 100644 --- a/src/tabcontrollers/AudioTabController.h +++ b/src/tabcontrollers/AudioTabController.h @@ -22,8 +22,6 @@ namespace advsettings { float micVol = 0.0; bool micMute = false; bool mirrorMute = false; - //TODO all the settings!!! huehue - //bool showNotification = false; };