Amuse your enemies!
Loop the intro to a song infinitely!
This program has a list of times, and when it reaches that time in a song it rolls dice to decide wether to rewind the song.
Recommended use: insert your own song, and use Audacity (or any music player I guess) to find the times you want the randomizer to use. If you only want to loop one section, enter only 2 numbers: the beginning and end of the looped section. It's a lot more fun with a longer list, though.
SOURCE CODE v2.0:
Code: Select all
source = love.audio.newSource("song.wav", "static")
times = {
1.383,
6.914,
7.872,
15.317,
18.902,
22.521,
26.198,
29.840,
32.594,
34.288,
37.124,
44.477,
51.830,
57.340
}
love.window.setTitle("\"Let the bodies hit the") --random window titles
position = 0;
rewindTime = 2;
love.audio.play(source)--This hack was a mistake.
function love.load()
end
function love.update()
position = source:tell()
if position >= times[rewindTime] then
choosePostion()
end
end
function choosePostion()
old = rewindTime
if (old > 2 and love.math.random(3) == 2) then
source:seek( times[rewindTime-1], "seconds" )
else
while rewindTime >= old and rewindTime > old-3 do
rewindTime = love.math.random( table.getn(times) )
end
source:seek( times[rewindTime], "seconds" )
old = rewindTime
while rewindTime <= old and rewindTime < old + 3 do
rewindTime = love.math.random( table.getn(times) )
end
end
end