I have reported a similar bug in 2011 at
http://hg.pygame.org/pygame/issue/89/sounds-arent-played-at-the-
expected-moment . The problem was with Windows XP. The init line solves
the problem, but it makes the line mandatory if you are writing games.

I wanted to know if the regression appeared in SDL or in pygame, so
today I have examined pygame's repository. Here are the results. The
canonical version with the expected behavior is (in my opinion) the
1.7.1. The changes occurred in src/mixer.c .

In 1.7.1:
#define MIX_DEFAULT_CHUNKSIZE   1024

In 1.8.0rc5:
/* 1024 * 3 seems to be the magic number to stop scratchy sound. On some 
systems.  */
#define MIX_DEFAULT_CHUNKSIZE 3072

In 1.9.1release:
/* Since they are documented, the default init values are defined here
   rather than taken from SDL_mixer. It also means that the default
   size is defined in Pygame, rather than SDL AUDIO_xxx, terms.
 */
#define PYGAME_MIXER_DEFAULT_FREQUENCY 22050
#define PYGAME_MIXER_DEFAULT_SIZE -16
#define PYGAME_MIXER_DEFAULT_CHANNELS 2
#define PYGAME_MIXER_DEFAULT_CHUNKSIZE 4096

3 commits explain the reason of the changes:

https://bitbucket.org/pygame/pygame/commits/05f77b15cd466411a13cf4ce97217a34da6aeeb0
" [...] Also changed default chunk size to avoid a common scratchy sound 
problem."

https://bitbucket.org/pygame/pygame/commits/a59e9011ebbf28290c40f7150bed30ff56425539
"Added comment to explain change of chunksize."

https://bitbucket.org/pygame/pygame/commits/c12cc74fe422a38bc93a1cfbca14660008693db9
"Bugzilla issue 6: add keyword arguments to mixer.init (and pre_init).
Default buffer size is now explicitly 4096 to be consistent with the
documented power of 2 requirement. It was already implicitly 4096
as buffer values are rounded up to the nearest power of two anyway."

So the error appeared in 2 stages:
- First, a developer changed the default value from 1024 to 3072 to solve a 
problem on "some systems", causing a regression (unbearable delay).
- Later, another developer rounded 3072 to 4096, which shouldn't change the 
result.

Actually, the 1024 value was mentioned in the 1.7.1 docs:
"pygame.mixer.init [...] The default buffersize is 1024 samples, sometimes a 
larger value is required. "

So I am wondering, should they go back to the 1.7.1 value, since the
defaults are not suited for games?  What do you think?

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/295369

Title:
  pygame sound is delayed a lot

To manage notifications about this bug go to:
https://bugs.launchpad.net/pygame/+bug/295369/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to