From 7208a424b05fea766cf2cb22f5466a4639d6f2ca Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Wed, 25 Oct 2023 11:54:48 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20doxygen=20from=20@=20pschatzma?= =?UTF-8?q?nn/arduino-audio-tools@56f97c5808a54d784b905495176b93f5ee051f76?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _audio_config_8h_source.html | 573 ++++++++++++++++++----------------- _i2_s_r_p2040_8h_source.html | 544 ++++++++++++++++----------------- 2 files changed, 560 insertions(+), 557 deletions(-) diff --git a/_audio_config_8h_source.html b/_audio_config_8h_source.html index a46eeb4057..7c015c3e26 100644 --- a/_audio_config_8h_source.html +++ b/_audio_config_8h_source.html @@ -470,296 +470,297 @@
427 #define PIN_I2S_WS PIN_I2S_BCK+1
428 #define PIN_I2S_DATA_IN 28
429 #define PIN_I2S_DATA_OUT 28
-
430 // Default Setting: The mute pin can be switched actovated by setting it to a gpio (e.g 4). Or you could drive the LED by assigning LED_BUILTIN
-
431 #define PIN_I2S_MUTE -1
-
432 #define SOFT_MUTE_VALUE 0
-
433 #define PIN_CS PIN_SPI0_SS
-
434 
-
435 // fix missing __sync_synchronize symbol
-
436 #define FIX_SYNC_SYNCHRONIZE
-
437 #define IRAM_ATTR
-
438 
-
439 #ifndef ANALOG_BUFFER_SIZE
-
440 #define ANALOG_BUFFER_SIZE 256
-
441 #endif
-
442 
-
443 #ifndef ANALOG_BUFFERS
-
444 #define ANALOG_BUFFERS 100
-
445 #endif
-
446 
-
447 //#define USE_ESP8266_AUDIO
-
448 #endif
-
449 
-
450 // The Pico W has WIFI support
-
451 #if defined(ARDUINO_ARCH_RP2040) && LWIP_IPV4==1
-
452 # include <WiFi.h>
-
453 # define USE_URL_ARDUINO
-
454 # define USE_WIFI
-
455 # define USE_WIFI_CLIENT_SECURE
-
456 # define USE_AUDIO_SERVER
-
457 using WiFiServerSecure = BearSSL::WiFiServerSecure;
-
458 #endif
-
459 
+
430 #define PIN_I2S_MCK -1
+
431 // Default Setting: The mute pin can be switched actovated by setting it to a gpio (e.g 4). Or you could drive the LED by assigning LED_BUILTIN
+
432 #define PIN_I2S_MUTE -1
+
433 #define SOFT_MUTE_VALUE 0
+
434 #define PIN_CS PIN_SPI0_SS
+
435 
+
436 // fix missing __sync_synchronize symbol
+
437 #define FIX_SYNC_SYNCHRONIZE
+
438 #define IRAM_ATTR
+
439 
+
440 #ifndef ANALOG_BUFFER_SIZE
+
441 #define ANALOG_BUFFER_SIZE 256
+
442 #endif
+
443 
+
444 #ifndef ANALOG_BUFFERS
+
445 #define ANALOG_BUFFERS 100
+
446 #endif
+
447 
+
448 //#define USE_ESP8266_AUDIO
+
449 #endif
+
450 
+
451 // The Pico W has WIFI support
+
452 #if defined(ARDUINO_ARCH_RP2040) && LWIP_IPV4==1
+
453 # include <WiFi.h>
+
454 # define USE_URL_ARDUINO
+
455 # define USE_WIFI
+
456 # define USE_WIFI_CLIENT_SECURE
+
457 # define USE_AUDIO_SERVER
+
458 using WiFiServerSecure = BearSSL::WiFiServerSecure;
+
459 #endif
460 
-
461 //----- AVR -----------
-
462 #ifdef __AVR__
-
463 #define USE_SD_NO_NS
-
464 #define USE_PWM
-
465 #define USE_TIMER
-
466 // Uncomment to activate network
-
467 //#include <Ethernet.h>
-
468 //#define USE_URL_ARDUINO
-
469 #ifndef assert
-
470 #define assert(T)
-
471 #endif
-
472 
-
473 #define PIN_PWM_START 6
-
474 #define PIN_CS SS
-
475 
-
476 #undef PWM_BUFFER_SIZE
-
477 #define PWM_BUFFER_SIZE 125
-
478 
-
479 #undef DEFAULT_BUFFER_SIZE
-
480 #define DEFAULT_BUFFER_SIZE 125
-
481 
-
482 // #undef USE_AUDIO_LOGGING
-
483 // logging is using too much memory
-
484 #undef LOG_PRINTF_BUFFER_SIZE
-
485 #define LOG_PRINTF_BUFFER_SIZE 80
-
486 
-
487 #define NO_TRACED
-
488 #define NO_TRACEI
-
489 
-
490 // we use spi to emulate i2s
-
491 #define PIN_I2S_BCK 13
-
492 #define PIN_I2S_WS 10
-
493 #define PIN_I2S_DATA_IN 12
-
494 #define PIN_I2S_DATA_OUT 11
-
495 #define PIN_I2S_MUTE -1
-
496 
-
497 #endif
-
498 
+
461 
+
462 //----- AVR -----------
+
463 #ifdef __AVR__
+
464 #define USE_SD_NO_NS
+
465 #define USE_PWM
+
466 #define USE_TIMER
+
467 // Uncomment to activate network
+
468 //#include <Ethernet.h>
+
469 //#define USE_URL_ARDUINO
+
470 #ifndef assert
+
471 #define assert(T)
+
472 #endif
+
473 
+
474 #define PIN_PWM_START 6
+
475 #define PIN_CS SS
+
476 
+
477 #undef PWM_BUFFER_SIZE
+
478 #define PWM_BUFFER_SIZE 125
+
479 
+
480 #undef DEFAULT_BUFFER_SIZE
+
481 #define DEFAULT_BUFFER_SIZE 125
+
482 
+
483 // #undef USE_AUDIO_LOGGING
+
484 // logging is using too much memory
+
485 #undef LOG_PRINTF_BUFFER_SIZE
+
486 #define LOG_PRINTF_BUFFER_SIZE 80
+
487 
+
488 #define NO_TRACED
+
489 #define NO_TRACEI
+
490 
+
491 // we use spi to emulate i2s
+
492 #define PIN_I2S_BCK 13
+
493 #define PIN_I2S_WS 10
+
494 #define PIN_I2S_DATA_IN 12
+
495 #define PIN_I2S_DATA_OUT 11
+
496 #define PIN_I2S_MUTE -1
+
497 
+
498 #endif
499 
-
500 //---- STM32 ------------
-
501 #if defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)
-
502 #define STM32
-
503 #endif
-
504 
-
505 #ifdef STM32
-
506 #define USE_I2S
-
507 #define USE_PWM
-
508 #define USE_TIMER
-
509 #define USE_ANALOG_ARDUINO
-
510 #define USE_INT24_FROM_INT
-
511 
-
512 #define ANALOG_BUFFER_SIZE 1024
-
513 #define ANALOG_BUFFERS 20
-
514 #define PIN_ANALOG_START PA0
-
515 #define PIN_PWM_START PA0
-
516 #define PWM_DEFAULT_TIMER TIM2
-
517 #define PWM_FREQ_TIMER_NO 3
-
518 
-
519 #define PIN_I2S_BCK -1
-
520 #define PIN_I2S_WS -1
-
521 #define PIN_I2S_DATA_IN -1
-
522 #define PIN_I2S_DATA_OUT -1
-
523 #define PIN_I2S_MUTE -1
-
524 #define SOFT_MUTE_VALUE 0
-
525 #define PIN_CS 10
-
526 #endif
-
527 
-
528 //---- SAMD ------------
-
529 
-
530 #ifdef ARDUINO_ARCH_SAMD
-
531 #define USE_I2S
-
532 #define USE_INT24_FROM_INT
-
533 #define PIN_I2S_BCK 1
-
534 #define PIN_I2S_WS PIN_I2S_BCK+1
-
535 #define PIN_I2S_DATA_IN 3
-
536 #define PIN_I2S_DATA_OUT 3
-
537 #define PIN_I2S_MUTE -1
-
538 #define SOFT_MUTE_VALUE 0
-
539 #endif
-
540 
-
541 #ifdef ARDUINO_SAMD_MKRWIFI1010
-
542 #include <WiFiNINA.h>
-
543 #define USE_URL_ARDUINO
-
544 #define USE_AUDIO_SERVER
-
545 #endif
-
546 
-
547 //---- GIGA ------------
-
548 // DRAFT Support - Not tested !
-
549 #if defined(ARDUINO_GIGA)
-
550 #include <WiFi.h>
-
551 #include <Arduino_AdvancedAnalog.h>
-
552 #define IS_MBED
-
553 #define USE_INT24_FROM_INT
-
554 #define USE_TYPETRAITS
-
555 #define USE_EFFECTS_SUITE
-
556 #define USE_ANALOG
-
557 #define USE_STREAM_WRITE_OVERRIDE
-
558 #define ANALOG_BUFFER_SIZE 1024
-
559 #define ANALOG_BUFFERS 10
-
560 #define USE_URL_ARDUINO
-
561 #define USE_AUDIO_SERVER
-
562 
-
563 #define PIN_ANALOG_START A7
-
564 #define PIN_DAC_1 A12
-
565 #define PIN_DAC_2 A13
-
566 
-
567 #endif
-
568 
-
569 // //---- Portenta ------------
-
570 // // DRAFT: not tested
-
571 #if defined(ARDUINO_ARCH_MBED_PORTENTA)
-
572 #include <WiFi.h>
-
573 #include <Arduino_AdvancedAnalog.h>
-
574 #define IS_MBED
-
575 #define USE_INT24_FROM_INT
-
576 #define USE_TYPETRAITS
-
577 #define USE_EFFECTS_SUITE
-
578 #define USE_ANALOG
-
579 #define USE_TIMER
-
580 #define USE_PWM
-
581 #define USE_STREAM_WRITE_OVERRIDE
-
582 #define ANALOG_BUFFER_SIZE 1024
-
583 #define ANALOG_BUFFERS 10
-
584 #define USE_URL_ARDUINO
-
585 #define USE_AUDIO_SERVER
-
586 
-
587 #define PIN_ANALOG_START A0
-
588 #define PIN_PWM_START D2
-
589 #define PIN_DAC_1 D0
-
590 #define PIN_DAC_2 D1
-
591 #endif
-
592 
-
593 //------ RENESAS ----------
-
594 // Arduino UNO R4
-
595 #if defined(ARDUINO_ARCH_RENESAS) || defined(_RENESAS_RA_)
-
596 // no trace to save on memory
-
597 #define NO_TRACE
-
598 //#define LOG_NO_MSG // around 4K less
-
599 
-
600 #define USE_INT24_FROM_INT
-
601 #define IS_RENESAS 1
-
602 #define USE_TYPETRAITS
-
603 #define USE_EFFECTS_SUITE
-
604 #define USE_TIMER
-
605 #define USE_PWM
-
606 #define PIN_PWM_START D2
-
607 #define PIN_PWM_COUNT 12
-
608 #define USE_ANALOG
-
609 #define USE_ANALOG_ARDUINO
-
610 #define USE_SD_NO_NS
-
611 #define PIN_ANALOG_START A0
-
612 #define ANALOG_BUFFER_SIZE 512
-
613 #define ANALOG_BUFFERS 5
-
614 #define ANALOG_MAX_OUT_CHANNELS 1
-
615 #define ANALOG_MAX_SAMPLE_RATE 16000
-
616 // default pins for UNO VS1053 shield
-
617 #define VS1053_CS 6
-
618 #define VS1053_DCS 7
-
619 #define VS1053_DREQ 2
-
620 #define VS1053_CS_SD 9
-
621 #define VS1053_RESET 8
-
622 #define VS1053_DEFINED
-
623 #define PIN_CS 9
-
624 
-
625 #if defined(ARDUINO) && !defined(ARDUINO_MINIMA)
-
626 # define USE_WIFI
-
627 # define USE_URL_ARDUINO
-
628 # define USE_AUDIO_SERVER
-
629 # include "WiFiS3.h"
-
630 #endif
-
631 
-
632 #endif
-
633 
-
634 //------ VS1053 ----------
-
635 
-
636 // Default Pins for VS1053
-
637 #ifndef VS1053_DEFINED
-
638 # define VS1053_CS 5
-
639 # define VS1053_DCS 16
-
640 # define VS1053_DREQ 4
-
641 # define VS1053_RESET 15
-
642 # define VS1053_CS_SD -1
-
643 #endif
-
644 
-
645 // use 0 for https://github.com/baldram/ESP_VS1053_Library
-
646 // use 1 for https://github.com/pschatzmann/arduino-vs1053
-
647 #define VS1053_EXT 1
-
648 #define VS1053_DEFAULT_VOLUME 0.7
-
649 
+
500 
+
501 //---- STM32 ------------
+
502 #if defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)
+
503 #define STM32
+
504 #endif
+
505 
+
506 #ifdef STM32
+
507 #define USE_I2S
+
508 #define USE_PWM
+
509 #define USE_TIMER
+
510 #define USE_ANALOG_ARDUINO
+
511 #define USE_INT24_FROM_INT
+
512 
+
513 #define ANALOG_BUFFER_SIZE 1024
+
514 #define ANALOG_BUFFERS 20
+
515 #define PIN_ANALOG_START PA0
+
516 #define PIN_PWM_START PA0
+
517 #define PWM_DEFAULT_TIMER TIM2
+
518 #define PWM_FREQ_TIMER_NO 3
+
519 
+
520 #define PIN_I2S_BCK -1
+
521 #define PIN_I2S_WS -1
+
522 #define PIN_I2S_DATA_IN -1
+
523 #define PIN_I2S_DATA_OUT -1
+
524 #define PIN_I2S_MUTE -1
+
525 #define SOFT_MUTE_VALUE 0
+
526 #define PIN_CS 10
+
527 #endif
+
528 
+
529 //---- SAMD ------------
+
530 
+
531 #ifdef ARDUINO_ARCH_SAMD
+
532 #define USE_I2S
+
533 #define USE_INT24_FROM_INT
+
534 #define PIN_I2S_BCK 1
+
535 #define PIN_I2S_WS PIN_I2S_BCK+1
+
536 #define PIN_I2S_DATA_IN 3
+
537 #define PIN_I2S_DATA_OUT 3
+
538 #define PIN_I2S_MUTE -1
+
539 #define SOFT_MUTE_VALUE 0
+
540 #endif
+
541 
+
542 #ifdef ARDUINO_SAMD_MKRWIFI1010
+
543 #include <WiFiNINA.h>
+
544 #define USE_URL_ARDUINO
+
545 #define USE_AUDIO_SERVER
+
546 #endif
+
547 
+
548 //---- GIGA ------------
+
549 // DRAFT Support - Not tested !
+
550 #if defined(ARDUINO_GIGA)
+
551 #include <WiFi.h>
+
552 #include <Arduino_AdvancedAnalog.h>
+
553 #define IS_MBED
+
554 #define USE_INT24_FROM_INT
+
555 #define USE_TYPETRAITS
+
556 #define USE_EFFECTS_SUITE
+
557 #define USE_ANALOG
+
558 #define USE_STREAM_WRITE_OVERRIDE
+
559 #define ANALOG_BUFFER_SIZE 1024
+
560 #define ANALOG_BUFFERS 10
+
561 #define USE_URL_ARDUINO
+
562 #define USE_AUDIO_SERVER
+
563 
+
564 #define PIN_ANALOG_START A7
+
565 #define PIN_DAC_1 A12
+
566 #define PIN_DAC_2 A13
+
567 
+
568 #endif
+
569 
+
570 // //---- Portenta ------------
+
571 // // DRAFT: not tested
+
572 #if defined(ARDUINO_ARCH_MBED_PORTENTA)
+
573 #include <WiFi.h>
+
574 #include <Arduino_AdvancedAnalog.h>
+
575 #define IS_MBED
+
576 #define USE_INT24_FROM_INT
+
577 #define USE_TYPETRAITS
+
578 #define USE_EFFECTS_SUITE
+
579 #define USE_ANALOG
+
580 #define USE_TIMER
+
581 #define USE_PWM
+
582 #define USE_STREAM_WRITE_OVERRIDE
+
583 #define ANALOG_BUFFER_SIZE 1024
+
584 #define ANALOG_BUFFERS 10
+
585 #define USE_URL_ARDUINO
+
586 #define USE_AUDIO_SERVER
+
587 
+
588 #define PIN_ANALOG_START A0
+
589 #define PIN_PWM_START D2
+
590 #define PIN_DAC_1 D0
+
591 #define PIN_DAC_2 D1
+
592 #endif
+
593 
+
594 //------ RENESAS ----------
+
595 // Arduino UNO R4
+
596 #if defined(ARDUINO_ARCH_RENESAS) || defined(_RENESAS_RA_)
+
597 // no trace to save on memory
+
598 #define NO_TRACE
+
599 //#define LOG_NO_MSG // around 4K less
+
600 
+
601 #define USE_INT24_FROM_INT
+
602 #define IS_RENESAS 1
+
603 #define USE_TYPETRAITS
+
604 #define USE_EFFECTS_SUITE
+
605 #define USE_TIMER
+
606 #define USE_PWM
+
607 #define PIN_PWM_START D2
+
608 #define PIN_PWM_COUNT 12
+
609 #define USE_ANALOG
+
610 #define USE_ANALOG_ARDUINO
+
611 #define USE_SD_NO_NS
+
612 #define PIN_ANALOG_START A0
+
613 #define ANALOG_BUFFER_SIZE 512
+
614 #define ANALOG_BUFFERS 5
+
615 #define ANALOG_MAX_OUT_CHANNELS 1
+
616 #define ANALOG_MAX_SAMPLE_RATE 16000
+
617 // default pins for UNO VS1053 shield
+
618 #define VS1053_CS 6
+
619 #define VS1053_DCS 7
+
620 #define VS1053_DREQ 2
+
621 #define VS1053_CS_SD 9
+
622 #define VS1053_RESET 8
+
623 #define VS1053_DEFINED
+
624 #define PIN_CS 9
+
625 
+
626 #if defined(ARDUINO) && !defined(ARDUINO_MINIMA)
+
627 # define USE_WIFI
+
628 # define USE_URL_ARDUINO
+
629 # define USE_AUDIO_SERVER
+
630 # include "WiFiS3.h"
+
631 #endif
+
632 
+
633 #endif
+
634 
+
635 //------ VS1053 ----------
+
636 
+
637 // Default Pins for VS1053
+
638 #ifndef VS1053_DEFINED
+
639 # define VS1053_CS 5
+
640 # define VS1053_DCS 16
+
641 # define VS1053_DREQ 4
+
642 # define VS1053_RESET 15
+
643 # define VS1053_CS_SD -1
+
644 #endif
+
645 
+
646 // use 0 for https://github.com/baldram/ESP_VS1053_Library
+
647 // use 1 for https://github.com/pschatzmann/arduino-vs1053
+
648 #define VS1053_EXT 1
+
649 #define VS1053_DEFAULT_VOLUME 0.7
650 
651 
-
652 //----------------
-
653 
-
654 // Full Arduino functionality using emulator
-
655 #ifdef IS_DESKTOP
-
656 # include <Client.h>
-
657 # include <WiFi.h>
-
658 # define USE_WIFI
-
659 # define USE_URL_ARDUINO
-
660 # define USE_STREAM_WRITE_OVERRIDE
-
661 # define USE_STREAM_READ_OVERRIDE
-
662 # define USE_STREAM_READCHAR_OVERRIDE
-
663 //# define USE_3BYTE_INT24
-
664 typedef WiFiClient WiFiClientSecure;
-
665 #endif
-
666 
-
667 // Minimum desktop functionality w/o Arduino emulator
-
668 #ifdef IS_MIN_DESKTOP
-
669 # include "AudioLibs/Desktop/NoArduino.h"
-
670 # include "AudioLibs/Desktop/Millis.h"
-
671 # include "AudioLibs/Desktop/Main.h"
-
672 # include "AudioLibs/Desktop/File.h"
-
673 # define USE_STREAM_READ_OVERRIDE
-
674 #endif
-
675 
-
676 #ifndef ARDUINO
-
677 # define USE_STREAM_WRITE_OVERRIDE
-
678 #endif
-
679 
-
680 #ifdef IS_JUPYTER
-
681 # define USE_STREAM_READ_OVERRIDE
-
682 #endif
-
683 
-
684 #ifdef AUDIOKIT_USE_IDF
-
685 # define USE_INT24_FROM_INT
-
686 #endif
-
687 
-
688 #if USE_INLINE_VARS && !defined(INGNORE_INLINE_VARS)
-
689 # define INLINE_VAR inline
-
690 #else
-
691 # define INLINE_VAR static
-
692 #endif
-
693 
-
694 #ifndef ANALOG_MAX_SAMPLE_RATE
-
695 # define ANALOG_MAX_SAMPLE_RATE 44000
-
696 #endif
-
697 
-
698 // select int24 implementation
-
699 #include "AudioBasic/Int24_3bytes_t.h"
-
700 #include "AudioBasic/Int24_4bytes_t.h"
-
701 #ifdef USE_3BYTE_INT24
-
702 using int24_t = audio_tools::int24_3bytes_t;
-
703 #else
-
704 using int24_t = audio_tools::int24_4bytes_t;
-
705 #endif
-
706 
-
707 #ifndef ESP32
-
708 #define ESP_IDF_VERSION_VAL(a, b , c) 0
-
709 #endif
-
710 
-
711 #pragma GCC diagnostic ignored "-Wunused-variable"
-
712 #pragma GCC diagnostic ignored "-Wunused-function"
-
713 #pragma GCC diagnostic ignored "-Wvla"
-
714 #pragma GCC diagnostic ignored "-Wsign-compare"
-
715 #ifdef USE_INITIALIZER_LIST
-
716 #pragma GCC diagnostic ignored "-Wnarrowing"
-
717 #endif
-
718 
-
719 #undef rewind
+
652 
+
653 //----------------
+
654 
+
655 // Full Arduino functionality using emulator
+
656 #ifdef IS_DESKTOP
+
657 # include <Client.h>
+
658 # include <WiFi.h>
+
659 # define USE_WIFI
+
660 # define USE_URL_ARDUINO
+
661 # define USE_STREAM_WRITE_OVERRIDE
+
662 # define USE_STREAM_READ_OVERRIDE
+
663 # define USE_STREAM_READCHAR_OVERRIDE
+
664 //# define USE_3BYTE_INT24
+
665 typedef WiFiClient WiFiClientSecure;
+
666 #endif
+
667 
+
668 // Minimum desktop functionality w/o Arduino emulator
+
669 #ifdef IS_MIN_DESKTOP
+
670 # include "AudioLibs/Desktop/NoArduino.h"
+
671 # include "AudioLibs/Desktop/Millis.h"
+
672 # include "AudioLibs/Desktop/Main.h"
+
673 # include "AudioLibs/Desktop/File.h"
+
674 # define USE_STREAM_READ_OVERRIDE
+
675 #endif
+
676 
+
677 #ifndef ARDUINO
+
678 # define USE_STREAM_WRITE_OVERRIDE
+
679 #endif
+
680 
+
681 #ifdef IS_JUPYTER
+
682 # define USE_STREAM_READ_OVERRIDE
+
683 #endif
+
684 
+
685 #ifdef AUDIOKIT_USE_IDF
+
686 # define USE_INT24_FROM_INT
+
687 #endif
+
688 
+
689 #if USE_INLINE_VARS && !defined(INGNORE_INLINE_VARS)
+
690 # define INLINE_VAR inline
+
691 #else
+
692 # define INLINE_VAR static
+
693 #endif
+
694 
+
695 #ifndef ANALOG_MAX_SAMPLE_RATE
+
696 # define ANALOG_MAX_SAMPLE_RATE 44000
+
697 #endif
+
698 
+
699 // select int24 implementation
+
700 #include "AudioBasic/Int24_3bytes_t.h"
+
701 #include "AudioBasic/Int24_4bytes_t.h"
+
702 #ifdef USE_3BYTE_INT24
+
703 using int24_t = audio_tools::int24_3bytes_t;
+
704 #else
+
705 using int24_t = audio_tools::int24_4bytes_t;
+
706 #endif
+
707 
+
708 #ifndef ESP32
+
709 #define ESP_IDF_VERSION_VAL(a, b , c) 0
+
710 #endif
+
711 
+
712 #pragma GCC diagnostic ignored "-Wunused-variable"
+
713 #pragma GCC diagnostic ignored "-Wunused-function"
+
714 #pragma GCC diagnostic ignored "-Wvla"
+
715 #pragma GCC diagnostic ignored "-Wsign-compare"
+
716 #ifdef USE_INITIALIZER_LIST
+
717 #pragma GCC diagnostic ignored "-Wnarrowing"
+
718 #endif
+
719 
+
720 #undef rewind
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
24bit integer which is used for I2S sound processing. The values are really using 3 bytes....
Definition: Int24_3bytes_t.h:16
24bit integer which is used for I2S sound processing. The values are represented as int32_t,...
Definition: Int24_4bytes_t.h:16
diff --git a/_i2_s_r_p2040_8h_source.html b/_i2_s_r_p2040_8h_source.html index f9a302b14b..ff2d473318 100644 --- a/_i2_s_r_p2040_8h_source.html +++ b/_i2_s_r_p2040_8h_source.html @@ -129,281 +129,283 @@
68  LOGE("Could not set data pin: %d", cfg.pin_data);
69  return false;
70  }
-
71  if (!i2s.setMCLK(cfg.pin_mck)){
-
72  LOGE("Could not set data pin: %d", cfg.pin_mck);
-
73  return false;
-
74  }
-
75 
-
76  if (cfg.bits_per_sample==8 || !i2s.setBitsPerSample(cfg.bits_per_sample)){
-
77  LOGE("Could not set bits per sample: %d", cfg.bits_per_sample);
-
78  return false;
-
79  }
-
80 
-
81  if (!i2s.setBuffers(cfg.buffer_count, cfg.buffer_size)){
-
82  LOGE("Could not set buffers: Count: '%d', size: '%d'", cfg.buffer_count, cfg.buffer_size);
-
83  return false;
-
84  }
-
85 
-
86  // setup format
-
87  if(cfg.i2s_format == I2S_STD_FORMAT || cfg.i2s_format == I2S_PHILIPS_FORMAT){
-
88  // default setting: do nothing
-
89  } else if(cfg.i2s_format == I2S_LEFT_JUSTIFIED_FORMAT || cfg.i2s_format==I2S_LSB_FORMAT){
-
90  if(!i2s.setLSBJFormat()){
-
91  LOGE("Could not set LSB Format")
-
92  return false;
-
93  }
-
94  } else {
-
95  LOGE("Unsupported I2S format");
-
96  return false;
-
97  }
-
98 
-
99  if (cfg.channels < 1 || cfg.channels > 2 ){
-
100  LOGE("Unsupported channels: '%d'", cfg.channels);
-
101  return false;
-
102  }
-
103 
-
104  if (!i2s.begin(cfg.sample_rate)){
-
105  LOGE("Could not start I2S");
-
106  return false;
-
107  }
-
108  return true;
-
109  }
-
110 
-
112  void end() {
-
113  flush();
-
114  i2s.end();
-
115  }
-
116 
-
118  I2SConfigStd config() {
-
119  return cfg;
-
120  }
-
121 
-
123  size_t writeBytes(const void *src, size_t size_bytes) {
-
124  LOGD("writeBytes(%d)", size_bytes);
-
125  size_t result = 0;
-
126 
-
127  if (cfg.channels==1){
-
128  result = writeExpandChannel(src, size_bytes);
-
129  } else if (cfg.channels==2){
-
130  const uint8_t *p = (const uint8_t*) src;
-
131  while(size_bytes >= sizeof(int32_t)){
-
132  bool justWritten = i2s.write(*(int32_t*)p,true); //I2S::write(int32,bool) actually only returns 0 or 1
-
133  if(justWritten){
-
134  size_bytes -= sizeof(int32_t);
-
135  p += sizeof(int32_t);
-
136  result += sizeof(int32_t);
-
137  } else return result;
-
138  }
-
139  }
-
140  return result;
-
141  }
-
142 
-
143  size_t readBytes(void *dest, size_t size_bytes) {
-
144  TRACED();
-
145  switch(cfg.channels){
-
146  case 1:
-
147  return read1Channel(dest, size_bytes);
-
148  case 2:
-
149  return read2Channels(dest, size_bytes);
-
150  }
-
151  return 0;
-
152  }
-
153 
-
154  int availableForWrite() {
-
155  if (cfg.channels == 1){
-
156  return cfg.buffer_size;
-
157  } else {
-
158  return i2s.availableForWrite();
-
159  }
-
160  }
-
161 
-
162  int available() {
-
163  return min(i2s.available(), cfg.buffer_size);
-
164  }
-
165 
-
166  void flush() {
-
167  i2s.flush();
-
168  }
-
169 
-
170  protected:
-
171  I2SConfigStd cfg;
-
172  I2S i2s;
-
173  bool has_input[2];
-
174 
-
176  //returns amount of bytes written from src to i2s
-
177  size_t writeExpandChannel(const void *src, size_t size_bytes) {
-
178  switch(cfg.bits_per_sample){
-
179  // case 8: {
-
180  // int8_t *pt8 = (int8_t*) src;
-
181  // int16_t sample16 = static_cast<int16_t>(*pt8) << 8;
-
182  // for (int j=0;j<size_bytes;j++){
-
183  // // 8 bit does not work
-
184  // i2s.write8(pt8[j], pt8[j]);
-
185  // //LOGI("%d", pt8[j]);
-
186  // }
-
187  // } break;
-
188  case 16: {
-
189  int16_t *pt16 = (int16_t*) src;
-
190  for (int j=0;j<size_bytes/sizeof(int16_t);j++){
-
191  i2s.write16(pt16[j], pt16[j]);
-
192  }
-
193  } break;
-
194  case 24: {
-
195  int32_t *pt24 = (int32_t*) src;
-
196  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
-
197  i2s.write24(pt24[j], pt24[j]);
-
198  }
-
199  } break;
-
200  case 32:{
-
201  int32_t *pt32 = (int32_t*) src;
-
202  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
-
203  i2s.write32(pt32[j], pt32[j]);
-
204  }
-
205  } break;
-
206  }
-
207  return size_bytes;
-
208  }
-
209 
-
211  size_t read2Channels(void *dest, size_t size_bytes) {
-
212  TRACED();
-
213  size_t result = 0;
-
214  switch(cfg.bits_per_sample){
-
215  // case 8:{
-
216  // int8_t *data = (int8_t*)dest;
-
217  // for (int j=0;j<size_bytes;j+=2){
-
218  // if (i2s.read8(data+j, data+j+1)){
-
219  // result+=2;;
-
220  // } else {
-
221  // return result;
-
222  // }
-
223  // }
-
224  // }break;
-
225 
-
226  case 16:{
-
227  int16_t *data = (int16_t *)dest;
-
228  for (int j=0;j<size_bytes/sizeof(int16_t);j+=2){
-
229  if (i2s.read16(data+j, data+j+1)){
-
230  result+=4;
-
231  } else {
-
232  return result;
-
233  }
-
234  }
-
235  }break;
-
236 
-
237  case 24:{
-
238  int32_t *data = (int32_t *)dest;
-
239  for (int j=0;j<size_bytes/sizeof(int32_t);j+=2){
-
240  if (i2s.read24(data+j, data+j+1)){
-
241  result+=8;
-
242  } else {
-
243  return result;
-
244  }
-
245  }
-
246  }break;
-
247 
-
248  case 32:{
-
249  int32_t *data = (int32_t *)dest;
-
250  for (int j=0;j<size_bytes/sizeof(int32_t);j+=2){
-
251  if (i2s.read32(data+j, data+j+1)){
-
252  result+=8;
-
253  } else {
-
254  return result;
-
255  }
-
256  }
-
257 
-
258  }break;
-
259  }
-
260  return result;
-
261  }
-
262 
-
264  size_t read1Channel(void *dest, size_t size_bytes) {
-
265  TRACED();
-
266  size_t result = 0;
-
267  switch(cfg.bits_per_sample){
-
268  // case 8:{
-
269  // int8_t tmp[2];
-
270  // int8_t *data = (int8_t*)dest;
-
271  // for (int j=0;j<size_bytes;j++){
-
272  // if (i2s.read8(tmp, tmp+1)){
-
273  // data[j] = mix(tmp[0], tmp[1]);
-
274  // result++;;
-
275  // } else {
-
276  // return result;
-
277  // }
-
278  // }
-
279  // }break;
-
280 
-
281  case 16:{
-
282  int16_t tmp[2];
-
283  int16_t *data = (int16_t*)dest;
-
284  for (int j=0;j<size_bytes/sizeof(int16_t);j++){
-
285  if (i2s.read16(tmp, tmp+1)){
-
286  data[j] = mix(tmp[0], tmp[1]);
-
287  result+=2;
-
288  } else {
-
289  return result;
-
290  }
-
291  }
-
292  }break;
-
293 
-
294  case 24:{
-
295  int32_t tmp[2];
-
296  int32_t *data = (int32_t*)dest;
-
297  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
-
298  if (i2s.read24(tmp, tmp+1)){
-
299  data[j] = mix(tmp[0],tmp[1]);
-
300  result+=4;
-
301  } else {
-
302  return result;
-
303  }
-
304  }
-
305  }break;
-
306 
-
307  case 32:{
-
308  int32_t tmp[2];
-
309  int32_t *data = (int32_t*)dest;
-
310  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
-
311  if (i2s.read32(tmp, tmp+1)){
-
312  data[j] = mix(tmp[0],tmp[1]);
-
313  result+=4;
-
314  } else {
-
315  return result;
-
316  }
-
317  }
-
318  }break;
-
319  }
-
320  return result;
-
321  }
-
322 
-
323  // we just provide the avg of both samples
-
324  template <class T>
-
325  T mix (T left, T right) {
-
326  if (left!=0) has_input[0]=true;
-
327  if (right!=0) has_input[1]=true;
-
328 
-
329  // if right is always empty we return left
-
330  if (has_input[0]&&!has_input[1]){
-
331  return left;
-
332  }
-
333 
-
334  // if left is always empty we return right
-
335  if (!has_input[0]&&has_input[1]){
-
336  return right;
-
337  }
-
338 
-
339  return (left/2) + (right/2);
-
340 
-
341  }
+
71  if (cfg.pin_mck != -1){
+
72  if (!i2s.setMCLK(cfg.pin_mck)){
+
73  LOGE("Could not set data pin: %d", cfg.pin_mck);
+
74  return false;
+
75  }
+
76  }
+
77 
+
78  if (cfg.bits_per_sample==8 || !i2s.setBitsPerSample(cfg.bits_per_sample)){
+
79  LOGE("Could not set bits per sample: %d", cfg.bits_per_sample);
+
80  return false;
+
81  }
+
82 
+
83  if (!i2s.setBuffers(cfg.buffer_count, cfg.buffer_size)){
+
84  LOGE("Could not set buffers: Count: '%d', size: '%d'", cfg.buffer_count, cfg.buffer_size);
+
85  return false;
+
86  }
+
87 
+
88  // setup format
+
89  if(cfg.i2s_format == I2S_STD_FORMAT || cfg.i2s_format == I2S_PHILIPS_FORMAT){
+
90  // default setting: do nothing
+
91  } else if(cfg.i2s_format == I2S_LEFT_JUSTIFIED_FORMAT || cfg.i2s_format==I2S_LSB_FORMAT){
+
92  if(!i2s.setLSBJFormat()){
+
93  LOGE("Could not set LSB Format")
+
94  return false;
+
95  }
+
96  } else {
+
97  LOGE("Unsupported I2S format");
+
98  return false;
+
99  }
+
100 
+
101  if (cfg.channels < 1 || cfg.channels > 2 ){
+
102  LOGE("Unsupported channels: '%d'", cfg.channels);
+
103  return false;
+
104  }
+
105 
+
106  if (!i2s.begin(cfg.sample_rate)){
+
107  LOGE("Could not start I2S");
+
108  return false;
+
109  }
+
110  return true;
+
111  }
+
112 
+
114  void end() {
+
115  flush();
+
116  i2s.end();
+
117  }
+
118 
+
120  I2SConfigStd config() {
+
121  return cfg;
+
122  }
+
123 
+
125  size_t writeBytes(const void *src, size_t size_bytes) {
+
126  LOGD("writeBytes(%d)", size_bytes);
+
127  size_t result = 0;
+
128 
+
129  if (cfg.channels==1){
+
130  result = writeExpandChannel(src, size_bytes);
+
131  } else if (cfg.channels==2){
+
132  const uint8_t *p = (const uint8_t*) src;
+
133  while(size_bytes >= sizeof(int32_t)){
+
134  bool justWritten = i2s.write(*(int32_t*)p,true); //I2S::write(int32,bool) actually only returns 0 or 1
+
135  if(justWritten){
+
136  size_bytes -= sizeof(int32_t);
+
137  p += sizeof(int32_t);
+
138  result += sizeof(int32_t);
+
139  } else return result;
+
140  }
+
141  }
+
142  return result;
+
143  }
+
144 
+
145  size_t readBytes(void *dest, size_t size_bytes) {
+
146  TRACED();
+
147  switch(cfg.channels){
+
148  case 1:
+
149  return read1Channel(dest, size_bytes);
+
150  case 2:
+
151  return read2Channels(dest, size_bytes);
+
152  }
+
153  return 0;
+
154  }
+
155 
+
156  int availableForWrite() {
+
157  if (cfg.channels == 1){
+
158  return cfg.buffer_size;
+
159  } else {
+
160  return i2s.availableForWrite();
+
161  }
+
162  }
+
163 
+
164  int available() {
+
165  return min(i2s.available(), cfg.buffer_size);
+
166  }
+
167 
+
168  void flush() {
+
169  i2s.flush();
+
170  }
+
171 
+
172  protected:
+
173  I2SConfigStd cfg;
+
174  I2S i2s;
+
175  bool has_input[2];
+
176 
+
178  //returns amount of bytes written from src to i2s
+
179  size_t writeExpandChannel(const void *src, size_t size_bytes) {
+
180  switch(cfg.bits_per_sample){
+
181  // case 8: {
+
182  // int8_t *pt8 = (int8_t*) src;
+
183  // int16_t sample16 = static_cast<int16_t>(*pt8) << 8;
+
184  // for (int j=0;j<size_bytes;j++){
+
185  // // 8 bit does not work
+
186  // i2s.write8(pt8[j], pt8[j]);
+
187  // //LOGI("%d", pt8[j]);
+
188  // }
+
189  // } break;
+
190  case 16: {
+
191  int16_t *pt16 = (int16_t*) src;
+
192  for (int j=0;j<size_bytes/sizeof(int16_t);j++){
+
193  i2s.write16(pt16[j], pt16[j]);
+
194  }
+
195  } break;
+
196  case 24: {
+
197  int32_t *pt24 = (int32_t*) src;
+
198  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
+
199  i2s.write24(pt24[j], pt24[j]);
+
200  }
+
201  } break;
+
202  case 32:{
+
203  int32_t *pt32 = (int32_t*) src;
+
204  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
+
205  i2s.write32(pt32[j], pt32[j]);
+
206  }
+
207  } break;
+
208  }
+
209  return size_bytes;
+
210  }
+
211 
+
213  size_t read2Channels(void *dest, size_t size_bytes) {
+
214  TRACED();
+
215  size_t result = 0;
+
216  switch(cfg.bits_per_sample){
+
217  // case 8:{
+
218  // int8_t *data = (int8_t*)dest;
+
219  // for (int j=0;j<size_bytes;j+=2){
+
220  // if (i2s.read8(data+j, data+j+1)){
+
221  // result+=2;;
+
222  // } else {
+
223  // return result;
+
224  // }
+
225  // }
+
226  // }break;
+
227 
+
228  case 16:{
+
229  int16_t *data = (int16_t *)dest;
+
230  for (int j=0;j<size_bytes/sizeof(int16_t);j+=2){
+
231  if (i2s.read16(data+j, data+j+1)){
+
232  result+=4;
+
233  } else {
+
234  return result;
+
235  }
+
236  }
+
237  }break;
+
238 
+
239  case 24:{
+
240  int32_t *data = (int32_t *)dest;
+
241  for (int j=0;j<size_bytes/sizeof(int32_t);j+=2){
+
242  if (i2s.read24(data+j, data+j+1)){
+
243  result+=8;
+
244  } else {
+
245  return result;
+
246  }
+
247  }
+
248  }break;
+
249 
+
250  case 32:{
+
251  int32_t *data = (int32_t *)dest;
+
252  for (int j=0;j<size_bytes/sizeof(int32_t);j+=2){
+
253  if (i2s.read32(data+j, data+j+1)){
+
254  result+=8;
+
255  } else {
+
256  return result;
+
257  }
+
258  }
+
259 
+
260  }break;
+
261  }
+
262  return result;
+
263  }
+
264 
+
266  size_t read1Channel(void *dest, size_t size_bytes) {
+
267  TRACED();
+
268  size_t result = 0;
+
269  switch(cfg.bits_per_sample){
+
270  // case 8:{
+
271  // int8_t tmp[2];
+
272  // int8_t *data = (int8_t*)dest;
+
273  // for (int j=0;j<size_bytes;j++){
+
274  // if (i2s.read8(tmp, tmp+1)){
+
275  // data[j] = mix(tmp[0], tmp[1]);
+
276  // result++;;
+
277  // } else {
+
278  // return result;
+
279  // }
+
280  // }
+
281  // }break;
+
282 
+
283  case 16:{
+
284  int16_t tmp[2];
+
285  int16_t *data = (int16_t*)dest;
+
286  for (int j=0;j<size_bytes/sizeof(int16_t);j++){
+
287  if (i2s.read16(tmp, tmp+1)){
+
288  data[j] = mix(tmp[0], tmp[1]);
+
289  result+=2;
+
290  } else {
+
291  return result;
+
292  }
+
293  }
+
294  }break;
+
295 
+
296  case 24:{
+
297  int32_t tmp[2];
+
298  int32_t *data = (int32_t*)dest;
+
299  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
+
300  if (i2s.read24(tmp, tmp+1)){
+
301  data[j] = mix(tmp[0],tmp[1]);
+
302  result+=4;
+
303  } else {
+
304  return result;
+
305  }
+
306  }
+
307  }break;
+
308 
+
309  case 32:{
+
310  int32_t tmp[2];
+
311  int32_t *data = (int32_t*)dest;
+
312  for (int j=0;j<size_bytes/sizeof(int32_t);j++){
+
313  if (i2s.read32(tmp, tmp+1)){
+
314  data[j] = mix(tmp[0],tmp[1]);
+
315  result+=4;
+
316  } else {
+
317  return result;
+
318  }
+
319  }
+
320  }break;
+
321  }
+
322  return result;
+
323  }
+
324 
+
325  // we just provide the avg of both samples
+
326  template <class T>
+
327  T mix (T left, T right) {
+
328  if (left!=0) has_input[0]=true;
+
329  if (right!=0) has_input[1]=true;
+
330 
+
331  // if right is always empty we return left
+
332  if (has_input[0]&&!has_input[1]){
+
333  return left;
+
334  }
+
335 
+
336  // if left is always empty we return right
+
337  if (!has_input[0]&&has_input[1]){
+
338  return right;
+
339  }
+
340 
+
341  return (left/2) + (right/2);
342 
-
343 
-
344 };
+
343  }
+
344 
345 
-
346 using I2SDriver = I2SDriverRP2040;
+
346 };
347 
-
348 
-
349 }
+
348 using I2SDriver = I2SDriverRP2040;
+
349 
350 
-
351 #endif
+
351 }
+
352 
+
353 #endif
RxTxMode
Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Sink at the same time!
Definition: AudioTypes.h:24
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10