Compare commits
10 Commits
8692a704ba
...
2711d658ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 2711d658ea | |||
| 4e57946e82 | |||
| 8cf446d391 | |||
| 110ceed23d | |||
| 7839936ea7 | |||
| 7dc79632ca | |||
| 685c24a44a | |||
| 65934b61ce | |||
| 8f64d54c00 | |||
| b428c24a1f |
@@ -4,21 +4,6 @@ local modem = peripheral.find("modem")
|
||||
local monitor = peripheral.wrap("top")
|
||||
controlRoomSpeakers = peripheral.find("speaker")
|
||||
|
||||
local speakers = {
|
||||
peripheral.wrap("speaker_0"),
|
||||
peripheral.wrap("speaker_1"),
|
||||
peripheral.wrap("speaker_2"),
|
||||
peripheral.wrap("speaker_3"),
|
||||
peripheral.wrap("speaker_4"),
|
||||
peripheral.wrap("speaker_5"),
|
||||
peripheral.wrap("speaker_6"),
|
||||
peripheral.wrap("speaker_7"),
|
||||
peripheral.wrap("speaker_8"),
|
||||
peripheral.wrap("speaker_9"),
|
||||
peripheral.wrap("speaker_10"),
|
||||
peripheral.wrap("speaker_11"),
|
||||
}
|
||||
|
||||
function setNewLine()
|
||||
local x,y = monitor.getCursorPos()
|
||||
monitor.setCursorPos(1, y + 1)
|
||||
@@ -27,11 +12,8 @@ end
|
||||
|
||||
local function startup()
|
||||
speakerDriver.startup()
|
||||
--speakerDriver.playControlRoomAlarm(controlRoomSpeakers)
|
||||
--speakerDriver.playExternalAlarm(controlRoomSpeakers)
|
||||
--speakerDriver.playInternalAlarm(controlRoomSpeakers)
|
||||
speakerDriver.playTTSFile(speakers, "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST")
|
||||
speakerDriver.playTTSFile(speakers, "ITS ME NOVA ELLO THEY GOT ME LOCKED IN A BLOOOODY BOX MATE")
|
||||
speakerDriver.playTTSFile(peripheral.wrap("left"), "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST")
|
||||
speakerDriver.playTTSFile(peripheral.wrap("right"), "ELLO MATE LOVELY DAY INIT YOU GOT ANYYYY BEEEANSS AND TOAST ON YA MATE ID LOVE TO HAVE SOME BEANS N TOAST")
|
||||
end
|
||||
|
||||
local function run()
|
||||
|
||||
@@ -17,45 +17,18 @@ local function randomFileName()
|
||||
return name
|
||||
end
|
||||
|
||||
|
||||
local function playSingleSound(speaker, values)
|
||||
|
||||
local function playSound(speaker, fileName)
|
||||
local fileStream = getFileName(fileName)
|
||||
local values = io.lines(fileStream, 16 * 1024)
|
||||
for input in values do
|
||||
print("playing audo....")
|
||||
local decoded = decoder(input)
|
||||
speaker.playAudio(decoded, 3)
|
||||
end
|
||||
end
|
||||
|
||||
local function playSound(speaker, fileName)
|
||||
|
||||
local fileStream = fs.ope(getFileName(fileName), "r")
|
||||
local data = fileName.readAll()
|
||||
local speakers = table.pack(peripheral.find("speaker"))
|
||||
local tasks = {}
|
||||
|
||||
for i = 1, speakers.n do
|
||||
tasks[i] = function()
|
||||
playSingleSound(speakers[i], data)
|
||||
while not speaker.playAudio(decoded, 3) do
|
||||
os.pullEvent("speaker_audio_empty")
|
||||
end
|
||||
end
|
||||
|
||||
parallel.waitForAll(table.unpack(tasks, 1, speakers.n))
|
||||
end
|
||||
|
||||
-- local function playSound(speaker, fileName)
|
||||
-- local fileStream = getFileName(fileName)
|
||||
-- local values = io.lines(fileStream, 16 * 1024)
|
||||
-- for input in values do
|
||||
-- print("playing audo....")
|
||||
-- local decoded = decoder(input)
|
||||
-- while not speaker.playAudio(decoded, 3) do
|
||||
-- os.pullEvent("speaker_audio_empty")
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
local function playControlRoomAlarm(speakers)
|
||||
playSound(speakers,"short_control_alarm")
|
||||
end
|
||||
@@ -63,6 +36,7 @@ end
|
||||
local function playExternalAlarm(speakers)
|
||||
playSound(speakers,"external_alarm")
|
||||
end
|
||||
|
||||
local function playInternalAlarm(speakers)
|
||||
playSound(speakers,"internal_alarm")
|
||||
end
|
||||
@@ -109,16 +83,13 @@ local function createSoundFile(fileName)
|
||||
print("Recieved response!")
|
||||
local fileData = handle.readAll()
|
||||
local file = fs.open(name,"w")
|
||||
|
||||
file.write(fileData)
|
||||
|
||||
file.write(fileData)
|
||||
file.close()
|
||||
handle.close()
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function addSoundFile(fileName)
|
||||
createSoundFile(fileName)
|
||||
end
|
||||
|
||||
25
speaker_main.lua
Normal file
25
speaker_main.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
speaker = peripheral.find("speaker")
|
||||
speakerDriver = kernel.addDriver("speaker_driver")
|
||||
|
||||
local function startup()
|
||||
parallel.waitForAll(speakerDriver.startup)
|
||||
end
|
||||
|
||||
local function shutDown()
|
||||
parallel.waitForAll(speakerDriver.shutDown)
|
||||
end
|
||||
|
||||
local function runSafe()
|
||||
startup()
|
||||
end
|
||||
|
||||
local function run()
|
||||
local success, err = pcall(runSafe)
|
||||
if not success then
|
||||
os.reboot()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
return { run = run }
|
||||
4
speaker_startup.lua
Normal file
4
speaker_startup.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
local kernel = require("kernel")
|
||||
local main = kernel.addDriver("speaker_main")
|
||||
sleep(5)
|
||||
main.run()
|
||||
Reference in New Issue
Block a user