Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.find("modem", rednet.open)
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- local decoder = dfpwm.make_decoder()
- string.startswith = function(self, str)
- return self:find('^' .. str) ~= nil
- end
- while true do
- id, message = rednet.receive()
- if message:startswith("play_song") then
- for chunk in io.lines(string.sub(message, 10, string.len(message)) .. ".dfpwm", 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment