Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
376 Chapter 15 If you start experimenting gradually, as I suggested, moving down the table, you should find that beyond a certain point things just won't play out right. The playback is going to skip, repeat and hiccup and it just won't sound right. What is happening is that the freadM() function has reached its limit and is not capable of keeping up with the audio playback demands. The time it takes, on average, to load a new buffer of data is longer than the time it takes to consume one, hence after a short while the PlayWAV() routine starts falling behind and the audio playback function starts repeating a buffer or playing back buffers that are not completely filled yet. Optimizing the File I/O When we wrote the file I/O library, and even before, when we wrote the low-level functions to access the SD/MMC card, we were focusing just on getting things done, but we have never really tried to assess the level of performance provided. Perhaps now we have the right motivation to go and look into it. Throughout this book, we have resisted using any of the optimization features of the compiler, so that every example could be simply tested using the free MPLAB C Lite compiler version, and we want to maintain this commitment. Perhaps there is some room to improve the performance using just a little ingenuity.