Playing Audio Wave Files using the OLED Screen Board
Overview:Amongst the many other functionalities that our 2.8inch OLED Board comes featured with, one of them is the ability to play audio files in wave (.wav) format. In fact, there is a dedicated micro-sd socket that is specially meant to store audio wave files for the BlazingCore OS to easily retrieve and stream to the audio output.
In this tutorial, we'll show you how easy it is to play audio wave files from the OLED Screen Board.
What you will need:Hardware
Software
Hardware SetupFollow the complete setup for connecting the OLED board to the BCore100 Board shown here.
Now the only thing left is to connect the audio output to either a standard stereo earphone, or to a USB/ Battery powered speaker.
The 2 options are illustrated below.
If you're using a USB Powered Speaker, plug the USB cable into your PC and the audio jack into the audio output of the OLED Screen Board. For those who are using loud speakers that are rated higher than 8ohms 1W, be sure to have an additional audio amplifier in between the audio output and the loudspeaker. The audio circuit and amplifier onboard supports standard stereo earphones and speakers of up to 8ohm 1W rating.
Audio File/s Preparation
The audio circuit onboard the OLED Screen Board supports wave files of the following format: Stereo, 256Kbps Bitrate
To check the bitrate of your wave file, right click on the file, choose properties, and click on the details tab. You may choose to use Audacity or your audio software of choice to convert / resample the files that you want to play.
Once you're done with getting the wave files to the above format, plug your micro-sd card into your PC.
If you only have a couple of files and don't need the seperate it into different directories. Creating just one folder named 'SG1' is fine. All your wave files should go in there. To have more directories. Name them SG2, SG3 and so on.
Rename your wave files with a prefix of the letter 'S', and then a number. eg. (S01, S02 and so on, to represent sound file number 1, 2, etc) We'll be making use of the numbers of the directory and the sound files later on in the code.
Once your sound files are in, remove it from the PC, and plug the micro sd card with the gold plates facing up into the micro-sd card socket labelled 'SOUND' as shown in the image below.
Source CodeCopy & Paste the following code into a New Project in Sonata IDE. The code itself is heavily commented, and you would find the full list of commands and explanation in the documentation under the section of "OLED".
'CODE1
What the code above does is to initialise the OLED and Audio, and then locate the first sound file (S01.wav) in the first directory (SG1). Loads it up into channel 1's buffer. And proceeds to play it. Control is given to the Pushbuttons on the OLED board for Play, and Pause.
Note: The Audio circuit can support 2 channels of audio stream. Meaning you can play 2 sound files at the same time. eg( One main sound track, with occasional injections of another sound file when called upon)
For that, you can use channel 2.
What's next? Check out our other OLED tutorials on how to make a nice U.I to play the wave files! Have fun!
Need help? Head over to our forum. |






