InternalAudioSink.cpp 1010 B

1234567891011121314151617181920212223242526272829303132
  1. #include "InternalAudioSink.h"
  2. #include "driver/i2s.h"
  3. InternalAudioSink::InternalAudioSink() {
  4. softwareVolumeControl = true;
  5. usign = true;
  6. #ifdef I2S_MODE_DAC_BUILT_IN
  7. i2s_config_t i2s_config = {
  8. .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX |
  9. I2S_MODE_DAC_BUILT_IN), // Only TX
  10. .sample_rate = (i2s_bits_per_sample_t)44100,
  11. .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
  12. .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
  13. .communication_format = (i2s_comm_format_t)I2S_COMM_FORMAT_STAND_I2S,
  14. .intr_alloc_flags = 0, //ESP_INTR_FLAG_LEVEL1
  15. .dma_buf_count = 6,
  16. .dma_buf_len = 512,
  17. .use_apll = true,
  18. .tx_desc_auto_clear = true, //Auto clear tx descriptor on underflow
  19. .fixed_mclk = -1};
  20. //install and start i2s driver
  21. i2s_driver_install((i2s_port_t)0, &i2s_config, 0, NULL);
  22. //init DAC
  23. i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
  24. #endif
  25. startI2sFeed();
  26. }
  27. InternalAudioSink::~InternalAudioSink() {}