Created
October 17, 2012 06:36
-
-
Save mebens/3904043 to your computer and use it in GitHub Desktop.
Generate sine wave tones in Love2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local samples = 100000 | |
local data = love.sound.newSoundData(samples) | |
local noteChange = 10000 | |
local note = 200 | |
local change = 50 | |
local minimum = 100 | |
for i = 0, samples * 2 - 1 do | |
if i % noteChange == 0 then | |
local factor = -2 + math.random(0, 4) | |
if note <= minimum then factor = 1 end | |
note = note + change * factor | |
end | |
data:setSample(i, math.sin(i % note / note / (math.pi * 2))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment