From a97c5d8dae8d8e9a343845b996fc7472f0977305 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 8 Aug 2022 13:58:34 +0200 Subject: [PATCH 1/6] add codec wm8960 --- lib/lib_audio/wm8960/library.json | 7 + lib/lib_audio/wm8960/library.properties | 9 + lib/lib_audio/wm8960/src/wm8960.cpp | 114 ++++++++ lib/lib_audio/wm8960/src/wm8960.h | 372 ++++++++++++++++++++++++ 4 files changed, 502 insertions(+) create mode 100644 lib/lib_audio/wm8960/library.json create mode 100644 lib/lib_audio/wm8960/library.properties create mode 100755 lib/lib_audio/wm8960/src/wm8960.cpp create mode 100755 lib/lib_audio/wm8960/src/wm8960.h diff --git a/lib/lib_audio/wm8960/library.json b/lib/lib_audio/wm8960/library.json new file mode 100644 index 000000000..7825e53d5 --- /dev/null +++ b/lib/lib_audio/wm8960/library.json @@ -0,0 +1,7 @@ +{ + "name": "WM8960", + "description": "Audio codec", + "keywords": "ESP8266, ESP32, MP3, AAC, WAV, MOD, FLAC, RTTTL, MIDI, I2S, DAC, Delta-Sigma, TTS", + "version": "1.0.0", + "frameworks": "Arduino" +} diff --git a/lib/lib_audio/wm8960/library.properties b/lib/lib_audio/wm8960/library.properties new file mode 100644 index 000000000..933df97b3 --- /dev/null +++ b/lib/lib_audio/wm8960/library.properties @@ -0,0 +1,9 @@ +name=WM8960 +version=1.0 +author= +maintainer= +sentence=Audio codec for ESP32 +paragraph= +category=Signal Output +url= +architectures=esp32 diff --git a/lib/lib_audio/wm8960/src/wm8960.cpp b/lib/lib_audio/wm8960/src/wm8960.cpp new file mode 100755 index 000000000..d8211831c --- /dev/null +++ b/lib/lib_audio/wm8960/src/wm8960.cpp @@ -0,0 +1,114 @@ + +#ifdef ESP32 + +#include +#include +#include "esp_log.h" +#include "wm8960.h" + +static TwoWire *ws8960wire; + + +void W8960_Write(uint8_t reg_addr, uint16_t data) { + reg_addr <<= 1; + reg_addr |= ((data >> 8) & 1); + data &= 0xff; + ws8960wire->beginTransmission(W8960_ADDR); + ws8960wire->write(reg_addr); + ws8960wire->write(data); + ws8960wire->endTransmission(); +} + +void W8960_Init(TwoWire *tw) { + +ws8960wire = tw; + + // reset + W8960_Write(0x0f, 0x0000); + delay(10); + + // enable dac and adc + W8960_Write(0x19, (1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)); + // left speaker not used + W8960_Write(0x1A, (1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)); + W8960_Write(0x2F, (1<<5)|(1<<4)|(1<<3)|(1<<2)); + + // Configure clock + W8960_Write(0x04, 0x0000); + + // Configure ADC/DAC + W8960_Write(0x05, 0x0000); + + // Configure audio interface + // I2S format 16 bits word length + //W8960_Write(0x07 0x0002) + W8960_Write(0x07, 0x0022); + + // Configure HP_L and HP_R OUTPUTS + W8960_Write(0x02, 0x017f); + W8960_Write(0x03, 0x017f); + + // Configure SPK_RP and SPK_RN + W8960_Write(0x28, 0x0177); + W8960_Write(0x29, 0x0177); + + // Enable the OUTPUTS, only right speaker is wired + W8960_Write(0x31, 0x0080); + + // Configure DAC volume + W8960_Write(0x0a, 0x01FF); + W8960_Write(0x0b, 0x01FF); + + // Configure MIXER + W8960_Write(0x22, (1<<8)|(1<<7)); + W8960_Write(0x25, (1<<8)|(1<<7)); + + // Jack Detect + //W8960_Write(0x18, (1<<6)|(0<<5)); + //W8960_Write(0x17, 0x01C3); + //W8960_Write(0x30, 0x0009); + + // input volume + W8960_Write(0x00, 0x0127); + W8960_Write(0x01, 0x0127); + + // set ADC Volume + W8960_Write(0x15, 0x01c3); + W8960_Write(0x16, 0x01c3); + + // disable bypass switch + W8960_Write(0x2d, 0x0000); + W8960_Write(0x2e, 0x0000); + + // connect LINPUT1 to PGA and set PGA Boost Gain. + W8960_Write(0x20, 0x0020|(1<<8)|(1<<3)); + W8960_Write(0x21, 0x0020|(1<<8)|(1<<3)); + +} + +void W8960_SetGain(uint8_t sel, uint16_t value) { + switch (sel) { + case 0: + // output dac in 0.5 db steps + value &= 0x00ff; + value |= 0x0100; + W8960_Write(0x0a, value); + W8960_Write(0x0b, value); + break; + case 1: + // input pga in 0.75 db steps + value &= 0x001f; + value |= 0x0120; + W8960_Write(0x00, value); + W8960_Write(0x01, value); + break; + case 2: + // adc in 0.5 db steps + value &= 0x00ff; + value |= 0x0100; + W8960_Write(0x15, value); + W8960_Write(0x16, value); + break; + } +} +#endif // ESP32 diff --git a/lib/lib_audio/wm8960/src/wm8960.h b/lib/lib_audio/wm8960/src/wm8960.h new file mode 100755 index 000000000..7d07cc0e6 --- /dev/null +++ b/lib/lib_audio/wm8960/src/wm8960.h @@ -0,0 +1,372 @@ +#ifndef _WM8960_H_ +#define _WM8960_H_ + +#define W8960_ADDR 0x1a + +//static const char *TAG = "WM8960"; +#define SDA_PIN 21 +#define SCL_PIN 22 +#define I2C_BUS_NO 0 +#define ACK_CHECK_EN 0 +#define ACK_CHECK_DIS 0 +#define ACK_VAL 0 +#define NACK_VAL 1 + + +#define R0_LEFT_INPUT_VOLUME_ADR 0x00 +#define R1_RIGHT_INPUT_VOLUME_ADR 0x01 +#define R2_LOUT1_VOLUME_ADR 0x02 +#define R3_ROUT1_VOLUME_ADR 0x03 +#define R4_CLOCKING_1_ADR 0x04 +#define R5_ADC_DAC_CONTROL_CTR1_ADR 0x05 +#define R6_ADC_DAC_CONTROL_CTR2_ADR 0x06 +#define R7_AUDIO_INTERFACE_1_ADR 0x07 +#define R8_CLOCKING_2_ADR 0x08 +#define R10_LEFT_DAC_VOLUME_ADR 0x09 +#define R11_RIGHT_DAC_VOLUME_ADR 0x0A +#define R15_RESET_ADR 0x0F +#define R16_3D_CONTROL_ADR 0x10 +#define R17_ALC1_ADR 0x11 +#define R18_ALC2_ADR 0x12 +#define R19_ALC3_ADR 0x13 +#define R20_NOISE_GATE_ADR 0x14 +#define R21_LEFT_ADC_VOLUME_ADR 0x15 +#define R22_RIGHT_ADC_VOLUME_ADR 0x16 +#define R23_ADDITIONAL_CONTROL_1_ADR 0x17 +#define R24_ADDITIONAL_CONTROL_2_ADR 0x18 +#define R25_PWR_MGMT_1_ADR 0x19 +#define R26_PWR_MGMT_2_ADR 0x1A +#define R27_ADDITIONAL_CONTROL_3_ADR 0x1B +#define R28_ANTI_POP_1_ADR 0x1C +#define R29_ANTI_POP_2_ADR 0x1D +#define R32_ADCL_SIGNAL_PATH 0x20 +#define R33_ADCR_SIGNAL_PATH 0x21 +#define R34_LEFT_OUT_MIX_2 0x22 +#define R37_RIGHT_OUT_MIX_2 0x23 +#define R38_MONO_OUT_MIX_1 0x26 +#define R39_MONO_OUT_MIX_2 0x27 +#define R40_LOUT2_VOLUME 0x28 +#define R41_ROUT2_VOLUME 0x29 +#define R42_MONOOUT_VOLUME 0x2A +#define R43_INPUT_BOOST_MIXER_1 0x2B +#define R44_INPUT_BOOST_MIXER_2 0x2C +#define R45_BYPASS_1 0x2D +#define R46_BYPASS_2 0x2E +#define R47_PWR_MGMT_3 0x2F +#define R48_ADDITONAL_CTRL_4 0x30 +#define R49_CLASS_D_CTRL_1 0x31 +#define R51_CLASS_D_CTRL_3 0x33 + + + +typedef struct R0_LEFT_INPUT_VOLUME_t +{ + uint16_t LINVOL :6; //Bits 5:0 + uint16_t LIZC :1; //Bits 6 + uint16_t LINMUTE :1; //Bits 7 + uint16_t IPUV :1; //Bits 8 + +} __attribute__((packed, aligned(2))) R0_LEFT_INPUT_VOLUME_t; + + +typedef struct R1_RIGHT_INPUT_VOLUME_t +{ + uint16_t RINVOL :6; //Bits 5:0 + uint16_t RIZC :1; //Bits 6 + uint16_t RINMUTE :1; //Bits 7 + uint16_t IPUV :1; //Bits 8 + +} __attribute__((packed, aligned(2))) R1_RIGHT_INPUT_VOLUME_t; + + +typedef struct R2_LOUT1_VOLUME_t +{ + uint16_t LOUT1VOL :7; //Bits 6:0 + uint16_t LO1ZC :1; //Bits 7 + uint16_t OUT1VU :1; //Bits 8 +} __attribute__((packed, aligned(2))) R2_LOUT1_VOLUME_t; + +typedef struct R3_ROUT1_VOLUME_t +{ + uint16_t ROUT1VOL :7; //Bits 6:0 + uint16_t RO1ZC :1; //Bits 7 + uint16_t OUT1VU :1; //Bits 8 +} __attribute__((packed, aligned(2))) R3_ROUT1_VOLUME_t; + +typedef struct R4_CLOCKING_1_t{ + + uint16_t ADCDIV :3; //Bits 8:6 + uint16_t DACDIV :3; //Bits 5:3 + uint16_t SYSCLKDIV :2; //Bits 2:1 + uint16_t CLKSEL :1; //Bits 0 +} __attribute__((packed, aligned(2))) R4_CLOCKING_1_t; + +typedef struct R5_ADC_DAC_CONTROL_CTR1_t{ + + uint16_t ADCHPD :1; //Bits 0 + uint16_t DEEMPH :2; //Bits 2:1 + uint16_t DACMU :1; //Bits 3 + uint16_t R5RES_4 :1; + uint16_t ADCPOL :2; //Bits 6:5 + uint16_t DACDIV2 :1; //Bits 7 + uint16_t R5RES_8 :1; +}__attribute__((packed, aligned(2))) R5_ADC_DAC_CONTROL_CTR1_t ; + +typedef struct R6_ADC_DAC_CONTROL_CTR2_t{ + + uint16_t DACSLOPE :1; //Bits 1 + uint16_t DACMR :1; //Bits 2 + uint16_t DACSMM :1; //Bits 3 + uint16_t DACPOL :2; //Bits 6:5 +}__attribute__((packed, aligned(2))) R6_ADC_DAC_CONTROL_CTR2_t; + +typedef struct R7_AUDIO_INTERFACE_t{ + uint16_t FORMAT :2; // bit 1:0 + uint16_t WL :2; // bit 1:0 + uint16_t LRP :1; // bit 4 + uint16_t DLRSWAP :1; // bit 5 + uint16_t MS :1; // bit 6 + uint16_t BCLKINV :1; // bit 7 + uint16_t ALRSWAP :1; // bit 8 +}__attribute__((packed, aligned(2))) R7_AUDIO_INTERFACE_t; + +typedef struct R8_CLOCKING_2_t{ + uint16_t BCLKDIV :4; // bit 3:0 + uint16_t DCLKDIV :3; // bit 2:0 +}__attribute__((packed, aligned(2))) R8_CLOCKING_2_t; + +typedef struct R9_AUDIO_INTERFACE_t{ + uint16_t LOOPBACK :1; // bit 0 + uint16_t ADCCOMP :2; // bits 1:0 + uint16_t DACCOMP :2; // bits 1:0 + uint16_t WL8 :1; // bit 5 + uint16_t ALRCGPIO :1; // bit 6 +}__attribute__((packed, aligned(2))) R9_AUDIO_INTERFACE_t; + +typedef struct R10_LEFT_DAC_VOLUME_t{ + uint16_t LDACVOL :8; // bit 7:0 + uint16_t DACVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R10_LEFT_DAC_VOLUME_t; + +typedef struct R11_RIGHT_DAC_VOLUME_t{ + uint16_t RDACVOL :8; // bit 7:0 + uint16_t DACVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R11_RIGHT_DAC_VOLUME_t; + +// typedef struct R15_RESET_t{}; + +typedef struct R16_3D_CONTROL_t{ + uint16_t D3EN :1; // bit 0 + uint16_t D3DEPTH :4; // bits 3:0 + uint16_t D3LC :1; // bit 5 + uint16_t D3UC :1; // bit 6 +}__attribute__((packed, aligned(2))) R16_3D_CONTROL_t; + +typedef struct R17_ALC1_t{ + uint16_t ALCL :4; // bits 3:0 + uint16_t MAXGAIN :3; // bits 2:0 + uint16_t ALCSEL :2; // bits 1:0 +}__attribute__((packed, aligned(2))) R17_ALC1_t; + +typedef struct R18_ALC2_t{ + uint16_t HLD :4; // bits 3:0 + uint16_t MINGAIN :3; // bits 2:0 +}__attribute__((packed, aligned(2))) R18_ALC2_t; + +typedef struct R19_ALC3_t{ + uint16_t ATK :4; // bits 3:0 + uint16_t DCY :4; // bits 3:0 +}__attribute__((packed, aligned(2))) R19_ALC3_t; + +typedef struct R20_NOISE_GATE_t{ + uint16_t NGAT :1; // bit 0 + uint16_t NGTH :5; // bit 4:0 +}__attribute__((packed, aligned(2))) R20_NOISE_GATE_t; + +typedef struct R21_LEFT_ADC_VOLUME_t{ + uint16_t LADCVOL :8; // bits 7:0 + uint16_t ADCVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R21_LEFT_ADC_VOLUME_t; + +typedef struct R22_RIGHT_ADC_VOLUME_t{ + uint16_t RADCVOL :8; // bits 7:0 + uint16_t ADCVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R22_RIGHT_ADC_VOLUME_t; + +typedef struct R23_ADDITIONAL_CONTROL_1_t{ + uint16_t TOEN :1; // bit 1 + uint16_t TOCLKSEL :1; // bit 2 + uint16_t DATSEL :2; // bits 1:0 + uint16_t DMONOMIX :1; // bit 4 + uint16_t VSEL :2; // bits 1:0 + uint16_t TSDEN :1; // bit 8 +}__attribute__((packed, aligned(2))) R23_ADDITIONAL_CONTROL_1_t; + +typedef struct R24_ADDITIONAL_CONTROL_2_t{ + uint16_t LRCM :1; // bit 2 + uint16_t TRIS :1; // bit 3 + uint16_t HPSWPOL :1; // bit 5 + uint16_t HPSWEN :1; // bit 6 +}__attribute__((packed, aligned(2))) R24_ADDITIONAL_CONTROL_2_t; + +typedef struct R25_PWR_MGMT_1_t{ + uint16_t DIGENB :1; // bit 0 + uint16_t MICB :1; // bit 1 + uint16_t ADCR :1; // bit 2 + uint16_t ADCL :1; // bit 3 + uint16_t AINR :1; // bit 4 + uint16_t AINL :1; // bit 5 + uint16_t VREF :1; // bit 6 + uint16_t VMIDSEL :2; // bit 1:0 +}__attribute__((packed, aligned(2))) R25_PWR_MGMT_1_t; + +typedef struct R26_PWR_MGMT_2_t{ + uint16_t PLL_EN :1; // bit 0 + uint16_t OUT3 :1; // bit 1 + uint16_t SPKR :1; // bit 3 + uint16_t SPKL :1; // bit 4 + uint16_t ROUT1 :1; // bit 5 + uint16_t LOUT1 :1; // bit 6 + uint16_t DACR :1; // bit 7 + uint16_t DACL :1; // bit 8 +}__attribute__((packed, aligned(2))) R26_PWR_MGMT_2_t; + +typedef struct R27_ADDITIONAL_CONTROL_3_t{ + uint16_t ADC_ALC_SR :3; // bits 2:0 + uint16_t OUT3CAP :1; // bit 3 + uint16_t VROI :1; // bit 6 +}__attribute__((packed, aligned(2))) R27_ADDITIONAL_CONTROL_3_t; + +typedef struct R28_ANTI_POP_1_t{ + uint16_t HPSTBY :1; // bit 0 + uint16_t SOFT_ST :1; // bit 2 + uint16_t BUFIOEN :1; // bit 3 + uint16_t BUFDCOPEN :1; // bit 4 + uint16_t POBCTRL :1; // bit 7 +}__attribute__((packed, aligned(2))) R28_ANTI_POP_1_t; + +typedef struct R29_ANTI_POP_2_t{ + uint16_t DRES :2; // bits 1:0 + uint16_t DISOP :1; // bit 5 +}__attribute__((packed, aligned(2))) R29_ANTI_POP_2_t; + +typedef struct R32_ADCL_SIGNAL_PATH_t{ + uint16_t LMIC2B :1; // bit 3 + uint16_t LMICBOOST :2; // bits 1:0 + uint16_t LMP2 :1; // bit 6 + uint16_t LMP3 :1; // bit 7 + uint16_t LMN1 :1; // bit 8 +}__attribute__((packed, aligned(2))) R32_ADCL_SIGNAL_PATH_t; + +typedef struct R33_ADCR_SIGNAL_PATH_t{ + uint16_t RMIC2B :1; // bit 3 + uint16_t RMICBOOST :2; // bits 1:0 + uint16_t RMP2 :1; // bit 6 + uint16_t RMP3 :1; // bit 7 + uint16_t RMN1 :1; // bit 8 +}__attribute__((packed, aligned(2))) R33_ADCR_SIGNAL_PATH_t; + +typedef struct R34_LEFT_OUT_MIX_1_t{ + uint16_t LI2LOVOL :3; // bits 2:0 + uint16_t LI2LO :1; // bit 7 + uint16_t LD2LO :1; // bit 8 +}__attribute__((packed, aligned(2))) R34_LEFT_OUT_MIX_1_t; + +typedef struct R37_RIGHT_OUT_MIX_2_t{ + uint16_t RI2ROVOL :3; // bits 2:0 + uint16_t RI2RO :1; // bit 7 + uint16_t RD2RO :1; // bit 8 +}__attribute__((packed, aligned(2))) R37_RIGHT_OUT_MIX_2_t; + +typedef struct R38_MONO_OUT_MIX_1_t{ + uint16_t L2MO :1; // bit 7 +}__attribute__((packed, aligned(2))) R38_MONO_OUT_MIX_1_t; + +typedef struct R39_MONO_OUT_MIX_2_t{ + uint16_t R2MO :1; // bit 7 +}__attribute__((packed, aligned(2))) R39_MONO_OUT_MIX_2_t; + +typedef struct R40_LOUT2_VOLUME_t{ + uint16_t SPKLVOL :7; // bits 6:0 + uint16_t SPKLZC :1; // bit 7 + uint16_t SPKVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R40_LOUT2_VOLUME_t; + +typedef struct R41_ROUT2_VOLUME_t{ + uint16_t SPKRVOL :7; // bits 6:0 + uint16_t SPKLZC :1; // bit 7 + uint16_t SPKVU :1; // bit 8 +}__attribute__((packed, aligned(2))) R41_ROUT2_VOLUME_t; + +typedef struct R42_MONOOUT_VOLUME_t{ + uint16_t MOUTVOL :1; //bit 6 +}__attribute__((packed, aligned(2))) R42_MONOOUT_VOLUME_t; + +typedef struct R43_INPUT_BOOST_MIXER_1_t{ + uint16_t LIN2BOOST :3; // bits 2:0 + uint16_t LIN3BOOST :3; // bits 2:0 +}__attribute__((packed, aligned(2))) R43_INPUT_BOOST_MIXER_1_t; + +typedef struct R44_INPUT_BOOST_MIXER_2_t{ + uint16_t RIN2BOOST :3; // bits 2:0 + uint16_t RIN3BOOST :3; // bits 2:0 +}__attribute__((packed, aligned(2))) R44_INPUT_BOOST_MIXER_2_t; + +typedef struct R45_BYPASS_1_t{ + uint16_t LB2LOVOL :3; // bits 2:0 + uint16_t LB2LO :1; // bit 5 +}__attribute__((packed, aligned(2))) R45_BYPASS_1_t; + +typedef struct R46_BYPASS_2_t{ + uint16_t RB2ROVOL :3; // bits 2:0 + uint16_t RB2RO :1; // bit 5 +}__attribute__((packed, aligned(2))) R46_BYPASS_2_t; + +typedef struct R47_PWR_MGMT_3_t{ + uint16_t ROMIX :1; // bit 2 + uint16_t LOMIX :1; // bit 3 + uint16_t RMIC :1; // bit 4 + uint16_t LMIC :1; // bit 5 +}__attribute__((packed, aligned(2))) R47_PWR_MGMT_3_t; + +typedef struct R48_ADDITIONAL_CONTROL_4_t{ + uint16_t MBSEL :1; // bit 0 + uint16_t TSENSEN :1; // bit 1 + uint16_t HPSEL :2; // bits 1:0 + uint16_t GPIOSEL :3; // bits 2:0 + uint16_t GPIOPOL :1; // bit 7 +}__attribute__((packed, aligned(2))) R48_ADDITIONAL_CONTROL_4_t; + +typedef struct R49_CLASS_D_CONTROL_1_t{ + uint16_t SPK_OP_EN :2; // bits 1:0 +}__attribute__((packed, aligned(2))) R49_CLASS_D_CONTROL_1_t; + +typedef struct R51_CLASS_D_CONTROL_3_t{ + uint16_t ACGAIN :3; // bits 2:0 + uint16_t DCGAIN :3; // bits 2:0 +}__attribute__((packed, aligned(2))) R51_CLASS_D_CONTROL_3_t; + +typedef struct R52_PLL_N_t{ + uint16_t PLLN :4; // bits 3:0 + uint16_t PLLRESCALE :1; // bit 4 + uint16_t SDM :1; // bit 5 + uint16_t OPCLKDIV :3; // bits 2:0 +}__attribute__((packed, aligned(2))) R52_PLL_N_t; + +typedef struct R53_PLL_K_1_t{ + uint16_t PLLK :8; // bits 23:16 +}__attribute__((packed, aligned(2))) R53_PLL_K_1_t; + +typedef struct R54_PLL_K_2_t{ + uint16_t PLLK :8; // bits 15:8 +}__attribute__((packed, aligned(2))) R54_PLL_K_2_t; + +typedef struct R55_PLL_K_3_t{ + uint16_t PLLK :8; // bits 7:0 +}__attribute__((packed, aligned(2))) R55_PLL_K_3_t; + + +void W8960_Init(TwoWire *tw); +void W8960_SetGain(uint8_t sel, uint16_t value); + +#endif From 7831c72be5d3a7a2ac60c0a5eed8c15bf4788cc0 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 8 Aug 2022 13:58:54 +0200 Subject: [PATCH 2/6] add setgain --- lib/lib_audio/es7243e/src/es7243e.cpp | 7 +++++++ lib/lib_audio/es7243e/src/es7243e.h | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/lib_audio/es7243e/src/es7243e.cpp b/lib/lib_audio/es7243e/src/es7243e.cpp index 536c237ec..6ea7824fb 100644 --- a/lib/lib_audio/es7243e/src/es7243e.cpp +++ b/lib/lib_audio/es7243e/src/es7243e.cpp @@ -95,4 +95,11 @@ esp_err_t es7243e_adc_init(TwoWire *tw, audio_hal_codec_config_t *codec_cfg) } return ret; } + +void es7243e_setgain(uint8_t gain) { + uint8_t gaintab[8] = {0x10, 0x12, 0x20, 0x22, 0x04, 0x40, 0x06, 0x42}; + es7243e_write_reg(0x08, gaintab[gain & 7] | 0x09); +} + + #endif diff --git a/lib/lib_audio/es7243e/src/es7243e.h b/lib/lib_audio/es7243e/src/es7243e.h index bef4b3ba6..b96889810 100644 --- a/lib/lib_audio/es7243e/src/es7243e.h +++ b/lib/lib_audio/es7243e/src/es7243e.h @@ -72,6 +72,7 @@ esp_err_t es7243e_adc_init(TwoWire *tw, audio_hal_codec_config_t *codec_cfg); */ // esp_err_t es7243_adc_set_gain(es7243_input_mics_t mic_mask, es7243_gain_value_t gain); +void es7243e_setgain(uint8_t gain); #ifdef __cplusplus } From 4dc910391f7d03e76d75551af5098677c708b828 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 8 Aug 2022 14:00:55 +0200 Subject: [PATCH 3/6] update i2s audio --- .../xdrv_42_0_i2s_audio.ino | 71 +++++++++++++------ .../xdrv_42_1_i2s_mp3mic.ino | 47 ++++++++---- .../xdrv_42_2_i2s_mp3stream.ino | 10 ++- ...i2s_s3box.ino => xdrv_42_4_i2s_codecs.ino} | 19 ++++- 4 files changed, 108 insertions(+), 39 deletions(-) rename tasmota/tasmota_xdrv_driver/{xdrv_42_4_i2s_s3box.ino => xdrv_42_4_i2s_codecs.ino} (93%) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino index 8dc835059..935a95633 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino @@ -67,13 +67,13 @@ #define i2s_port_t uint8_t #endif -#ifdef ESP32 #define MODE_MIC 0 #define MODE_SPK 1 + #ifndef MICSRATE -#define MICSRATE 16000 +#define MICSRATE 32000 #endif -#endif // ESP32 + struct AUDIO_I2S_t { uint8_t is2_volume; // should be in settings @@ -105,6 +105,7 @@ struct AUDIO_I2S_t { #ifdef ESP32 TaskHandle_t mp3_task_h; TaskHandle_t mic_task_h; +#endif // ESP32 uint32_t mic_size; uint32_t mic_rate; uint8_t *mic_buff; @@ -118,9 +119,10 @@ struct AUDIO_I2S_t { int8_t mic_ws = -1; int8_t mic_din = -1; int8_t mic_dout = -1; + uint8_t mic_gain = 1; bool use_stream = false; i2s_port_t mic_port; -#endif // ESP32 + #ifdef USE_SHINE uint32_t recdur; @@ -130,10 +132,13 @@ struct AUDIO_I2S_t { ESP8266WebServer *MP3Server; #endif + uint8_t mode; + } audio_i2s; - +#ifndef MIC_CHANNELS #define MIC_CHANNELS 1 +#endif #ifdef USE_TTGO_WATCH #undef AUDIO_PWR_ON @@ -198,6 +203,15 @@ void Cmd_MicRec(void); void Cmd_wav2mp3(void); void Cmd_Time(void); +void copy_micpars(uint32_t port) { + audio_i2s.mic_mclk = audio_i2s.mclk; + audio_i2s.mic_bclk = audio_i2s.bclk; + audio_i2s.mic_ws = audio_i2s.ws; + audio_i2s.mic_dout = audio_i2s.dout; + audio_i2s.mic_din = audio_i2s.din; + audio_i2s.mic_port = (i2s_port_t)port; +} + int32_t I2S_Init_0(void) { audio_i2s.i2s_port = (i2s_port_t)0; @@ -216,6 +230,9 @@ int32_t I2S_Init_0(void) { audio_i2s.ws = DAC_IIS_WS; audio_i2s.dout = DAC_IIS_DOUT; audio_i2s.din = DAC_IIS_DIN; + + copy_micpars(0); + #else #ifdef USE_I2S_NO_DAC if (PinUsed(GPIO_I2S_DOUT)) { @@ -235,12 +252,7 @@ int32_t I2S_Init_0(void) { audio_i2s.dout = Pin(GPIO_I2S_DOUT); audio_i2s.din = Pin(GPIO_I2S_DIN); - audio_i2s.mic_mclk = audio_i2s.mclk; - audio_i2s.mic_bclk = audio_i2s.bclk; - audio_i2s.mic_ws = audio_i2s.ws; - audio_i2s.mic_dout = audio_i2s.dout; - audio_i2s.mic_din = audio_i2s.din; - audio_i2s.mic_port = (i2s_port_t)0; + copy_micpars(0); // check if 2 ports used, use second for micro if (PinUsed(GPIO_I2S_BCLK, 1) && PinUsed(GPIO_I2S_WS, 1) && PinUsed(GPIO_I2S_DIN, 1)) { @@ -265,12 +277,7 @@ int32_t I2S_Init_0(void) { audio_i2s.dout = Pin(GPIO_I2S_DOUT, 1); audio_i2s.din = Pin(GPIO_I2S_DIN, 1); - audio_i2s.mic_mclk = audio_i2s.mclk; - audio_i2s.mic_bclk = audio_i2s.bclk; - audio_i2s.mic_ws = audio_i2s.ws; - audio_i2s.mic_dout = audio_i2s.dout; - audio_i2s.mic_din = audio_i2s.din; - audio_i2s.mic_port = (i2s_port_t)1; + copy_micpars(1); } else { return -1; @@ -299,21 +306,32 @@ int32_t I2S_Init_0(void) { #endif // USE_I2S_EXTERNAL_DAC + audio_i2s.mode = MODE_SPK; + +#idef USE_I2S_COMMON_IO + audio_i2s.out->SetRate(MICSRATE); +#endif + + return 0; } void I2S_Init(void) { - #if defined(ESP32) && defined(ESP32S3_BOX) - S3boxInit(); - #endif - if (I2S_Init_0()) { return; } - audio_i2s.is2_volume=10; - audio_i2s.out->SetGain(((float)audio_i2s.is2_volume/100.0)*4.0); +#if defined(ESP32) && defined(ESP32S3_BOX) + S3boxInit(); +#endif + +#ifdef USE_W8960 + W8960_Init(); +#endif + + audio_i2s.is2_volume = 10; + audio_i2s.out->SetGain(((float)audio_i2s.is2_volume / 100.0) * 4.0); audio_i2s.out->stop(); audio_i2s.mp3ram = nullptr; @@ -517,12 +535,17 @@ void Play_mp3(const char *path) { if (I2S_Task) { xTaskCreatePinnedToCore(mp3_task, "MP3", 8192, NULL, 3, &audio_i2s.mp3_task_h, 1); } else { +#define MP3_TIMEOUT 30000 + uint32_t tout = millis(); while (audio_i2s.mp3->isRunning()) { if (!audio_i2s.mp3->loop()) { audio_i2s.mp3->stop(); break; } OsWatchLoop(); + if (millis()-tout > MP3_TIMEOUT) { + break; + } } audio_i2s.out->stop(); mp3_delete(); @@ -568,6 +591,7 @@ const char kI2SAudio_Commands[] PROGMEM = "I2S|" #endif // USE_I2S_WEBRADIO #if defined(USE_SHINE) && ( (defined(USE_I2S_AUDIO) && defined(USE_I2S_MIC)) || defined(USE_M5STACK_CORE2) || defined(ESP32S3_BOX) ) "|REC" + "|MGain" #ifdef MP3_MIC_STREAM "|STREAM" #endif // MP3_MIC_STREAM @@ -587,6 +611,7 @@ void (* const I2SAudio_Command[])(void) PROGMEM = { #endif // USE_I2S_WEBRADIO #if defined(USE_SHINE) && ( (defined(USE_I2S_AUDIO) && defined(USE_I2S_MIC)) || defined(USE_M5STACK_CORE2) || defined(ESP32S3_BOX) ) ,&Cmd_MicRec + ,&Cmd_MicGain #ifdef MP3_MIC_STREAM ,&Cmd_MP3Stream #endif // MP3_MIC_STREAM diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_1_i2s_mp3mic.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_1_i2s_mp3mic.ino index 53550300c..d9ba85259 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_1_i2s_mp3mic.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_1_i2s_mp3mic.ino @@ -21,30 +21,36 @@ #ifdef ESP32 #if defined(USE_SHINE) && ( (defined(USE_I2S_AUDIO) && defined(USE_I2S_MIC)) || defined(USE_M5STACK_CORE2) || defined(ESP32S3_BOX) ) -#define MP3_BOUNDARY "e8b8c539-047d-4777-a985-fbba6edff11e" uint32_t SpeakerMic(uint8_t spkr) { esp_err_t err = ESP_OK; +#ifndef USE_I2S_COMMON_IO if (spkr == MODE_SPK) { - if (audio_i2s.mic_port == 0) { + if (audio_i2s.i2s_port == audio_i2s.mic_port) { + if (audio_i2s.mode != MODE_SPK) { + i2s_driver_uninstall(audio_i2s.mic_port); + } I2S_Init_0(); - audio_i2s.out->SetGain(((float)(audio_i2s.is2_volume-2)/100.0)*4.0); + audio_i2s.out->SetGain(((float)(audio_i2s.is2_volume - 2) / 100.0) * 4.0); audio_i2s.out->stop(); } + audio_i2s.mode = spkr; return 0; } // set micro - if (audio_i2s.mic_port == 0) { + if (audio_i2s.i2s_port == audio_i2s.mic_port) { // close audio out if (audio_i2s.out) { audio_i2s.out->stop(); delete audio_i2s.out; audio_i2s.out = nullptr; } - i2s_driver_uninstall(audio_i2s.i2s_port); + if (audio_i2s.mode == MODE_SPK) { + i2s_driver_uninstall(audio_i2s.i2s_port); + } } // config mic @@ -104,6 +110,10 @@ esp_err_t err = ESP_OK; } err += i2s_set_clk(audio_i2s.mic_port, audio_i2s.mic_rate, I2S_BITS_PER_SAMPLE_16BIT, mode); +#endif // USE_I2S_COMMON_IO + + audio_i2s.mode = spkr; + return err; } @@ -112,8 +122,6 @@ esp_err_t err = ESP_OK; #include #include -#define MP3HANDLECLIENT audio_i2s.MP3Server->handleClient(); - // micro to mp3 file or stream void mic_task(void *arg){ int8_t error = 0; @@ -144,7 +152,9 @@ void mic_task(void *arg){ audio_i2s.client.setTimeout(3); audio_i2s.client.print("HTTP/1.1 200 OK\r\n" "Content-Type: audio/mpeg;\r\n\r\n"); - MP3HANDLECLIENT + + // Webserver->send(200, "application/octet-stream", ""); + //"Content-Type: audio/mp3;\r\n\r\n"); } shine_set_config_mpeg_defaults(&config.mpeg); @@ -183,6 +193,13 @@ void mic_task(void *arg){ while (!audio_i2s.mic_stop) { uint32_t bytes_read; i2s_read(audio_i2s.mic_port, (char *)buffer, bytesize, &bytes_read, (100 / portTICK_RATE_MS)); + + if (audio_i2s.mic_gain > 1) { + // set gain + for (uint32_t cnt = 0; cnt < bytes_read / 2; cnt++) { + buffer[cnt] *= audio_i2s.mic_gain; + } + } ucp = shine_encode_buffer_interleaved(s, buffer, &written); if (!audio_i2s.use_stream) { @@ -192,7 +209,7 @@ void mic_task(void *arg){ } } else { audio_i2s.client.write((const char*)ucp, written); - MP3HANDLECLIENT + if (!audio_i2s.client.connected()) { break; } @@ -206,7 +223,6 @@ void mic_task(void *arg){ mp3_out.write(ucp, written); } else { audio_i2s.client.write((const char*)ucp, written); - MP3HANDLECLIENT } @@ -223,13 +239,12 @@ exit: if (audio_i2s.use_stream) { audio_i2s.client.stop(); - MP3HANDLECLIENT } SpeakerMic(MODE_SPK); audio_i2s.mic_stop = 0; audio_i2s.mic_error = error; - AddLog(LOG_LEVEL_INFO, PSTR("mp3task error: %d"), error); + AddLog(LOG_LEVEL_INFO, PSTR("mp3task result code: %d"), error); audio_i2s.mic_task_h = 0; audio_i2s.recdur = 0; audio_i2s.stream_active = 0; @@ -292,6 +307,14 @@ void Cmd_MicRec(void) { } +// mic gain in factor not percent +void Cmd_MicGain(void) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 256)) { + audio_i2s.mic_gain = XdrvMailbox.payload; + } + ResponseCmndNumber(audio_i2s.mic_gain); +} + #endif // USE_SHINE #endif // USE_I2S_AUDIO #endif // ESP32 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_2_i2s_mp3stream.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_2_i2s_mp3stream.ino index 72495edb9..af4a873bf 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_2_i2s_mp3stream.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_2_i2s_mp3stream.ino @@ -4,6 +4,11 @@ #ifdef MP3_MIC_STREAM +#ifndef MP3_STREAM_PORT +#define MP3_STREAM_PORT 81 +#endif + + void Stream_mp3(void) { if (!audio_i2s.stream_enable) { return; @@ -28,10 +33,11 @@ void i2s_mp3_loop(void) { void i2s_mp3_init(uint32_t on) { if (on) { if (!audio_i2s.MP3Server) { - audio_i2s.MP3Server = new ESP8266WebServer(81); + audio_i2s.MP3Server = new ESP8266WebServer(MP3_STREAM_PORT); audio_i2s.MP3Server->on(PSTR("/stream.mp3"), Stream_mp3); + audio_i2s.MP3Server->on(PSTR("/stream.m3a"), Stream_mp3); audio_i2s.MP3Server->begin(); - AddLog(LOG_LEVEL_INFO, PSTR("MP3: server created")); + AddLog(LOG_LEVEL_INFO, PSTR("MP3: server created on port: %d "), MP3_STREAM_PORT); } } else { if (audio_i2s.MP3Server) { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_s3box.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_codecs.ino similarity index 93% rename from tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_s3box.ino rename to tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_codecs.ino index 8bf927fc2..1b66edbf9 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_s3box.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_4_i2s_codecs.ino @@ -70,7 +70,6 @@ uint32_t es7243e_init() { return ret_val; } - // box adc init uint32_t es7210_init() { uint32_t ret_val = ESP_OK; @@ -124,7 +123,7 @@ uint32_t ES8311_init() { return ret_val; } -void S3boxInit() { +void S3boxInit(void) { if (TasmotaGlobal.i2c_enabled_2) { // box lite ES8156_init(); @@ -137,4 +136,20 @@ void S3boxInit() { } } #endif // ESP32S3_BOX + + +#ifdef USE_W8960 + +#include + +void W8960_Init(void) { + if (TasmotaGlobal.i2c_enabled_2) { + if (I2cSetDevice(W8960_ADDR, 1)) { + I2cSetActiveFound(W8960_ADDR, "W8960-I2C", 1); + W8960_Init(&Wire1); + } + } +} +#endif // USE_W8960 + #endif // ESP32 From 73a4174d4e4eef6844da6c1f14c5d8a7c346d270 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 8 Aug 2022 14:09:51 +0200 Subject: [PATCH 4/6] Update xdrv_42_0_i2s_audio.ino --- tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino index 935a95633..8c1259d0f 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio.ino @@ -308,7 +308,7 @@ int32_t I2S_Init_0(void) { audio_i2s.mode = MODE_SPK; -#idef USE_I2S_COMMON_IO +#ifdef USE_I2S_COMMON_IO audio_i2s.out->SetRate(MICSRATE); #endif From fdda6e6c2a4b344fbed8146a08000ed9e6386ff7 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 9 Aug 2022 08:02:53 +0200 Subject: [PATCH 5/6] move library --- lib/{lib_audio => libesp32_audio}/es7210/library.json | 0 .../es7210/library.properties | 0 lib/{lib_audio => libesp32_audio}/es7210/src/es7210.cpp | 4 ++-- lib/{lib_audio => libesp32_audio}/es7210/src/es7210.h | 0 lib/{lib_audio => libesp32_audio}/es7243e/library.json | 0 .../es7243e/library.properties | 0 lib/{lib_audio => libesp32_audio}/es7243e/src/es7243e.cpp | 0 lib/{lib_audio => libesp32_audio}/es7243e/src/es7243e.h | 0 lib/{lib_audio => libesp32_audio}/es8156/library.json | 0 .../es8156/library.properties | 0 lib/{lib_audio => libesp32_audio}/es8156/src/audio_hal.h | 0 lib/{lib_audio => libesp32_audio}/es8156/src/es8156.cpp | 0 lib/{lib_audio => libesp32_audio}/es8156/src/es8156.h | 0 .../es8156/src/esxxx_common.h | 0 lib/{lib_audio => libesp32_audio}/es8311/library.json | 0 .../es8311/library.properties | 0 lib/{lib_audio => libesp32_audio}/es8311/src/es8311.cpp | 0 lib/{lib_audio => libesp32_audio}/es8311/src/es8311.h | 0 lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/COPYING | 0 lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/LICENSE | 0 .../mp3_shine_esp32/README.md | 0 .../mp3_shine_esp32/changelog.txt | 0 .../mp3_shine_esp32/component.mk | 0 .../mp3_shine_esp32/library.json | 7 ++++--- .../mp3_shine_esp32/library.properties | 0 .../mp3_shine_esp32/src/bitstream.cpp | 1 - .../mp3_shine_esp32/src/bitstream.h | 0 .../mp3_shine_esp32/src/huffman.cpp | 0 .../mp3_shine_esp32/src/huffman.h | 0 .../mp3_shine_esp32/src/l3bitstream.cpp | 0 .../mp3_shine_esp32/src/l3bitstream.h | 0 .../mp3_shine_esp32/src/l3loop.cpp | 0 .../mp3_shine_esp32/src/l3loop.h | 0 .../mp3_shine_esp32/src/l3mdct.cpp | 0 .../mp3_shine_esp32/src/l3mdct.h | 0 .../mp3_shine_esp32/src/l3subband.cpp | 0 .../mp3_shine_esp32/src/l3subband.h | 0 .../mp3_shine_esp32/src/layer3.cpp | 0 .../mp3_shine_esp32/src/layer3.h | 0 .../mp3_shine_esp32/src/mult_mips_gcc.h | 0 .../mp3_shine_esp32/src/mult_noarch_gcc.h | 0 .../mp3_shine_esp32/src/mult_sarm_gcc.h | 0 .../mp3_shine_esp32/src/reservoir.cpp | 0 .../mp3_shine_esp32/src/reservoir.h | 0 .../mp3_shine_esp32/src/tables.cpp | 0 .../mp3_shine_esp32/src/tables.h | 0 .../mp3_shine_esp32/src/types.h | 0 lib/{lib_audio => libesp32_audio}/wm8960/library.json | 0 .../wm8960/library.properties | 0 lib/{lib_audio => libesp32_audio}/wm8960/src/wm8960.cpp | 0 lib/{lib_audio => libesp32_audio}/wm8960/src/wm8960.h | 0 51 files changed, 6 insertions(+), 6 deletions(-) rename lib/{lib_audio => libesp32_audio}/es7210/library.json (100%) rename lib/{lib_audio => libesp32_audio}/es7210/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/es7210/src/es7210.cpp (99%) rename lib/{lib_audio => libesp32_audio}/es7210/src/es7210.h (100%) rename lib/{lib_audio => libesp32_audio}/es7243e/library.json (100%) rename lib/{lib_audio => libesp32_audio}/es7243e/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/es7243e/src/es7243e.cpp (100%) rename lib/{lib_audio => libesp32_audio}/es7243e/src/es7243e.h (100%) rename lib/{lib_audio => libesp32_audio}/es8156/library.json (100%) rename lib/{lib_audio => libesp32_audio}/es8156/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/es8156/src/audio_hal.h (100%) rename lib/{lib_audio => libesp32_audio}/es8156/src/es8156.cpp (100%) rename lib/{lib_audio => libesp32_audio}/es8156/src/es8156.h (100%) rename lib/{lib_audio => libesp32_audio}/es8156/src/esxxx_common.h (100%) rename lib/{lib_audio => libesp32_audio}/es8311/library.json (100%) rename lib/{lib_audio => libesp32_audio}/es8311/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/es8311/src/es8311.cpp (100%) rename lib/{lib_audio => libesp32_audio}/es8311/src/es8311.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/COPYING (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/LICENSE (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/README.md (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/changelog.txt (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/component.mk (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/library.json (50%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/bitstream.cpp (99%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/bitstream.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/huffman.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/huffman.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3bitstream.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3bitstream.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3loop.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3loop.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3mdct.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3mdct.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3subband.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/l3subband.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/layer3.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/layer3.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/mult_mips_gcc.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/mult_noarch_gcc.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/mult_sarm_gcc.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/reservoir.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/reservoir.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/tables.cpp (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/tables.h (100%) rename lib/{lib_audio => libesp32_audio}/mp3_shine_esp32/src/types.h (100%) rename lib/{lib_audio => libesp32_audio}/wm8960/library.json (100%) rename lib/{lib_audio => libesp32_audio}/wm8960/library.properties (100%) rename lib/{lib_audio => libesp32_audio}/wm8960/src/wm8960.cpp (100%) rename lib/{lib_audio => libesp32_audio}/wm8960/src/wm8960.h (100%) diff --git a/lib/lib_audio/es7210/library.json b/lib/libesp32_audio/es7210/library.json similarity index 100% rename from lib/lib_audio/es7210/library.json rename to lib/libesp32_audio/es7210/library.json diff --git a/lib/lib_audio/es7210/library.properties b/lib/libesp32_audio/es7210/library.properties similarity index 100% rename from lib/lib_audio/es7210/library.properties rename to lib/libesp32_audio/es7210/library.properties diff --git a/lib/lib_audio/es7210/src/es7210.cpp b/lib/libesp32_audio/es7210/src/es7210.cpp similarity index 99% rename from lib/lib_audio/es7210/src/es7210.cpp rename to lib/libesp32_audio/es7210/src/es7210.cpp index 3bf680308..65b2c0cb7 100644 --- a/lib/lib_audio/es7210/src/es7210.cpp +++ b/lib/libesp32_audio/es7210/src/es7210.cpp @@ -45,7 +45,7 @@ static es7210_gain_value_t gain; /* * Clock coefficient structer */ -struct _coeff_div { +struct _coeff_div_es7210 { uint32_t mclk; /* mclk frequency */ uint32_t lrck; /* lrck */ uint8_t ss_ds; @@ -75,7 +75,7 @@ static es7210_input_mics_t mic_select = (es7210_input_mics_t)(ES7210_INPUT_MIC1 * lrckh: 0x04 * lrckl: 0x05 */ -static const struct _coeff_div coeff_div[] = { +static const struct _coeff_div_es7210 coeff_div[] = { //mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl /* 8k */ {12288000, 8000 , 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00}, diff --git a/lib/lib_audio/es7210/src/es7210.h b/lib/libesp32_audio/es7210/src/es7210.h similarity index 100% rename from lib/lib_audio/es7210/src/es7210.h rename to lib/libesp32_audio/es7210/src/es7210.h diff --git a/lib/lib_audio/es7243e/library.json b/lib/libesp32_audio/es7243e/library.json similarity index 100% rename from lib/lib_audio/es7243e/library.json rename to lib/libesp32_audio/es7243e/library.json diff --git a/lib/lib_audio/es7243e/library.properties b/lib/libesp32_audio/es7243e/library.properties similarity index 100% rename from lib/lib_audio/es7243e/library.properties rename to lib/libesp32_audio/es7243e/library.properties diff --git a/lib/lib_audio/es7243e/src/es7243e.cpp b/lib/libesp32_audio/es7243e/src/es7243e.cpp similarity index 100% rename from lib/lib_audio/es7243e/src/es7243e.cpp rename to lib/libesp32_audio/es7243e/src/es7243e.cpp diff --git a/lib/lib_audio/es7243e/src/es7243e.h b/lib/libesp32_audio/es7243e/src/es7243e.h similarity index 100% rename from lib/lib_audio/es7243e/src/es7243e.h rename to lib/libesp32_audio/es7243e/src/es7243e.h diff --git a/lib/lib_audio/es8156/library.json b/lib/libesp32_audio/es8156/library.json similarity index 100% rename from lib/lib_audio/es8156/library.json rename to lib/libesp32_audio/es8156/library.json diff --git a/lib/lib_audio/es8156/library.properties b/lib/libesp32_audio/es8156/library.properties similarity index 100% rename from lib/lib_audio/es8156/library.properties rename to lib/libesp32_audio/es8156/library.properties diff --git a/lib/lib_audio/es8156/src/audio_hal.h b/lib/libesp32_audio/es8156/src/audio_hal.h similarity index 100% rename from lib/lib_audio/es8156/src/audio_hal.h rename to lib/libesp32_audio/es8156/src/audio_hal.h diff --git a/lib/lib_audio/es8156/src/es8156.cpp b/lib/libesp32_audio/es8156/src/es8156.cpp similarity index 100% rename from lib/lib_audio/es8156/src/es8156.cpp rename to lib/libesp32_audio/es8156/src/es8156.cpp diff --git a/lib/lib_audio/es8156/src/es8156.h b/lib/libesp32_audio/es8156/src/es8156.h similarity index 100% rename from lib/lib_audio/es8156/src/es8156.h rename to lib/libesp32_audio/es8156/src/es8156.h diff --git a/lib/lib_audio/es8156/src/esxxx_common.h b/lib/libesp32_audio/es8156/src/esxxx_common.h similarity index 100% rename from lib/lib_audio/es8156/src/esxxx_common.h rename to lib/libesp32_audio/es8156/src/esxxx_common.h diff --git a/lib/lib_audio/es8311/library.json b/lib/libesp32_audio/es8311/library.json similarity index 100% rename from lib/lib_audio/es8311/library.json rename to lib/libesp32_audio/es8311/library.json diff --git a/lib/lib_audio/es8311/library.properties b/lib/libesp32_audio/es8311/library.properties similarity index 100% rename from lib/lib_audio/es8311/library.properties rename to lib/libesp32_audio/es8311/library.properties diff --git a/lib/lib_audio/es8311/src/es8311.cpp b/lib/libesp32_audio/es8311/src/es8311.cpp similarity index 100% rename from lib/lib_audio/es8311/src/es8311.cpp rename to lib/libesp32_audio/es8311/src/es8311.cpp diff --git a/lib/lib_audio/es8311/src/es8311.h b/lib/libesp32_audio/es8311/src/es8311.h similarity index 100% rename from lib/lib_audio/es8311/src/es8311.h rename to lib/libesp32_audio/es8311/src/es8311.h diff --git a/lib/lib_audio/mp3_shine_esp32/COPYING b/lib/libesp32_audio/mp3_shine_esp32/COPYING similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/COPYING rename to lib/libesp32_audio/mp3_shine_esp32/COPYING diff --git a/lib/lib_audio/mp3_shine_esp32/LICENSE b/lib/libesp32_audio/mp3_shine_esp32/LICENSE similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/LICENSE rename to lib/libesp32_audio/mp3_shine_esp32/LICENSE diff --git a/lib/lib_audio/mp3_shine_esp32/README.md b/lib/libesp32_audio/mp3_shine_esp32/README.md similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/README.md rename to lib/libesp32_audio/mp3_shine_esp32/README.md diff --git a/lib/lib_audio/mp3_shine_esp32/changelog.txt b/lib/libesp32_audio/mp3_shine_esp32/changelog.txt similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/changelog.txt rename to lib/libesp32_audio/mp3_shine_esp32/changelog.txt diff --git a/lib/lib_audio/mp3_shine_esp32/component.mk b/lib/libesp32_audio/mp3_shine_esp32/component.mk similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/component.mk rename to lib/libesp32_audio/mp3_shine_esp32/component.mk diff --git a/lib/lib_audio/mp3_shine_esp32/library.json b/lib/libesp32_audio/mp3_shine_esp32/library.json similarity index 50% rename from lib/lib_audio/mp3_shine_esp32/library.json rename to lib/libesp32_audio/mp3_shine_esp32/library.json index d7de5755a..f73928c85 100644 --- a/lib/lib_audio/mp3_shine_esp32/library.json +++ b/lib/libesp32_audio/mp3_shine_esp32/library.json @@ -1,7 +1,8 @@ { - "name": "mp3_shine_esp32", + "name":"mp3_shine_esp32", + "version": "1.0.0", "description": "mp3 encoder", "keywords": "ESP32, MP3", - "version": "1.0.0", - "frameworks": "Arduino" + "frameworks": "Arduino", + "platforms": "espressif32" } diff --git a/lib/lib_audio/mp3_shine_esp32/library.properties b/lib/libesp32_audio/mp3_shine_esp32/library.properties similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/library.properties rename to lib/libesp32_audio/mp3_shine_esp32/library.properties diff --git a/lib/lib_audio/mp3_shine_esp32/src/bitstream.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/bitstream.cpp similarity index 99% rename from lib/lib_audio/mp3_shine_esp32/src/bitstream.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/bitstream.cpp index 866e94704..81b6d3b98 100755 --- a/lib/lib_audio/mp3_shine_esp32/src/bitstream.cpp +++ b/lib/libesp32_audio/mp3_shine_esp32/src/bitstream.cpp @@ -9,7 +9,6 @@ #include "types.h" #include "bitstream.h" - #if !defined(__APPLE__) && !defined(__FreeBSD__) #include #endif diff --git a/lib/lib_audio/mp3_shine_esp32/src/bitstream.h b/lib/libesp32_audio/mp3_shine_esp32/src/bitstream.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/bitstream.h rename to lib/libesp32_audio/mp3_shine_esp32/src/bitstream.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/huffman.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/huffman.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/huffman.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/huffman.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/huffman.h b/lib/libesp32_audio/mp3_shine_esp32/src/huffman.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/huffman.h rename to lib/libesp32_audio/mp3_shine_esp32/src/huffman.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3bitstream.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/l3bitstream.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3bitstream.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/l3bitstream.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3bitstream.h b/lib/libesp32_audio/mp3_shine_esp32/src/l3bitstream.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3bitstream.h rename to lib/libesp32_audio/mp3_shine_esp32/src/l3bitstream.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3loop.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/l3loop.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3loop.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/l3loop.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3loop.h b/lib/libesp32_audio/mp3_shine_esp32/src/l3loop.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3loop.h rename to lib/libesp32_audio/mp3_shine_esp32/src/l3loop.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3mdct.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/l3mdct.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3mdct.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/l3mdct.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3mdct.h b/lib/libesp32_audio/mp3_shine_esp32/src/l3mdct.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3mdct.h rename to lib/libesp32_audio/mp3_shine_esp32/src/l3mdct.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3subband.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/l3subband.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3subband.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/l3subband.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/l3subband.h b/lib/libesp32_audio/mp3_shine_esp32/src/l3subband.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/l3subband.h rename to lib/libesp32_audio/mp3_shine_esp32/src/l3subband.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/layer3.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/layer3.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/layer3.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/layer3.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/layer3.h b/lib/libesp32_audio/mp3_shine_esp32/src/layer3.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/layer3.h rename to lib/libesp32_audio/mp3_shine_esp32/src/layer3.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/mult_mips_gcc.h b/lib/libesp32_audio/mp3_shine_esp32/src/mult_mips_gcc.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/mult_mips_gcc.h rename to lib/libesp32_audio/mp3_shine_esp32/src/mult_mips_gcc.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/mult_noarch_gcc.h b/lib/libesp32_audio/mp3_shine_esp32/src/mult_noarch_gcc.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/mult_noarch_gcc.h rename to lib/libesp32_audio/mp3_shine_esp32/src/mult_noarch_gcc.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/mult_sarm_gcc.h b/lib/libesp32_audio/mp3_shine_esp32/src/mult_sarm_gcc.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/mult_sarm_gcc.h rename to lib/libesp32_audio/mp3_shine_esp32/src/mult_sarm_gcc.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/reservoir.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/reservoir.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/reservoir.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/reservoir.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/reservoir.h b/lib/libesp32_audio/mp3_shine_esp32/src/reservoir.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/reservoir.h rename to lib/libesp32_audio/mp3_shine_esp32/src/reservoir.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/tables.cpp b/lib/libesp32_audio/mp3_shine_esp32/src/tables.cpp similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/tables.cpp rename to lib/libesp32_audio/mp3_shine_esp32/src/tables.cpp diff --git a/lib/lib_audio/mp3_shine_esp32/src/tables.h b/lib/libesp32_audio/mp3_shine_esp32/src/tables.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/tables.h rename to lib/libesp32_audio/mp3_shine_esp32/src/tables.h diff --git a/lib/lib_audio/mp3_shine_esp32/src/types.h b/lib/libesp32_audio/mp3_shine_esp32/src/types.h similarity index 100% rename from lib/lib_audio/mp3_shine_esp32/src/types.h rename to lib/libesp32_audio/mp3_shine_esp32/src/types.h diff --git a/lib/lib_audio/wm8960/library.json b/lib/libesp32_audio/wm8960/library.json similarity index 100% rename from lib/lib_audio/wm8960/library.json rename to lib/libesp32_audio/wm8960/library.json diff --git a/lib/lib_audio/wm8960/library.properties b/lib/libesp32_audio/wm8960/library.properties similarity index 100% rename from lib/lib_audio/wm8960/library.properties rename to lib/libesp32_audio/wm8960/library.properties diff --git a/lib/lib_audio/wm8960/src/wm8960.cpp b/lib/libesp32_audio/wm8960/src/wm8960.cpp similarity index 100% rename from lib/lib_audio/wm8960/src/wm8960.cpp rename to lib/libesp32_audio/wm8960/src/wm8960.cpp diff --git a/lib/lib_audio/wm8960/src/wm8960.h b/lib/libesp32_audio/wm8960/src/wm8960.h similarity index 100% rename from lib/lib_audio/wm8960/src/wm8960.h rename to lib/libesp32_audio/wm8960/src/wm8960.h From de84f3a2151f6ff2bee4e0ddc4f7be0895463e88 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 9 Aug 2022 08:05:05 +0200 Subject: [PATCH 6/6] Update platformio_tasmota_env32.ini --- platformio_tasmota_env32.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 44c5de0df..d8e90f58c 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -18,6 +18,7 @@ lib_extra_dirs = ${common.lib_extra_dirs} lib/libesp32_lvgl lib/libesp32_div lib/libesp32_eink + lib/libesp32_audio lib_ignore = HTTPUpdateServer ESP RainMaker