A problem with using std::accumulate to calculate the mean is that small numbers get rounded down to zero when dealing with floating point numbers. This is solved by implementing the Kahan summation algorithm (https://en.wikipedia.org/wiki/Kahan_summation_algorithm).
The content of src/archutils/Darwin/VectorHelper.cpp is very old, these are AltiVec and SSE2 instructions. This is only actually used in RageSoundMixBuffer.cpp. This level of micro-optimization is not needed since platforms this old are not supported by ITGm.
NTpad is a driver for Windows 2000/XP which enables the use of a controller via the parallel port. This is not needed anymore and is just causing lag by constantly scanning the list of input devices on Windows.
Summary of changes
1) Fix issues in RageTimer and RageSoundPosMap
2) Calculate seconds from microseconds more accurately
3) Replace lrint(x) with static_cast<int>(x+0.5) for better performance
4) Replace C style casting with C++ style casting
5) Make important values 64-bit wide
6) Update RageUtil.cpp (timer conversion RStrings had some math which needed to be fixed after fixing RageTimer's math)
7) Ensure floating point math is done as floating point
8) Improve code commentary all around
9) Improve clarity and efficiency of RageSoundPosMap "return closest position" error logging
Mainloop lock needs to be held to access PulseAudio object from outside the
event loop thread, in particular in GetPosition() calls. Otherwise we might hit
a race condition and have the call fail. There's also a possibility that the
call might randomly fail if it's called before first timing data is received
for the stream, so handle that case as well.
Also fix the stream write callback to call Mix() with correct parameters, as
well as do the work in a loop in case pa_stream_begin_write() returns smaller
memory buffer than was requested.
Enforcing HIGH_PRIORITY_CLASS is best for Win10+ where Windows Update can interrupt the game and it also prevents streaming apps (OBS/Discord) from causing stutter by taking rendering priority away from ITGMania.
Update ArchHooks_Win32.cpp
Update ArchHooks_Win32Static.cpp
This code provided a 7x accuracy improvement over timeGetTime(). (0.2ms vs 1.4ms std dev*3)
Rename variables to fit with existing naming mechanism
PulseAudio driver used to report position of last frame written to audio stream
instead of actual playback position. This kind of worked, since on average the
write position doesn't diverge too much from actual elaped time, but it can
result in note stuttering and in general isn't very accurate. Change the
implementation to use actual playback position from PulseAudio stream.
Remove some compatibity code with old PulseAudio, since version 0.9.10 was
released in 2008.
Also, as an optimization to avoid unnecessary memory copying, use
pa_stream_begin_write() to mix audio directly into PulseAudio memory.
StepMania generates some files during build but it's a bit unusual to generate
them in source directory instead of build directory. Move them to build
directory and remove src/generated from .gitignore.
When AddAttribute() is called multiple times with overlapping ranges, old
attributes need to be removed and/or fixed. Otherwise the old colors might
show up when the text is rendered.
It's possible for LUA to redirect input and not bring it back when screen is
ending (and there are existing bugs like this in Simply Love). Considering that
each screen is a separate entity, it seems like this shouldn't be possible and
each screen should handle redirection separately. Split redirection state per
each screen in the stack and clear it once screen is ending.