Expand Pulp-Audio LUA functions (Pause/Resume, Global Volume Control)

,

Today I got to play around with the exported pulp-audio.lua package and have identified some odd behaviors.

When a Pulp song is playing, by default it is assumed to be looping continuously, however the code seems to keep track of both ‘ticks’ which accumulate while the pulp.audio.update function is going, and also general time at init.

This means that if you only want the song running in certain update processes, you get a cascade of notes play when you reenter that update loop as it tries to match it’s expected song point with the elapsed time since the last update.
I would expect the note tracking to stop when the update loop is not running, or for it to just resume triggering notes at the new time point, instead of playing all notes missed since.

To this end, a pauseSong() resumeSong() function would be great to allow for better control of this behavior.

On the other end of this, being able to globally control song volume and mute operations would be super useful too.

Anyone had a chance to look into this one?

I had a poke around the code to see if I could leverage the setVolume() voice functions but they’re basically set globally for all voices (0.65 or whatever the json you plug in gives it), so unless this whole library rewritten to assume individual voice controls thats probably a no go.

The ticks thing is still a problem, and I’m struggling to understand the code as its been written, unlike the voice and volume parameter functions, while I can understand that something in the way the ticks code is written is causing it to continue to increment while the song is in a isPaused state, and that that is what is causing this overflow catchup behaviour, the code is written so differently to how I would write something like this that I am not having much success even breaking the function down.