Do you have config files for Esp32 to be used as a USB to I2s transport ? I want to check what the output is .
The code that allows the use of esp32 with dir9001 has been uploaded to GitHub. You can replace dir9001 with another i2s source that transmits data at 44.1 kHz 24 or 32 bits. If your source is 44.1kHz 24 /32 bits you can directly replace dir9001 and it will work without any changes to the code.
I forgot, your source should be (Master), it should generate the clocks. MCLK is not needed in the current configuration. This code will allow you to implement biquad iir filters. I only use it for system EQ instead of the expensive MiniDSP. The project I am currently developing and about to upload to GitHub is based on this one but, esp32 has been replaced with esp32s3 which supports SIMD instructions and handles FIR filters better. 3 esp32s3 have been added to handle FIR filters and simulate a three-way crossover.
what do you think , will this work :
#include "usb_host.h"
#include "driver/i2s.h"
void app_main(void) {
// Initialize USB Host
usb_host_init();
// Configure I2S
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX,
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 64,
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_BCK_PIN,
.ws_io_num = I2S_WS_PIN,
.data_out_num = I2S_DO_PIN,
.data_in_num = I2S_PIN_NO_CHANGE
};
i2s_set_pin(I2S_NUM_0, &pin_config);
// Transfer data from USB to I2S
while (1) {
uint8_t usb_data[128];
size_t bytes_read;
usb_host_read(usb_data, sizeof(usb_data), &bytes_read);
i2s_write(I2S_NUM_0, usb_data, bytes_read, &bytes_read, portMAX_DELAY);
}
}
#include "usb_host.h"
#include "driver/i2s.h"
void app_main(void) {
// Initialize USB Host
usb_host_init();
// Configure I2S
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX,
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 64,
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_BCK_PIN,
.ws_io_num = I2S_WS_PIN,
.data_out_num = I2S_DO_PIN,
.data_in_num = I2S_PIN_NO_CHANGE
};
i2s_set_pin(I2S_NUM_0, &pin_config);
// Transfer data from USB to I2S
while (1) {
uint8_t usb_data[128];
size_t bytes_read;
usb_host_read(usb_data, sizeof(usb_data), &bytes_read);
i2s_write(I2S_NUM_0, usb_data, bytes_read, &bytes_read, portMAX_DELAY);
}
}
Interesting, from the code I understand that you want to send audio data from a computer to the esp32 via the esp's USB controller? If so, you need to make sure that the data received from the usb is sampled, properly aligned and normalized before sending it to i2s for writing. Otherwise I don't see any reason why it wouldn't work if you send the samples correctly.
Exactly my idea is to use the ESP as a transport and of course Bluetooth, but let`s start testing first with the USB . What happened with the output noise , have you been able to remove it ?
It seems that USB won't work. You can use an external USB audio decoder (for example PCM2704, PCM2902 or ES9018K2M with USB interface) that accepts USB audio and outputs an I2S signal. Another option is to use my ready-made Bluetooth example.
The standard ESP32 (and ESP32-S2) does not have a USB Host, only USB-to-Serial for flashing and debugging.
This means that you cannot directly connect a USB audio device (such as a USB DAC or USB microphone) to it.
This means that you cannot directly connect a USB audio device (such as a USB DAC or USB microphone) to it.
I just separated the power supplies of the DACs and the ESP32S3 and the annoying noise disappeared. I'm not good at this and I can't describe the sound, but what I notice is that it doesn't seem to come out of the speakers but is reproduced in front of them. I can clearly hear details that were very blurred before. This is probably due to the phase linearity, I have set the FIR filters to the same length so that they have the same delay. I have a lot of experiments ahead with EQ and Fir filters.
- Home
- Source & Line
- Digital Line Level
- Esp32_DSP