Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keystrokes to adjust applications volume and mute #16273

Merged
merged 29 commits into from
Apr 16, 2024

Conversation

mltony
Copy link
Contributor

@mltony mltony commented Mar 7, 2024

Link to issue number:

Closes #16052.

Summary of the issue:

Needd commands to adjust volume of all applications other than NVDA.

Description of user facing changes

Adding commands to adjust volume of all applications other than NVDA bound to nvda+alt+pageUp/pageDown.
Also adding a command to mute all applications other than NVDA bound to nvda+alt+delete.
Also adding corresponding settings to audio panel.

Description of development approach

Making use of sound split code - we already have code to set volume of all other apps, but it's only used to mute left or right channel. Reusing same code to adjust volume as well.

Testing strategy:

Tested manually.

Known issues with pull request:

N/A

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@AppVeyorBot
Copy link

See test results for failed build of commit dd9a25b6f1

@amirsol81
Copy link

@mltony Thanks for implementing these highly requested items. One note, though:
NVDA+ALT+PageUp and PageDown are already used by NVDA Remote and Tele NVDA. I suggest SHIFT+NVDA+PageUp and PageDown.

@CyrilleB79
Copy link
Collaborator

@mltony have you tested this feature in combination with Sound split feature?
E.g. Split sound, change volume, then unsplit sound, etc.

@amirsol81 we may consider key conflicts with very popular add-ons, but remember that at the end NVDA may be favoured and the add-ons need to adapt if there is no other acceptable gesture found for NVDA.
The gestures you suggest are already used in NVDA laptop layout.

@cary-rowen
Copy link
Contributor

Hi @mltony

Demands related to volume adjustment and audio device control are very popular.

So @huaiyinfeilong from the Chinese community developed the Audio Manager add-on.

There are several features that we consider indispensable.

  1. Set an audio output/input device as the system default playback/recording device. This allows users with multiple sound cards to freely manage their devices in different situations.
  2. Set up output/input devices for different applications, for example I can set the browser's output device to a connected bluetooth speaker and keep the screen reader on the laptop speaker since bluetooth devices have higher latency.

Maybe you or others can get some inspiration from it.

Thanks
Cary

@CyrilleB79
Copy link
Collaborator

@cary-rowen, the volume adjustment and muting of other apps as presented and implemented by @mltony has already been triaged (validated) by NV Access and already fulfills the need of many users.

I understand that some users may need more specific features as described by you. I'd recommend to discuss this in a specific issue rather than in this PR. I think that there is already one opened, but if not, you can open a new one.

If your issue is accepted (triaged), it may be implemented in a subsequent PR and maybe Tony is willing to do this. If it is rejected as a core feature because considered to target too few users, you still can ask the imploementation of a clean interface (specific functions, extension points, etc.) to ease the interfacing of the add-on (e.g. no patch).

@cary-rowen
Copy link
Contributor

@CyrilleB79
I'll try creating a Feature Request to see if anyone else is interested.

@mltony
Copy link
Contributor Author

mltony commented Mar 7, 2024

@amirsol81,
Happy to change to whatever keystrokes people agree upon. But I think Sean is likely to ask me to remove default keystrokes all together.

@CyrilleB79

have you tested this feature in combination with Sound split feature?

Yes, both features use the same codepath, there are no issues as far as I can see.

@cary-rowen
I personally don't see Audio Manager being useful for myself - I don't switch audio devices often. But I agree if there is enough demand - the question of including this into core can be raised. Also I looked at its github repo - it seems to be using a lot of native code for which I couldn't easily find source code - so you might have to contact the author if he is willing to do the job himself.

@mltony mltony marked this pull request as ready for review March 7, 2024 19:16
@mltony mltony requested review from a team as code owners March 7, 2024 19:16
Copy link
Collaborator

@CyrilleB79 CyrilleB79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this very useful PR.

Here is my feedback. Except for English grammar, let me know if you find some remark not relevant and why.

Also I have two open questions that I'll ask separately so that it can be discussed out of this review.

user_docs/en/changes.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
==== Mute other applications ====[MuteApplications]

This checkbox allows to mute all applications other than NVDA.
If any new applications start to output sound, their sound output will also be muted.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous paragraph; feel free to accept or decline.

Suggested change
If any new applications start to output sound, their sound output will also be muted.
If any new applications start to output sound, its sound output will also be muted.

source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
@CyrilleB79
Copy link
Collaborator

CyrilleB79 commented Mar 8, 2024

Three more general questions regarding the user experience.

  1. I understand that Other apps volume is stored in the config, so that the preferred volume can be memorized for subsequent runs of NVDA.
    On the contrary, memorizing the mute other apps in the config seems useless to me and even risky:
  • if a user mutes other apps without noticing, e.g. when no other sound is played, and then the config is saved, we may end up with bug reports such as "NVDA breaks the audio of other applications"
  • Is there a use case to memorize the mute state in the config? I imagine mute as a temporary feature, but no one with the other apps sound muted permanently.
  1. The original sound level is not restored when NVDA exits. Is it on purpose?
    Note that I have no strong opinion on this topic, but it seems quite strange to have on one hand this volume set when NVDA start but not restored when it exits.
    IMO:
  • either the volume should not be stored at all in the config and the shortcuts would only allow to permanently modify the volume which remains as is when NVDA exits, or when NVDA's config is reset (NVDA+control+R)
  • or the volume is stored in the config and it is set when NVDA starts, exits or its config is restored (NVDA+control+R)

What is the link with the volumes in the Windows volume mixer?

@cary-rowen
Copy link
Contributor

Sorry, I haven't tested this yet, but I saw @CyrilleB79's comment and I felt the need to give my opinion:

Imo, adjusting the volume of other applications should be in sync with the system's volume synthesizer, whether it is mute state or volume, and conversely, when the user adjusts the volume or mute state of an app using the system volume synthesizer, NVDA should also Reflect this.

Regarding what I call "system volume synthesizer", you can find it by pressing Win+B to find the speaker icon, pressing the Application key to pop up the menu, or open a similar application volume management by executing the settings URI in the run dialog(ms-settings:apps-volume).

The AudioManager add-on I mentioned in my previous comment does this. Doing this ensures a consistent user experience.

I'll test this PR later and if there's anything I've misunderstood in the above comment I'll collapse it.

Thanks
Cary

Copy link
Collaborator

@XLTechie XLTechie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some responses to @CyrilleB79's suggestions, and a few of my own.

user_docs/en/changes.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
@XLTechie
Copy link
Collaborator

XLTechie commented Mar 8, 2024 via email

@CyrilleB79
Copy link
Collaborator

(apart from me still not being sure why sndvol.exe or other Windows methods are insufficient for this purpose):

Because when you open a video (or an add) on internet, if the volume is too loud with respect to NVDA, it will be difficult to go to sndvol.exe and find the slider or the checkbox of your browser to lower or mute the volume of your browser.
Could you explain how you manage this situation?

I agree that if possible, interacting with Windows mixer's volumes would be better.

@codeofdusk
Copy link
Contributor

Because when you open a video (or an add) on internet, if the volume is too loud with respect to NVDA, it will be difficult to go to sndvol.exe and find the slider or the checkbox of your browser

In this situation, I use NVDA+Shift+d to duck down that audio, then adjust if needed.

mltony and others added 9 commits March 8, 2024 11:10
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Luke Davis <8139760+XLTechie@users.noreply.github.com>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
@seanbudd seanbudd marked this pull request as draft March 14, 2024 04:43
mltony and others added 5 commits March 16, 2024 11:05
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
@mltony
Copy link
Contributor Author

mltony commented Mar 16, 2024

@CyrilleB79,

memorizing the mute other apps in the config seems useless to me

I changed this; now I restore muted to False at startup.

The original sound level is not restored when NVDA exits.

Fixed

What is the link with the volumes in the Windows volume mixer?

In my understanding there is no link. My guess is that the volume in volume mixer can be adjusted using ISimpleAudioVolume interface and we're using IChannelAudioVolume. But I haven't tested this hypothesis.

mltony and others added 5 commits March 16, 2024 13:30
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@mltony mltony marked this pull request as ready for review March 16, 2024 20:32
@XLTechie
Copy link
Collaborator

XLTechie commented Mar 18, 2024 via email

@seanbudd
Copy link
Member

Thanks @mltony - can you reserve merge conflicts?

Copy link
Member

@Qchristensen Qchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Apr 16, 2024
@seanbudd seanbudd merged commit 275ab4d into nvaccess:master Apr 16, 2024
1 check passed
@nvaccessAuto nvaccessAuto added this to the 2024.2 milestone Apr 16, 2024
seanbudd added a commit that referenced this pull request Apr 23, 2024
seanbudd added a commit that referenced this pull request May 10, 2024
Reverts PR
Reverts #16273

Issues fixed
Fixes #16409
Fixes #16402

Issues reopened
#16052

Brief reason for revert
We started with mltony creating:
#16051 Feature request: Sound split

Which was a duplicate of:
#12985 Audio settings with stereo headset (or speakers) - Send NVDA sounds on one side and the rest of Windows sounds on the other side

And then implemented by:
#16071 Sound split

mltony also created:
#16052 Feature request: add command to adjust volume of all applications except for NVDA

Which was implemented in:
#16273 Keystrokes to adjust applications volume and mute

This PR was approved and merged and was then found to cause issues:
#16402 Unmuting other apps does not work as expected
#16409 Apps mute and volume features work very unexpectedly with WASAPI disabled

Due to these issues and the considerable debate on the approach, the above PR #16273 was reverted by:
#16440

As an alternative to the revert #16440 to resolve the 2 issues (#16402, #16409) and keep #16273, mltony created:
#16404

The question now becomes, how do we proceed from here?

NV Access's position is that the sound split functionality (#16051) is a useful feature to add into core. However, due to the following reasons, we believe that further work on the volume adjustment features (#16273, #16404) to improve the UX is required on a branch (off master/alpha) before it can be added back in:

Windows sound mixer has reasonable accessibility.
Sound split on its own provides value to users.
The UX of swapping between NVDA volume control and windows volume control needs to be resolved.
The UX of resolving volume issues due to NVDA crashes needs to be resolved.
As one of the contributors on the threads said, "So now there are two mixers in the chain, one of which can be invisible, and overrides the other, or makes its settings relative instead of absolute."
seanbudd pushed a commit that referenced this pull request Sep 3, 2024
Closes #16052.
Please note that this is my second attempt to implement this. The first attempt was #16273 which was reverted in #16440# by commit f63841f.

Summary of the issue:
Provide a way to adjust volume of other applications, so that when using sound split the volume of aplications channel can be adjusted separately from NVDA volume.

Description of user facing changes
New keystrokes:

NVDA+alt+pageUp/pageDown adjusts volume of all other applications.
NVDA+alt+delete Cycles between three states
Disabled (default)
Enabled
Muted - all applications except NVDA will be muted
Description of development approach
I refactored sound split code. Sound split and applications volume adjustment need to use same callbacks in a similar fashion. In order to reduce code reduplication, I extracted common logic and put it in audio/utils.py. Now it provides an abstract class AudioSessionCallback and customers (sound split and app volume adjuster) are implementing this class. Two methods that need to be implemented are onSessionUpdate and onSessionTerminated, which operate on a single audio session. All the plumbing is hidden in utils.py so that clients don't need to worry about setting up and dealing with multiple lower-level callbacks.
Applications' voluem adjusting logic is implemented in audio/appsVolume.py and is quite straightforward now.
Volume and mute status are adjusted via ISimpleAudioVolume interface, which means that both are reflected in Windows Volume Mixer.
4.Initial volume and mute status of applications is storedand upon exit will be restored.
Applciation volume adjustment is now completely independent of sound split and both features can operate independently of each other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: add command to adjust volume of all applications except for NVDA