Commit Graph
45 Commits
Author SHA1 Message Date
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 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 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 6bc8f56092 For I2S, only enable mclkPin if it's actually used (#772)
Fixes #761
2025-10-08 15:04:06 -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 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
Piotr Gaczkowski 50bc3f7279 Add MCLK support for RP2040 (#707) 2024-10-06 16:54:01 -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
Nils Trubkin 0abcf71012 Add ability to SwapClocks(bool) on I2S. rp2040 only. (#639)
Fixes #638
2023-06-30 11:02:49 -07:00
Sylwester 4ba7df1928 Add support for I2S MCLK. (#594) 2023-01-04 09:46:05 -08:00
FedericoBusero f95f15fcb3 I2S: register I2S object to platform failed (#568)
ESP32: When calling destructor after stop, and then create a new object, then an error is shown "I2S: register I2S object to platform failed" because i2s_driver_uninstall had not been called.
ESP8266 : i2s_end is not called when stopping, but i2sOn is false, resulting in new call i2s_rxtx_begin
2022-09-01 12:16:14 -07:00
FedericoBusero e24223e3d5 ESP32: Fix compilation of I2S in Arduino ESP32 core 1.0.6 (#565) 2022-08-24 12:49:24 -07:00
Earle F. Philhower, III 879fe48b78 Clean up ESP32 I2S interface undefineds (#533) 2022-05-19 13:17:07 -07:00
Earle F. Philhower, III be8b8efbf2 Clean ESP32 build (#529) 2022-05-18 18:43:50 -07:00
Earle F. Philhower, III 9384bb0f3d Update for RP2040 core v2.0 new I2S (#528)
The I2S subsystem was rewritten in the RP2040 core V2.0, so update to
use the new object and calls.

Also clean up some code warnings and remove SPIFFS from the RP2040\
2022-05-18 17:37:34 -07:00
Frank c55d240ade Fix for issue #474, and a few other bugs in MODGenerator (#478)
Fixes #474

This bug was already present in stellaplayer. Obviously "effectNumber" must be checked, because "effectParameterX" just holds the "upper nibble" of effectParameter

- do channel mixing in 32bit, to avoid noise from over/underflow
- write audio output as "signed int" (not unsigned)
- add int16 saturation check ("clipping")
* avoid crash when MOD file has to many CHANNELS
- avoid guru meditation, by logging an error and refusing playback in case MOD.numberOfChannels > CHANNELS
2022-01-05 08:25:26 -08:00
FedericoBusero 4971e5ce68 Increase I2S buffer size (#472)
Increase I2S buffer size from 64 samples/ block to 128 samples/block. 
Thus fixes sound artifacts described in issue https://github.com/earlephilhower/ESP8266Audio/issues/442

Fixes #442
2021-12-26 09:29:09 -08:00
FedericoBusero 7ac86f015f I2S Fix Builtin DAC&PDM on ESP32 & compiling warning ESP32-C3 (#461)
* Update AudioOutputI2S.cpp

* Update AudioOutputSPDIF.cpp

* Fix PDM & DAC mode ESP32

The code for enabling compatibility with ESP32C3 had broken DAC builtin and PDM mode on ESP32. This should fix it again

* Update AudioOutputI2S.cpp
2021-12-17 19:31:49 -08:00
Wojtek Kaniewski 0d132c1391 Support LSB Justified DACs (e.g. PT8211) (#459) 2021-12-03 18:47:01 -08:00
FedericoBusero 2c1aeba4ab ESP32-C3 Support (#454)
* ESP32-C3 has no ULP coprocessor

Only the ESP32, ESP32-S2 and ESP32-S3 chips have an ULP coprocessor, ESP32-C3 doesn't have it. So exclude this code from compiling, as it cannot compile in the C3 environment.

* uint32_t and size_t is not the same on RISC-V

This change is necessary to be able to compile it on ESP32-C3

* uint32_t and size_t is not the same on RISC-V

The change is necessary to compile it on ESP32-C3

* ESP32-C3: I2S_MODE_DAC_BUILT_IN / I2S_MODE_PDM not available

On some ESP32 chips (e.g. ESP32-C3), builtin DAC is not possible as it lacks the hardware module. In order to be able to compile the library on ESP32-C3 the defines cannot be used.
2021-11-30 12:25:30 -08:00
Jesper Noer 617b06d09a Fixing I2S includes to work with ESP8266 Arduino version < 3.0.0 (#453) 2021-11-29 12:11:57 -08:00
qnxsgwy 6882b6e1b6 Fix 'i2s_write_bytes' was not declared in this scope on ESP32 (#428) 2021-09-08 08:57:25 -07:00
david gauchard c3c9a147c5 i2s on esp8266: fix include (#402) 2021-06-28 21:45:16 -07:00
Earle F. Philhower, III 8d6631e4ab Update I2S class API for RP2040 2021-04-05 17:03:34 -07:00
Earle F. Philhower, III b37e9d232b Add support for Raspberry Pi Pico Arduino Core
Adds support for the RP2040 core and the PIO based I2S output device.
https://github.com/earlephilhower/arduino-pico

Poisons some ARM optimizations which don't work on modern Thumbs.
2021-04-02 19:40:58 -07:00
david gauchard 435e2cf028 Fix for esp8266 I2S/NoDAC (#344)
* esp8266: Allows I2S-NoDAC to use only I2S-out-data GPIO
avoiding conflicts with repurposed GPIO, especially conflicting with SDFS.

* +message

* new upstream API update

* check i2s_begin's return value
2020-12-11 16:46:07 -08:00
Adamcbrz 299db3d03d Modify AudioOutputI2S to initialize i2s during begin (#331)
Fixes #330
2020-11-14 11:02:48 -08:00
Felix Eckhardt e59319f605 added missing DMA buffer flush, see issue #270 for details (#271) 2020-05-21 13:16:34 -07:00
Earle F. Philhower, III be0ee8283f Free BCK and WS pins for general use with NoDAC (#251)
The BCK and WS pins aren't needed or used when using the I2SNoDAC
option.  Restore their settings to whatever they were before, leaving
them untouched.  Apps may configure the additional pins either before or
after the I2SNoDac is created.
2020-04-14 11:49:12 -07: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
Earle F. Philhower, III ce9f023592 Add'l warning removal 2019-04-12 15:49:55 -07:00
h3ndrik c6ee72e9db make dma_buf_count configurable by user, so we can have a larger dma buffer on ESP32 (#106)
* make dma_buf_count configurable by user, so we can have a larger dma buffer on esp32

* fix comment about interrupt priority (see esp-idf documentation system/intr_alloc)
2018-08-20 07:49:42 -07:00
h3ndrik 4c8cc0a591 replace esp32s i2s_push_sample() (#116)
as it is deprecated and changed behaviour between esp-idf v2.0 and v3.0. this fixes the chipmunks in #110 and #105
2018-08-03 08:01:57 -07:00
Earle F. Philhower, III 0987b12e58 Fix 8->16 bit output conversion overflow error
The I2S outputs were converting samples in the buffer passed in
from u8->s16 on every call.  When the I2S was full, however, the
sample would not get pushed and the output function would be
called at a later time with the same buffer...which was already
at 16 bits.  It'd be converted again and turned into a high
frequency noise on the output.

Now only modify a copy of the input sample in I2S and I2SNoDAC.
Fixes the conversion problem competely.

Fixes #2
2018-05-23 22:40:29 -07:00
reaper7 32cbbfed45 Add PDM mode for ESP32 (#77)
Add PDM (pulse delta modulation) mode for ESP32 using the builtin hardware.
2018-03-25 12:11:29 -07:00
Earle F. Philhower, III 11bd5d2188 Set builtindac mamber before calling SetPinout
Hans-J. Ubben found a bug where the pinout wasn't being set properly on
ESP32s because the builtInDAC member was not set before calling SetPinout.
Fix per his suggestion.
2018-02-17 15:24:29 -08:00
Earle F. Philhower, III 54498a21a0 Fix overflow for 256x oversampling
Fixes #55
2018-02-08 17:39:51 -08:00
h3ndrik 0bb859037b handle esp32 apll issues (#51)
* make use_apll user-configurable (fixes #37)

* disable apll per default (fixes #47)
2018-02-06 08:06:22 -08:00
Earle F. Philhower, III eb677664f2 Add more default values to I2S output 2018-02-01 12:30:30 -08:00
h3ndrik e7c2aba2aa don't use audio pll on buggy rev0 chips (#40)
as ESP32_MP3_Decoder does
2018-01-26 07:51:49 -08:00
h3ndrik f1916051ec initialize member variables (#39)
if AudioOutputI2S is instanciated in a function (like in the examples) the member variables are not initialized to a default value.
2018-01-26 07:50:43 -08:00
Earle F. Philhower, III b9f13a3161 Enable onboard DAC output 2018-01-25 20:52:58 -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