Hi there,
is there any reason why the MemoryAudioSource’s int position
variable isn’t wrapped around while looping?
Within the getNextAudioBlock (see JUCE/juce_MemoryAudioSource.cpp at fbe95b0b073ccb589e28255cb0cd56e1382dc2c9 · juce-framework/JUCE · GitHub) the value of position is always increasing. It might overflow sooner or later (probably later).
The temporary copy of it int i = position;
actually gets modulo`d within the process loop, however, once wrapped around this might yield a negative value, and from there I expect things to go south. (Haven’t actually waited for the overflow).
Even though the statements within the loop might catch that (haven’t had a deeper look into it, yet), it makes it quite inconvenient to compute the current progress as I expected it to be:
auto progress = static_cast<float> (getNextReadPosition()) / getTotalLength();
which will get bigger and bigger unless I perform the modulo myself:
auto progress = static_cast<float> (getNextReadPosition() % getTotalLength()) / getTotalLength();
Which I wouldn’t have expected having it to perform myself.