Open Szeroy opened 1 month ago
It's recommended to utilize the read/write callback function which perform as out/in way for each element. For example:
audio_element_set_write_cb(i2s_writer_el, i2s_write_cb, (void *)Input_file);
audio_element_set_read_cb(i2s_reader_el, i2s_read_cb, (void *)Output_file);
static int i2s_write_cb(audio_element_handle_t self, char *buffer, int len, TickType_t ticks_to_wait, void *context)
{
memcpy(buffer, YOUR CONTENT, LEN);
}
static int i2s_read_cb(audio_element_handle_t self, char *buffer, int len, TickType_t ticks_to_wait, void *context)
{
memcpy(YOUR NEED CONTENT, buffer, LEN);
}
The other method is to use a ring buffer to read/write data. Please refer to examples/recorder/element_cb_sdcard_amr for more details.
I want to use a routine to read data from digital microphone and save it to sd card, but the routine uses chip reading microphone inside, my current microphone is directly i2s directly read 24bit raw data, how should I modify it? I see that the initialization inside the direct call is the component's function to read, do not know how I should write my own read function put in. This is a function inside the routine,I see that there are many parameters in the structure i2s_stream_cfg_t , I am not clear how to modify it.Pass on the data I've read myself.