@RhoSigma Hi,
I will say it quite openly. I am amazed by the simplicity and efficiency of your version. The reason why mine was complicated there has one main and essential reason and another irrelevant reason.
The main reason is that I'm not very familiar with these bit operations, and your way of writing a program is simply beyond my knowledge.
The irrelevant one is that I will continue to use the samples in another program, so I needed to store them in memory.
When I think about it in retrospect, I'm surprised that it didn't hit me in the eye and ear right away. I assumed the correct samples would play with (255 ^ 3/2) but it didn't work properly. So I was expecting _SNDRAW number 8290688, but it's not there. There is 8388608. I'll try to find out the reason.
I'll put it this way. Many thanks for looking at it and showing me this solution. Lines 45, 46, 49, 50 would not occur to me in any way to solve in this way, it is definitely exactly what I can't do. Yet.