Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

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

  1. #1
    Junior Member
    Join Date
    Nov 2016
    Location
    Spain
    Posts
    8

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

    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=0By...HFSLWNpd3VoOTQ

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

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

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

    Click image for larger version. 

Name:	cap01.jpg 
Views:	171 
Size:	69.1 KB 
ID:	9773Click image for larger version. 

Name:	cap02.jpg 
Views:	202 
Size:	151.0 KB 
ID:	9774Click image for larger version. 

Name:	cap03.jpg 
Views:	138 
Size:	167.6 KB 
ID:	9775
    Last edited by RndMnkIII; 02-21-2017 at 06:23 PM. Reason: add comments about others changes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •