L/R: Left/Right channel select. Determines whether the device outputs data on the left or right channel.
How to do this?
L/R: Left/Right channel select. Determines whether the device outputs data on the left or right channel.
How to do this?
If you are using a 1CH relay module : G-SENSE : ICS-43434 MEMS High Precision Omnidirectional Microphone I2S - pcbcupid . You have a dedicated L/R pin to control the LEFT & RIGHT channel of the Audio
As for the 2CH relay module : G-SENSE : ICS-43434 2CH MEMS High Precision Omnidirectional Microphone I2S - pcbcupid . You need to control that on the Arduino code.
Best way to get started would be the example code : 2-CH I2S MIC | PCBCUPID (And just init the Audio info with 1 CH)
AudioInfo info(44100, 1, 32);
This code relies on Arduino-Audio-tools library, you can go through the wiki/examples to get an idea on how the library works : Home ยท pschatzmann/arduino-audio-tools Wiki ยท GitHub
#include <WiFi.h>
#include <WiFiUdp.h>
#include <driver/i2s.h>
const char* ssid = "Vivek";
const char* password = "Kumar";
const char* udpAddress = "192.168.68.106"; // <-- IP of your PC
const int udpPort = 3000;
const int sample_rate = 16000;
const int i2s_read_len = 512; // Safe packet size for Windows UDP
uint8_t buffer[i2s_read_len];
// ---------- WiFi ----------
WiFiUDP udp;
void setupWiFi() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected. IP: " + WiFi.localIP().toString());
}
// ---------- I2S ----------
void setupI2SMic() {
const i2s_config_t i2s_config = {
.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = sample_rate,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_STAND_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 1024,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};
const i2s_pin_config_t pin_config = {
.bck_io_num = 18,
.ws_io_num = 20,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = 19
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM_0, &pin_config);
i2s_zero_dma_buffer(I2S_NUM_0);
}
// ---------- SETUP ----------
void setup() {
Serial.begin(115200);
setupWiFi();
setupI2SMic();
}
// ---------- LOOP ----------
void loop() {
size_t bytes_read = 0;
esp_err_t result = i2s_read(I2S_NUM_0, buffer, i2s_read_len, &bytes_read, portMAX_DELAY);
if (result == ESP_OK && bytes_read > 0) {
udp.beginPacket(udpAddress, udpPort);
udp.write(buffer, bytes_read);
udp.endPacket();
}
}
ffplay -f f32le -ar 16000 -ac 1 udp://@192.168.68.105:3000
ffmpeg -f f32le -ar 16000 -ac 1 -t 180 -i udp://0.0.0.0:3000 recorded_audio.wav
ffplay -f f32le -ar 16000 -ac 1 udp://@0.0.0.0:3000
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://0.0.0.0:3000
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://127.0.0.1:3000
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://0.0.0.0:3000 -af "lowpass=f=4000,highpass=f=100,volume=1.5"
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://127.0.0.1:3000 -af "lowpass=f=4000,highpass=f=100,volume=1.5"
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://0.0.0.0:3000 -af "afftdn"
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://0.0.0.0:3000 -af "highpass=f=100,lowpass=f=4000,afftdn"
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://127.0.0.1:3000 -af "afftdn"
ffplay -fflags nobuffer -f s32le -ac 2 -ar 16000 -i udp://127.0.0.1:3000 -af "highpass=f=100,lowpass=f=4000,afftdn"
ffmpeg -f s16le -ac 1 -ar 16000 -i udp://0.0.0.0:3000 -t 30 -acodec pcm_s16le esp32_audio.wav
ffmpeg -f dshow -i udp://0.0.0.0:3000 -filter_complex "showwaves=s=640x120:mode=line" -f sdl "Live Audio Waveform"
ffmpeg -f s32le -ar 16000 -ac 2 -i udp://0.0.0.0:3000 -f s16le -ar 16000 -ac 2 - | ffplay -f s16le -ar 16000 -ac 2 -
Edited the reply : Fixed the broken link for linkedin post!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.