Coder Social home page Coder Social logo

frankboesing / arduino-teensy-codec-lib Goto Github PK

View Code? Open in Web Editor NEW
110.0 18.0 41.0 90.01 MB

MP3/AAC/FLAC Codecs for Teensy 3.x

C++ 1.70% C 84.72% Assembly 1.74% CSS 0.31% HTML 0.05% Python 0.01% CMake 0.47% Makefile 3.31% Perl 0.19% Shell 6.74% M4 0.76%

arduino-teensy-codec-lib's Introduction

Arduino-Teensy-Codec-lib

Audiolibrary plugin, plays up to 320 kbps MP3, MP4(AAC), M4A(AAC), AAC-Raw or FLAC in software without external hardware - with only 48MHz.

  • Optimized for ARM Thumb2.
  • Play from SD, built-in Flash or optional serial Flash (with audio-shield)
  • Flac 4-24 BIT, (Teensy <= 3.2: Blocksize 128-1024 Bytes)

TODO:

  • parse ID3 / APE / MP4 for extended information

not possible: SBR (aac-HE (low bitrate)) - (not enough ram).

arduino-teensy-codec-lib's People

Contributors

frankboesing avatar jcj83429 avatar mjs513 avatar wwatson4506 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-teensy-codec-lib's Issues

Project abandoned?

After having asked a questions for three weeks now, I assume this project is abandoned?

Can't play MP3 unless I reexport it

Hello, this will be a pretty long post, I'll try to be as clear as possible :)

I want to make my own mp3 / FLAC player based on the Teensy 3.2 with the audio board. I decided to use this hardware after seing your github.

I have an Adafruit FeatherWing attached for the battery, an I2C OLED SSD1306 screen, and some push buttons connected to the Teensy pins 0 to 5, and 8 (avoiding the pins used by the audio board).

I installed the Arduino-Teensy-Codec-lib and tried the "Complete_MP3_AAC_MP4_M4A_example" sketch.
I uploaded an MP3 encoded at 320 kbps 44100hz to my SD card before inserting it in the Teensy audio board, but had no sound coming out. Here are the specs of the MP3 file below (obtained via Reaper DAW):

orignal mp3 specs

I printed the "lastError" attribute of the "AudioPlaySdMp3" (inherited from "AudioCodec"), and I constantly get the "ERR_CODEC_FORMAT" error. According to Reaper, it should be good though. I don't imagine LAME MP3 encoding with anything else than 16 bit depth.

I opened it with notepad++ to check which version of LAME MP3 I used to encode this at the time. The version is 3.93.

Now when I import this song into Reaper, the digital audio workstation I use, export it with LAME MP3 3.99, and put it on the SD card, the song is played by the Teensy wth no modification made to the sketch.

The files are different, but the id3 tags are identical. Could the problem come from the fact that the "old" mp3 was encoded with an ancient version of LAME MP3 ?

The same problem occurs with the FLAC music I have. The examples files provided with the example "FlacFilePlayer" work wonders, but when I put one of my pieces of music there is no sound. I was not able to have the FLAC song played by my Teensy after re-exporting it with the same characteristics.

I do not yet have a deep understanding of your library, and don't know if this request is at the right place nor if you are still working on this library, but I want you to know that there are people out there using your stuff :)

If you need any information / tests / images / whatever, I'll do my best to provide you with what you need.

audio.h location

Hi Frank..
I was trying to compile your tetris for Teensy and ran into problems with the flac codec, where it calls for "audio.h", but it is not being found.

Arduino-Teensy-Codec-lib/FLAC/stream_decoder.c:59:#include "audio.h"

Where should I be sourcing that?

I am working on a linux system and had some other minor problems compiling, due to inconsistent capitalization of the directory name FLAC/flac. I manually made them consistent. As a beginner, if there was a better way to fix those file not found errors, I would appreciate any pointers!
[Tetris is a bit of a diversion, mostly trying to learn more about DSP and the teensy audio library].

Thanks for any help.
Best wishes,
Bill.

Stops playing MP3s on T4.1

On Teensy 4.1, at seemingly random intervals a few to a few tens of minutes apart, the MP3 player just stops playing.

What I know and have tried:

Tried a few different MP3-files and two different SD-cards - no change.

Ported the library to directly use SdFat instead of going via Arduino SD - no change.

To verify the SD card and filesystem code I set up a loop to continuously read and checksum the file over several hours:

  • Reading at full speed - works fine.
  • Reading at a slowed pace, similar to that of audio playback - works fine.
  • Reading random-length chunks of the file - works fine.

The Teensy Audio system is still running; other sources continue playing.

Calling another .play() gets the MP3Player going just fine again.

When the problem occurs, _fposition of the CodecFile class just sits there without changing, but I haven't taken any further plunges into the code - wanted to ask for ideas or suggestions first.

Got any? :)

Read file metadata tag info

Hey! I'm blown away at how well done this is. One thing I can imagine being a major enhancement: ID3 tag reading support.

I wrote this project some 5 years ago now and it might be something workable to include/revise/rewrite: t413/read_ID3_info.

I'll go through it tomorrow and see how well it still works and look at AAC tags. Another possible library is (taglib)[http://taglib.github.io].

Library not working any longer on Teensy 3.2

Hi Frank,

thank you for this impressing piece of code that I already used years ago when I bought some Teensy 3.2 boards which at this time were new.

When testing the boards against the new codec library I downloaded from github, I noticed that it does not run anymore on my Teensy 3.2. I compiled and uploaded the Complete_MP3_AAC_MP4_M4A_example after only two small changes:

  1. I adapted the SDCard CS pin to 10 to match the teensy audio board
    and
  2. I added some lines of code that print the result of the play functions.

The board entered an endless loop trying to play the MP3 files on the sdcard (I used the original sdtest1-4.mp3 files), not playing anything but reporting out of memory errors (3/ERR_CODEC_OUT_OF_MEMORY).

Just to be sure, I afterwards added a WAV file player (from the Teensy audio library) that successfully plays WAVs, so I am quite sure that my hardware is ok. Even after commenting out all parts of the AAC module, the MP3 module refuses to work.

I am running version 2.2.1 of Arduino IDE with the Teensy 1.58 stuff. Unfortunately switching to an older version of the codec library neither seems no work due to incompatibilities of the SD card code (although I have not tested this fully).

Are you aware of these problems? Can you give me a hint what I am doing wrong?

Thanks in advance,
Matthias

Todo: check free memory before playing

FLAC can have very harsh RAM requirements at blocksize > 1024
First, have to figure out how to get frameinfo before starting first frame.. at first sight, there is no api-call (?!?)

Good for MP3+AAC too.

Teensy LC + Prop Shield LC not supported?

Getting this error when compiling for the Teensy LC + Prop Shield LC:
Documents\Arduino\libraries\Arduino-Teensy-Codec-lib-master/play_sd_mp3.h:44:0
Documents\Arduino\libraries\Arduino-Teensy-Codec-lib-master/codecs.h:40:2: error: #error This platform is not supported.

can't play multiple mp3 files at the same time

Hello, I'd like to be able to play many different mp3 files on my teensy 3.6 and then route them through mixers to listen to them at the same time. the problem is that when I put more than 1 AudioPlaySdMp3 in my code, the music just won't play. Here is an example code:

`
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

#include <play_sd_mp3.h>

// GUItool: begin automatically generated code
AudioPlaySdMp3 playMp31, playMp32; //xy=154,78
AudioOutputI2S i2s1; //xy=334,89
AudioConnection patchCord1(playMp31, 0, i2s1, 0);
AudioConnection patchCord2(playMp31, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=240,153
// GUItool: end automatically generated code

void setup() {
Serial.begin(9600);

// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(5);

sgtl5000_1.enable();
sgtl5000_1.volume(0.5);

SPI.setMOSI(7);
SPI.setSCK(14);
if (!(SD.begin(10))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}

playMp31.play("canada.mp3");
playMp32.play("france.mp3"); // both of these tunes won't play, but if i comment the seccond one,
// then the other plays fine.
}

void loop() {
delay(100);
}
`

Playing files from different sources

Hello, Now audio library use sdfat, but I can't play file from sdfat card, because method play(); haven't SdFs argument. For example:

SdFs card1;
SdFs card2;
...

Mp3player.play(&card1, "test.mp3");

I get many warnings while compiling and the code not working.

How to chose source sd card for playing files if I have two or more sd cards on one teensy?

Thank you.

Library doesn't work with Teensy 3.0?

The library says that it support Teensy 3.x but when I compile it with my Teensy 3.0 I get a compile error "platform not supported".

Is this correct? If it is, please update the documentation that Teensy 3.0 is not supported.

FLAC: CRC

TODO:

  • Option to disable CRC-Calculations
  • optional: Use Teensy-CRC-Unit

Encoding FLAC?

Is there any way to use this library to encode FLAC (for the purposes of writing to an SD card)? Would a Teensy be able to handle it?

positionMillis() time units are not milliseconds

Firstly, this is a fantastic library and has worked straight out of the box to play AAC and MP3 files for my SD audio projects!

Delving a little deeper though, I'm trying to use the positionMillis() function to get the elapsed time of a playing track on a Teensy 4.1 using Arduino 1.8.16 and Teensyduino 1.55. In the standard Teensy Audio library, this is returns the elapsed time in milliseconds, however for the play_sd_aac library the value appears to be ~1950x greater than expected. What unit of time should be returned by positionMillis()?

This is a short example comparing the normal Arduino millis() and position.Millis(). The file did not start playing at millis() == 0, but this demonstrates the discrepancy in relative change between the two values:

millis() positionMillis()
16843 19694706
16853 19717286
16863 19734220
16873 19751154
16883 19773734
16893 19790668
16903 19813248
16913 19830182
16923 19852760
16933 19869696
16943 19892274
16953 19909208
16963 19931788
16973 19948722
16983 19965656
16993 19988236
17003 20005170
17013 20027750
17023 20044684
17033 20067264
17043 20084198
17054 20106776
17064 20123712
17074 20146290
17084 20163224
17094 20180160
17104 20202738
17114 20219672
17124 20242252
17134 20259186
17144 20281766
17154 20298700
17164 20321280
17174 20338214
17184 20355148
17194 20377728
17204 20394662
17214 20417240

These values were generated as part of a larger project thus:
songPos = playAac1.positionMillis()
Serial.print(millis());
Serial.print("...");
Serial.print(songPos);
Serial.print("...");

If need be, I can knock up a full test to replicate the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.