Custom function like yield
Without any hint, what you are actually doing in your long loops, it is difficult to say, what way would be the best for your case. I don't believe, there is a standard way of doing this, but there are basically only two ways of multitasking on a microcontroller:


Interrupt driven: You can set a timer interrupt, that occurs regularly to call the AudioGenerator::loop() function (which fills the buffer with the next data).
Non-blocking code: If you are using non-blocking code, you can first do one thing and then do another in sequence, so fast, that both codes are executed often enough. Thats exactly what the library you use is designed for (according to the README file).


If you are using more than one of these long loops in your loop() function, you may consider doing things with a finite state machine (FSM), so that you don't have to always add the AudioGenerator::loop() function to your long loops, but only once for the normal loop() function.