moai/moai-dev — pull request #106 by kengonakajima (2012-01-21 21:19:41+00:00)
Title: Enabling software synth  with UNTZ

Now you can create software synthesizer on moai UNTZ.
In this snippets you generate math.sin() wave sound:

local samplebuf = MOAIUntzSampleBuffer.new()
samplebuf:prepareBuffer( nChan, freq * totalLenSec , freq )

local data = {}
for i=1,10000 do
data[i] = math.sin( i / 5 ) -- set wavedata from -1 to 1
end
samplebuf:setData( data,1 )
s = MOAIUntzSound.new()
s:load(samplebuf)
s:setVolume(1)
s:setLooping(true)
s:play()

Of cource you can mix it with sounds from wav files.