Anyway, I've wrote a couple of functions that minimize the delay.
GLOBAL waveLoops[] AS WAVELOOP
TYPE WAVELOOP
waveid
state
length
chn
mil
ENDTYPE
FUNCTION wlAdd: id, l
LOCAL wl AS WAVELOOP
wl.waveid = id
wl.length = l
wl.state = 0
wl.chn = 0
wl.mil = 0
DIMPUSH waveLoops[], wl
RETURN LEN(waveLoops) - 1
ENDFUNCTION
FUNCTION wlPlay: id
waveLoops[id].state = 1
waveLoops[id].chn = PLAYSOUND(waveLoops[id].waveid, 0, 1)
waveLoops[id].mil = GETTIMERALL() + waveLoops[id].length
ENDFUNCTION
FUNCTION wlUpdate:
LOCAL mil
FOREACH wl IN waveLoops[]
IF wl.state = 1
mil = GETTIMERALL()
IF mil >= wl.mil
wl.chn = PLAYSOUND(wl.waveid, 0, 1)
wl.mil = GETTIMERALL() + wl.length
ENDIF
ENDIF
NEXT
ENDFUNCTION
- wlAdd function for adding a previously loaded wave file to the list (you need to specify the length in milliseconds)
- wlPlay to start the loop
- wlUpdate must be called continuously in the main program loop
Needs to add wlPause, wlStop, wlIsPlaying, and some volume and panning functions.
Thanks for replies!