Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//funcs
- function playNote(pitch, side)
- if not(pitch == -1) then
- peripheral.call(side,"setPitch",pitch)
- peripheral.call(side,"triggerNote")
- end
- end
- function pause(beatlength, length)
- os.sleep(beatlength/length)
- end
- function getSongInfo(file)
- local dataH = fs.open(file, "r")
- local data = textutils.unserialise(dataH.readAll())
- dataH.close()
- local song = {}
- song.beatlength = data[1]
- song.notes = data[#data]
- return song
- end
- --//
- local args = {...}
- local file = args[1]
- local loop = args[2] == "loop"
- local debug = args[3] == "debug"
- local song = getSongInfo(file)
- local notes = song.notes
- local beatlength = song.beatlength
- repeat
- for _, accord in pairs(notes) do
- for _,note in pairs(accord[1])do
- playNote(note[1], note[2])
- end
- pause(beatlength, accord[2])
- end
- until not loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement