Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local speaker = peripheral.wrap("left")
- local notes = {
- ["F#1"]=0, ["F#2"]=12,
- ["Gb1"]=0, ["Gb2"]=12,
- ["G1"]=1, ["G2"]=13,
- ["G#1"]=2, ["G#2"]=14,
- ["Ab1"]=2, ["Ab2"]=14,
- ["A1"]=3, ["A2"]=15,
- ["A#1"]=4, ["A#2"]=16,
- ["Bb1"]=4, ["Bb2"]=16,
- ["B1"]=5, ["B2"]=17,
- ["C1"]=6, ["C2"]=18,
- ["C#1"]=7, ["C#2"]=19,
- ["Db1"]=7, ["Db2"]=19,
- ["D1"]=8, ["D2"]=20,
- ["D#1"]=9, ["D#2"]=21,
- ["Eb1"]=9, ["Eb2"]=21,
- ["E1"]=10, ["E2"]=22,
- ["F1"]=11, ["F2"]=23,
- ["F#3"]=24,
- ["Gb3"]=24,
- }
- local function playNote(instrument,note,volume)
- volume = volume or 1
- speaker.playNote(instrument,volume,notes[note])
- end
- local function harp(note,volume)
- playNote("harp",note,volume)
- end
- --test
- local function a1()
- harp "E1"
- harp "G2"
- harp "B2"
- end
- local function a2()
- harp "G2"
- harp "C2"
- harp "E2"
- end
- local function a3()
- harp "G2"
- harp "B2"
- harp "D2"
- end
- local function a4()
- harp "D1"
- harp "F#2"
- harp "A2"
- end
- --[[
- --local bpm = 136
- --local bps = bpm / 60
- --local spb = 1 / bps
- --local quarter = spb / 4
- --]]
- local function a(f,...)
- local t={...}
- for _,s in ipairs(t) do
- if s > 0 then
- f()
- sleep(0.15 * s)
- else
- sleep(-0.15 * s)
- end
- end
- end
- local function song()
- a(a1, 2,2,1,2,2)
- a(a2, 1,2,2)
- a(a3, 1,2,2)
- a(a4, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1,2,2)
- a(a3, 1,2,2)
- a(a4, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1)
- local t1 = 1/3
- local t2 = 2/3
- parallel.waitForAll(
- function() a(a1, 2,2,1,2,2) end,
- function() a(function()harp "B2" end, -t1,t1,t2,t2) end
- )
- a(a2, 1,2,2)
- a(a3, 1,2,2)
- a(a4, 1)
- parallel.waitForAll(
- function() a(a1, 2,2,1,2,2) end,
- function() a(function()harp "B2" end, -t1,t1,t2,t2) end
- )
- a(a2, 1)
- a(a1, 2,2,1,2,2)
- a(a2, 1)
- for i=1,4 do
- parallel.waitForAll(
- function() a(a1, 2,2,1) end,
- function() a(function()harp "B2" end, -t1,t1,t2,t2) end
- )
- end
- for i=1,3 do
- parallel.waitForAll(
- function() a(a1, 2,2,1) end,
- function() a(function()harp "B2" end, -t1,t1,t2,t1,t1) end
- )
- end
- parallel.waitForAll(
- function() a(a1, 2,2,1) end,
- function() a(function()harp "B2" end, -t1,t1,t2) end
- )
- for j=1,3 do
- a(a1, .5,.5,.5,.5,1)
- a(a1, .5,.5,.5,.5,.5,.5,1)
- a(a2, .5,.5,.5,.5,.5,.5,1)
- a(a3, .5,.5,.5,.5,.5,.5,1)
- a(a4, .5,.5)
- for i=1,3 do
- a(a1, .5,.5,.5,.5,1)
- a(a1, .5,.5,.5,.5,.5,.5,1)
- a(a2, .5,.5)
- end
- a(a2, .5,.5,.5,.5,1)
- a(a3, .5,.5,.5,.5,.5,.5,1)
- a(a4, .5,.5)
- end
- end
- local function scrollWrite(text)
- local w,h = term.getSize()
- text = string.rep(" ", w) .. text
- term.clear()
- while #text > 0 do
- sleep(0.5,text)
- term.setCursorPos(1,h)
- term.clearLine()
- term.write(text)
- text = text:sub(2)
- end
- term.clear()
- end
- local monitor = peripheral.wrap("bottom")
- term.redirect(monitor)
- parallel.waitForAll(
- function() scrollWrite("What's the song at 00:06?") end,
- song
- )
- term.redirect(term.native())
- --eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement