Compare commits

..

11 Commits

Author SHA1 Message Date
eddb5e3744 updated kernel address 2025-12-09 22:41:38 -05:00
2711d658ea updated a bunch 2025-06-17 17:09:57 -04:00
4e57946e82 fix: update TTS playback for speaker initialization 2025-06-16 20:52:18 -04:00
8cf446d391 d 2025-06-16 20:50:37 -04:00
110ceed23d fix: replace peripheral.wrap with peripheral.find for speaker initialization 2025-06-16 20:49:03 -04:00
7839936ea7 da 2025-06-16 20:47:06 -04:00
7dc79632ca updated 2025-06-16 20:45:43 -04:00
685c24a44a updated 2025-06-16 20:43:41 -04:00
65934b61ce updated 2025-06-16 20:40:57 -04:00
8f64d54c00 fix: simplify playSingleSound function by removing unnecessary loop 2025-06-16 20:37:06 -04:00
b428c24a1f updated 2025-06-16 20:36:04 -04:00
5 changed files with 39 additions and 57 deletions

View File

@@ -2,7 +2,7 @@ local function addDriver(fileName)
local extension = ".lua"
local fullFile = fileName .. extension
shell.execute("rm", fullFile)
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
local baseRoute = "https://git.astrocore.space/root/nova-corp/raw/branch/main/"
shell.execute("wget", baseRoute .. fullFile)
sleep(1)
return require(fileName)

View File

@@ -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()

View File

@@ -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
@@ -111,14 +85,11 @@ local function createSoundFile(fileName)
local file = fs.open(name,"w")
file.write(fileData)
file.close()
handle.close()
end
function addSoundFile(fileName)
createSoundFile(fileName)
end

25
speaker_main.lua Normal file
View 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
View File

@@ -0,0 +1,4 @@
local kernel = require("kernel")
local main = kernel.addDriver("speaker_main")
sleep(5)
main.run()