pulsar/unique.lua

78 lines
1.3 KiB
Lua

function _init()
local bgm=build_bgm()
local free_patterns={}
for i=0,63 do add(free_patterns,i) end
bgm:build(free_patterns,0)
cstore(0x3100,0x3100,0x1200)
music(0)
end
function _update()
end
function _draw()
cls(0)
print("enjoy the music!")
end
function build_bgm()
local bgm=track:new()
bgm:add(32)
bgm:add(32)
trumpet=instrument:new(play_trumpet)
local perf=performer:new(bgm,0,trumpet,0,{30})
perf:play(3,0)
perf:play(3,7)
perf:play(3,5,"warb")
perf:play(1,3)
perf:play(1,2)
perf:play(1,0)
perf:play(2,-2)
perf:play(2,-4)
perf:play(3,-5,"hold")
perf:play(3,5,"hold")
perf:play(4,4,"warb")
perf:rest(1)
perf:play(1,-2)
perf:play(1,0)
perf:play(1,2)
perf:play(1,3)
perf:play(1,5)
perf:play(2,7)
perf:play(2,5)
perf:play(2,12)
perf:play(2,14)
perf:play(2,15)
perf:play(1,17)
perf:play(1,15)
perf:play(2,14)
perf:play(2,12)
perf:play(2,10)
perf:play(1,12)
perf:play(1,10)
perf:play(2,8)
perf:play(1,10)
perf:play(1,8)
perf:play(4,7)
perf:rest(4)
return bgm
end
function play_trumpet(duration,pitch,verbs)
local e=0
if (verbs.slide) e=1
if (verbs.warb) e=2
local out={}
for i=1,duration do
out[i]=nflags:new{p=pitch,v=2,w=2,e=e}
end
if (not verbs.slide) out[1].e=4
if (not verbs.hold and #out>1) out[#out].e=5
return out
end