9#define AUDIOTOOLS_VERSION "1.0.1"
10#define AUDIOTOOLS_MAJOR_VERSION 1
11#define AUDIOTOOLS_MIOR_VERSION 0
14#if defined(IS_MIN_DESKTOP)
16# include "AudioTools/AudioLibs/Desktop/Time.h"
17# include "AudioTools/AudioLibs/Desktop/Main.h"
18# define USE_STREAM_READ_OVERRIDE
22#elif defined(IS_DESKTOP_WITH_TIME_ONLY)
23# include "AudioTools/AudioLibs/Desktop/Time.h"
28#elif defined(IS_DESKTOP)
33# define USE_URL_ARDUINO
34# define USE_STREAM_WRITE_OVERRIDE
35# define USE_STREAM_READ_OVERRIDE
36# define USE_STREAM_READCHAR_OVERRIDE
41typedef WiFiClient WiFiClientSecure;
46#elif defined(ESP32_CMAKE)
48# include "esp_idf_version.h"
53# define USE_STREAM_READ_OVERRIDE
59#include "AudioTools/CoreAudio/AudioRuntime.h"
63#if __has_include("AudioConfigLocal.h")
64#include "AudioConfigLocal.h"
68#ifndef AUDIO_INCLUDE_CORE
69# define AUDIO_INCLUDE_CORE true
73#ifndef PREFER_FIXEDPOINT
74# define PREFER_FIXEDPOINT false
78#ifndef USE_AUDIOTOOLS_NS
79# define USE_AUDIOTOOLS_NS true
90#ifndef USE_AUDIO_LOGGING
91# define USE_AUDIO_LOGGING true
95# define LOG_LEVEL AudioLogger::Warning
99# define LOG_STREAM Serial
102#ifndef LOG_PRINTF_BUFFER_SIZE
103# define LOG_PRINTF_BUFFER_SIZE 303
107# define LOG_METHOD __PRETTY_FUNCTION__
111#ifndef USE_CHECK_MEMORY
112# define USE_CHECK_MEMORY false
118# define USE_OBSOLETE false
125#ifndef DEFAULT_BUFFER_SIZE
126# define DEFAULT_BUFFER_SIZE 1024
129#ifndef DEFAULT_SAMPLE_RATE
130# define DEFAULT_SAMPLE_RATE 44100
133#ifndef DEFAULT_CHANNELS
134# define DEFAULT_CHANNELS 2
137#ifndef DEFAULT_BITS_PER_SAMPLE
138# define DEFAULT_BITS_PER_SAMPLE 16
141#ifndef I2S_DEFAULT_PORT
142# define I2S_DEFAULT_PORT 0
145#ifndef I2S_BUFFER_SIZE
146# define I2S_BUFFER_SIZE 512
149#ifndef I2S_BUFFER_COUNT
150# define I2S_BUFFER_COUNT 6
153#ifndef ANALOG_BUFFER_SIZE
154# define ANALOG_BUFFER_SIZE 512
157#ifndef ANALOG_BUFFER_COUNT
158# define ANALOG_BUFFER_COUNT 6
161#ifndef A2DP_BUFFER_SIZE
162# define A2DP_BUFFER_SIZE 512
165#ifndef A2DP_BUFFER_COUNT
166# define A2DP_BUFFER_COUNT 30
169#ifndef CODEC_DELAY_MS
170# define CODEC_DELAY_MS 10
173#ifndef COPY_DELAY_ON_NODATA
174# define COPY_DELAY_ON_NODATA 10
177#ifndef COPY_RETRY_LIMIT
178# define COPY_RETRY_LIMIT 20
181#ifndef MAX_SINGLE_CHARS
182# define MAX_SINGLE_CHARS 8
187# define HTTP_MAX_LEN 1024
191#ifndef HTTP_CHUNKED_SIZE_MAX_LEN
192# define HTTP_CHUNKED_SIZE_MAX_LEN 80
196#ifndef USE_RESAMPLE_BUFFER
197# define USE_RESAMPLE_BUFFER true
203#ifndef PWM_BUFFER_SIZE
204# define PWM_BUFFER_SIZE 1024
207#ifndef PWM_BUFFER_COUNT
208# define PWM_BUFFER_COUNT 4
211#ifndef PWM_AUDIO_FREQUENCY
212# define PWM_AUDIO_FREQUENCY 30000
225#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C3)
228# define USE_INT24_FROM_INT
232#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S2)
236#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S3)
243#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C6)
249#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32P4)
261# if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
262# define USE_SERVER_ACCEPT true
264# if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
265# define USE_CONCURRENCY
267# define USE_PRINT_FLUSH true
269# define USE_PRINT_FLUSH false
271# define USE_SD_SUPPORTS_SPI
273# if !defined(ARDUINO)
274# define USE_IDF_LOGGER
279#if defined(ESP32) && !defined(ESP32X) && !defined(CONFIG_IDF_TARGET_ESP32H2)
280#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
281# define USE_INT24_FROM_INT
291# define USE_WIFI_CLIENT_SECURE
292# define USE_URL_ARDUINO
293# define USE_AUDIO_SERVER
295# define USE_TOUCH_READ
298#define USE_TYPETRAITS
299#define USE_STREAM_WRITE_OVERRIDE
300#define USE_STREAM_READ_OVERRIDE
301#define USE_EXT_BUTTON_LOGIC
303#define USE_ALLOCATOR true
305#define USE_TASK false
307#define PWM_FREQENCY 30000
308#define PIN_PWM_START 12
309#define PIN_I2S_BCK 14
311#define PIN_I2S_DATA_IN 32
312#define PIN_I2S_DATA_OUT 22
313#define PIN_I2S_MCK -1
314#define I2S_USE_APLL true
316#define PIN_I2S_MUTE -1
317#define SOFT_MUTE_VALUE 0
321#define I2S_AUTO_CLEAR true
324#define URL_STREAM_CORE 0
325#define URL_STREAM_PRIORITY 2
326#define URL_STREAM_BUFFER_COUNT 10
327#define STACK_SIZE 30000
328#define URL_CLIENT_TIMEOUT 60000;
329#define URL_HANDSHAKE_TIMEOUT 120000
337#if ESP_IDF_VERSION_MAJOR < 4 && !defined(I2S_COMM_FORMAT_STAND_I2S)
338# define I2S_COMM_FORMAT_STAND_I2S (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
339# define I2S_COMM_FORMAT_STAND_MSB (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB)
340# define I2S_COMM_FORMAT_STAND_PCM_LONG (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG)
341# define I2S_COMM_FORMAT_STAND_PCM_SHORT (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT)
343typedef int eps32_i2s_sample_rate_type;
345typedef uint32_t eps32_i2s_sample_rate_type;
352#if defined(ESP32) && defined(ESP32X)
354# include "esp32-hal-log.h"
356# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
357# define USE_INT24_FROM_INT
362#define USE_URL_ARDUINO
364#define USE_WIFI_CLIENT_SECURE
366#define USE_AUDIO_SERVER
367#define USE_TYPETRAITS
369#define USE_STREAM_WRITE_OVERRIDE
370#define USE_STREAM_READ_OVERRIDE
372#define USE_ALLOCATOR true
375#define PWM_FREQENCY 30000
376#define PIN_PWM_START 1
377#define PIN_I2S_MCK -1
380#define PIN_I2S_DATA_OUT 8
381#define PIN_I2S_DATA_IN 9
382#define I2S_USE_APLL true
384#define PIN_I2S_MUTE -1
385#define SOFT_MUTE_VALUE 0
389#define I2S_AUTO_CLEAR true
393#define URL_STREAM_CORE 0
394#define URL_STREAM_PRIORITY 2
395#define URL_STREAM_BUFFER_COUNT 10
396#define STACK_SIZE 30000
397#define URL_CLIENT_TIMEOUT 60000;
398#define URL_HANDSHAKE_TIMEOUT 120000
405typedef uint32_t eps32_i2s_sample_rate_type;
411#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32H2)
412#include "esp32-hal-log.h"
413#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
414# define USE_INT24_FROM_INT
423#define USE_TYPETRAITS
425#define USE_STREAM_WRITE_OVERRIDE
426#define USE_STREAM_READ_OVERRIDE
428#define USE_ALLOCATOR true
431#define PWM_FREQENCY 30000
432#define PIN_PWM_START 1
433#define PIN_I2S_MCK -1
436#define PIN_I2S_DATA_OUT 8
437#define PIN_I2S_DATA_IN 9
438#define I2S_USE_APLL true
440#define PIN_I2S_MUTE -1
441#define SOFT_MUTE_VALUE 0
444#define I2S_AUTO_CLEAR true
446typedef uint32_t eps32_i2s_sample_rate_type;
453# include <ESP8266WiFi.h>
456#define USE_TYPETRAITS
459#define USE_AUDIO_SERVER
460#define USE_URL_ARDUINO
462#define PIN_PWM_START 12
463#define PIN_I2S_BCK -1
465#define PIN_I2S_DATA_IN -1
466#define PIN_I2S_DATA_OUT -1
467#define I2S_USE_APLL false
468#define PIN_I2S_MUTE 23
469#define SOFT_MUTE_VALUE 0
471#define USE_SERVER_ACCEPT 1
473#define URL_CLIENT_TIMEOUT 60000;
474#define URL_HANDSHAKE_TIMEOUT 120000
475#define USE_SD_SUPPORTS_SPI
480#if (defined(ARDUINO_SEEED_XIAO_NRF52840_SENSE) || defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_MBED_NANO)) && !defined(ARDUINO_ARCH_ZEPHYR)
482#define USE_INT24_FROM_INT
485#define USE_TYPETRAITS
488#define USE_ALT_PIN_SUPPORT
490#define PIN_PWM_START 5
493#define PIN_I2S_DATA_IN 4
494#define PIN_I2S_DATA_OUT 4
496#define PIN_I2S_MUTE -1
497#define SOFT_MUTE_VALUE 0
502#if defined(ARDUINO_ARCH_MBED_RP2040)
507#define USE_ANALOG_ARDUINO
508#define USE_TYPETRAITS
510#define USE_INT24_FROM_INT
512#define PIN_ANALOG_START 26
513#define PIN_PWM_START 6
514#define PIN_I2S_BCK 26
515#define PIN_I2S_WS PIN_I2S_BCK+1
516#define PIN_I2S_DATA_IN 28
517#define PIN_I2S_DATA_OUT 28
519#define PIN_I2S_MUTE -1
520#define SOFT_MUTE_VALUE 0
524#define FIX_SYNC_SYNCHRONIZE
526#ifndef ANALOG_BUFFER_SIZE
527#define ANALOG_BUFFER_SIZE 1024
530#ifndef ANALOG_BUFFERS
531#define ANALOG_BUFFERS 50
537#elif defined(ARDUINO_ARCH_RP2040)
542#define USE_ANALOG_ARDUINO
543#define USE_TYPETRAITS
545#define USE_INT24_FROM_INT
547#define PIN_ANALOG_START 26
548#define PIN_PWM_START 6
549#define PIN_I2S_BCK 26
550#define PIN_I2S_WS PIN_I2S_BCK+1
551#define PIN_I2S_DATA_IN 28
552#define PIN_I2S_DATA_OUT 28
553#define PIN_I2S_MCK -1
555#define PIN_I2S_MUTE -1
556#define SOFT_MUTE_VALUE 0
557#define PIN_CS PIN_SPI0_SS
558#define USE_SERVER_ACCEPT true
564#ifndef ANALOG_BUFFER_SIZE
565#define ANALOG_BUFFER_SIZE 256
568#ifndef ANALOG_BUFFERS
569#define ANALOG_BUFFERS 100
573#define USE_SD_SUPPORTS_SPI
578#define VS1053_DREQ 10
579#define VS1053_CS_SD -1
580#define VS1053_RESET 11
581#define VS1053_DEFINED
585#if (defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_ARCH_RP2040)) && (LWIP_IPV4==1 || LWIP_IPV6==1) &&!defined(NO_WIFI)
588# define USE_WIFI_CLIENT_SECURE
589# define USE_URL_ARDUINO
590# define USE_AUDIO_SERVER
591using WiFiServerSecure = BearSSL::WiFiServerSecure;
600#define NO_INPLACE_INIT_SUPPORT
608#define PIN_PWM_START 6
611#undef PWM_BUFFER_SIZE
612#define PWM_BUFFER_SIZE 125
614#undef DEFAULT_BUFFER_SIZE
615#define DEFAULT_BUFFER_SIZE 125
618#undef USE_AUDIO_LOGGING
619#undef LOG_PRINTF_BUFFER_SIZE
620#define LOG_PRINTF_BUFFER_SIZE 60
626#define PIN_I2S_BCK 13
628#define PIN_I2S_DATA_IN 12
629#define PIN_I2S_DATA_OUT 11
630#define PIN_I2S_MUTE -1
636#if defined(ARDUINO_ARCH_STM32)
645#define USE_ANALOG_ARDUINO
646#define USE_INT24_FROM_INT
648#define PIN_ANALOG_START PA0
649#define PIN_PWM_START PA0
650#define PWM_DEFAULT_TIMER TIM2
651#define PWM_FREQ_TIMER_NO 3
654#define PIN_I2S_BCK -1
656#define PIN_I2S_DATA_IN -1
657#define PIN_I2S_DATA_OUT -1
658#define PIN_I2S_MUTE -1
659#define SOFT_MUTE_VALUE 0
663#define USE_URL_ARDUINO
664#define USE_AUDIO_SERVER
671#ifdef ARDUINO_ARCH_SAMD
672#define NO_INPLACE_INIT_SUPPORT
676#define USE_INT24_FROM_INT
678#define PIN_I2S_WS PIN_I2S_BCK+1
679#define PIN_I2S_DATA_IN 3
680#define PIN_I2S_DATA_OUT 3
681#define PIN_I2S_MUTE -1
682#define SOFT_MUTE_VALUE 0
687#ifdef ARDUINO_SAMD_MKRWIFI1010
689#define USE_URL_ARDUINO
690#define USE_AUDIO_SERVER
695#if defined(ARDUINO_GIGA)
697#include <Arduino_AdvancedAnalog.h>
699#define USE_INT24_FROM_INT
700#define USE_TYPETRAITS
702#define USE_STREAM_WRITE_OVERRIDE
703#define ANALOG_BUFFER_SIZE 1024
704#define ANALOG_BUFFERS 10
705#define USE_URL_ARDUINO
706#define USE_AUDIO_SERVER
708#define PIN_ANALOG_START A7
716#if defined(ARDUINO_ARCH_MBED_PORTENTA)
718#include <Arduino_AdvancedAnalog.h>
720#define USE_INT24_FROM_INT
721#define USE_TYPETRAITS
725#define USE_STREAM_WRITE_OVERRIDE
726#define ANALOG_BUFFER_SIZE 1024
727#define ANALOG_BUFFERS 10
728#define USE_URL_ARDUINO
729#define USE_AUDIO_SERVER
731#define PIN_ANALOG_START A0
732#define PIN_PWM_START D2
739#if defined(ARDUINO_ARCH_RENESAS) || defined(_RENESAS_RA_)
744#define USE_INT24_FROM_INT
746#define USE_TYPETRAITS
749#define PIN_PWM_START D2
750#define PIN_PWM_COUNT 12
752#define USE_ANALOG_ARDUINO
754#define PIN_ANALOG_START A0
755#define ANALOG_BUFFER_SIZE 512
756#define ANALOG_BUFFERS 5
757#define ANALOG_MAX_OUT_CHANNELS 1
758#define ANALOG_MAX_SAMPLE_RATE 16000
763#define VS1053_CS_SD 9
764#define VS1053_RESET 8
765#define VS1053_DEFINED
768#if defined(ARDUINO) && !defined(ARDUINO_MINIMA)
770# define USE_URL_ARDUINO
771# define USE_AUDIO_SERVER
779#ifdef ARDUINO_ARCH_ZEPHYR
781# define NO_INPLACE_INIT_SUPPORT
782# define USE_TYPETRAITS
784# define PIN_I2S_BCK 2
786# define PIN_I2S_DATA_IN 4
787# define PIN_I2S_DATA_OUT 4
789# define PIN_I2S_MUTE -1
790# define SOFT_MUTE_VALUE 0
791# define USE_NANO33BLE
792# define USE_ALT_PIN_SUPPORT
798#ifndef VS1053_DEFINED
800# define VS1053_DCS 16
801# define VS1053_DREQ 4
802# define VS1053_RESET 15
803# define VS1053_CS_SD -1
809#define VS1053_DEFAULT_VOLUME 0.7
816# define USE_STREAM_WRITE_OVERRIDE
819#ifndef ANALOG_MAX_SAMPLE_RATE
820# define ANALOG_MAX_SAMPLE_RATE 44100
823#ifndef PWM_MAX_SAMPLE_RATE
824# define PWM_MAX_SAMPLE_RATE 8000
828#ifndef URL_CLIENT_TIMEOUT
829# define URL_CLIENT_TIMEOUT 60000;
830# define URL_HANDSHAKE_TIMEOUT 120000
834# define USE_TASK false
837#ifndef USE_SERVER_ACCEPT
838# define USE_SERVER_ACCEPT false
842# define USE_ALLOCATOR false
845#ifndef USE_ESP32_LOGGER
846# define USE_ESP32_LOGGER false
850#ifndef USE_PRINT_FLUSH
851# define USE_PRINT_FLUSH true
854#ifndef ESP_IDF_VERSION_VAL
855# define ESP_IDF_VERSION_VAL(a, b , c) 0
859# define CHECK_MEMORY() checkMemory(true)
861# define CHECK_MEMORY()
864#pragma GCC diagnostic ignored "-Wunused-variable"
865#pragma GCC diagnostic ignored "-Wunused-function"
866#pragma GCC diagnostic ignored "-Wvla"
867#pragma GCC diagnostic ignored "-Wsign-compare"
868#pragma GCC diagnostic ignored "-Woverloaded-virtual"
869#pragma GCC diagnostic ignored "-Wdouble-promotion"
871#ifdef USE_NO_MEMACCESS
872#pragma GCC diagnostic ignored "-Wclass-memaccess"
875#ifdef USE_INITIALIZER_LIST
876#pragma GCC diagnostic ignored "-Wnarrowing"
882#include "AudioTools/CoreAudio/AudioBasic/Int24_3bytes_t.h"
883#include "AudioTools/CoreAudio/AudioBasic/Int24_4bytes_t.h"
884#include "AudioTools/CoreAudio/AudioBasic/FloatAudio.h"
887 #ifdef USE_3BYTE_INT24
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...