readix

music screen

Feb 26th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.20 KB | None | 0 0
  1. --[[
  2. Exposes a single function, playNote(instrument,note)
  3. where instrument is 0 for piano, 1 for bass drum, 2 for snare, 3 for clicks or 4 for bass guitar,
  4. and note is 0-24 in number of right-clicks.
  5. ]]--
  6.  
  7. diskSide="left"
  8. mon = peripheral.wrap("top")
  9. nb = peripheral.wrap("right")
  10.  
  11. version = "v1.0"
  12. mon.setTextScale(0.5)
  13. w,h = mon.getSize() -- 57,10
  14. wPos=0
  15. hPos=0
  16. char1=nil
  17. char2=nil
  18. instrument = nil
  19. piano={}
  20. drum={}
  21. snare={}
  22. clicks={}
  23. guitar={}
  24. tempo=5
  25.  
  26. function printC(ph,text)
  27. tw,th = term.getSize()
  28. term.setCursorPos((tw/2)-(#text/2),ph)
  29. write(text)
  30. end
  31.  
  32. function welcomeScreen()
  33. term.setTextColour(colours.yellow)
  34. printC(2,"Music Maker "..version)
  35. printC(3,"by fredthead")
  36. term.setTextColour(colours.white)
  37. printC(5,"Instructions")
  38. print("") print("")
  39. print("The 5 lines on the monitor control the different")
  40. print("instruments. From top to bottom: Piano, Bass Drum")
  41. print("Snare, Clicks and Bass Guitar.")
  42. print("")
  43. print("Right click on the small coloured boxes to")
  44. print("activate individual notes. Keep right clicking")
  45. print("to change the pitch. You can go up to 24.")
  46. print("")
  47. print("When you have composed a tune, click on play. You")
  48. print("can also adjust the tempo. It is advisable not to")
  49. print("make it too low or too high though.")
  50. end
  51.  
  52. function greenNote(x,y,text1,text2)
  53. mon.setBackgroundColour(colours.green)
  54. mon.setCursorPos(x,y)
  55. mon.write(text1)
  56. mon.setCursorPos(x,y+1)
  57. mon.write(text2)
  58. mon.setBackgroundColour(colours.black)
  59. end
  60.  
  61. function limeNote(x,y,text1,text2)
  62. mon.setBackgroundColour(colours.lime)
  63. mon.setCursorPos(x,y)
  64. mon.write(text1)
  65. mon.setCursorPos(x,y+1)
  66. mon.write(text2)
  67. mon.setBackgroundColour(colours.black)
  68. end
  69.  
  70. function blueNote(x,y,text1,text2)
  71. mon.setBackgroundColour(colours.blue)
  72. mon.setCursorPos(x,y)
  73. mon.write(text1)
  74. mon.setCursorPos(x,y+1)
  75. mon.write(text2)
  76. mon.setBackgroundColour(colours.black)
  77. end
  78.  
  79. function cyanNote(x,y,text1,text2)
  80. mon.setBackgroundColour(colours.cyan)
  81. mon.setCursorPos(x,y)
  82. mon.write(text1)
  83. mon.setCursorPos(x,y+1)
  84. mon.write(text2)
  85. mon.setBackgroundColour(colours.black)
  86. end
  87.  
  88. function orangeNote(x,y,text1,text2)
  89. mon.setBackgroundColour(colours.orange)
  90. mon.setCursorPos(x,y)
  91. mon.write(text1)
  92. mon.setCursorPos(x,y+1)
  93. mon.write(text2)
  94. mon.setBackgroundColour(colours.black)
  95. end
  96.  
  97. function redNote(x,y,text1,text2)
  98. mon.setBackgroundColour(colours.red)
  99. mon.setCursorPos(x,y)
  100. mon.write(text1)
  101. mon.setCursorPos(x,y+1)
  102. mon.write(text2)
  103. mon.setBackgroundColour(colours.black)
  104. end
  105.  
  106. function greyNote(x,y,text1,text2)
  107. mon.setBackgroundColour(colours.grey)
  108. mon.setCursorPos(x,y)
  109. mon.write(text1)
  110. mon.setCursorPos(x,y+1)
  111. mon.write(text2)
  112. mon.setBackgroundColour(colours.black)
  113. end
  114.  
  115. function lightGreyNote(x,y,text1,text2)
  116. mon.setBackgroundColour(colours.lightGrey)
  117. mon.setCursorPos(x,y)
  118. mon.write(text1)
  119. mon.setCursorPos(x,y+1)
  120. mon.write(text2)
  121. mon.setBackgroundColour(colours.black)
  122. end
  123.  
  124. function purpleNote(x,y,text1,text2)
  125. mon.setBackgroundColour(colours.purple)
  126. mon.setCursorPos(x,y)
  127. mon.write(text1)
  128. mon.setCursorPos(x,y+1)
  129. mon.write(text2)
  130. mon.setBackgroundColour(colours.black)
  131. end
  132.  
  133. function pinkNote(x,y,text1,text2)
  134. mon.setBackgroundColour(colours.pink)
  135. mon.setCursorPos(x,y)
  136. mon.write(text1)
  137. mon.setCursorPos(x,y+1)
  138. mon.write(text2)
  139. mon.setBackgroundColour(colours.black)
  140. end
  141.  
  142. function drawNotes()
  143. --mon.clear()
  144. place=1
  145. for i=1,28 do
  146. if place==1 then
  147. char1="P" char2="N"
  148. else
  149. decodeTable(piano,place-1)
  150. end
  151. greenNote(place,1,char1,char2)
  152. place=place+2
  153. end
  154.  
  155. place=2
  156. for i=1,28 do
  157. decodeTable(piano,place-1)
  158. limeNote(place,1,char1,char2)
  159. place=place+2
  160. end
  161.  
  162. place=1
  163. for i=1,25 do
  164. if place==1 then
  165. char1="D" char2="M"
  166. else
  167. decodeTable(drum,place-1)
  168. end
  169. blueNote(place,3,char1,char2)
  170. place=place+2
  171. end
  172.  
  173. place=2
  174. for i=1,25 do
  175. decodeTable(drum,place-1)
  176. cyanNote(place,3,char1,char2)
  177. place=place+2
  178. end
  179.  
  180. place=1
  181. for i=1,25 do
  182. if place==1 then
  183. char1="S" char2="R"
  184. else
  185. decodeTable(snare,place-1)
  186. end
  187. redNote(place,5,char1,char2)
  188. place=place+2
  189. end
  190.  
  191. place=2
  192. for i=1,25 do
  193. decodeTable(snare,place-1)
  194. orangeNote(place,5,char1,char2)
  195. place=place+2
  196. end
  197.  
  198. place=1
  199. for i=1,25 do
  200. if place==1 then
  201. char1="C" char2="K"
  202. else
  203. decodeTable(clicks,place-1)
  204. end
  205. greyNote(place,7,char1,char2)
  206. place=place+2
  207. end
  208.  
  209. place=2
  210. for i=1,25 do
  211. decodeTable(clicks,place-1)
  212. lightGreyNote(place,7,char1,char2)
  213. place=place+2
  214. end
  215.  
  216. place=1
  217. for i=1,25 do
  218. if place==1 then
  219. char1="G" char2="T"
  220. else
  221. decodeTable(guitar,place-1)
  222. end
  223. purpleNote(place,9,char1,char2)
  224. place=place+2
  225. end
  226.  
  227. place=2
  228. for i=1,25 do
  229. decodeTable(guitar,place-1)
  230. pinkNote(place,9,char1,char2)
  231. place=place+2
  232. end
  233.  
  234. for i=1,10 do
  235. mon.setBackgroundColour(colours.black)
  236. mon.setCursorPos(50,i)
  237. mon.write(" ")
  238. end
  239.  
  240. mon.setBackgroundColour(colours.orange)
  241. mon.setTextColour(colours.black)
  242. mon.setCursorPos(51,4)
  243. mon.write(" ")
  244. mon.setCursorPos(51,5)
  245. mon.write(" PLAY ")
  246. mon.setCursorPos(51,6)
  247. mon.write(" ")
  248. mon.setBackgroundColour(colours.yellow)
  249. mon.setCursorPos(51,1)
  250. mon.write(" ")
  251. mon.setCursorPos(51,2)
  252. mon.write(" TEMPO")
  253. mon.setCursorPos(51,3)
  254. mon.write(" UP DN")
  255. mon.setCursorPos(51,9)
  256. mon.write(" ")
  257. mon.setCursorPos(51,10)
  258. mon.write(" MENU ")
  259. mon.setBackgroundColour(colours.black)
  260. mon.setTextColour(colours.white)
  261.  
  262. end
  263.  
  264. function resetMusic()
  265. tempo=5
  266. piano = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}
  267. drum = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}
  268. snare = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}
  269. clicks = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}
  270. guitar = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}
  271. end
  272.  
  273. function decodeTable(tab,pos)
  274. local val = tab[pos]
  275. if val == nil then
  276. char1=" " char2=" "
  277. elseif val>=0 and val <= 9 then
  278. char1=tostring(0) char2=tostring(val)
  279. elseif val>=10 and val <= 19 then
  280. char1=tostring(1) char2=tostring(val-10)
  281. elseif val>=20 and val <= 24 then
  282. char1=tostring(2) char2=tostring(val-20)
  283. elseif val==25 then
  284. char1=" " char2=" "
  285. end
  286. end
  287.  
  288.  
  289.  
  290. function addClick()
  291.  
  292.  
  293. local val= instrument[wPos-1]
  294. val= val+1
  295. if val == 26 then val = 0 end
  296.  
  297. table.remove(instrument,wPos-1)
  298.  
  299. table.insert(instrument,wPos-1,val)
  300.  
  301. tempSave()
  302. return listen()
  303. end
  304.  
  305. function drawTempo()
  306. mon.setTextColour(colours.orange)
  307. mon.setBackgroundColour(colours.yellow)
  308. mon.setCursorPos(51,1)
  309. mon.write(" ")
  310. mon.setCursorPos(54,1)
  311. if type(tempo)~="number" then
  312. for i,v in pairs(tempo) do
  313. tempo = v
  314. end
  315. end
  316. mon.write(tostring(tempo))
  317. mon.setBackgroundColour(colours.black)
  318. mon.setTextColour(colours.white)
  319. end
  320.  
  321. function tempSave()
  322. local saveTable={{piano},{drum},{snare},{clicks},{guitar},tempo}
  323. dataToSave= textutils.serialize(saveTable)
  324. fs.delete("temp")
  325. fs.makeDir("temp")
  326. print(dataToSave)
  327. handle = fs.open("temp/tempFile","w")
  328. handle.write(dataToSave)
  329. handle.close()
  330. end
  331.  
  332. function tempLoad()
  333. handle=fs.open("temp/tempFile","r")
  334. local fileLoadedTable = handle.readAll()
  335. handle.close()
  336. fileLoadedTable=textutils.unserialize(fileLoadedTable)
  337. piano =fileLoadedTable[1][1]
  338. drum =fileLoadedTable[2][1]
  339. snare =fileLoadedTable[3][1]
  340. clicks=fileLoadedTable[4][1]
  341. guitar=fileLoadedTable[5][1]
  342. tempo= fileLoadedTable[6]
  343. listen()
  344. end
  345.  
  346. function overwrite()
  347. mon.setBackgroundColour(colours.yellow)
  348. mon.setTextColour(colours.black)
  349. mon.setCursorPos(20,4)
  350. mon.write(" ")
  351. mon.setCursorPos(20,5)
  352. mon.write(" OK NO ")
  353. mon.setCursorPos(20,6)
  354. mon.write(" ")
  355. mon.setBackgroundColour(colours.black)
  356. mon.setTextColour(colours.white)
  357. for i=4,6 do
  358. mon.setCursorPos(28,i) mon.write(" ")
  359. end
  360. while true do
  361. local event,p1,p2,p3 = os.pullEvent()
  362. if event=="monitor_touch" and p3 >=4 and p3 <= 6 then
  363. if p2 >=20 and p2 <= 27 then
  364. local saveTable={{piano},{drum},{snare},{clicks},{guitar},{tempo}}
  365. dataToSave= textutils.serialize(saveTable)
  366. if disk.isPresent(diskSide)==false then
  367. diskOps()
  368. end
  369. handle = fs.open("disk/saves/"..input,"w")
  370. handle.write(dataToSave)
  371. handle.close()
  372. mon.clear()
  373. mon.setCursorPos(16,2)
  374. mon.write("Music has been saved to disk")
  375. sleep(1)
  376. listen()
  377. elseif p2 >=31 and p2 <= 38 then
  378. save()
  379. end
  380. end
  381. end
  382. end
  383.  
  384. function loadTheFile()
  385. if disk.isPresent(diskSide)==false then
  386. diskOps()
  387. end
  388. handle=fs.open("disk/saves/"..chooseFile,"r")
  389. local fileLoadedTable = handle.readAll()
  390. handle.close()
  391. fileLoadedTable=textutils.unserialize(fileLoadedTable)
  392. piano =fileLoadedTable[1][1]
  393. drum =fileLoadedTable[2][1]
  394. snare =fileLoadedTable[3][1]
  395. clicks=fileLoadedTable[4][1]
  396. guitar=fileLoadedTable[5][1]
  397. tempo= fileLoadedTable[6]
  398. for i = 9,19 do
  399. term.setCursorPos(1,i)
  400. write(string.rep(" ",w))
  401. end
  402. printC(9,chooseFile.." loaded")
  403. sleep(1)
  404. listen()
  405. end
  406.  
  407. function load()
  408. mon.clear()
  409. if fs.exists("disk/saves")==false then
  410. mon.setCursorPos(16,2)
  411. mon.write("No save files on this disk")
  412. sleep(1.5)
  413. listen()
  414. else
  415. loadTab= fs.list("disk/saves")
  416. if #loadTab==0 or #loadTab=="nil" then
  417. mon.clear()
  418. mon.setCursorPos(16,2)
  419. mon.write("No save files on this disk")
  420. sleep(1.5)
  421. listen()
  422. else
  423.  
  424. term.clear()
  425. term.setTextColour(colours.yellow)
  426. printC(2,"Music Maker "..version)
  427. printC(3,"by fredthead")
  428. term.setTextColour(colours.white)
  429. printC(5,"Enter a filename or type refresh or cancel")
  430. for i,v in pairs(loadTab) do
  431. if #loadTab <=10 then
  432. printC(i+8,v)
  433. elseif #loadTab >1 and #loadTab <= 20 and i <= 10 then
  434. term.setCursorPos(14,i+8)
  435. write(v)
  436. elseif #loadTab >10 and #loadTab <=20 and i > 10 then
  437. term.setCursorPos(30,i-2)
  438. write(v)
  439. elseif #loadTab >20 and #loadTab <=30 and i<=10 then
  440. term.setCursorPos(8,i+8)
  441. write(v)
  442. elseif #loadTab >20 and #loadTab <=30 and i > 10 and i<=20 then
  443. term.setCursorPos(22,i-2)
  444. write(v)
  445. elseif #loadTab >20 and #loadTab <=30 and i > 20 and i<=30 then
  446. term.setCursorPos(37,i-12)
  447. write(v)
  448. end
  449. end
  450. term.setCursorPos(19,7)
  451. write("> ")
  452.  
  453. chooseFile=io.read()
  454. if chooseFile==string.lower("refresh") then load() end
  455. if chooseFile==string.lower("cancel") then
  456. listen()
  457. else
  458. for i=1,#loadTab do
  459. --print(loadTab[i])
  460. if chooseFile==loadTab[i] then
  461. loadTheFile()
  462. end
  463. end
  464. print("Unknown filename")
  465. sleep(1)
  466. load()
  467. end
  468. end
  469.  
  470. end
  471. end
  472.  
  473. function max30PerDisk()
  474. term.clear()
  475. printC(5,"Sorry, only 30 tracks per disk")
  476. sleep(1)
  477. menu()
  478. end
  479.  
  480. function save()
  481. mon.clear()
  482. if fs.exists("disk/saves")==false then
  483. fs.makeDir("disk/saves")
  484. end
  485. saveNum = fs.list("disk/saves")
  486. if #saveNum > 29 then
  487. max30PerDisk()
  488. end
  489.  
  490. mon.setCursorPos(16,2)
  491. mon.write("Enter a name for your music on")
  492. mon.setCursorPos(16,3)
  493. mon.write(" the terminal below")
  494. input = ""
  495. local count = 0
  496. local inputEntered=false
  497. term.clear()
  498.  
  499. while inputEntered == false do
  500. term.setCursorPos(10,4)
  501. printC(4,"Please enter a filename")
  502. local event,p1,p2,p3 = os.pullEvent()
  503. if event=="char" and count < 11 then
  504.  
  505. term.setCursorPos(20,6)
  506.  
  507. input = input..p1
  508. count=count+1
  509. term.write(input)
  510. elseif event == "key" and p1==14 and count>0 then
  511. input=string.sub(input,1,(string.len(input)-1))
  512. term.setCursorPos(20,6)
  513. count=count-1
  514. term.write(input.." ")
  515. elseif event == "key" and p1==28 and input ~= "" then
  516. inputEntered=true
  517. term.clear()
  518. term.setCursorPos(20,4)
  519. print("Thank you")
  520. end
  521. end
  522.  
  523. if fs.exists("disk/saves/"..input) == true then
  524. mon.clear()
  525. mon.setCursorPos(18,2)
  526. mon.write("File exists. Overwrite?")
  527. overwrite()
  528. else
  529. local saveTable={{piano},{drum},{snare},{clicks},{guitar},tempo}
  530. dataToSave= textutils.serialize(saveTable)
  531. if disk.isPresent(diskSide)==false then
  532. diskOps()
  533. end
  534. handle = fs.open("disk/saves/"..input,"w")
  535. handle.write(dataToSave)
  536. handle.close()
  537. mon.clear()
  538. mon.setCursorPos(16,2)
  539. mon.write("Music has been saved to disk")
  540. sleep(1)
  541. listen()
  542. end
  543. end
  544.  
  545. function menu()
  546. mon.clear()
  547. mon.setBackgroundColour(colours.yellow)
  548. mon.setTextColour(colours.black)
  549. mon.setCursorPos(15,4)
  550. mon.write(" ")
  551. mon.setCursorPos(15,5)
  552. mon.write(" LOAD SAVE NEW ")
  553. mon.setCursorPos(15,6)
  554. mon.write(" ")
  555. mon.setCursorPos(51,9)
  556. mon.write(" ")
  557. mon.setCursorPos(51,10)
  558. mon.write(" BACK ")
  559. mon.setBackgroundColour(colours.black)
  560. mon.setTextColour(colours.white)
  561. for i=4,6 do
  562. mon.setCursorPos(23,i) mon.write(" ")
  563. end
  564. for i=4,6 do
  565. mon.setCursorPos(34,i) mon.write(" ")
  566. end
  567. while true do
  568. local event,p1,p2,p3 = os.pullEvent()
  569. if event=="monitor_touch" and p3 >=4 and p3 <= 6 then
  570. if p2 >=15 and p2 <= 22 then
  571. state="load"
  572. diskOps()
  573. --load()
  574. elseif p2 >=26 and p2 <= 33 then
  575. state="save"
  576. diskOps()
  577. --save()
  578. elseif p2 >=37 and p2 <=44 then
  579. --are you sure
  580. mon.clear()
  581. mon.setBackgroundColour(colours.yellow)
  582. mon.setTextColour(colours.black)
  583. mon.setCursorPos(20,4)
  584. mon.write(" ")
  585. mon.setCursorPos(20,5)
  586. mon.write(" OK NO ")
  587. mon.setCursorPos(20,6)
  588. mon.write(" ")
  589. mon.setBackgroundColour(colours.black)
  590. mon.setTextColour(colours.white)
  591. for i=4,6 do
  592. mon.setCursorPos(28,i) mon.write(" ")
  593. end
  594. while true do
  595. local event,p1,p2,p3 = os.pullEvent()
  596. if event=="monitor_touch" and p3 >=4 and p3 <= 6 then
  597. if p2 >=20 and p2 <= 27 then -- OK
  598. resetMusic()
  599. tempSave()
  600. listen()
  601. elseif p2 >=31 and p2 <= 38 then -- CANCEL
  602. listen()
  603. end
  604. end
  605. end
  606. end
  607. elseif event=="monitor_touch" and p3==9 or p3==10 then
  608. if p2 >= 51 and p2 <= 56 then -- BACK clicked
  609. listen()
  610. end
  611. end
  612. end
  613.  
  614. end
  615.  
  616. function diskOps()
  617. mon.clear()
  618. if disk.hasData("left")==false then
  619. mon.setCursorPos(16,2)
  620. mon.write("Please insert a floppy disk")
  621. mon.setBackgroundColour(colours.yellow)
  622. mon.setTextColour(colours.black)
  623. mon.setCursorPos(20,4)
  624. mon.write(" ")
  625. mon.setCursorPos(20,5)
  626. mon.write(" OK CANCEL ")
  627. mon.setCursorPos(20,6)
  628. mon.write(" ")
  629. mon.setBackgroundColour(colours.black)
  630. mon.setTextColour(colours.white)
  631. for i=4,6 do
  632. mon.setCursorPos(28,i) mon.write(" ")
  633. end
  634. while true do
  635. local event,p1,p2,p3 = os.pullEvent()
  636. if event=="monitor_touch" and p3 >=4 and p3 <= 6 then
  637. if p2 >=20 and p2 <= 27 then
  638. mon.clear()
  639. sleep(0.5)
  640. diskOps()
  641. elseif p2 >=31 and p2 <= 38 then
  642. listen()
  643. end
  644. end
  645. end
  646. else
  647. if state=="load" then
  648. load()
  649. elseif state=="save" then
  650. save()
  651. end
  652. end
  653. end
  654.  
  655. function listen()
  656. term.clear()
  657. term.setCursorPos(1,1)
  658. welcomeScreen()
  659. drawNotes()
  660. drawTempo()
  661. repeat
  662. local event,p1,p2,p3 = os.pullEvent()
  663. if event=="monitor_touch" and p2 > 1 and p2 < 50 then
  664. --print("width "..p2..", height "..p3)
  665. wPos=p2
  666. hPos=p3
  667. if p3 == 1 or p3 == 2 then instrument = piano
  668. elseif p3==3 or p3==4 then instrument = drum
  669. elseif p3==5 or p3==6 then instrument = snare
  670. elseif p3==7 or p3==8 then instrument = clicks
  671. elseif p3==9 or p3==10 then instrument= guitar
  672. end
  673. return addClick()
  674. elseif event =="monitor_touch" and p2 >= 51 and p2 <= 53 and p3== 3 then
  675. tempo=tempo+1
  676. if tempo > 9 then tempo = 9 end
  677. if tempo < 1 then tempo = 1 end
  678. drawTempo()
  679. elseif event =="monitor_touch" and p2 >= 54 and p2 <= 56 and p3== 3 then
  680. tempo=tempo-1
  681. if tempo > 9 then tempo = 9 end
  682. if tempo < 1 then tempo = 1 end
  683. drawTempo()
  684. elseif event=="monitor_touch" and p2 >= 51 and p2 <= 56 and p3 >= 4 and p3 <= 6 then
  685. play()
  686. elseif event=="monitor_touch" and p2 >= 51 and p2 <= 56 and p3 >= 9 and p3 <= 10 then
  687. menu()
  688. end
  689. until event=="char" and p1==("x")
  690. end
  691.  
  692. function play()
  693. mon.setTextColour(colours.white)
  694. mon.setBackgroundColour(colours.black)
  695. for i=1,10 do
  696. mon.setCursorPos(50,i)
  697. mon.write(" ")
  698. end
  699. mon.setCursorPos(54,2)
  700. mon.write("P")
  701. mon.setCursorPos(54,3)
  702. mon.write("L")
  703. mon.setCursorPos(54,4)
  704. mon.write("A")
  705. mon.setCursorPos(54,5)
  706. mon.write("Y")
  707. mon.setCursorPos(54,6)
  708. mon.write("I")
  709. mon.setCursorPos(54,7)
  710. mon.write("N")
  711. mon.setCursorPos(54,8)
  712. mon.write("G")
  713. mon.setBackgroundColour(colours.yellow)
  714. mon.setTextColour(colours.red)
  715. mon.setCursorPos(53,10)
  716. mon.write("STOP")
  717. mon.setTextColour(colours.white)
  718. mon.setBackgroundColour(colours.black)
  719.  
  720.  
  721. local noteCount=1
  722. local speed = ((10 - tempo)/10)/2
  723. playTimer=os.startTimer(speed)
  724.  
  725. while noteCount < 49 do
  726. local event,p1,p2,p3 = os.pullEvent()
  727. if event=="timer" and playTimer==p1 then
  728. playTimer=os.startTimer(speed)
  729. if piano[noteCount] ~= 25 then nb.playNote(0,piano[noteCount]) end
  730. if drum[noteCount] ~= 25 then nb.playNote(1,drum[noteCount]) end
  731. if snare[noteCount] ~= 25 then nb.playNote(2,snare[noteCount]) end
  732. if clicks[noteCount] ~= 25 then nb.playNote(3,clicks[noteCount]) end
  733. if guitar[noteCount] ~= 25 then nb.playNote(4,guitar[noteCount]) end
  734. noteCount=noteCount+1
  735. elseif event=="monitor_touch" and p3 == 10 and p2 >= 53 and p2 <= 56 then
  736. listen()
  737. end
  738. end
  739. listen()
  740. end
  741.  
  742.  
  743.  
  744. if fs.exists("temp/tempFile") then
  745. tempLoad()
  746. else
  747. resetMusic()
  748. end
  749.  
  750. listen()
Add Comment
Please, Sign In to add comment