My audio file gets loaded like this in the main section of my program:
hitSound = audio.loadStream("audio/hit\_target.mp3")
The sound should get played when a target gets hit, so my Runtime onEnterEvent fuction looks like this:
local function onEnterFrame(event)
if(targetsHit > 0) then
local hitSoundChannel = audio.play(hitSound)
print(hitSoundChannel)
end
end
The print statement was added for debugging. When multiple targets get hit in short succession, I would expect multiple audio channels to be opened, i.e. the sounds should overlap. However, the output of the print statement shows that only ever one channel is opened (#1) and unless that channel has finished playing the sound, audio.play returns 0 as an error code:
23:28:36.395 1
23:28:36.457 0
23:28:36.552 0
23:28:36.661 0
23:28:36.802 0
23:28:37.786 1
23:28:37.848 0
23:28:37.895 0
23:28:37.942 0
23:28:37.973 0
23:28:38.020 0
23:28:38.255 1
23:28:38.380 0
23:28:38.426 0
Why wouldn’t it allocate the next available channel as per the documentation instead?