1. How would you determine the length (playback time) of a module, which is explicitly infinitely looped with Bxx and Dxx effects?
It's not like this is an unsolved problem, plenty of other plugins and XMPlay's own module player can do it as well.
To give you a very rough idea of how OpenMPT (and most likely also XMPlay) does it...
- Initialize some bit array which stores one bit for every row of every pattern. Bit set = row has been visited. Initially, all bits are 0.
- Emulate module playback (i.e. without rendering samples and such, since it's not necessary), and for every row that has been visited, set the corresponding bit to 1.
- If a row has been visited before (bit is 1), abort length detection.
- For seeking, extend the above behaviour to also keep track of row times, and as soon as the wanted seek time is reached, stop the emulated playback process and set the "real" player's playback position to the one determined by the emulation.
Now if a module is set to loop endlessly, obviously the reported song length would be the time at which the song starts to loop.
Two things to keep in mind:
- Pattern loops may lead to infinite loops. To avoid this, Keep track of the time of first row of the pattern loop, and when you reach the end of the loop, add the time that has passed since the first row of the loop as many times as the loop count is set to.
- Emulation should probably keep track of any kind of "global" effects such as global volume changes, so that their correct value is set when seeking.
Since, as far as I understand, you are also the author of libdigibooster3, it should be possible for you to implement this stuff directly in the library.