Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a=peripheral.wrap("top")
- b=peripheral.wrap("bottom")
- c=peripheral.wrap("front")
- d=peripheral.wrap("back")
- e=peripheral.wrap("left")
- f=peripheral.wrap("right")
- if a then
- g=a
- elseif b then
- g=b
- elseif c then
- g=c
- elseif d then
- g=d
- elseif e then
- g=e
- elseif f then
- g=f
- else
- print("Iron Note Block not present. API 'music' will not be used.")
- function noteblock()
- return nil
- end
- function bpm(num)
- return 1/num*60
- end
- function note()
- return nil
- end
- function piano()
- return nil
- end
- function bassdrum()
- return nil
- end
- function snare()
- return nil
- end
- function click()
- return nil
- end
- function bass()
- return nil
- end
- return
- end
- function noteblock()
- return g
- end
- function bpm(num)
- return 1/num*60
- end
- function note(name)
- if name=="F#3" or name=="Gb3" then
- return 0
- elseif name=="G3" then
- return 1
- elseif name=="G#3" or name=="Ab3" then
- return 2
- elseif name=="A3" then
- return 3
- elseif name=="A#3" or name=="Bb3" then
- return 4
- elseif name=="B3" then
- return 5
- elseif name=="C4" then
- return 6
- elseif name=="C#4" or name=="Db4" then
- return 7
- elseif name=="D4" then
- return 8
- elseif name=="D#4" or name=="Eb4" then
- return 9
- elseif name=="E4" then
- return 10
- --elseif name=="E#4" or name=="Fb4" then
- --return 10
- elseif name=="F4" then
- return 11
- elseif name=="F#4" or name=="Gb4" then
- return 12
- elseif name=="G4" then
- return 13
- elseif name=="G#4" or name=="Ab4" then
- return 14
- elseif name=="A4" then
- return 15
- elseif name=="A#4" or name=="Bb4" then
- return 16
- elseif name=="B4" then
- return 17
- elseif name=="C5" then
- return 18
- elseif name=="C#5" or name=="Db5" then
- return 19
- elseif name=="D5" then
- return 20
- elseif name=="D#5" or name=="Eb5" then
- return 21
- elseif name=="E5" then
- return 22
- elseif name=="F5" then
- return 23
- elseif name=="F#5" or name=="Ab5" then
- return 24
- else
- error("Not a valid note name.")
- end
- end
- function piano(no)
- if tonumber(no) then
- noteblock().playNote(0,no)
- else
- noteblock().playNote(0,note(no))
- end
- end
- function bassdrum(no)
- if tonumber(no) then
- noteblock().playNote(1,no)
- else
- noteblock().playNote(1,note(no))
- end
- end
- function snare(no)
- if tonumber(no) then
- noteblock().playNote(2,no)
- else
- noteblock().playNote(2,note(no))
- end
- end
- function click(no)
- if tonumber(no) then
- noteblock().playNote(3,no)
- else
- noteblock().playNote(3,note(no))
- end
- end
- function bass(no)
- if tonumber(no) then
- noteblock().playNote(4,no)
- else
- noteblock().playNote(4,note(no))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement