Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local speaker = nil
- for k, v in pairs(peripheral.getNames()) do
- local type = peripheral.getType(v)
- if type == "speaker" then
- speaker = peripheral.wrap(v)
- end
- end
- if speaker == nil then
- print("Error: No speaker found!")
- return
- end
- local music = "Jurassic Park Theme"
- if #tArgs > 1 then
- print("Usage: <music>")
- return
- end
- if #tArgs ~= 1 then
- print("Default to playing ", music)
- end
- local N_L = {FS=0, G=1, GS=2, A=3, AS=4, B=5}
- local N_M = {C=6, CS=7, D=8, DS=9, E=10, F=11, FS=12, G=13, GS=14, A=15, AS=16, B=17}
- local N_H = {C=18, CS=19, D=20, DS=21, E=22, F=23, FS=24}
- if music == "Jurassic Park Theme" then
- -- A number between 0 and 3, 3 is the volume of a normal note block.
- local vol = 2
- -- The instrument to play the song in
- local inst = "harp"--"guitar"
- local bpm = 100
- local tempo = bpm/60
- local a8 = tempo*(1/8)
- local a4 = tempo*(1/4)
- local a2 = tempo*(1/2)
- local a1 = tempo
- function note(pitch, length)
- speaker.playNote(inst, vol, pitch)
- sleep(length)
- end
- -- pitch goes from (0) F# to (24) F# 2 octaves higher.
- note(N_M.G, a2 + a4) -- G
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a2 + a4) -- G
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4 + a8) -- G
- note(N_M.A, a8) -- A
- note(N_M.A, a4 + a8) -- A
- note(N_H.C, a8) -- C
- note(N_H.C, a2 + a4) -- C
- note(N_M.B, a8) -- B
- note(N_M.G, a8) -- G
- note(N_M.A, a4 + a8) -- A
- note(N_M.FS, a8) -- F#
- note(N_M.D, a4) -- D
- note(N_M.B, a8) -- B
- note(N_M.G, a8) -- G
- note(N_M.A, a4 + a8) -- A
- note(N_H.D, a8) -- D (Third octav)
- note(N_M.G, a8) -- G
- vol = 3
- note(N_H.C, a4 + a8) -- C (Third octav)
- note(N_M.B, a8) -- B
- note(N_M.B, a4 + a8) -- B
- note(N_M.A, a8) -- A
- note(N_M.A, a2) -- A
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4) -- G
- note(N_M.D, a4) -- D
- note(N_M.C, a4) -- C
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4) -- G
- note(N_M.D, a4) -- D
- note(N_M.C, a4) -- C
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4 + a8) -- G
- note(N_M.D, a4) -- D
- note(N_L.G, a4) -- G
- note(N_M.F, a2) -- F
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4) -- G
- note(N_M.D, a4) -- D
- note(N_M.C, a4) -- C
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4) -- G
- note(N_M.D, a4) -- D
- note(N_M.C, a4) -- C
- note(N_M.G, a8) -- G
- note(N_M.FS, a8) -- F#
- note(N_M.FS, a8) -- F#
- note(N_M.G, a4 + a8) -- G
- note(N_M.D, a4) -- D
- note(N_L.G, a4) -- G
- note(N_M.G, a1) -- G
- note(N_M.FS, a1) -- F#
- note(N_M.G, a1) -- G
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement