Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- spk = peripheral.wrap("right")
- songname = "Untitled.mid"
- pats = {
- snare = {},
- hat = {},
- basedrum = {},
- bass = {},
- harp = {},
- flute = {},
- bell = {},
- chime = {},
- guitar = {},
- }
- instNames = {
- "snare",
- "hat",
- "basedrum",
- "bass",
- "harp",
- "flute",
- "bell",
- "chime",
- "guitar",
- }
- songLength = 32
- function Main()
- while true do
- DrawHome()
- end
- end
- function DrawHome()
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.blue)
- mon.write(" " .. songname .. " ")
- mon.setCursorPos(19,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.green)
- mon.write(" PLAY ")
- mon.setCursorPos(25,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.red)
- mon.write(" STOP ")
- mon.setCursorPos(33,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.orange)
- mon.write(" SAVE ")
- mon.setCursorPos(39,1)
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.black)
- mon.write("X")
- local c = 0
- mon.setBackgroundColor(colors.black)
- for k, v in pairs(pats) do
- mon.setCursorPos(4,3+i)
- if #v > 0 then
- mon.setTextColor(colors.green)
- else
- mon.setTextColor(colors.gray)
- end
- mon.write(k)
- c = c + 1
- end
- local x, y = GetClick()
- if y == 1 then
- if x >= 19 and x <= 24 then
- -- PLAY
- elseif x >= 25 and x <= 30 then
- -- STOP
- elseif x >= 33 and x <= 38 then
- -- SAVE
- elseif x == 39 then
- -- QUIT
- end
- elseif y >= 3 and y <= 11 then
- local instIndex = y - 2
- if x >= 4 and x <= instNames[instIndex]:len() - 1 then
- DrawPat(instNames[instIndex])
- end
- end
- end
- function DrawPat(inst)
- local viewSection = 1
- while true do
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.orange)
- mon.write(" " .. inst .. " ")
- mon.setCursorPos(19,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.green)
- mon.write(" PLAY ")
- mon.setCursorPos(25,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.red)
- mon.write(" STOP ")
- mon.setCursorPos(34,1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.orange)
- mon.write(" BACK ")
- for i = 1, 9 do
- for j = 1, 32 do
- mon.setCursorPos(3,2+j)
- if pats[inst][j] == i then
- mon.setBackgroundColor(colors.blue)
- else
- mon.setBackgroundColor(colors.black)
- end
- mon.write(" ")
- end
- end
- local x, y = GetClick()
- if y == 1 then
- if x >= 19 and x <= 24 then
- -- PLAY
- elseif x >= 25 and x <= 30 then
- -- STOP
- elseif x >= 34 and x <= 39 then
- -- BACK
- end
- -- elseif y >= 3 and y <= 11 then
- -- local instIndex = y - 2
- -- if x >= 4 and x <= instNames[instIndex]:len() - 1 then
- -- DrawPat(instNames[instIndex])
- -- end
- end
- end
- end
- function GetClick()
- while true do
- local event, p1, p2, p3 = os.pullEvent()
- if event == "monitor_touch" or event == "mouse_click" then
- return p2, p3
- end
- end
- end
- args = {...}
- if #args > 0 then
- -- load a saved file
- else
- for k, v in pats do
- for i = 1, songLength do
- table.insert(v, 0)
- end
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement