Repository: nvaccess/nvda

Issue:
win10-14986 nvda next latest build, audio ducking not working
hello.

please test if you also are experiencng this problem, i have only one device for this time and cannot test on other.

audioducking is not working for me.


Discussion:
Can you give us a log?

Also, in your config, file (NVDA.ini) put


there's a way to enable audio ducking support. Not sure if its in the wikki.

there is no error.

so, always duck and duck when outputting speech and sounds behaviour is the same.
@Josephsl


On 12/27/2016 8:23 PM, beqa gozalishvili wrote:
>
> there is no error.
>
> on option always duck, audio is ducked for several milliseconds and 
> then restored again.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub 
> <https://github.com/nvaccess/nvda/issues/6684#issuecomment-269419486>, 
> or mute the thread 
> <https://github.com/notifications/unsubscribe-auth/AFGivZXak4twhCXMe_W6Vve69XMNYrzkks5rMdYqgaJpZM4LWpJy>.
>

-- 
------------------------------------------------------------------------


    Derek Riemer

  * Department of computer science, third year undergraduate student.
  * Proud user of the NVDA screen reader.
  * Open source enthusiast.
  * Member of Bridge Cu
  * Avid skiier.

Websites:
Honors portfolio <http://derekriemer.com>
Awesome little hand built weather app! 
<http://django.derekriemer.com/weather/>

email me at derek.riemer@colorado.edu <mailto:derek.riemer@colorado.edu>
Phone: (303) 906-2194


Hi,

Partly confirmed: "always duck" option is broken.

STR:

1. In Windows 10 Insider Preview build 14986, open a media player or point your browser to a page that has multimedia content (such as YouTube).
2. While a file is playing, press NVDA+Shift+D to switch between audio ducking options.
3. For each option, use a command you know will cause a long text to be spoken (e.g. NVDA+T for title).

Expected: audio ducking settings are respected.
Actual: if audio ducking is set to "always duck", media volume is restored once NVDA finishes speaking.

@MichaelDCurran, anything we can do besides sending a feedback?

Thanks.
This was due to a change made by Microsoft. Prior to 14986, ducking in Windows was static; i.e. you turned it on and it stayed on until you turned it off. NVDA does the dynamic (speech and sounds) ducking itself by turning static ducking on and off as needed. In 14986, Microsoft changed Windows ducking to be dynamic; i.e. it does speech and sounds ducking itself. This means that "always duck" is no longer possible. We also feel that Microsoft's implementation of speech and sounds ducking does not fit for NVDA. Thus, we're trying to convince Microsoft to give us separate options for static and dynamic ducking in a future build.
Setting this to p2 for now, since we need to push Microsoft to fix this ASAP, but this should possibly even be p1, since it has significant user impact.
Pushing to p1 as per discussion with Mick.

Resolving patch:
diff --git a/source/audioDucking.py b/source/audioDucking.py
--- a/source/audioDucking.py
+++ b/source/audioDucking.py
@@ -9,6 +9,7 @@
 import time
 import config
 from logHandler import log
+import winVersion
 
 def _isDebug():
 	return config.conf["debugLog"]["audioDucking"]
@@ -28,6 +29,9 @@ def __del__(self):
 AUDIODUCKINGMODE_OUTPUTTING=1
 AUDIODUCKINGMODE_ALWAYS=2
 
+# The Windows build number where Microsoft introduced its own dynamic ducking
+WINVERSION_DYNAMICDUCKING_MIN=14986
+
 audioDuckingModes=[
 	# Translators: An audio ducking mode which specifies how NVDA affects the volume of other applications.
 	# See the Audio Ducking Mode section of the User Guide for details.
@@ -40,6 +44,11 @@ def __del__(self):
 	_("Always duck"),
 ]
 
+# Some Windows builds introduced their own dynamic ducking which makes our 'always duck' mode  impossible.
+# Thus on these builds, remove that option
+if winVersion.winVersion.build>=WINVERSION_DYNAMICDUCKING_MIN:
+	del audioDuckingModes[-1]
+
 ANRUS_ducking_AUDIO_ACTIVE=4
 ANRUS_ducking_AUDIO_ACTIVE_NODUCK=8
 
@@ -94,8 +103,15 @@ def setAudioDuckingMode(mode):
 	global _audioDuckingMode, _modeChangeEvent
 	if not isAudioDuckingSupported():
 		raise RuntimeError("audio ducking not supported")
-	if mode<0 or mode>=len(audioDuckingModes):
-		raise ValueError("%s is not an audio ducking mode")
+	# Normalize mode to within the exceptable range of values.
+	# We normalize rather than rasing an error as certain values only exist on certain builds of Windows, such as 'always duck'. 
+	mode=max(min(mode,len(audioDuckingModes)-1),0)
+	# Some Windows builds introduce their own dynamic ducking which is incompatible with our dynamic ducking.
+	# Therefore, if the user chooses  dynamic ducking,  force our 'always duck' mode, which then allows the OS to dynamic duck.
+	if winVersion.winVersion.build>=WINVERSION_DYNAMICDUCKING_MIN and mode==AUDIODUCKINGMODE_OUTPUTTING:
+		if _isDebug():
+			log.debug("Allowing oS to handle dynamic ducking")
+		mode=AUDIODUCKINGMODE_ALWAYS
 	with _duckingRefCountLock:
 		oldMode=_audioDuckingMode
 		_audioDuckingMode=mode


Test patch: