In this recipe, you will learn how to create a function that, when called, will play a specific audio file on the built-in speakers. This recipe will illustrate how to get access to the audio output device, as well as how to read the contents of a .wav file, convert it to an audio stream, and feed that audio stream to the onboard audio playback device. The techniques shown in this recipe can be used in all sorts of projects that need more fine control over the way audio files are played back.
Creating a function to play audio files
Getting ready
You will need access to the REPL on Circuit Playground Express to run the code presented in this recipe.