utils={} function utils.accuracy(beatDivisions, time) local ticksToPrevDiv=(game.ticker.ticks-1)%beatDivisions local ticksToNextDiv=beatDivisions-ticksToPrevDiv local prevDivTime=game.ticker.lastTickTime-ticksToPrevDiv*game.ticker.tickTime local nextDivTime=game.ticker.lastTickTime+ticksToNextDiv*game.ticker.tickTime local closest=math.min(math.abs(time-prevDivTime), math.abs(time-nextDivTime)) local halfDivision=beatDivisions/2*game.ticker.tickTime -- print(math.abs(time-nextDivTime),"to next beat, ",math.abs(time-prevDivTime)," to previous beat. Half division is ",halfDivision,". Closest is ",closest,". The current time is ",time,", and the next division is at ", nextDivTime,", last tick happened at ",game.ticker.lastTickTime," and is tick number ",game.ticker.ticks) return (halfDivision-closest)/halfDivision -- Math is hard end local volumeScale=0.0029 function utils.setSourcePosition(source, x, y) source:setPosition(x,8,0) source:setVolume(volumeScale*game.field.height-volumeScale*math.abs(player.y-y)) end