Commit Graph
105 Commits
Author SHA1 Message Date
Earle F. Philhower, III 07dee61fbf Merge branch 'hosttests' 2018-01-19 21:25:34 -08:00
Earle F. Philhower, III 0172f17b51 MP3 test in Valgrind
Run a host MP3 test using valgrind, shows no errors.
2018-01-19 21:23:17 -08:00
Earle F. Philhower, III da068e30e6 Ensure BPS=16 is set in MP3 decoder
Valgrind found another uninitialized use.  BitsPerSample was not being
called by the LIBMAD decoder, so it was possible to start out in a bad
state.  Now always set it to 16, the decoder native output size.

Channels are initialized to 2, but this setting is always reset on
a per-frame basis anyway.
2018-01-19 21:09:37 -08:00
Earle F. Philhower, III 158fe23181 Don't crash on an invalid (layer I or II) frame
We removed the MP2-layer I and II decoders to save space, but an occasional
bad frame can come in that, by random chance, specifies one of this type.
Was calling NULL because of that.  Now, just skip the frame and no crash.
2018-01-19 20:40:00 -08:00
Earle F. Philhower, III cffb424c2c WIP - build some code on the PC to run valgrind/etc. 2018-01-19 19:39:19 -08:00
Earle F. Philhower, III e5d23a4692 Enable Travis-CI builds
Enable automatic building of all examples and SAM(speech) on a
commit by using Travis-CI.  Build against ESP8266 and ESP32.

Minor tweaks to examples and codebase to allow successful compilation
on ESP32 compiler.
2018-01-19 15:57:30 -08:00
Earle F. Philhower, III 5986831bd6 Fix I2S helpers to send/nonblock properly
The original I2S setup had the wrong # of bits being sent to the DAC
as well as wrong timeouts specified on the write_sample wrappers.
Fix those, allowing things like WebRadio.ino to work.
2018-01-19 10:01:43 -08:00
Earle F. Philhower, III 94a3f9ab91 Remove hostname setting for ESP32 compatability
The examples were setting a hostname for the WiFi connection, but this is
done via a different call on the ESP32 vs. the ESP8266.  To avoid #ifdef
explosion, simply remove the call as it's unneeded anyway.

Thanks to @reaper7 for reporting this in pull #33.
2018-01-18 10:57:02 -08:00
Earle F. Philhower, III 244007b0c5 Enable AAC-SBR on ESP-32, there's enough RAM
AAC-SBR allows for lower bitrates to have higher quality audio output,
and is used by many web radio stations.  It was disables on the ESP8266
due to RAM limitations (about 50KB too little), but the ESP32 has no
such problem.  Enable it automatically during compile.
2018-01-18 10:53:03 -08:00
Earle F. Philhower, III bd40d8af6f Include info on using BCLK/LRCLK as inputs w/SWDAC
The bit clock and l/r clock can be used as inputs, per issue #32 testing.
Explain how to do this in the readme.
2018-01-18 10:15:02 -08:00
Earle F. Philhower, III ddf4db187c Update to include 2.4 release + ESP32 support 2018-01-18 10:09:25 -08:00
Earle F. Philhower, III e84123e03d Clean up ESP32 compile warnings, use audio PLL
Remove a couple compiler warnings found when building for the ESP32.

Enable the high-precision audio PLL as clock source on ESP32.
2018-01-18 10:01:32 -08:00
tueddy 03aa2467f0 Porting for ESP-32 (#33)
* support ESP-32
* make compile with ESP-32/arduino platform
* fixed: use libmad on ESP8266 as original
2018-01-18 08:55:03 -08:00
Earle F. Philhower, III 0c002cd014 Obey data size field, avoid WAV clicks w/metadata
The DATA chunk has a size field that was ignored.  When there was additional
metadata after the chunk, however, it would try and play it leading to
clicks.  Store and only read that amount of data now.
2018-01-10 08:04:39 -08:00
Earle F. Philhower, III 2e348d2b1f Redirect to original SPIRAM library
Change from my own patched copy of SPIRAM libs to the original source
since the required patches were just commited.
2018-01-04 10:01:50 -08:00
Earle F. Philhower, III 6b30ed77f5 Fix infinite loop on EOF in SPI buffer
Emil Plalan found and fixed a bug where the buffer refill would loop
forever (until WDT) when there was no more data to read.  For web streams
this wasn't detected, since there isn't really an EOF.  However, single
files streamed from a web server would have this problem.
2018-01-04 09:46:16 -08:00
Earle F. Philhower, III 2d25b16f09 Preallocate all memory and move imdct_s to progmem
Because the mp3 player is a long living object and needs to allocate
large contiguous chunks on each frame, it is safer to allocate the
large xr[] and tmp[] arrays at the beginning.  Add them to the frame
structure which lives the entire time the mp3 object is alive.  No
heap allocations are now used by the mp3 player.

Move the imdct_s[] array to progmem, but do a memcpy_P() to stack
as the macros may cause a 16-bit access after optimization.  It's only
36 words long and each data is read, anyway, so this doesn't increase
the CPU work significantly.
2018-01-01 11:41:31 -08:00
Earle F. Philhower, III d06dcf1123 Include type and volume in checksum, cleanup code 2017-12-24 09:31:36 -08:00
Earle F. Philhower, III 025edf0d81 Clean up DecodeNextFrame path to something sane
As seen in issue #21, the MP3 decoder would barf on a single lost sync
error, even though it was not actually a fatel error.

Rewrote the logic to include another Input() on DNF failure, and only die
when Input() actually fails.  Seems to fix the problem in issue #21 and also
did not break the WebRadio.
2017-12-24 09:20:01 -08:00
Earle F. Philhower, III e844536251 Fix the URL max limit in web interface
The web interface has a hardcoded 64 char URL limit, even though the
actual url[] array was increased to 96 chars.  Use sizeof(url) in the
handler instead of a hardcoded number to enable use of all space.
Addresses issue #21 , again.
2017-12-22 21:39:13 -08:00
Earle F. Philhower, III 4cb8861070 Fix PROGMEM string accesses in callbacks
The MD and STATUS callbacks can be passed PROGMEM strings, so be sure to
use proper strcpy_p()s to move them to RAM before printing to avoid crashes.
Found during debug of issue #21 .
2017-12-22 21:28:28 -08:00
Earle F. Philhower, III 6c3064a4b5 Remove infinite loop on error in DecodeNextFrame
DecodeNextFrame had a leftover while(1) in the inner loop without any
additional Input() calls, which could lead to an infinite loop on an
error condition.  Remove that unneeded loop.  Addresses some of the
stuff found in issue #21
2017-12-22 21:19:06 -08:00
Earle F. Philhower, III e4c1c8fc66 Fix ID3V2.2 decoding, non-unsync handling
Add handing of ID3V2.2.x (tested) and (I think) V2.3.x, and fix the
unsync handling.

Issue 23 found a problem where ID3V2.2 headers, which are very different
from v2.3 and v2.4, caused crashes.  Fixing that showed another bug where
the unsyunc flag was not honored and all data was assumed to be unsync'd
causing improper reads of ID3 tags in some circumstances.
2017-12-22 20:20:46 -08:00
Earle F. Philhower, III 8c7b30add3 Update to include the 2.4.0-rc2 JSON link 2017-12-16 16:17:47 -08:00
Earle F. Philhower, III 5b45a79cf7 Fix ICY decoder overflow causing streams to die 2017-12-16 16:16:01 -08:00
Earle F. Philhower, III 397aee8c19 Actually change volume in the HandleVolue callback 2017-12-15 22:18:23 -08:00
Earle F. Philhower, III 5a9340c452 Fix ICY decoding when apostrophes encountered
The ICYMDReader was not properly returning the unread "'" characters
and so StreamTitles were being truncated at the first apostrophe.  Fix
the unread() and read() member functions to clean up.
2017-12-15 19:49:37 -08:00
Earle F. Philhower, III 0f0b6cd664 Fix EEPROM save/load and corruption on restart
EEPROM saving was not calculating the correct checksum because it was
not clearing memory before writing.  Fix that so it automatically will
restart the connection on a reset.

There was a fatal corruption caused by improper delete'ing of objects
without clearing their pointers when the initial connection to a stream
failed.  Refactor to use the proper StopPlaying() routine.

Extend the URL to 96 characters.  We not have enough memory to do so!
2017-12-15 19:03:03 -08:00
Earle F. Philhower, III 65a6cc4be7 Fix MetadataCallback function signatures
The MD callback now gets a string, not a stream, so update the examples
to compile properly.
2017-12-15 14:58:14 -08:00
Earle F. Philhower, III 43273e3394 Add instructions for use with GIT 2.4+ only 2017-12-15 14:44:56 -08:00
Earle F. Philhower, III 8e94702468 Replace Stream with simple string in MD callback
@armSeb found that the stream interface caused a big slowdown and
hiccups in his playback, replace the MetadataCallback's *Stream with
a simple *char for faster operation and less overhead.
2017-12-15 12:54:49 -08:00
Earle F. Philhower, III d923ebef36 Move the callback constant strings to PMEM 2017-12-15 12:03:05 -08:00
Earle F. Philhower, III 634d0b8d02 Store AAC/MP3 flag in EEPROM for WebRadio 2017-12-15 10:31:19 -08:00
Earle F. Philhower, III 9f42358f31 Try and restart a stream 2secs after a disconnect. 2017-12-14 15:58:39 -08:00
Earle F. Philhower, III e3da480772 Add URL save and restore on reboot 2017-12-14 11:09:43 -08:00
Earle F. Philhower, III 8d401a4a39 Move strings to PROGMEM, save a few heap bytes 2017-12-14 10:50:55 -08:00
Earle F. Philhower, III ee7febe1ec Refactor and store to EEPROM, restore on reboot
Save the current URL to EEPROM on each change, and try and restart it
after a power loss or reset
2017-12-14 10:35:14 -08:00
Earle F. Philhower, III 143c4e65ae Move request buff to stack
Save 384 heap bytes by handling the web request buffering in the loop()
stack context.
2017-12-14 09:47:00 -08:00
Earle F. Philhower, III ec4979e6f5 Fix web page update, move string to PROGMEM 2017-12-14 09:43:19 -08:00
Earle F. Philhower, III 94489c005a Use low-mem web server to save RAM for playback
Instead of ESP8266WebServer, which is something of a RAM hog and has
extensive use of Strings and allocations, use a simpler one with no
dynamic memory allocations at all, borrowed from PsychoPlug
https://github.com/earlephilhower/psychoplug.
2017-12-12 17:06:21 -08:00
Earle F. Philhower, III cce9ceaffd Try and allocate inner loop mem on stack
Check the available stack space, and if large enough use a stack
variable for the inner loop.  If not, fall back to heap allocation.
2017-12-12 16:57:20 -08:00
Earle F. Philhower, III f2550b0ab1 Remove debugging stack() calls 2017-12-12 14:04:13 -08:00
Earle F. Philhower, III 3d88015cc2 Add in status update and free memory reporting
Also removed Serial.print() of status and Serial.flush() to avoid
hiccups.
2017-12-08 22:09:46 -08:00
Earle F. Philhower, III 23a8ed8724 Add HELIX MP3 decoder initial revision
Include the RealNetworks HELIX MP3 decoder as AudioGeneratorMP3a.
Right now runs fine, but requires a full 1152*2 sample buffer and
seems to run slower than real time.
2017-12-08 19:58:45 -08:00
Earle F. Philhower, III 8893ced2af Add WebRadio example, a web page controller
Simple example web interface to the player.  Can change the volume and
the station through a slider and menu box.
2017-12-08 13:07:59 -08:00
Earle F. Philhower, III 1690289714 Rationalize the MP3 generation loop
Remove the inInnerDecode flag in the main generation loop and make the
render path more readable in the MP3 decoder object.
2017-12-08 07:16:01 -08:00
Earle F. Philhower, III 9c120a777a Add callbacks for metadata and status reports
All objects can have a metadata and/or status report callback once created.
They will call the source program with the parsed ID3 tag, ICY StreamTitle,
or text and numeric error ID of any interesting event.  It is up to the end
application to figure out what to do with this.  Normally, you'd just print
it to the LCD or Serial port.  But it is possible to detect, say, a buffer
overflow and then switch to a lower bitrate stream for example.
2017-12-06 21:11:23 -08:00
Earle F. Philhower, III 1ab9348a4c Update the instructions for installation
The library will not compile w/o the SPI driver, add it to the README.
Point to my fork until @armSeb's pull request in the original is merged.
2017-12-06 14:20:39 -08:00
armSeb 97c05c9f34 SPIRAM buffer support from @armSeb
* Initial SPIRAM buffering support

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* SPI RAM Buffering fill & read.

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* First "working" version...

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Improved version of SPIRAM buffering

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Fixed spiram.h path

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Buffer fill optimization

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Modified read block min to avoid too little buffering attempts

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Temps buffer size decrease from 2048 to 1600 Bytes

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Decrease the temp buffer to 256Bytes

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Local buffer variable

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Added loop function to SPIRAMBuffer that refill it automatically

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Compile issue

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Add possibility to define Chip Select pin from Sketch

Signed-off-by: Sebastien Decourriere <sebtx452@gmail.com>

* Externalize libspiram

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Copyright fix

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Deleted embedded libspiram

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Added comments, example and keyword

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* README modification

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Correction

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* Schema example

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>

* README correction

Signed-off-by: sebastien <armseb@MacBook-de-sebastien.local>
2017-12-06 13:30:51 -08:00
Earle F. Philhower, III 471034707d Add ICY Metadata callback to the example 2017-12-04 12:53:58 -08:00