I have a PCM streaming function. You could spend some time to manually program a looping function here. There are also some other abstractions included that relate to XL2's work. Also, a direct-to-sound-driver PCM sound effect playback.
It is tuned specifically for 30.72 KHz mono PCM sound. WHY: A single frame is a single sample, at 2048 bytes.
Sound effects could be tuned for any rate, but as it stands it is 30.72 and 15.36 (2048 bytes per frame or 1024, at 30 fps).
Note this is a "big" demo project. When running it, hit C first and watch the top left indicator (started or stopped). When it says started, stop hitting C immediately, wait until it says stopped. This is a file loading indicator. You also cannot hit D-pad left or right until the model file has loaded (you will see it when you stop moving). But you are more interested in the code.
To add loops, you would set play_ref to zero when you reach EOF and inject a break at that point to re-open the file at zero sectors.
This also isn't perfect, nor is it done: obviously, music loops and changing music file are important features that I haven't gotten to yet.
There are, at points, static injected into the PCM music. I have set-ups where this does not happen, but trust me, you don't want those. I've no idea why the PCM music gets static.
This also directly allocates regions of sound memory that other development libraries might be using. I know, for instance, SGL will NOT behave if you try to use it with this.
The file you want to look at for all PCM stuff is msfs.c (master sound & file system).
http://www.mediafire.com/file/nnzs2zadne94bfz/sharevbt.zip/file
Addendum: Why would I do this by manually sending commands to sound CPU and manually dictating a stream with GFS_NwFread?
Simple: I cannot for the life of me get SBL to work properly. So I do things my way.