InternalAudioSink.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include "InternalAudioSink.h"
  2. #include "driver/i2s.h"
  3. InternalAudioSink::InternalAudioSink()
  4. {
  5. softwareVolumeControl = true;
  6. usign = true;
  7. #ifdef I2S_MODE_DAC_BUILT_IN
  8. i2s_config_t i2s_config = {
  9. .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | 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. };
  21. //install and start i2s driver
  22. i2s_driver_install((i2s_port_t)0, &i2s_config, 0, NULL);
  23. //init DAC
  24. i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
  25. #endif
  26. startI2sFeed();
  27. }
  28. InternalAudioSink::~InternalAudioSink()
  29. {
  30. }