Commit Graph
80 Commits
Author SHA1 Message Date
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
Earle F. Philhower, III 3226d6ec0a Add metadta callback for Icy streams
Allow a UI to get a notification when a StreamTitle or other metadata
comes into the stream. Callback function would normally just update a
flag and let the next global event loop handle updating the display.
2017-12-04 12:45:16 -08:00
Earle F. Philhower, III 8c6bb549f1 Fix crash on ::loop in MIDI generator
Forgot to save the passed in *AudioFileSource, since it was not needed
in the MIDI playback engine (it's encapsulated in a buffered object).  Now
with ::loop in every object, it's needed and we were calling a garbage
object causing a random crash.
2017-12-04 10:51:20 -08:00
Earle F. Philhower, III 75268b5e3b Add inline ID3 decoder w/callback interface
ID3 tags can now automatically give your app a callback with different tag
types without any additional work on your application.  See the PlayMP3 example
for a very simple example of AudioFileSourceID3's use.
2017-12-02 13:01:46 -08:00
Earle F. Philhower, III fece88a9be Add loop method to all input and outputs
Adds a virtual loop() method to the file input and audio output objects.
By default does nothing, but it can be used to prefill buffers/etc. in the
case of a buffered input, or to update a volume meter on an output, etc.

The AudioGenerators all now call it as part of their own loop()s, so there
is no user intervention required to make it work.

Thanks to @armSeb for the idea with his SPI RAM code.
2017-11-24 10:35:20 -08:00
Earle F. Philhower, III df4588197f Add note about SBR not being supported due to RAM 2017-11-23 20:01:38 -08:00
Earle F. Philhower, III 373b4ef6ff Move a few small tables into PROGMEM
No reason not to save a few bytes of RAM by moving some char[] to PROGMEM.
2017-11-23 19:31:39 -08:00
Earle F. Philhower, III 1875683ce1 Add SBR code back in, but disable for now.
The SBR code compiles, but it requires an additional 50,788 bytes of system
RAM to run so it's not going to work on the ESP8266.  Add the code in just in
case someone wants to move it to another architecture w/more RAM available.
2017-11-23 19:04:30 -08:00
Earle F. Philhower, III 432f892d70 Add retry logic to HTTP Streams
On a 0-byte read or a disconnect, optionally automatically reconnect
up to a user specified number of tries with a delay between each attempt.
2017-11-22 07:20:42 -08:00
Earle F. Philhower, III 2737dec473 Fix block corruption when hitting an ICY block
Wasn't incrementing the returned data pointer when we had to split the
requested read into pre- and post-ICY blocks.  This resulted in errors
in the decoded stream.
2017-11-21 20:09:37 -08:00
Earle F. Philhower, III 4b2bbe7ad5 Preliminary ICY HTTP stream support
Add a subclass of the HTTPStream that can extract the ICY metadata.
Needs to implement a callback function or parse it internally and expose
a class variable to let the UI see the current stream information.
2017-11-21 11:55:23 -08:00
Earle F. Philhower, III 64032d8f43 Force refill of buffer when emptied completely
@armSeb founf another case in issue #9 where the buffer would never
refill if the input stream was very slightly below the output stream
velocity.  In that case, when we hit a 0-water mark, force a complete
refill of the buffer on the next pass.
2017-11-21 08:36:17 -08:00
Earle F. Philhower, III fad8af052f Reduce default MP3 buffer to max frame size + fluff
MP3 maximum frame size of 1441 bytes, and now that there is a real
buffering class available it makes no sense to include additional space
in ths decoder.  Reduce to the minimum to save memory in default case.
2017-11-21 08:11:05 -08:00
Earle F. Philhower, III 09b8079ef7 Add FIR and decimation filter for frequency xvert
A simple FIR filter with decimation and specifable taps and rational
decimation allows for frequency conversion or any other kind of filtering
desired.
2017-11-21 07:45:02 -08:00
Earle F. Philhower, III 9c3f579c96 Add buffering to MP3 streaming
The buffer class seems to work very well to avoid hiccups while
streaming from the web, so add it by default to the example to
make it easier for users to cut-n-paste and make it work.
2017-11-20 12:15:32 -08:00
Earle F. Philhower, III 8b080899af Fix buffer example snippet to actually work
@gerardwr found that the cut-n-pasted original example code could never
actually work, in issue 9.  Rewrite so instead of a full working sample
(which would be 40+ lines due to WiFi setup) only the relevant changes are
shown.
2017-11-20 07:11:17 -08:00
Earle F. Philhower, III 860c6678ab Fix noise during amplification
@armSeb, in issue 7, noticed noise being introduced when amplifying the
output.  By moving the amplification to right before submitting the sample
to I2S it went away.  Update with his suggested fix.
2017-11-20 07:04:11 -08:00
Earle F. Philhower, III 8a19c9c093 Fix buffering losing bytes
Correct issue @armSeb found and fixed where some bytes on the fallthrough
case were not being recorded as stored, leading to mp3 playback errors.
Fixes one half of issue 7.
2017-11-20 06:59:57 -08:00
Earle F. Philhower, III 3f7cf95a15 Save 88 bytes by moving a table to PROGMEM 2017-11-18 19:15:46 -08:00
Earle F. Philhower, III d723b36aca Free 188 bytes of RAM by moving bitrevtab to PMEM 2017-11-18 19:12:24 -08:00
Earle F. Philhower, III fdffe0226e Fix typos and add links to other projects 2017-11-18 19:04:33 -08:00
Earle F. Philhower, III f4702a0719 Remove GCC -Wall warnings
Clear up warnings generated with -Wall used to compile.  No functional change.
2017-11-18 18:53:58 -08:00
Earle F. Philhower, III 5e5a15359c Remove the FastROMFS bits for now
Having the FastROMFS file source caused the importation of the entire
FastROMFS library, which most folks will not have installed.  Remove it
for now.
2017-11-18 08:45:48 -08:00
Earle F. Philhower, III 551a8ac0bb Add AAC playback using Helix from RealNetworks
AACs can now be played back on the ESP8266 thanks to the RealNetworks
Helix project's AAC decoder.  SBR is *not* supported, as there is not
enough RAM in the system to support it.
2017-11-18 08:42:09 -08:00
Earle F. Philhower, III 14010d340e Add SetGain to I2S outputs to scale output volume
A new SetGain(float 0.0 ... 4.0) method can scale the output volume of
an I2S DAC or SW DAC by scaling the samples. Proper clipping is performed.
Adds a 16x16 multiply and a couple shifts/branches to every sample output.
2017-11-17 08:48:19 -08:00
Earle F. Philhower, III 65c1373300 Less naive double-buffer reading
Use memcpy instead of complicated byte-by-byte operations to read data
out of the buffer.  Should allow for somewhat faster reads.
2017-11-15 13:17:43 -08:00