Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAC audio playback broken in ESP-IDF 4.4 (works in 4.3) (IDFGH-7160) #8634

Closed
phoddie opened this issue Mar 23, 2022 · 4 comments
Closed

DAC audio playback broken in ESP-IDF 4.4 (works in 4.3) (IDFGH-7160) #8634

phoddie opened this issue Mar 23, 2022 · 4 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@phoddie
Copy link
Contributor

phoddie commented Mar 23, 2022

Environment

  • Development Kit: M5Stack
  • Module or chip used: ESP32
  • IDF version: v4.4
  • Build System: CMake
  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2) 8.4.0
  • Operating System: macOS
  • Using an IDE?: No

Problem Description

Audio playback using i2s_ API to DAC fails:

  • The same code works under ESP-IDF 4.3
  • No errors are reported by the i2s_* calls
  • The I2s_write calls return nearly immediately. For example, about 1000 ms of 16-bit 11 kHz mono data is accepted by is2_write in about 50 ms. This suggests that the audio data is not being correctly queued by the driver. When it works correctly, the i2s_write calls are roughly evenly spaced across the one second interval.

The implementation used is in the Moddable SDK audio output module.

Code to reproduce this issue

Summary of implementation:

	i2s_config_t i2s_config = {
		.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
		.sample_rate = 11025,
		.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
		.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
		.communication_format = I2S_COMM_FORMAT_STAND_I2S,
		.intr_alloc_flags = 0,
		.dma_buf_count = 2,
		.dma_buf_len = 1024,
		.use_apll = false
	};
	i2s_driver_install(0, &i2s_config, 0, NULL);
	i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);

	while (moreAudioToPlay)
		i2s_write(0, buffer, 4096, &bytes_written, portMAX_DELAY);

Other information

We first became aware of this issue when reported against the Moddable SDK (#881). There is a report (#6470) of ADC output being broken in ESP-IDF v4.1, but this is not the issue we have (our code works with ESP-IDF v4.3). That report has a comment which mentions ADC audio is broken on ESP-IDF v4.4 also.

@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 12, 2022
@github-actions github-actions bot changed the title DAC audio playback broken in ESP-IDF 4.4 (works in 4.3) DAC audio playback broken in ESP-IDF 4.4 (works in 4.3) (IDFGH-7160) Apr 12, 2022
@L-KAYA
Copy link
Collaborator

L-KAYA commented Apr 12, 2022

As mentioned in No AudioOut sounds with ESP-IDF v4.4

  1. Checkout to the latest release/v4.4 branch;
  2. Set communication_format to I2S_COMM_FORMAT_STAND_MSB;
  3. For stereo case, set channel_format to I2S_CHANNEL_FMT_RIGHT_LEFT and for mono case, set channel_format to I2S_CHANNEL_FMT_ONLY_RIGHT or I2S_CHANNEL_FMT_ONLY_LEFT

@phoddie
Copy link
Contributor Author

phoddie commented Apr 12, 2022

It looks like the ESP-IDF v4.4 changes for analog audio did break the Moddable SDK. Following the advice above, we have it working again. Thank you!

@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting and sharing the updates, good to hear it working again, feel free to reopen.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: Opened Issue is new labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants