Audio play music in TF Card
Update time:2018-04-13 Views:5451
Fireduino Audio
Fireduino internal integration of the HIFI level high quality of audio decoder,professional hardware accelerators to decode MP3,low loss decoded audio hardware accelerators and rich peripherals,support wi-fi protocol,support 24bits 192k Hz sampling rate,low loss,low power consumption of audio decoding.
Fireduino support to play audio files on the SD card and network, support the format APE/FLAC/WAV/MP3/WMA/AAC/OGG;
Fireduino Audio library
Fireduino is very good in audio decoding,using the API of Audio library allows users to more easy to audio development.Fireduino provides audio interface is as follows:
Fireduino Audio play TF music
This example demonstrates how the Fireduino play music files of TF,at regular intervals to judge whether the play stop and continue play next one or loop.
Hardware requirement
1.Fireduino board
2.TF Card
3.Music files
Code
Before start
Before using Audio and TF Card,first of all have to include Audio and TF library header files
#include "TF.h"#include "Audio.h"
setup()
1.Initialize the serial port,to convenient print debugging information for later.
2.Initialize the TF card,the subsequent need to read music from the TF card file for decoding.
3.Initialize Audio,and use the way of AUDIO_SD.
4.If initialize the Audio successfully,then play the MP3 files.
void setup() { Serial.begin(115200); Serial.print("\r\narduino setup ...\r\n");if(!SD.begin()){ Serial.println("sd init err\r\n");while(1);} Audio.begin(AUDIO_SD);if(Audio){ Audio.playFile("\\4.MP3");}}
loop()
1.Get the status of Audio state machine.
2.judge if the status of decoding is stop status.
3.If it's to stop status,continue to decode the specified file.
void loop() { Serial.println("loop"); delay(2000);if(Audio.getStatus() == AudioStop){ Audio.playFile("\\3.MP3");}}
Example program -- play the TF music
#include <Arduino.h>#include "TF.h"#include "Audio.h"void setup() { Serial.begin(115200); Serial.print("\r\narduino setup ...\r\n");if(!SD.begin()){ Serial.println("sd init err\r\n");while(1);} Audio.begin(AUDIO_SD);if(Audio){ Audio.playFile("\\4.MP3");}}void loop() { Serial.println("loop"); delay(2000);if(Audio.getStatus() == AudioStop){ Audio.playFile("\\3.MP3");}}