Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- local player = {}
- function player.playSoundByPath(path)
- local decoder = dfpwm.make_decoder()
- if not decoder then
- return error("decoder not found")
- end
- for chunk in io.lines(path, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- return "sound played"
- end
- function player.playNotice()
- player.playSoundByPath("../sounds/icq_sms.dfpwm");
- end
- function player.playStartup()
- player.playSoundByPath("../sounds/startup-sound.dfpwm");
- end
- return player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement