9 #define AUDIOTOOLS_VERSION "1.0.0"
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 # include "AudioTools/AudioLibs/Desktop/File.h"
19 # define USE_STREAM_READ_OVERRIDE
23 #elif defined(IS_DESKTOP_WITH_TIME_ONLY)
24 # include "AudioTools/AudioLibs/Desktop/Time.h"
29 #elif defined(IS_DESKTOP)
34 # define USE_URL_ARDUINO
35 # define USE_STREAM_WRITE_OVERRIDE
36 # define USE_STREAM_READ_OVERRIDE
37 # define USE_STREAM_READCHAR_OVERRIDE
42 typedef WiFiClient WiFiClientSecure;
43 #elif defined(ARDUINO)
47 #elif defined(ESP32_CMAKE)
49 # include "AudioTools/CoreAudio/AudioRuntime.h"
54 # define USE_STREAM_READ_OVERRIDE
60 #include "AudioTools/CoreAudio/AudioRuntime.h"
65 #if __has_include("AudioConfigLocal.h")
66 #include "AudioConfigLocal.h"
70 #ifndef AUDIO_INCLUDE_CORE
71 # define AUDIO_INCLUDE_CORE true
75 #ifndef PREFER_FIXEDPOINT
76 # define PREFER_FIXEDPOINT false
80 #ifndef USE_AUDIOTOOLS_NS
81 # define USE_AUDIOTOOLS_NS true
92 #ifndef USE_AUDIO_LOGGING
93 # define USE_AUDIO_LOGGING true
97 # define LOG_LEVEL AudioLogger::Warning
101 # define LOG_STREAM Serial
104 #ifndef LOG_PRINTF_BUFFER_SIZE
105 # define LOG_PRINTF_BUFFER_SIZE 303
109 # define LOG_METHOD __PRETTY_FUNCTION__
113 #ifndef USE_CHECK_MEMORY
114 # define USE_CHECK_MEMORY false
120 # define USE_OBSOLETE false
127 #ifndef DEFAULT_BUFFER_SIZE
128 # define DEFAULT_BUFFER_SIZE 1024
131 #ifndef DEFAULT_SAMPLE_RATE
132 # define DEFAULT_SAMPLE_RATE 44100
135 #ifndef DEFAULT_CHANNELS
136 # define DEFAULT_CHANNELS 2
139 #ifndef DEFAULT_BITS_PER_SAMPLE
140 # define DEFAULT_BITS_PER_SAMPLE 16
143 #ifndef I2S_DEFAULT_PORT
144 # define I2S_DEFAULT_PORT 0
147 #ifndef I2S_BUFFER_SIZE
148 # define I2S_BUFFER_SIZE 512
151 #ifndef I2S_BUFFER_COUNT
152 # define I2S_BUFFER_COUNT 6
155 #ifndef ANALOG_BUFFER_SIZE
156 # define ANALOG_BUFFER_SIZE 512
159 #ifndef ANALOG_BUFFER_COUNT
160 # define ANALOG_BUFFER_COUNT 6
163 #ifndef A2DP_BUFFER_SIZE
164 # define A2DP_BUFFER_SIZE 512
167 #ifndef A2DP_BUFFER_COUNT
168 # define A2DP_BUFFER_COUNT 30
171 #ifndef CODEC_DELAY_MS
172 # define CODEC_DELAY_MS 10
175 #ifndef COPY_DELAY_ON_NODATA
176 # define COPY_DELAY_ON_NODATA 10
179 #ifndef COPY_RETRY_LIMIT
180 # define COPY_RETRY_LIMIT 20
183 #ifndef MAX_SINGLE_CHARS
184 # define MAX_SINGLE_CHARS 8
189 # define HTTP_MAX_LEN 1024
192 #ifndef USE_RESAMPLE_BUFFER
193 # define USE_RESAMPLE_BUFFER true
199 #ifndef PWM_BUFFER_SIZE
200 # define PWM_BUFFER_SIZE 1024
203 #ifndef PWM_BUFFER_COUNT
204 # define PWM_BUFFER_COUNT 4
207 #ifndef PWM_AUDIO_FREQUENCY
208 # define PWM_AUDIO_FREQUENCY 30000
221 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C3)
224 # define USE_INT24_FROM_INT
228 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S2)
232 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S3)
239 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C6)
245 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32P4)
256 # if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
257 # define USE_SERVER_ACCEPT true
259 # if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
260 # define USE_CONCURRENCY
262 # define USE_PRINT_FLUSH true
264 # define USE_PRINT_FLUSH false
266 # define USE_SD_SUPPORTS_SPI
270 #if defined(ESP32) && !defined(ESP32X) && !defined(CONFIG_IDF_TARGET_ESP32H2)
271 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
272 # define USE_INT24_FROM_INT
282 # define USE_WIFI_CLIENT_SECURE
283 # define USE_URL_ARDUINO
284 # define USE_AUDIO_SERVER
288 #define USE_TYPETRAITS
289 #define USE_STREAM_WRITE_OVERRIDE
290 #define USE_STREAM_READ_OVERRIDE
291 #define USE_TOUCH_READ
292 #define USE_EXT_BUTTON_LOGIC
294 #define USE_ALLOCATOR true
296 #define USE_TASK false
298 #define PWM_FREQENCY 30000
299 #define PIN_PWM_START 12
300 #define PIN_I2S_BCK 14
301 #define PIN_I2S_WS 15
302 #define PIN_I2S_DATA_IN 32
303 #define PIN_I2S_DATA_OUT 22
304 #define PIN_I2S_MCK -1
305 #define I2S_USE_APLL true
307 #define PIN_I2S_MUTE -1
308 #define SOFT_MUTE_VALUE 0
312 #define I2S_AUTO_CLEAR true
315 #define URL_STREAM_CORE 0
316 #define URL_STREAM_PRIORITY 2
317 #define URL_STREAM_BUFFER_COUNT 10
318 #define STACK_SIZE 30000
319 #define URL_CLIENT_TIMEOUT 60000;
320 #define URL_HANDSHAKE_TIMEOUT 120000
328 #if ESP_IDF_VERSION_MAJOR < 4 && !defined(I2S_COMM_FORMAT_STAND_I2S)
329 # define I2S_COMM_FORMAT_STAND_I2S (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
330 # define I2S_COMM_FORMAT_STAND_MSB (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB)
331 # define I2S_COMM_FORMAT_STAND_PCM_LONG (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG)
332 # define I2S_COMM_FORMAT_STAND_PCM_SHORT (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT)
334 typedef int eps32_i2s_sample_rate_type;
336 typedef uint32_t eps32_i2s_sample_rate_type;
343 #if defined(ESP32) && defined(ESP32X)
344 #include "esp32-hal-log.h"
345 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
346 # define USE_INT24_FROM_INT
352 #define USE_URL_ARDUINO
354 #define USE_WIFI_CLIENT_SECURE
356 #define USE_AUDIO_SERVER
357 #define USE_TYPETRAITS
359 #define USE_STREAM_WRITE_OVERRIDE
360 #define USE_STREAM_READ_OVERRIDE
362 #define USE_ALLOCATOR true
365 #define PWM_FREQENCY 30000
366 #define PIN_PWM_START 1
367 #define PIN_I2S_MCK -1
368 #define PIN_I2S_BCK 6
370 #define PIN_I2S_DATA_OUT 8
371 #define PIN_I2S_DATA_IN 9
372 #define I2S_USE_APLL true
374 #define PIN_I2S_MUTE -1
375 #define SOFT_MUTE_VALUE 0
379 #define I2S_AUTO_CLEAR true
383 #define URL_STREAM_CORE 0
384 #define URL_STREAM_PRIORITY 2
385 #define URL_STREAM_BUFFER_COUNT 10
386 #define STACK_SIZE 30000
387 #define URL_CLIENT_TIMEOUT 60000;
388 #define URL_HANDSHAKE_TIMEOUT 120000
395 typedef uint32_t eps32_i2s_sample_rate_type;
401 #if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32H2)
402 #include "esp32-hal-log.h"
403 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
404 # define USE_INT24_FROM_INT
413 #define USE_TYPETRAITS
415 #define USE_STREAM_WRITE_OVERRIDE
416 #define USE_STREAM_READ_OVERRIDE
418 #define USE_ALLOCATOR true
421 #define PWM_FREQENCY 30000
422 #define PIN_PWM_START 1
423 #define PIN_I2S_MCK -1
424 #define PIN_I2S_BCK 6
426 #define PIN_I2S_DATA_OUT 8
427 #define PIN_I2S_DATA_IN 9
428 #define I2S_USE_APLL true
430 #define PIN_I2S_MUTE -1
431 #define SOFT_MUTE_VALUE 0
434 #define I2S_AUTO_CLEAR true
436 typedef uint32_t eps32_i2s_sample_rate_type;
443 # include <ESP8266WiFi.h>
446 #define USE_TYPETRAITS
449 #define USE_AUDIO_SERVER
450 #define USE_URL_ARDUINO
452 #define PIN_PWM_START 12
453 #define PIN_I2S_BCK -1
454 #define PIN_I2S_WS -1
455 #define PIN_I2S_DATA_IN -1
456 #define PIN_I2S_DATA_OUT -1
457 #define I2S_USE_APLL false
458 #define PIN_I2S_MUTE 23
459 #define SOFT_MUTE_VALUE 0
461 #define USE_SERVER_ACCEPT 1
463 #define URL_CLIENT_TIMEOUT 60000;
464 #define URL_HANDSHAKE_TIMEOUT 120000
465 #define USE_SD_SUPPORTS_SPI
470 #if (defined(ARDUINO_SEEED_XIAO_NRF52840_SENSE) || defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_MBED_NANO)) && !defined(ARDUINO_ARCH_ZEPHYR)
471 #define USE_NANO33BLE
472 #define USE_INT24_FROM_INT
475 #define USE_TYPETRAITS
478 #define USE_ALT_PIN_SUPPORT
480 #define PIN_PWM_START 5
481 #define PIN_I2S_BCK 2
483 #define PIN_I2S_DATA_IN 4
484 #define PIN_I2S_DATA_OUT 4
486 #define PIN_I2S_MUTE -1
487 #define SOFT_MUTE_VALUE 0
492 #if defined(ARDUINO_ARCH_MBED_RP2040)
497 #define USE_ANALOG_ARDUINO
498 #define USE_TYPETRAITS
500 #define USE_INT24_FROM_INT
502 #define PIN_ANALOG_START 26
503 #define PIN_PWM_START 6
504 #define PIN_I2S_BCK 26
505 #define PIN_I2S_WS PIN_I2S_BCK+1
506 #define PIN_I2S_DATA_IN 28
507 #define PIN_I2S_DATA_OUT 28
509 #define PIN_I2S_MUTE -1
510 #define SOFT_MUTE_VALUE 0
514 #define FIX_SYNC_SYNCHRONIZE
516 #ifndef ANALOG_BUFFER_SIZE
517 #define ANALOG_BUFFER_SIZE 1024
520 #ifndef ANALOG_BUFFERS
521 #define ANALOG_BUFFERS 50
527 #elif defined(ARDUINO_ARCH_RP2040)
532 #define USE_ANALOG_ARDUINO
533 #define USE_TYPETRAITS
535 #define USE_INT24_FROM_INT
537 #define PIN_ANALOG_START 26
538 #define PIN_PWM_START 6
539 #define PIN_I2S_BCK 26
540 #define PIN_I2S_WS PIN_I2S_BCK+1
541 #define PIN_I2S_DATA_IN 28
542 #define PIN_I2S_DATA_OUT 28
543 #define PIN_I2S_MCK -1
545 #define PIN_I2S_MUTE -1
546 #define SOFT_MUTE_VALUE 0
547 #define PIN_CS PIN_SPI0_SS
548 #define USE_SERVER_ACCEPT true
554 #ifndef ANALOG_BUFFER_SIZE
555 #define ANALOG_BUFFER_SIZE 256
558 #ifndef ANALOG_BUFFERS
559 #define ANALOG_BUFFERS 100
563 #define USE_SD_SUPPORTS_SPI
568 #define VS1053_DREQ 10
569 #define VS1053_CS_SD -1
570 #define VS1053_RESET 11
571 #define VS1053_DEFINED
575 #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)
578 # define USE_WIFI_CLIENT_SECURE
579 # define USE_URL_ARDUINO
580 # define USE_AUDIO_SERVER
581 using WiFiServerSecure = BearSSL::WiFiServerSecure;
590 #define NO_INPLACE_INIT_SUPPORT
598 #define PIN_PWM_START 6
601 #undef PWM_BUFFER_SIZE
602 #define PWM_BUFFER_SIZE 125
604 #undef DEFAULT_BUFFER_SIZE
605 #define DEFAULT_BUFFER_SIZE 125
609 #undef LOG_PRINTF_BUFFER_SIZE
610 #define LOG_PRINTF_BUFFER_SIZE 80
616 #define PIN_I2S_BCK 13
617 #define PIN_I2S_WS 10
618 #define PIN_I2S_DATA_IN 12
619 #define PIN_I2S_DATA_OUT 11
620 #define PIN_I2S_MUTE -1
626 #if defined(ARDUINO_ARCH_STM32)
635 #define USE_ANALOG_ARDUINO
636 #define USE_INT24_FROM_INT
638 #define PIN_ANALOG_START PA0
639 #define PIN_PWM_START PA0
640 #define PWM_DEFAULT_TIMER TIM2
641 #define PWM_FREQ_TIMER_NO 3
644 #define PIN_I2S_BCK -1
645 #define PIN_I2S_WS -1
646 #define PIN_I2S_DATA_IN -1
647 #define PIN_I2S_DATA_OUT -1
648 #define PIN_I2S_MUTE -1
649 #define SOFT_MUTE_VALUE 0
653 #define USE_URL_ARDUINO
654 #define USE_AUDIO_SERVER
661 #ifdef ARDUINO_ARCH_SAMD
662 #define NO_INPLACE_INIT_SUPPORT
663 #ifndef SEEED_XIAO_M0
666 #define USE_INT24_FROM_INT
667 #define PIN_I2S_BCK 1
668 #define PIN_I2S_WS PIN_I2S_BCK+1
669 #define PIN_I2S_DATA_IN 3
670 #define PIN_I2S_DATA_OUT 3
671 #define PIN_I2S_MUTE -1
672 #define SOFT_MUTE_VALUE 0
677 #ifdef ARDUINO_SAMD_MKRWIFI1010
678 #include <WiFiNINA.h>
679 #define USE_URL_ARDUINO
680 #define USE_AUDIO_SERVER
685 #if defined(ARDUINO_GIGA)
687 #include <Arduino_AdvancedAnalog.h>
689 #define USE_INT24_FROM_INT
690 #define USE_TYPETRAITS
692 #define USE_STREAM_WRITE_OVERRIDE
693 #define ANALOG_BUFFER_SIZE 1024
694 #define ANALOG_BUFFERS 10
695 #define USE_URL_ARDUINO
696 #define USE_AUDIO_SERVER
698 #define PIN_ANALOG_START A7
699 #define PIN_DAC_1 A12
700 #define PIN_DAC_2 A13
706 #if defined(ARDUINO_ARCH_MBED_PORTENTA)
708 #include <Arduino_AdvancedAnalog.h>
710 #define USE_INT24_FROM_INT
711 #define USE_TYPETRAITS
715 #define USE_STREAM_WRITE_OVERRIDE
716 #define ANALOG_BUFFER_SIZE 1024
717 #define ANALOG_BUFFERS 10
718 #define USE_URL_ARDUINO
719 #define USE_AUDIO_SERVER
721 #define PIN_ANALOG_START A0
722 #define PIN_PWM_START D2
729 #if defined(ARDUINO_ARCH_RENESAS) || defined(_RENESAS_RA_)
734 #define USE_INT24_FROM_INT
736 #define USE_TYPETRAITS
739 #define PIN_PWM_START D2
740 #define PIN_PWM_COUNT 12
742 #define USE_ANALOG_ARDUINO
744 #define PIN_ANALOG_START A0
745 #define ANALOG_BUFFER_SIZE 512
746 #define ANALOG_BUFFERS 5
747 #define ANALOG_MAX_OUT_CHANNELS 1
748 #define ANALOG_MAX_SAMPLE_RATE 16000
752 #define VS1053_DREQ 2
753 #define VS1053_CS_SD 9
754 #define VS1053_RESET 8
755 #define VS1053_DEFINED
758 #if defined(ARDUINO) && !defined(ARDUINO_MINIMA)
760 # define USE_URL_ARDUINO
761 # define USE_AUDIO_SERVER
769 #ifdef ARDUINO_ARCH_ZEPHYR
771 # define NO_INPLACE_INIT_SUPPORT
772 # define USE_TYPETRAITS
774 # define PIN_I2S_BCK 2
775 # define PIN_I2S_WS 3
776 # define PIN_I2S_DATA_IN 4
777 # define PIN_I2S_DATA_OUT 4
779 # define PIN_I2S_MUTE -1
780 # define SOFT_MUTE_VALUE 0
781 # define USE_NANO33BLE
782 # define USE_ALT_PIN_SUPPORT
788 #ifndef VS1053_DEFINED
790 # define VS1053_DCS 16
791 # define VS1053_DREQ 4
792 # define VS1053_RESET 15
793 # define VS1053_CS_SD -1
799 #define VS1053_DEFAULT_VOLUME 0.7
806 # define USE_STREAM_WRITE_OVERRIDE
809 #ifndef ANALOG_MAX_SAMPLE_RATE
810 # define ANALOG_MAX_SAMPLE_RATE 44100
813 #ifndef URL_CLIENT_TIMEOUT
814 # define URL_CLIENT_TIMEOUT 60000;
815 # define URL_HANDSHAKE_TIMEOUT 120000
819 # define USE_TASK false
822 #ifndef USE_SERVER_ACCEPT
823 # define USE_SERVER_ACCEPT false
826 #ifndef USE_ALLOCATOR
827 # define USE_ALLOCATOR false
832 #ifndef USE_PRINT_FLUSH
833 # define USE_PRINT_FLUSH true
836 #ifndef ESP_IDF_VERSION_VAL
837 # define ESP_IDF_VERSION_VAL(a, b , c) 0
841 # define CHECK_MEMORY() checkMemory(true)
843 # define CHECK_MEMORY()
846 #pragma GCC diagnostic ignored "-Wunused-variable"
847 #pragma GCC diagnostic ignored "-Wunused-function"
848 #pragma GCC diagnostic ignored "-Wvla"
849 #pragma GCC diagnostic ignored "-Wsign-compare"
850 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
851 #pragma GCC diagnostic ignored "-Wdouble-promotion"
853 #ifdef USE_NO_MEMACCESS
854 #pragma GCC diagnostic ignored "-Wclass-memaccess"
857 #ifdef USE_INITIALIZER_LIST
858 #pragma GCC diagnostic ignored "-Wnarrowing"
864 #include "AudioTools/CoreAudio/AudioBasic/Int24_3bytes_t.h"
865 #include "AudioTools/CoreAudio/AudioBasic/Int24_4bytes_t.h"
866 #include "AudioTools/CoreAudio/AudioBasic/FloatAudio.h"
869 #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...