http://www.headchant.com/2011/11/01/sou ... ine-waves/
When I type in the listing - I changed the
Code: Select all
function Oscillator(freq)
local phase = 0
return function()
phase = phase + 2*math.pi/rate
if phase >= 2*math.pi then
phase = phase - 2*math.pi
end
return math.sin(freq*phase)
end
end
Code: Select all
function Oscillator(freq)
local phase = 0
return function()
phase = phase + 2*math.pi/rate
if phase >= 2*math.pi then
phase = phase - 2*math.pi
end
return math.sin(freq*phase)
end
end
So I am guessing that something is up with the way that the Oscillator is checking the phase?
Is there something wrong with the code snippet? I checked the documentation and there does not seem to be any depreciated library functions being called. It should just work right - with the exception of the >.
Lol I just want to get my tone playing then I can start to update the old school commodore books to lua.