OneLoneCoder/olcPixelGameEngine

PGEX Sound Questions

TediusTimmy opened this issue · 2 comments

I've started playing with PGEX Sound, and I have some notes about the code. I'm only going to comment on the Windows implementation, because that's all I have touched (I understand why you use float when a perfectly fine double will work, but it's not my thing).

Line 522:

		// Goofy hack to get maximum integer for a type at run-time
		short nMaxSample = (short)pow(2, (sizeof(short) * 8) - 1) - 1;

Why not use:
std::numeric_limits<short>::max() or (std::numeric_limits<short>::max)() (the second form suppresses macro expansion, if that is the problem)

There are also some variables that don't get used, but they look useful for debugging: nPreviousSample, tp1, tp2, and fElapsedTime.

And, why did you write the clip lambda instead of using std::clamp? I understand that clip takes only one argument.... Was that in the video and its been too long since I've seen it?

Other than my questions about the implementation, I've been having fun starting to implement a bare-bones music player. I'm hoping to write an overly complicated system for inputting music, based on BASIC's PLAY command.

You can see how I hacked and slashed your code here:
https://github.com/TediusTimmy/SoundEngine/blob/master/include/olcPGEX_Sound.h
There, you can also see the music player I created (over engineered).

I hadn't read through enough of the issues to see that you were going to re-engineer the sound engine.

I can at least answer the question about clip. The sound extension is quite old (and in need of a rewrite, doesn't work all the time), and then the pge didn't use C++17 feature, so it didn't make sense to use clamp and therefore bump up the compiler requirements.