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
- note1 = 0
- note2 = 0
- note3 = 0
- note4 = 0
- note5 = 0
- note6 = 0
- note7 = 0
- note8 = 0
- note9 = 0
- note10 = 0
- note1sec = 0
- note2sec = 0
- note3sec = 0
- note4sec = 0
- note5sec = 0
- note6sec = 0
- note7sec = 0
- note8sec = 0
- note9sec = 0
- note10sec = 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("Частота: ")
- note1 = io.read("*number")
- print("Частота установлена на"..note1)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note1sec = io.read("*number")
- print("Длительность установлена на"..note1sec)
- redrawMenu()
- end
- os.sleep(0.1)
- if keyboard.isKeyDown(0x3C) == true then -- f2
- os.sleep(0.1)
- print("Настройка ноты 2")
- -- Чтение частоты
- io.write("Частота: ")
- note2 = io.read("*number")
- print("Частота установлена на"..note2)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note2sec = io.read("*number")
- print("Длительность установлена на"..note2sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3D) == true then -- f3
- os.sleep(0.1)
- print("Настройка ноты 3")
- -- Чтение частоты
- io.write("Частота: ")
- note3 = io.read("*number")
- print("Частота установлена на"..note3)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note3sec = io.read("*number")
- print("Длительность установлена на"..note3sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3E) == true then -- f4
- os.sleep(0.1)
- print("Настройка ноты 4")
- -- Чтение частоты
- io.write("Частота: ")
- note4 = io.read("*number")
- print("Частота установлена на"..note4)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note4sec = io.read("*number")
- print("Длительность установлена на"..note4sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x3F) == true then -- f5
- os.sleep(0.1)
- print("Настройка ноты 5")
- -- Чтение частоты
- io.write("Частота: ")
- note5 = io.read("*number")
- print("Частота установлена на"..note5)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note5sec = io.read("*number")
- print("Длительность установлена на"..note5sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x40) == true then -- f6
- os.sleep(0.1)
- print("Настройка ноты 6")
- -- Чтение частоты
- io.write("Частота: ")
- note6 = io.read("*number")
- print("Частота установлена на"..note6)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note6sec = io.read("*number")
- print("Длительность установлена на"..note6sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x41) == true then -- f7
- os.sleep(0.1)
- print("Настройка ноты 7")
- -- Чтение частоты
- io.write("Частота: ")
- note7 = io.read("*number")
- print("Частота установлена на"..note7)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note7sec = io.read("*number")
- print("Длительность установлена на"..note7sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x42) == true then -- f8
- os.sleep(0.1)
- print("Настройка ноты 8")
- -- Чтение частоты
- io.write("Частота: ")
- note8 = io.read("*number")
- print("Частота установлена на"..note8)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note8sec = io.read("*number")
- print("Длительность установлена на"..note8sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x43) == true then -- f9
- os.sleep(0.1)
- print("Настройка ноты 9")
- -- Чтение частоты
- io.write("Частота: ")
- note9 = io.read("*number")
- print("Частота установлена на"..note9)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note9sec = io.read("*number")
- print("Длительность установлена на"..note9sec)
- redrawMenu()
- end
- if keyboard.isKeyDown(0x44) == true then -- f10
- os.sleep(0.1)
- print("Настройка ноты 10")
- -- Чтение частоты
- io.write("Частота: ")
- note10 = io.read("*number")
- print("Частота установлена на"..note10)
- -- Чтение длительностей
- io.write("Длительность (в секундах): ")
- note10sec = io.read("*number")
- print("Длительность установлена на"..note10sec)
- redrawMenu()
- end
- os.sleep(0.1)
- if keyboard.isKeyDown(0x02) == true then -- 1
- os.sleep(0.1)
- computer.beep(note1, note1sec)
- end
- if keyboard.isKeyDown(0x03) == true then -- 2
- os.sleep(0.1)
- computer.beep(note2, note2sec)
- end
- if keyboard.isKeyDown(0x04) == true then -- 3
- os.sleep(0.1)
- computer.beep(note3, note3sec)
- end
- if keyboard.isKeyDown(0x05) == true then -- 4
- os.sleep(0.1)
- computer.beep(note4, note4sec)
- end
- if keyboard.isKeyDown(0x06) == true then -- 5
- os.sleep(0.1)
- computer.beep(note5, note5sec)
- end
- if keyboard.isKeyDown(0x07) == true then -- 6
- os.sleep(0.1)
- computer.beep(note6, note6sec)
- end
- if keyboard.isKeyDown(0x08) == true then -- 7
- os.sleep(0.1)
- computer.beep(note7, note7sec)
- end
- if keyboard.isKeyDown(0x09) == true then -- 8
- os.sleep(0.1)
- computer.beep(note8, note8sec)
- end
- if keyboard.isKeyDown(0x0A) == true then -- 9
- os.sleep(0.1)
- computer.beep(note9, note9sec)
- end
- if keyboard.isKeyDown(0x0B) == true then -- 10
- os.sleep(0.1)
- computer.beep(note10, note10sec)
- end
- if keyboard.isKeyDown(0x2D) == true then -- Выход
- os.sleep(0.1)
- os.exit()
- end
- if keyboard.isShiftDown() == true then -- Рандом
- computer.beep(1500, 0.5)
- note1 = math.random(100, 2000)
- note2 = math.random(100, 2000)
- note3 = math.random(100, 2000)
- note4 = math.random(100, 2000)
- note5 = math.random(100, 2000)
- note6 = math.random(100, 2000)
- note7 = math.random(100, 2000)
- note8 = math.random(100, 2000)
- note9 = math.random(100, 2000)
- note10 = math.random(100, 2000)
- note1sec = 0.1
- note2sec = 0.2
- note3sec = 0.1
- note4sec = 0.3
- note5sec = 0.1
- note6sec = 0.5
- note7sec = 1
- note8sec = 0.1
- note9sec = 0.1
- note10sec = 0.4
- end
- if keyboard.isControlDown() == true then -- Играть
- io.write("Сколько раз повторять: ")
- i2 = io.read("*number")
- os.sleep(0.1)
- for i = 1, i2 do
- computer.beep(note1,note1sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note2,note2sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note3,note3sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note4,note4sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note5,note5sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note6,note6sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note7,note7sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note8,note8sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note9,note9sec)
- currentNote = currentNote + 1
- redrawMenu()
- computer.beep(note10,note10sec)
- currentNote = currentNote + 1
- currentNote = 0
- redrawMenu()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement