From d6221293cb9e8e9674332e79451ae2aa653fa358 Mon Sep 17 00:00:00 2001 From: itzmarkoni Date: Sun, 15 Jun 2025 19:32:14 -0400 Subject: [PATCH] updated sound --- speaker_driver.lua | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/speaker_driver.lua b/speaker_driver.lua index 5dcb9bc..fd9fb84 100644 --- a/speaker_driver.lua +++ b/speaker_driver.lua @@ -8,22 +8,9 @@ local function getFileName(name) return fullFile end -local function getSoundUrl(fileName) - local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/" - local name = getFileName(fileName) - local fullPath = baseRoute .. name - return fullPath -end -local function getSoundStream(fileName) - print("Getting sound stream for: " .. fileName) - local request = http.get(getSoundUrl(fileName)) - print(textutils.serialize(request.getResponseHeaders())) - request.close() -end local function playSound(speaker, fileName) - --local fileStream = getSoundStream(fileName) local fileStream = getFileName(fileName) local values = io.lines(fileStream, 16 * 1024) for input in values do @@ -41,15 +28,26 @@ local function playControlRoomAlarm(speakers) playSound(speakers,"short_control_alarm") end +local function createSoundFile(fileName) + + local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/" + local name = getFileName(fileName) + local fullPath = baseRoute .. name + + shell.execute("rm", name) + + local response = http.get(fullPath) + local fileData = response.readAll() + local file = fs.open(name,"w") + file.write(fileData) + file.close() + response.close() +end function addSoundFile(fileName) - local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/" - local name = getFileName(fileName) - local fullPath = baseRoute .. name - shell.execute("rm", name) - shell.execute("wget", fullPath) + createSoundFile(fileName) end local function watch() @@ -59,7 +57,7 @@ end local function startup() local sounds = { - { fileName = "control_alarm" } + { fileName = "short_control_alarm" } } for i, item in ipairs(sounds) do