We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
你好,在最终写入I2S设备的数据中,为什么要这样处理? 我的理解是,发送方采集128个数据转换成16bit,然后再转换成8bit,通过UDP或者ESP-NOW传输到接收方,接收方将128个8位数据经过如下处理写入到I2S设备中,但是我不理解为什么要经过这样的处理,这样处理完之后,最终写入到ESP32的数据是多少个?
void Output::write(int16_t *samples, int count) { int sample_index = 0; while (sample_index < count) { int samples_to_send = 0; for (int i = 0; i < NUM_FRAMES_TO_SEND && sample_index < count; i++) { int sample = process_sample(samples[sample_index]); m_frames[i * 2] = sample; // left channel m_frames[i * 2 + 1] = sample; // right channel samples_to_send++; sample_index++; } // write data to the i2s peripheral size_t bytes_written = 0; i2s_write(m_i2s_port, m_frames, samples_to_send * sizeof(int16_t) * 2, &bytes_written, portMAX_DELAY); if (bytes_written != samples_to_send * sizeof(int16_t) * 2) { ESP_LOGE(TAG, "Did not write all bytes"); } } }
The text was updated successfully, but these errors were encountered:
虽然我不知道你还有没有这个问题但是答案其实还是很简单的,这跟I2S这个协议的双通道相关,因为一些厂家想要搞扬声器放大器的时候贪图简单所以并不会给你选择使用右通道还是左通道的机会,他们会直接把两个通道的数据相加然后除以二,所以为了适配这些板子才需要搞这个左右通道。 你仔细看的话作者其实吧同一份数据复制了两遍然后发出的。
Sorry, something went wrong.
No branches or pull requests
你好,在最终写入I2S设备的数据中,为什么要这样处理?
我的理解是,发送方采集128个数据转换成16bit,然后再转换成8bit,通过UDP或者ESP-NOW传输到接收方,接收方将128个8位数据经过如下处理写入到I2S设备中,但是我不理解为什么要经过这样的处理,这样处理完之后,最终写入到ESP32的数据是多少个?
void Output::write(int16_t *samples, int count) { int sample_index = 0; while (sample_index < count) { int samples_to_send = 0; for (int i = 0; i < NUM_FRAMES_TO_SEND && sample_index < count; i++) { int sample = process_sample(samples[sample_index]); m_frames[i * 2] = sample; // left channel m_frames[i * 2 + 1] = sample; // right channel samples_to_send++; sample_index++; } // write data to the i2s peripheral size_t bytes_written = 0; i2s_write(m_i2s_port, m_frames, samples_to_send * sizeof(int16_t) * 2, &bytes_written, portMAX_DELAY); if (bytes_written != samples_to_send * sizeof(int16_t) * 2) { ESP_LOGE(TAG, "Did not write all bytes"); } } }
The text was updated successfully, but these errors were encountered: