73 Commits
Author SHA1 Message Date
Earle F. Philhower, III 7d99e6b7b9 BREAKING: Re-port MIDI, faster, lower memory, ESP32 support (#790)
* Pull untouched upstream TinySoundFont

Start from the upstream TinySoundFont by @schellingb at
https://github.com/schellingb/TinySoundFont and rearchitect the MIDI
processing.

* Convert to PROGMEM-based SoundFont structures.

This makes it much faster to access the SoundFont and also removes all the
static RAM usage.  The samples, the regions, the instruments are all now
in ROM.  Only the dynamic voices and related info takes up RAM.  No caching.

* (Re)convert to fixed point math.

TSF upstream is built for systems with real floating point units (and
produces great sound with it!), but processors like the Pico, ESP8266,
and several models of ESP32 don't have one so emulate FP in *extremely*
slow SW.  Use fixed point (integer) representations for the inner loop
and wherever possible to avoid `float` math.

For processors like the Pico 2 or original ESP32 with hardware FPUs this
still increases performance since integer is still much faster.

* Redo the example and add default SF2s

Rewrite the MIDI examples to use PROGMEM for both SF2 and MID file.
It simplifies life for the casual user and me.

* Breaking change

The MIDI object now has a `midi::SetSoundFont(tsf *)` instead of a
`midi::SetSoundfont(AudioFileSource *)`.  It no longer supports reading
SF2 from LittleFS or SD.
2025-10-20 18:26:41 -07:00
Earle F. Philhower, III 3032072561 Add ESP32 PDM 1-bit output support (#784)
Borrowed from BackgroundAudio PDM implementation
https://github.com/earlephilhower/BackgroundAudio

Requires an ESP32 model with PDM support.
2025-10-14 14:04:21 -07:00
Earle F. Philhower, III e0143bbf37 ESP IDF 6.0 compat, update I2S, DAC, ULP (#783)
Move to the new I2S driver for the ESP chips, since the next revisioncl
of the IDF will remove them completely.

Make the I2S constructors saner and add consistent SetPinout() and
SetBuffers calls to allow configuration.

Remove need for separate UseMCLK or SwapClocks calls, we can figure
that out from the pins selected.

Fixes #758
2025-10-14 12:06:34 -07:00
Earle F. Philhower, III f1d74df9f7 Rewrite OPUS driver, no extra libs, update (#780)
Move to Opus 1.5.1
Remove OpusFile and OGG libraries because we parse the OGG file in
the object directly with way less memory and overhead.

Update example for LittleFS and RP2040

Fixes #372
2025-10-10 15:19:20 -07:00
Earle F. Philhower, III 39188b81d6 Scan MP3 for header, avoid multiple burst errors (#764)
MP3 comes in chunks of encoded data started by a header sequence.
Scan for it in the decoder and only pass in data that starts with
this header to avoid the burst errors

Avoids a avalanche of `lost synchronization` error reports when there
is a file error.

Also enable additional sketches on the RP2040/RP2350
2025-10-07 23:22:54 -07:00
Earle F. Philhower, III f9e72dbb21 Add style check matching RP2040 core (#740)
Will let us backport the BackgroundAudio patches to libhelix easier and clean
up some ugly formatting we've let develop.
2025-04-11 12:09:49 -07:00
Earle F. Philhower, III a6141473fb Update for ESP32 Arduino 3.x (#685)
Implement the renamed network client and other API changes when built
under the 3.x branch of the Arduino ESP32 core.

Disable building TSF on the ESP32, the Xtensa G++ backend bug is still there.

Minimal changes to get I2S to build under new IDF.  Deprecated but
not removed, so warnings are expected but should not be fatal in
use.

Fixes #683
2024-06-06 14:43:45 -07:00
Earle F. Philhower, III 0b5da0e9dd Add PWMAudio support for the RP2040 (#597)
Uses the RP2040 HW PWM generator to provide a stereo audio signal.
2023-01-03 17:08:56 -08:00
刘帅 93c4e3a15a Fix build support gcc8 for other arch (#567) 2022-08-31 10:54:19 -07:00
Earle F. Philhower, III b9666d3652 Get ESP32 CI running again (#532)
Get ESP32 CI running again
ESP32 lacks separable CI stuff
ESP32 has broken GCC 8, don't build MIDI examples
2022-05-19 10:48:24 -07:00
Earle F. Philhower, III a6f1eda9a2 Get ESP8266 CI running again (#531)
Add LWIP to ESP8266 builds
New build step on ESP8266
Fix warnings, quiet get.py
Ack SPIFFS deprecation
Example fix
Clean up overzealous pragmas
Fix server.accept() deprecation
2022-05-18 22:12:33 -07:00
Earle F. Philhower, III 2069060574 Add RP2040 build (#530)
Fix examples to build on RP2040
Clean up generator warnings
No SPDIF on RP2040 (yet)
Add back C sources for AAC on ARM
No WiFi streaming on RP2040
No webradio on RP2040
No talking clock (NTP) on RP2040 either
2022-05-18 21:03:37 -07:00
Wouter van der Put c87b662cb6 Fix typo (#504) 2022-03-15 17:59:40 -07:00
Earle F. Philhower, III 86a1818da5 Add codespell to CI checks (#450) 2021-11-28 10:52:33 -08:00
Wouter van der Put b65bc2df8f Fix: add missing SPIFFS.begin() (#443)
Without this fix, there is no sound and the serial monitor shows:

Starting up...

[E][vfs_api.cpp:22] open(): File system is not mounted
[E][vfs_api.cpp:22] open(): File system is not mounted
BEGIN...
MIDI done
MIDI done

After this fix there is sound and no error on the serial monitor.
Then change is similar to the code in https://github.com/earlephilhower/ESP8266Audio/blob/master/examples/PlayMP3FromSPIFFS/PlayMP3FromSPIFFS.ino
2021-11-28 10:31:36 -08:00
pintomax c55abbfba5 Stream MP3 from HTTP to SPDIF (#436)
Stream MP3 from HTTP to SPDIF
2021-11-02 19:55:43 -07:00
Hideaki Tai f974af9bf3 Add AudioFileSourceFunction which can generate sound from functions (#383) 2021-04-11 18:37:38 -07:00
Hideaki Tai 9b4f36009b Fix compile error due to insufficient capacity (#384) 2021-04-11 13:57:55 -07:00
david gauchard 6ecb6afe30 API to force HTTPv1.0 allowing streaming clean data from some servers (#363) 2021-01-27 16:27:04 -08:00
david gauchard 3349608b11 StreamOnHost: play audio on host (#359)
* StreamOnHost: actually play audio

* (spaces)

* fix comment

* update message
2021-01-08 07:41:03 -08:00
david gauchard 0cee4d410e Proposal for various tiny fixes (#357)
* replace a disappeared shoutcast url by a working one from another example

* increase a buffer size (found by valgrind)

* make emulated example closer to the not emulated one
use `./onHost diff` to show the diff -u

* add `diff` option to onHost script

* add a delay to local copy of AudioOutputNull

* increase another buffer size

* make AudioOutputNullSlow.h compatible with arduino api (not only emulation on host)
2021-01-02 15:09:01 -08:00
david gauchard 1c51669729 test/run on host, output to null device (#299)
* test/run on host to null device

* compilation fix
2020-08-30 15:07:11 -07:00
Earle F. Philhower, III fae26d4010 Add Opus file format (and OGG demux) (#294)
Add ported versions of the Opus codec, OpusFile parser, and OGG demuxer
from Xiph.org.

Only works on the ESP32 due to memory limitations (of opusfile,
strangely enough, and not because of opus compression).

Adds a basic example and a host test.

Fixes #278
2020-08-11 20:56:13 -07:00
Earle F. Philhower, III f8d5ccf7d0 Add ESP32 build, break out ESP8266 install for CI (#288)
Re-enable ESP32 builds in CI

Fix examples which do not compile on ESP32
2020-08-08 16:40:21 -07:00
Earle F. Philhower, III 0f40d83241 Use GitHub CI to run tests (#287) 2020-08-08 15:36:06 -07:00
Earle F. Philhower, III e0d413622c Add Talkie (TI speech synthesizer) support (#269)
Rewrite https://github.com/going-digital/Talkie to work in the
ESP8266Audio framework.  Allows sync and async speech.

Add a very annoying talking clock example.
2020-05-13 20:16:48 -07:00
Earle F. Philhower, III 580706d7e3 Add LittleFS file source, MIDI example
LittleFS reads many times faster than SPIFFS, and is now in the ESP8266,
so include a file source for it and move the MIDI example to LittleFS.

Keep the SPIFFS as ESP32 doesn't support LittleFS yet.
2020-04-15 11:19:56 -07:00
Earle F. Philhower, III 7df1e005e5 Use same SSID/password settings as core examples (#252) 2020-04-14 22:33:10 -07:00
Earle F. Philhower, III 0fd2d0413b Replace external SPIRAM lib w/internal optimized (#250)
* Replace external SPIRAM lib w/internal optimized

Instead of requiring everyone to download and install another Arduino
library to use this lib, include an optimized, self-contained one from
the 8266 VM PR: https://github.com/esp8266/Arduino/pull/6994

Does change the API as it now requires a HW chip select, so that
parameter is removed from the SpiRAM buffer object.

* Redo the FIFO to try and be faster

* Fix the SPI interface, buffering.

SPI FIFO needs special care so do all work in a RAM copy and the copy it
over manually w/32b writes.

Ensure the SPI command is done before touching the FIFO.

Fix buffering organization.

Make the buffer report status as a #### bar.

* Fix infinite wait on EOF

* Add SW chip select support

* Update URL to one that's live today

* Clean up metadata printout

* Clean up readme refs to obsolete lib

* Slow down the DIO->SIO reset sequence

* Update readme to remove old SPIRam library ref

Also add the resistor to the 1T circuit to avoid transistor overheating.
2020-04-14 15:41:47 -07:00
david gauchard aba310d3a0 webradio: example: http: gently listen to the end of the sentence before saying goodbye (#245) 2020-03-24 20:06:03 -07:00
Ivan Kostoski 377b271edd ESP8266 SinglePinI2SDriver, SPDIF output improvements, FLAC memory optimization (#237)
* Added S/PDIF output using I2S peripheral

* Added AudioOutputSPDIF to README and PROGMEM changes

* SPDIF/I2S sample rate fixes

* Fix SPDIF example file name

* Minimal (single pin) I2S driver

* AudioOutputSPDIF changes for minimal I2S driver

* Documentation changes

* FLAC decoding memory optimization
2020-02-24 09:55:30 -08:00
Ivan Kostoski a7a8b917d2 Added S/PDIF output using I2S peripheral (#235)
* Added S/PDIF output using I2S peripheral

* Added AudioOutputSPDIF to README and PROGMEM changes
2020-02-07 13:05:03 -08:00
david gauchard 4fed6a230f install and use a global audioLogger instead of Serial (#198)
* use of global audioLogger-> instead of Serial.

* default to silence

* initialize logger in examples
2019-07-24 10:02:21 -07:00
Simon L e6a4e6c886 Document the internal DAC on ESP32 more explicitly (#184)
* Document INTERNAL_DAC explicitly and its usage

* Add INTERNAL_DAC usage comment in example
2019-05-12 08:31:08 -07:00
Earle F. Philhower, III 582e6e70ac Add RTTTL example and use a non-square waveform
Seems like I2S DACs don't like to be presented with perfect bang-bang
square waveforms, so build a very simple model and use that to avoid
abrupt changes in values.  Sounds about as good as you're going to get
with this.

Also add a simple example showing how to play a RTTTL string.
2018-03-26 08:00:56 -07:00
Earle F. Philhower, III 3c7ffbe0b3 Support volume on each input channel
Call stub->SetGain(float) to set an input's volume before mixing.
2018-02-25 14:24:38 -08:00
Earle F. Philhower, III ca50839712 WIP - AudioOutputMixer to combine multiple streams
This runs but amplification is not working yet.  See MixerSample
for a very crufty example.
2018-02-25 13:37:17 -08:00
h3ndrik 4d9d010e8b Fix webradio to use buffer, not raw input streams
Thanks to @h3ndrik, again.
2018-01-31 19:20:08 -08:00
Earle F. Philhower, III 96fc37dce5 Refactor I2S to be cleaner, more extensible
With the multiple I2S modes on the ESP32, it makes sense to use a
cleaner class hierarchy for the I2S tools.  Make I2SNoDAC into a
subclass of I2S (renamed from I2SDAC) and remove about 80% of the
code which was identical exept for the per-sample bitstream synthesis.
2018-01-25 19:15:02 -08:00
Earle F. Philhower, III 93f7d90baf Update WebRadio to use prealloc'd buffers
To avoid allocations in the application, preallocate all decoder and
buffer memory in and then never free it.  Use the new pre-alloc'd
constructors to generate the playback objects.
2018-01-21 15:07:40 -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 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
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 d06dcf1123 Include type and volume in checksum, cleanup code 2017-12-24 09:31:36 -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 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 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