Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- b = require("button")
- local arg = {...}
- local m = peripheral.wrap(arg[1])
- local s = peripheral.wrap(arg[2])
- volume = 1
- pitch = 0
- inst = "harp"
- m.clear()
- local function prints()
- m.setBackgroundColor(colors.white)
- m.setTextScale(1.5)
- m.setTextColor(colors.black)
- m.setCursorPos(2, 2)
- m.write("volume:" .. " " .. (volume * 10) .. " ")
- m.setCursorPos(8, 2)
- m.setTextColor(colors.green)
- m.write("\24")
- m.setTextColor(colors.red)
- m.setCursorPos(8, 3)
- m.write("\25")
- m.setTextColor(colors.black)
- m.setTextColor(colors.black)
- m.setCursorPos(2, 5)
- m.write("pitch:" .. " " .. pitch .. " ")
- m.setCursorPos(8, 5)
- m.setTextColor(colors.green)
- m.write("\24")
- m.setTextColor(colors.red)
- m.setCursorPos(8, 6)
- m.write("\25")
- m.setTextColor(colors.black)
- end
- local function printe()
- m.setCursorPos(14, 2)
- m.write("harp")
- m.setCursorPos(14, 3)
- m.write("bass")
- m.setCursorPos(14, 4)
- m.write("snare")
- m.setCursorPos(14, 5)
- m.write("hat")
- m.setCursorPos(14, 6)
- m.write("basedrum")
- m.setCursorPos(14, 7)
- m.write("flute")
- m.setCursorPos(20, 2)
- m.write("bell")
- m.setCursorPos(20, 3)
- m.write("chime")
- m.setCursorPos(20, 4)
- m.write("guitar")
- m.setCursorPos(2, 7)
- m.setBackgroundColor(colors.red)
- m.write("run note..")
- m.setBackgroundColor(colors.white)
- end
- prints()
- printe()
- local function touchIn(ins, x, y, l, out)
- if b.button(ins, x, y, l, 1) == true then
- inst = tostring(out)
- printe()
- m.setCursorPos(x, y)
- m.setBackgroundColor(colors.blue)
- m.write(tostring(inst))
- m.setBackgroundColor(colors.white)
- end
- end
- while true do
- local x = {os.pullEvent("monitor_touch")}
- touchIn(x, 14, 2, 4, "harp")
- touchIn(x, 14, 3, 4, "bass")
- touchIn(x, 14, 4, 5, "snare")
- touchIn(x, 14, 5, 5, "hat")
- touchIn(x, 14, 6, 8, "basedrum")
- touchIn(x, 14, 7, 5, "flute")
- touchIn(x, 20, 2, 4, "bell")
- touchIn(x, 20, 3, 5, "chime")
- touchIn(x, 20, 4, 6, "guitar")
- if b.button(x, 8, 2, 1, 1) == true then
- if volume <= 3 then
- volume = volume + 0.1
- prints()
- end
- elseif b.button(x, 8, 3, 1, 1) == true then
- if volume > 0.2 then
- volume = volume - 0.1
- prints()
- end
- end
- if b.button(x, 8, 5, 1, 1) == true then
- if pitch < 24 then
- pitch = pitch + 1
- prints()
- end
- elseif b.button(x, 8, 6, 1, 1) == true then
- if pitch > 0 then
- pitch = pitch - 1
- prints()
- end
- end
- if b.button(x, 2, 7, 10, 1) then
- s.playNote(inst, volume, pitch)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement