earlephilhower / ESP8266Audio

Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
GNU General Public License v3.0
2.03k stars 432 forks source link

Add MCLK output for ESP32-S3 #592

Closed DatanoiseTV closed 1 year ago

DatanoiseTV commented 1 year ago
    i2s_pin_config_t pins = {
        .mck_io_num = 18, // MCLK
        .bck_io_num = bclkPin,
        .ws_io_num = wclkPin,
        .data_out_num = doutPin,
        .data_in_num = I2S_PIN_NO_CHANGE};
    i2s_set_pin((i2s_port_t)portNo, &pins);
      i2s_config_t i2s_config_dac = {
          .mode = mode,
          .sample_rate = 44100,
          .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
          .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
          .communication_format = comm_fmt,
          .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
          .dma_buf_count = dma_buf_count,
          .dma_buf_len = 128,
          .use_apll = use_apll, // Use audio PLL
          .tx_desc_auto_clear = true, // Silence on underflow
          .fixed_mclk = 1, // constant MCLK
          .mclk_multiple = I2S_MCLK_MULTIPLE_256, // fs*256
          .bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT // Use bits per sample
      };
earlephilhower commented 1 year ago

Would you like to do a PR? You may need to add #ifdefs around things since the Espressif SDK seems to play with the I2S structs frequently, and the different boards all seem to have different I2S structs/capabilities.

DatanoiseTV commented 1 year ago

PR: https://github.com/earlephilhower/ESP8266Audio/pull/594