kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Player set_pitch crashes with 'directaudio' driver #638

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It works perfect with openal driver, according to:

http://www.pyglet.org/doc/api/index.html

This is Pyglet 1.4 alpha1 running on Windows Vista Home Basic SP2, Python 
2.7.3. Using AVbin 11.

Traceback (most recent call last):
  File "scripts\yafb", line 19, in <module>
    pyglet.app.run()
  File "c:\Python27\lib\site-packages\pyglet\app\__init__.py", line 123, in run
    event_loop.run()
  File "c:\Python27\lib\site-packages\pyglet\app\base.py", line 135, in run
    self._run_estimated()
  File "c:\Python27\lib\site-packages\pyglet\app\base.py", line 164, in _run_estimated
    timeout = self.idle()
  File "c:\Python27\lib\site-packages\pyglet\app\base.py", line 273, in idle
    redraw_all = self.clock.call_scheduled_functions(dt)
  File "c:\Python27\lib\site-packages\pyglet\clock.py", line 309, in call_scheduled_functions
    item.func(ts - item.last_ts, *item.args, **item.kwargs)
  File "C:\Users\Alex\Downloads\ya-falling-blocks-master\ya-falling-blocks-master\scripts\..\useboxnet\puzzle\__init__.py", line 94, in update
    self.scene.update(dt)
  File "C:\Users\Alex\Downloads\ya-falling-blocks-master\ya-falling-blocks-master\scripts\..\useboxnet\puzzle\scenes.py", line 315, in update
    self.scored.play().pitch = self.PITCH[self.combo_level] if self.combo_level < len(self.PITCH) else 1.0
  File "c:\Python27\lib\site-packages\pyglet\media\__init__.py", line 1176, in _player_property_set
    getattr(self._audio_player, set_name)(value)
  File "c:\Python27\lib\site-packages\pyglet\media\drivers\directsound\__init__.py", line 425, in set_pitch
    frequency = int(pitch * self.audio_format.sample_rate)
AttributeError: 'DirectSoundAudioPlayer' object has no attribute 'audio_format'

Original issue reported on code.google.com by useboxnet on 24 Mar 2013 at 8:24

GoogleCodeExporter commented 9 years ago
> This is Pyglet 1.4 alpha1 running on Windows Vista Home Basic SP2, Python 
2.7.3. Using AVbin 11.

This was 1.2 alpha1, sorry :)

Original comment by useboxnet on 23 May 2013 at 1:33

GoogleCodeExporter commented 9 years ago
I also encountered this issue and could fix it.

Fix: 
* Open "Python27\lib\site-packages\pyglet\media\drivers\directsound\__init__.
py"
* Go to the "set_pitch" function around line 425
* Change this: frequency = int(pitch * self.audio_format.sample_rate)
* ..to this: frequency = int(pitch * self.source_group.audio_format.sample_rate)

The problem was that audio_format is not a direct member of "self" but belongs 
to self.source_group.

Greetings,
Hauke

Original comment by basspl...@d-lab42.com on 21 Oct 2013 at 9:48

GoogleCodeExporter commented 9 years ago
Good stuff! Thanks, I'll check it when I have some time.

Original comment by useboxnet on 21 Oct 2013 at 9:50

GoogleCodeExporter commented 9 years ago
This issue was closed by revision f85d0596a569.

Original comment by useboxnet on 21 Oct 2013 at 4:46

GoogleCodeExporter commented 9 years ago
Thanks again for the patch!

I didn't see what was the problem when I reported the issue and because I use 
OpenAL, I didn't investigate any further :)

Original comment by useboxnet on 21 Oct 2013 at 4:48

GoogleCodeExporter commented 9 years ago
Glad I could help :). Thanks for your work!

Original comment by basspl...@d-lab42.com on 21 Oct 2013 at 6:26