Modifications for smooth audio playback with Arduino-Teensy-Codec-lib

Status
Not open for further replies.

RndMnkIII

Member
Hello. I've testing Frank Boesing's Arduino-Teensy-Codec-lib with Gameduino 2 modified library for Teensy 3.5/3.6 and SDIO, I find that modifying this lines in the mp3 library file in codecs.h:

Code:
line 81: bool fopen(const char *filename) {ftype=codec_file; /*AudioStartUsingSPI();*/ fptr=NULL; file=SD.open(filename); _fsize=file.size(); _fposition=0; return 

line 87:if (ftype==codec_file) {file.close(); /*AudioStopUsingSPI();*/}

the audio playback is better (not choppy). This should be best checked at compiled time
using #defines with the HAS_KINETIS_SDHC symbol as in used in the teensy Audio library, example in play_sd_wav.cpp file of the library:

Code:
#if defined(HAS_KINETIS_SDHC)	
	if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStartUsingSPI();
#else 	
	AudioStartUsingSPI();
#endif

Also for avoid duplicate definitions of max() function used in my example from C++ library <algorithm> as
Code:
std::max(r, std::max(g, b));
in ColorRGB.cpp file, I've modified codecs.h line 134:
Code:
unsigned lengthMillis(void) {return std::max(fsize() / (bitrate / 8 ) * 1000,  positionMillis());} //Ignores VBR
for use std::max and added #include <algorithm> at the beginning of file.


I've use heavily the spi bus for transfer data between teensy sram and the FT813 video ram (FT813 chip scales in realtime from 160x92 plasma image generated with teensy 3.6 at 240Mhz using CMSIS-DSP floating point math functions to 800x480 using bilinear sampling) in my demo and take advantage of SDIO for using it to load mp3 data leaving free the spi bus bandwidth. Without these modifications the audio playback is choppy.

My test example:
https://drive.google.com/open?id=0By5wADoEOJ9fVHFSLWNpd3VoOTQ

Modified gameduino 2 library (using Riverdi FT813 Screeen):
https://drive.google.com/open?id=0By5wADoEOJ9fc1g0OFlsdTZmcWM

Video testing application:
https://drive.google.com/open?id=0By5wADoEOJ9fSU1rYTJJajFjRVE

pictures of my custom shield with Teensy 3.6 + Audio Shield + FPC 20pin conector for FT813 Screen:

cap01.jpgcap02.jpgcap03.jpg
 
Last edited:
Status
Not open for further replies.
Back
Top