I will take you advice and write the samples out to a PCM wave file then examine them in audacity. Regarding the underflow, I always wipe the buffer with zeros before I play a note and the popping occurs sometimes when only one note is playing. That is when there is the least amount of processing, but you might be onto something. I am using the smallest buffer size of 512 samples and the threading system might not invoke my audio callback in time to fill the buffer before the sound should be playing. I will try to increase the buffer size which should relieve the race condition, but increasing the buffer size also increases the resolution where notes can be played making them less accurate.
And right now I just tested the buffer size and simplifying the computation of Left and Right samples. This greatly reduced the popping, so I am thinking the problem is related to my callback is taking too long to compute. That or SDL and Linux are not scheduling the audio callback as aggressively as they should. I will test on Windows with a lower end CPU (a different machine) and see if the problem presents itself there as well. If the problem lays in my computation taking too long, perhaps I will try compiling with different optimization levels or simplifying my audio callback. I am using doubles with division and multiplication (and the Sin function with some waveforms) quite a bit during my callback. Perhaps FPC generates less than ideal instructions to perform math on the double type.
-- _______________________________________________ lazarus mailing list [email protected] https://lists.lazarus-ide.org/listinfo/lazarus
