412 Commits
Author SHA1 Message Date
Earle F. Philhower, III 10d929ac01 Cast AdjustI2SRate result to uint32_t (#821)
Fixes #820
2026-08-02 10:06:52 -07:00
Earle F. Philhower, III 74fc1f09bb Fix C23 compilation errors (#814) 2.4.2 2026-07-21 08:38:24 -07:00
Wojtek Kaniewski 05f2fb0045 Fix memory corruption in AudioGeneratorAAC on non-ESP8266 platforms (#807)
The description of `AACDecode()` function states that the output buffer
must be big enough for 1024 samples per channel _or_ 2048 if SBR is
enabled. By default SBR is enabled on non-ESP8266 platforms, yet the
buffer in `AudioGeneratorAAC` is always 1024 samples per channel long.
This causes memory corruption on ESP32 and possibly Pi Pico. This change
makes the output buffer correct.
2026-03-18 07:30:39 -07:00
Александр 70defdb6c6 Fix u8 upsampling and mono mode for AudioGeneratorWAV (#802)
For AudioGeneratorWAV, the upsample from u8 to i16 bits has been fixed. Previously, playback of wav files with u8 encoding resulted in silence. The data was read, but not used in calculations. Additionally, in mono mode, I removed the unnecessary resolution increase for the second channel and implemented simple duplication. Now, when playing mono wav files, the audio will be in both the left and right channels.
2025-12-26 18:00:46 -08:00
Earle F. Philhower, III 3450935a2a Add new project link 2025-12-09 14:50:39 -08:00
NeoCat 94c68ecbaa Call i2s_channel_enable(_tx_handle) in AudioOutputSPDIF::begin() (#799)
i2s_channel_enable(_tx_handle) was only called within
AudioOutputSPDIF::SetRate(), which caused i2s_channel_write to fail
if the rate was the same with the default 44100Hz.
This fixes the issue by calling it in begin().
2025-11-12 15:29:27 -08:00
Earle F. Philhower, III cd98586a2c Suggest using latest pioarduino 2025-10-31 08:37:22 -07:00
Earle F. Philhower, III 89c60ad19b ESP32 Platform.IO information
Added section on ESP32 and Platform.IO integration issues and solutions.
2025-10-27 09:36:25 -07:00
Earle F. Philhower, III d6184e0897 Update version 2.4.1 2025-10-23 14:09:27 -07:00
Earle F. Philhower, III c075b393f1 Properly timeout for ESP32 I2S writes (#794)
The I2S write was always blocking meaning only a single loop call
might have ended up playing the entire audio output.

Replace the timeout of `10` with `0`.
2025-10-23 13:50:14 -07:00
Earle F. Philhower, III 5a0375f409 Speed MIDI decode 11%-64% with approximated powf (#793)
Use a numeric approximation to make powf much faster.  Loss of accuracy
isn't an issue in an audio output device.
2025-10-23 13:36:47 -07:00
Earle F. Philhower, III 41b96ef000 Increase MIDI speed by 20% by saturating at end (#792)
By rendering into a 32b int we don't have to saturate check in the inner
loop of the voice render, which is called multiple times per actual output
block.  That check is very expensive.

In tsf_render_short make the input `short *buffer` have 2x the space as
normal to allow the full 32b quantity for each sample to accumulate.
After all voices have been rendered, then resample with saturation into
int16_t values.

About 24% faster on the Pico while still saturating properly.
2025-10-22 18:32:35 -07:00
Earle F. Philhower, III 5cb3ef5d2d Fix typo in README 2025-10-20 18:50:51 -07:00
Earle F. Philhower, III 11576fe94c Update version 2.4.0 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 7ea583ff37 Update version 2.3.0 2025-10-14 14:36:15 -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 724b6d606e Update version 2.2.0 2025-10-11 15:32:12 -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 36dde3c85c Update README, ESP32 is supported 2025-10-09 12:35:45 -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 c5613c5a4b Add PWM/NoDAC filter and amp examples (#775)
Fixes #562
Fixes #732
2025-10-08 17:30:13 -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 297943c8a8 Update version 2.1.0 2025-10-08 10:46:52 -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, III a3e6f97862 Add auto-release GH action 2025-10-08 10:07:53 -07:00
Earle F. Philhower, III 069945007d Pin GH actions to SHA (#770) 2025-10-08 09:28:03 -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
Earle F. Philhower, III b09bad5b9c Fix stale acction warnings 2025-10-08 09:11:53 -07:00
Earle F. Philhower, III acc4dc426d Add CodeQL GH action (#768) 2025-10-08 09:05:51 -07:00
Jason2866 efcb98a2cd ESP32-S3 has no DAC (#490) 2025-10-08 08:46:29 -07:00
Earle F. Philhower, III 18796abb1e Up GH action operations 2025-10-08 08:28:51 -07:00
Earle F. Philhower, III df171f5657 Add stale issue tracker GH action (#766) 2025-10-08 08:26:34 -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