Python Forum
[PyGame] sound effect delay and program laggy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] sound effect delay and program laggy
#2
If i recall correctly, the sound delay was fixed via running this command before pygame.init(). I think i ran into this issue before and that solved it.
pygame.mixer.pre_init(44100, -16, 1, 512)
(Sep-26-2019, 09:36 PM)xBlackHeartx Wrote: Also, in general, I've noticed my programs tend to be really laggy.
We would have to see your full code. Most of the time people have some sort of bottleneck in your code that is dragging your program down. You can easily create a bottleneck that would drag a beefy computer to a halt in any language, not just python.

Common bottlenecks in code are:

--Do not load resources within the main game loop.
--Always load your images using .convert() or .convert_alpha()
--Reading and writing to disc is the slowest part. Either minimize this, or enhance the parts that are truly required.
--Use existing, well known 3rd party libraries instead of making your own reproductions of them. These libraries are updated and have been tweaked for maximum speed already, so why try to recreate it? One case might be NumPy usage.

If you can create a working example of the lag issue within minimized code it would be much easier to spot. But if not, we would need to pick through the code to find the bottleneck.
Recommended Tutorials:


Messages In This Thread
RE: Why do my sound effects always have a slight delay in them? - by metulburr - Sep-26-2019, 10:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Laggy Game Movement game_slayer_99 12 4,537 Oct-05-2022, 11:34 AM
Last Post: metulburr
Music [PyGame] Chopper wash effect efficiency questions. michael1789 9 4,519 Jan-19-2021, 07:12 PM
Last Post: michael1789
  Appropriately delay this PyGame code kleynah22 2 4,424 Nov-09-2017, 02:00 PM
Last Post: Windspar
  [PyGame] My program is very laggy GamePlanet 6 7,120 Aug-15-2017, 03:00 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020