Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local computer = require("computer")
- local keyboard = require("keyboard")
- currentNote = 0
- note = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- notesec = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- i = 0
- i2 = 0
- term.clear()
- function redrawMenu()
- term.clear()
- print("+-Note Sequencer-----------------+")
- print("+ 1-2-3-4-5-6-7-8-9 Играть ноты +")
- print("+ F1-F10 - Настройка нот +")
- print("+ Ctrl - Играть Shift - Random +")
- print("+ X - Выход +")
- print("+--------------------------------+")
- print("Сечас играет нота: "..currentNote)
- end
- redrawMenu()
- while true do
- os.sleep(0.1)
- if keyboard.isKeyDown(0x3B) == true then -- f1
- os.sleep(0.1)
- print("Настройка ноты 1")
- -- Чтение частоты
- io.write("Частота: ")
- note[1] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[1] = io.read("*number")
- redrawMenu()
- end
- os.sleep(0.1)
- if keyboard.isKeyDown(0x3C) == true then -- f2
- os.sleep(0.1)
- print("Настройка ноты 2")
- -- Чтение частоты
- io.write("Частота: ")
- note[2] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[2] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3D) == true then -- f3
- os.sleep(0.1)
- print("Настройка ноты 3")
- -- Чтение частоты
- io.write("Частота: ")
- note[3] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[3] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3E) == true then -- f4
- os.sleep(0.1)
- print("Настройка ноты 4")
- -- Чтение частоты
- io.write("Частота: ")
- note[4] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[4] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3F) == true then -- f5
- os.sleep(0.1)
- print("Настройка ноты 5")
- -- Чтение частоты
- io.write("Частота: ")
- notesec[5] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[5] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x40) == true then -- f6
- os.sleep(0.1)
- print("Настройка ноты 6")
- -- Чтение частоты
- io.write("Частота: ")
- note[6] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[6] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x41) == true then -- f7
- os.sleep(0.1)
- print("Настройка ноты 7")
- -- Чтение частоты
- io.write("Частота: ")
- note[7] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[7] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x42) == true then -- f8
- os.sleep(0.1)
- print("Настройка ноты 8")
- -- Чтение частоты
- io.write("Частота: ")
- note[8] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[8] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x43) == true then -- f9
- os.sleep(0.1)
- print("Настройка ноты 9")
- -- Чтение частоты
- io.write("Частота: ")
- note[9] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[9] = io.read("*number")
- redrawMenu()
- end
- if keyboard.isKeyDown(0x44) == true then -- f10
- os.sleep(0.1)
- print("Настройка ноты 10")
- -- Чтение частоты
- io.write("Частота: ")
- note[10] = io.read("*number")
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- notesec[10] = io.read("*number")
- redrawMenu()
- end
- os.sleep(0.1)
- if keyboard.isKeyDown(0x02) == true then -- 1
- os.sleep(0.1)
- computer.beep(note[1], notesec[1])
- end
- if keyboard.isKeyDown(0x03) == true then -- 2
- os.sleep(0.1)
- computer.beep(note[2], notesec[2])
- end
- if keyboard.isKeyDown(0x04) == true then -- 3
- os.sleep(0.1)
- computer.beep(note[3], notesec[3])
- end
- if keyboard.isKeyDown(0x05) == true then -- 4
- os.sleep(0.1)
- computer.beep(note[4], notesec[4])
- end
- if keyboard.isKeyDown(0x06) == true then -- 5
- os.sleep(0.1)
- computer.beep(note[5], notesec[5])
- end
- if keyboard.isKeyDown(0x07) == true then -- 6
- os.sleep(0.1)
- computer.beep(note[6], notesec[6])
- end
- if keyboard.isKeyDown(0x08) == true then -- 7
- os.sleep(0.1)
- computer.beep(note[7], notesec[7])
- end
- if keyboard.isKeyDown(0x09) == true then -- 8
- os.sleep(0.1)
- computer.beep(note[8], notesec[8])
- end
- if keyboard.isKeyDown(0x0A) == true then -- 9
- os.sleep(0.1)
- computer.beep(note[9], notesec[9])
- end
- if keyboard.isKeyDown(0x0B) == true then -- 10
- os.sleep(0.1)
- computer.beep(note[10], notesec[10])
- end
- if keyboard.isKeyDown(0x2D) == true then -- Выход
- os.sleep(0.1)
- os.exit()
- end
- if keyboard.isShiftDown() == true then -- Рандом
- computer.beep(1500, 0.5)
- note = {math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000), math.random(100,2000)}
- notesec = {0.1, 0.2, 0.3, 0.1, 0, 0.4, 0.1, 0.2, 0.1, 0.3}
- end
- if keyboard.isControlDown() == true then -- Играть
- io.write("Сколько раз повторять: ")
- i2 = io.read("*number")
- os.sleep(0.1)
- for i = 1, i2 do
- os.sleep(0)
- computer.beep(note[1],notesec[1])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[2],notesec[2])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[3],notesec[3])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[4],notesec[4])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[5],notesec[5])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[6],notesec[6])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[7],notesec[7])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[8],notesec[8])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[9],notesec[9])
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note[10],notesec[10])
- currentNote = currentNote + 1
- currentNote = 0
- redrawMenu()
- end
- end
- end
Advertisement
RAW Paste Data
Copied
Advertisement