It sounds like the directsound and xaudio2 audio drivers treat the .volume member on the Player differently.
Run the script below with xaudio2 as the driver and press the keys in order (ex: Q, W, E, R, T, Y). You should hear beeps that get gradually quieter. The "Y" key is silent.
Then, comment out the xaudio2 line and uncomment the directsound driver. Press the keys again in order. You will hear beeps that are pretty much at full loudness. Except, when you press "Y", you will hear a quiet beep.
I'd expect the volume "ramp" to be identical, regardless of what audio driver was chosen.
My environment:
- Python 3.8.6
- Pyglet: 1.5.11
- OS: WIndows 10 Home (1909)
import pyglet
pyglet.options["audio"] = ("xaudio2",)
# pyglet.options["audio"] = ("directsound",)
class VolumeTest(pyglet.window.Window):
def __init__(self):
super(VolumeTest, self).__init__()
self.sound = pyglet.media.StaticSource(pyglet.media.synthesis.Sine(0.3, frequency=440))
self.player = None
def on_key_press(self, symbol, modifiers):
if symbol == pyglet.window.key.Q:
self.player = self.sound.play()
self.player.volume = 1.0
if symbol == pyglet.window.key.W:
self.player = self.sound.play()
self.player.volume = 0.75
if symbol == pyglet.window.key.E:
self.player = self.sound.play()
self.player.volume = 0.5
if symbol == pyglet.window.key.R:
self.player = self.sound.play()
self.player.volume = 0.25
if symbol == pyglet.window.key.T:
self.player = self.sound.play()
self.player.volume = 0.1
if symbol == pyglet.window.key.Y:
self.player = self.sound.play()
self.player.volume = 0.0001
if __name__ == '__main__':
print(pyglet.media.get_audio_driver())
window = VolumeTest()
pyglet.app.run()
It sounds like the
directsoundandxaudio2audio drivers treat the.volumemember on thePlayerdifferently.Run the script below with
xaudio2as the driver and press the keys in order (ex: Q, W, E, R, T, Y). You should hear beeps that get gradually quieter. The "Y" key is silent.Then, comment out the
xaudio2line and uncomment thedirectsounddriver. Press the keys again in order. You will hear beeps that are pretty much at full loudness. Except, when you press "Y", you will hear a quiet beep.I'd expect the volume "ramp" to be identical, regardless of what audio driver was chosen.
My environment: