mazmazz / SRB2

A 3D Sonic the Hedgehog fangame built from Doom. See README for my contributions.
GNU General Public License v2.0
4 stars 2 forks source link

New Frame hook for music - fire 1/100th second instead of 1/TICRATE #26

Open mazmazz opened 6 years ago

mazmazz commented 6 years ago

Because

  1. ThinkFrame is only precise by 1/TICRATE (1/35th second) whereas 1/100th is more precise for music
  2. ThinkFrame does not run when you're not in a level. E.g., title screen, score card

Doesn't have to be 1/1000th (millisecond), I think 1/100th (centisecond) is good enough. Better than 1/35th, where music jumps are perceptible from imprecise position reading.

mazmazz commented 6 years ago

Is the right solution to execute hook every millisecond in mixer_sound? Is this desirable to call lua from I_Sound hardware code?

If from mixer, Millisecond hook must be performant or it will slow down sound processing.

Can we call a function every millisecond anywhere in the source?

At the very least, having a Frame hook outside of a level would be very helpful.

mazmazz commented 6 years ago

Advice from LJ Sonic:

Performance impact from running a hook 100 or 1000 times a second?

Possibly use system timers (or some kind of timer) to decouple from 1/TICRATE?

BUT: system timers are only checked 35 times a second. Sooooo, not possible? How to overcome this?