Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local aukit = require "aukit"
- -- assume we stored the song in "wxp.wav"
- -- read the data
- local file = fs.open("wxp.wav", "rb") -- read binary mode is important.
- if not file then
- error("Music file doesn't exist.", 0)
- end
- local data = file.readAll() -- actually read data
- file.close() -- important to close file handles.
- -- Now, for aukit stuff.
- local iterator, length = aukit.stream.wav(data)
- aukit.play(
- iterator,
- function(pos)
- -- do something with the current position
- -- Do not infinite loop in this function!
- end,
- 1, -- audio volume
- peripheral.find("speaker") -- speakers to play the audio on, in this case all speakers
- )
Advertisement
Add Comment
Please, Sign In to add comment