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.
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.
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.
When note_on tries to reallocate the voices[] array, realloc can return
NULL. In this case, instead of faulting, restore the original pointer
(which is untouched per realloc() semantics) and ignore the note_on
command.
MONO was not set and could result (randomly at start of runtime) in
mixing the two channels instead of sending them across unmolested.
Now initialize it to FALSE and normal behaviour.
AudioFileSourceBuffer allows system RAM to be used to buffer an
input file (normally just a HTTP Stream) to help avoid hiccups.
This could also be subclassed to use an external SRAM, at some
soint.
AudioGeneratorMIDI plays a .MID file using any Soundfont2 wavetable
synthesis file. This is a highly hacked combination of TinySoundFont
and MIDITONES, and requires the FastROMFS to run at real-time in most
cases.
AudioFileSourceFastROMFS connects with the new FastROMFS to enable
higher speed read from SPI flash for files. Requires
https://github.com/earlephilhower/ESP8266FastROMFS to be installed.
AudioOutputBuffer implements a 2nd-level memory buffer for output
dat to hopefully allow playback w/o hiccups, but needs to be vetted.
Without being able to call it from an interrupt, not sure it can actually
improve output performance.
HTTPStreamer assumed the server would drop the connection when no more
data was available to be transferred from the source file.
For individual files, though, the web server will send the expected length
in the headers and leave the connection open (i.e. to recycle the connection
and accelerate web browsing). In this case, the streamer would effectively
hang waiting for more data than was being transmitted.
Now check the read data against the expected data, and also add a 0.5s
timeout no matter what to the reading.
Tested on streaming and served files, seems to work fine.
Fixes issue #5 about choppy audio on low bitrate, mono MP3s.
The number of 32-sample elements to generate per MP3 data frame was
set to 36 as that was what I saw on all my source files. However, on
mono files only half the number of samples are to be generated and
you'd end up with the synthesizer bands running out of energy and
have periods of 0-samples between proper data.
Now simply check each decoded frame for the proper NSMAX value and
only generate that many. Tested on force.mp3 in the issue referenced.
AudioOutputSPIFFSWAV writes a valid WAV file to the SPIFFS filesystem.
Be sure to do a SPIFFS.start() or .format before calling any output.
Set the filename using the additional ->SetFilename() call.
Under Windows it seems that the Arduino compilation can't find
<config.h> from inside a subdirectory. So just point explicitly to
"../config.h" for includes in subdirs.
The FLAC makefile has additional -I include paths which let them use
files in other directories without path specifiers. Arduino doesn't
support this, so while my development system was using symlinks, this
would not work well under Windows. Instead, simply add proper path
specifiers to includes in other directories.
Ported libFLAC v1.3.2 to the ESP8266. Moved CRC constants to PROGMEM
and the error strings. Still to be done would be decreasing the output
buffer to an int16_t and moving a larce number of "const int" to enums
since "const int" eats 4 bytes per variable.
Implements a simple and stupid HTTP stream reader to allow for ShoutCast
and other MP3 radio streaming to happen. Presently seems to stutter on
128K, 44.1KHz streams, but may be better on lower bitrates.