it refuses to load many WAV/MP3 files, and will continue playing the file that's loaded and generates no error (a file.close() would help this)
the isPlaying() status does not get updated when it's done playing a file
getOffset() is reporting 24347.78 the entire time, and getLength() is reporting 0.04138322
it's really selective on when setFinishCallback/setLoopCallback fire. In that it prefers not to. setFinishCallback didn't fire until I set setLoopCallback for example, which is really weird
The sample requires MP3/WAVs placed in it's DATA/music folder. it'll tell you where/make the folder music.zip (42.5 KB)
Instructions: use the dpad to go to Show Files (once you have some), press A, then press A on a music file
1 Like
fosterdouglas
(Foster Douglas / Everyday Lemonade)
2
Didn't have time to fully test this, but your "nil" call is misspelled here and might be causing some of those issues:
function pd.update()
gfx.clear()
if Music == ni then
gfx.setFont(font)
Music = music(11)
Music:update(true)
end
Music:update()
pd.timer.updateTimers()
end
Looks like I broke getLength() and getOffset() for mp3 fileplayers in 1.10. And I think the problem with isPlaying() and the finish/loop callbacks is related--because length and offset aren't getting computed correctly it never sees that it's reached the end of the file. I've pushed a fix for that, hopefully we'll be able to get that out in the next update.
Unfortunately, we don't support WAV playback directly. The compiler converts WAV files to .pda format which is similar but slightly different. I looked into doing native WAV support but there were a bunch of audio formats in WAV (e.g. 24-bit, ADPCM..) that would be difficult to handle. But maybe we could do 16-bit PCM, since it's identical to .pda after the header. I'll file that now.
Might I suggest letting people drag/drop sound files onto the simulator, and it convert them and copy them to the music directory? (You'd also have to give us access to the global music directory)