Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Assuming the speaker is on the right side of the computer
- local speaker = peripheral.find("speaker")
- -- Function to play siren sound from a DFPWM file
- local function playSiren()
- local file = fs.open("siren.dfpwm", "rb")
- local audioData = file.readAll()
- file.close()
- -- Convert string to table of bytes
- local audioTable = {}
- for i = 1, #audioData do
- local byte = string.byte(audioData, i, i)
- table.insert(audioTable, byte)
- end
- speaker.playAudio(audioTable, 1)
- end
- -- Play the siren for testing
- playSiren()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement