This is my main.lua:
Code: Select all
size ,samplerate ,bitdepth ,channels ,buffers =
128 ,48000 ,16 ,1 ,8
bufs_per_ms = (samplerate / 1000) / size
function love.load()
sdata = love.sound.newSoundData(size, samplerate, bitdepth, channels)
source = love.audio.newQueueableSource(samplerate, bitdepth, channels, buffers)
end
function love.update(dt)
dt = dt * 1000
local bufs = dt * bufs_per_ms
local count = source:getFreeBufferCount()
print(
string.format('%.2f', dt)..' ms'
..' expected: '..string.format('%.2f', bufs)
..' got: '..(count>0 and count or 'none')
)
for _=1,count do
source:queue(sdata)
source:play()
end
end
Code: Select all
17.00 ms expected: 6.37 got: 8
16.43 ms expected: 6.16 got: 8
16.60 ms expected: 6.22 got: none
16.67 ms expected: 6.25 got: 8
16.83 ms expected: 6.31 got: 8
16.62 ms expected: 6.23 got: 8
16.66 ms expected: 6.25 got: none
16.63 ms expected: 6.24 got: 8
16.40 ms expected: 6.15 got: 8
16.98 ms expected: 6.37 got: 8
16.60 ms expected: 6.22 got: none
16.48 ms expected: 6.18 got: 8