Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local note = require("note")
- local os = require("os")
- local io = require("io")
- local fs = require("filesystem")
- local shell = require("shell")
- -- WRITTEN FOR OPEN COMPUTERS BY Voxelat3d
- -- Version 0.4
- local sleepsecs = 0.5
- local curtone = ""
- local curoct = 2
- function translatenotes(t)
- local curnote = note.name(note.ticks(t))
- local oct = curnote:gsub("%a","")
- oct = oct:gsub("#","")
- local octave = tonumber(oct)+curoct
- curtone = curnote:gsub("%d","")..octave
- end
- function n(t)
- os.sleep(sleepsecs)
- translatenotes(t)
- note.play(curtone)
- end
- function nn(t)
- os.sleep(sleepsecs)
- note.play(t)
- end
- --TRACKER BEGIN
- local args = {...}
- local sheet
- print(shell.getWorkingDirectory().."/"..args[1])
- if (fs.exists(shell.getWorkingDirectory().."/"..args[1])) then
- sheet = io.open(shell.getWorkingDirectory().."/"..args[1],"r")
- else
- sheet = io.open(args[1],"r")
- end
- local validdata = true
- local lc = 1
- while validdata do
- data = sheet:read()
- if data ~= nil then
- if not string.match(data,"#") or string.match(data,"%a+#") then
- if string.match(data,"s") then
- if string.match(data,"s%d+%.*%d*") then
- tosleep = string.match(data,"%d+%.*%d*")
- print("S ",tosleep)
- sleepsecs = tonumber(tosleep)
- else
- error("NOPE SLEEP SYNTAX WRONG @ "..lc)
- end
- elseif string.match(data,"o") then
- if string.match(data,"o%d+") then
- curoct = string.match(data,"%d+")
- print("O ",curoct)
- else
- error("NOPE OCTAVE SYNTAX WRONG @ "..lc)
- end
- elseif string.match(data,"%a+#%d+") or string.match(data,"%a+%d+") then
- print("+ ",data)
- nn(data)
- elseif string.match(data,"%d+") then
- print("* ",data)
- n(tonumber(data))
- else
- error("NOPE @ "..lc)
- end
- else
- print(data)
- end
- lc=lc+1
- else
- validdata = false
- end
- end
- sheet:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement