261 Commits
Author SHA1 Message Date
Earle F. Philhower, III 11576fe94c Update version 2025-10-20 18:36:36 -07:00
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 3e099fefe1 Don't skip CI, my son. 2025-10-20 16:26:45 -07:00
Earle F. Philhower, III 291cff213f Add block-based I2S write on Pico (#789) 2025-10-20 15:08:13 -07:00
Earle F. Philhower, III e2f215cea3 Add version defines (#788) 2025-10-20 08:44:57 -07:00
Earle F. Philhower, III 7704d78dc9 Add ConsumeSamples to Null output (#787)
Help with testing optimization by minimizing non-decode CPU usage
2025-10-20 08:30:24 -07:00
Earle F. Philhower, III 25c6165b3d Fix PDM compiles for older SOCs (#786)
Espressif changes the contents of the PDM struct depending on the
chip model.  Use a hopefully valid `#define` to avoid setting a
member that's not there in some cases.

Fixes #785
2025-10-18 17:38:23 -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 058e131b26 Remove 8-bit handling in output, promote WAV/FLAC to 16 (#782)
Only the WAV and FLAC generators can generate 8-bit values, so it is
more efficient and sane to just have those generators upscale to 16-bit
signed (if necessary) in generation and simplify all the other
Generators and Outputs.
2025-10-13 09:56:39 -07:00
Earle F. Philhower, III 2f5cc2a388 Remove unneeded opus.h files (#781) 2025-10-11 14:43:59 -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 c19a6153c9 Add Werror, etc. to CI process (#779) 2025-10-09 09:42:39 -07:00
Earle F. Philhower, III 1255a4240a Mixer stubs produce 16b, avoid 8b WAV issues (#776) 2025-10-09 07:33:48 -07:00
FedericoBuseroandEarle F. Philhower, III 8fe0911715 ESP32 AudioOutputULP fixes (#579)
* Fix ULP on ESP32

CONFIG_IDF_TARGET_ESP32 is not yet defined before #include "AudioOutputULP.h"

* AudioOutputULP: Fix DAC2 stereo in case of DAC1+DAC2

* ULP - no ESP32S2 / S3

On ESP32S2 it compiles, but no audio is coming out
On ESP32S3 DAC is not supported

* Astyle

---------

Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
2025-10-08 20:18:33 -07:00
Earle F. Philhower, III 94f6879f8d Add include for rtc_io_reg.h in AudioOutputULP.cpp 2025-10-08 19:55:02 -07:00
Earle F. Philhower, III 5cab5b34aa Fix div/0 error after WDT in ULP (#778)
Fixes #399

rtc_clk_cal can return 0 while calibration is underway.  If that happens
busy-wait until it returns a valid period.
2025-10-08 19:06:46 -07:00
Earle F. Philhower, III b4e76952c1 Rename helper fcn stack->stackenter for MAD (#777)
Fixes #379
2025-10-08 18:44:42 -07:00
Earle F. Philhower, III 81ebc8a11a Fix Talkie output on ESP32 (#774)
Fixes #629

Need to set the I2S clock after begin() for ESP32
2025-10-08 17:01:58 -07:00
Earle F. Philhower, III 15f9a65afa AudioOutputInternalDAC unitialized variable fix (#773)
Fixes #750
2025-10-08 15:17:17 -07:00
Earle F. Philhower, III 6bc8f56092 For I2S, only enable mclkPin if it's actually used (#772)
Fixes #761
2025-10-08 15:04:06 -07:00
Nils UliczkaandEarle F. Philhower, III b63c28449e Tell AudioOutputMixer the rate for the next sample (#129)
* Tell the mixer at which rate to consume the next sample
* Update SetRate method to include id parameter
* Refactor SetRate to minimize redundant updates
Optimize rate setting to avoid unnecessary calls.
* Add newHz and lastHz variables to AudioOutputMixer
---------
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
2025-10-08 14:50:47 -07:00
Earle F. Philhower, III d9e1ea710b Don't set I2S rate unless it's different (#771)
On the ESP32 it seems the i2s clock set will cause a hiccup, even
if it's setting the exact same clock as before.

Avoid it by only setting the I2S clock if it differs from the last set.
Initialize it to 0hz to ensure the first setRate call always works.

Supercedes #656
2025-10-08 10:36:16 -07:00
Earle F. Philhower, IIIandCopilot Autofix powered by AI 402278ab11 Potential fix for code scanning alert no. 9: Array offset used before range check (#769)
Very minor fix for damaged SoundFont files.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-10-08 09:21:26 -07:00
Jason2866 efcb98a2cd ESP32-S3 has no DAC (#490) 2025-10-08 08:46:29 -07:00
Earle F. Philhower, III 41309312d7 Remove error when ULP included on 8266/Pico (#767)
Fixes #760
2025-10-08 08:25:30 -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
frak0d 9dee3010c1 Added internal DAC support via DMA (#744) 2025-04-18 09:45:24 -07:00
Earle F. Philhower, III a852767b6f Speed up AAC decode by ~20% on Pico/ESP32 (#742)
Import the optimized (well...de-un-optimized) version of libhelix from
BackgroundAudio for about a 20% speedup on the Pico for AAC decode.
2025-04-12 10:25:55 -07:00
Earle F. Philhower, III 88a82209fd Remove ESP32 NDEBUG redefinition warnings (#741) 2025-04-11 12:16:20 -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
Nils Schimmelmann b589145da3 Add support for MIPS architecture (#738) 2025-04-08 10:13:40 -07:00
Kurt Haenenandkurt.haenen b0a06edde2 Fixing crash on MP3 playback on ESP8266. (#723)
Co-authored-by: kurt.haenen <kurt.haenen@quintux.com>
2024-12-25 13:19:16 -08:00
Earle F. Philhower, III cdd07c92c2 Only block tsf.h on Xtensa ESP32, not RISCV (#722)
Fixes #721
2024-12-19 14:33:24 -08:00
Earle F. Philhower, III aafabf2367 Ensure MP3 can safely exit on OOM (#716)
Fixes #715.  Good catch, @EternityForest
2024-12-19 09:33:01 -08:00
Earle F. Philhower, III fbe69b8cd8 Fix AAC HR decode on RP2040
U64 big/little endian mismatch for ARM cores.  Remove the whole PowerPC support option as there aren't any commerically significant PPC embedded systems still being developed.
2024-12-18 14:39:07 -08:00
TorrenteroandEdgar d32d8b4cc8 Performance improvement: ~13% faster on ESP32 and ~21% faster on ESP8266 (empirically tested) (#554)
* Performance improvement
- new tsf_note_on_fast returning playIndex and removing lowpass filter setup since it is not being processed in tsf_voice_render_fast anyway but is consuming a lot of cpu
- new tsf_note_off_fast using playIndex to stop voices faster
- Removing lowpass filter setup from tsf_voice_render_fast since it is not being processed
- Math tweaks trying to avoid complex math operations (specially conversions) at voice render stage
- Precalculating *F32P32 values to avoid doing them at voice render stage
* Fixing data type
* Initializing play indexes
---------
Co-authored-by: Edgar <edgar.coria@xema.tech>
2024-10-08 17:45:57 -07:00
Earle F. Philhower, III 235bcb12de Fix UTF-8 warning in RCSL doc 2024-10-08 13:59:49 -07:00
jmr-esandRASMUSSEN Joern 96dc79c9fa AudioOutputPWM: added amplification (#605)
Co-authored-by: RASMUSSEN Joern <joern.rasmussen-ext@hexagon.com>
2024-10-08 13:50:43 -07:00
Piotr Gaczkowski 50bc3f7279 Add MCLK support for RP2040 (#707) 2024-10-06 16:54:01 -07:00
Earle F. Philhower, III 79208f6701 Fix GCC14-detected warnings (#711)
* Fix pedantic GCC14 warnings on calloc order
* Ensure AAC read-in doesn't overflow internal structures when the file is corrupted/illegal.
2024-10-06 16:53:22 -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
ChuckMash b837e7d36a Stop output on OOM in MP3 (#658) 2024-04-25 17:53:07 -07:00
Infinity 51a584c2b7 Update AudioGeneratorRTTTL.cpp for dotted length (#668) 2024-04-25 17:51:42 -07:00
Earle F. Philhower, III b3c41668a2 Fix GCC12.3 new warnings for RP2040 (#679)
* Fix GCC12.3 new warnings for RP2040

* Remove OPUS encoder, not supported on embedded
2024-04-16 16:32:16 -07:00
Earle F. Philhower, III 139fba4116 Update opusfile.c (#678) 2024-04-16 15:14:14 -07:00
Earle F. Philhower, III b7d89058dd Update polyphase.c 2024-04-16 15:11:31 -07:00
Earle F. Philhower, III e306df208c Update AudioOutputSPDIF.h 2024-04-16 15:10:49 -07:00
Earle F. Philhower, III f6c0d562f8 Update AudioOutputSPDIF.cpp (#677) 2024-04-16 15:10:24 -07:00
Nils Trubkin 0abcf71012 Add ability to SwapClocks(bool) on I2S. rp2040 only. (#639)
Fixes #638
2023-06-30 11:02:49 -07:00