Tesselode wrote:Can you think of a specific instance where this would be useful? Or would it just be to make it more intuitive to work with songs of different time signatures? Either way, I think it's a good idea.
Well, you did mention 8th notes as .5b or half-beat time intervals, that suggests to me common time, or 4/4. Just a thought, it's not necessary but yeah, intuition. Especially, if someone wants to create a game like Crypt of the Necrodancer or something, and wants to use music with weirder beats.
Tesselode wrote:Yeah, I've definitely had some timing issues with looping and chaining pieces of music. I really wish LOVE had some way of working with audio more precisely, but I imagine I would have this issue with virtually any game engine. Do you think modifying love.run to get rid of the pause between frames would help?
Thing is, i'd say yes, but this is a library. You can't really ask the ones creating their game to conform to your own specs like that, only to notify them through notices that this should be called more than the probable vsync=true option would allow. (Note that this shouldn't be THAT big of an issue, unless the songs are in the 300+BPM range, or you'd set the beats to 16th or even shorter notes (like 1024th notes
))
That said, this is my current love.run that i use in my music generation related test projects:
Code: Select all
love.run = function()
if love.math then
love.math.setRandomSeed(os.time())
end
if love.load then love.load(arg) end
-- We don't want the first frame's dt to include time taken by love.load.
if love.timer then love.timer.step() end
local dt = 0.0 -- delta time
local tr = 1/100 -- tick rate
local fr = 1/75 -- frame rate
local da = 0.0 -- draw accumulator
local ua = 0.0 -- update accumulator
-- Main loop time.
while true do
-- Process events.
if love.event then
love.event.pump()
for name, a,b,c,d,e,f in love.event.poll() do
if name == "quit" then
if not love.quit or not love.quit() then
return a
end
end
love.handlers[name](a,b,c,d,e,f)
end
end
-- Update dt, as we'll be passing it to update
if love.timer then
love.timer.step()
dt = love.timer.getDelta()
da = da + dt
ua = ua + dt
end
-- Call audio
if love.atomic then love.atomic(dt) end
-- Call update
if ua > tr then
if love.update then
love.update(tr) -- will pass 0 if love.timer is disabled
end
ua = ua % tr
end
-- Call draw
if da > fr then
if love.graphics and love.graphics.isActive() then
love.graphics.clear(love.graphics.getBackgroundColor())
love.graphics.origin()
if love.draw then love.draw() end -- no interpolation
love.graphics.present()
end
da = da % fr
end
-- Optimal sleep time, anything higher does not go below 0.40 % cpu
-- utilization; 0.001 results in 0.72 %, so this is an improvement.
if love.timer then love.timer.sleep(0.002) end
end
end
[/size]