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

Problems with using examples\recorder\pipeline_recording_to_sdcard (AUD-5609) #1246

Open
Szeroy opened this issue Aug 11, 2024 · 1 comment

Comments

@Szeroy
Copy link

Szeroy commented Aug 11, 2024

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.

audio_element_handle_t i2s_stream_init(i2s_stream_cfg_t *config)
{
    audio_element_cfg_t cfg = DEFAULT_AUDIO_ELEMENT_CONFIG();
    audio_element_handle_t el;
    cfg.open = _i2s_open;
    cfg.close = _i2s_close;
    cfg.process = _i2s_process;
    cfg.destroy = _i2s_destroy;
    cfg.task_stack = config->task_stack;
    cfg.task_prio = config->task_prio;
    cfg.task_core = config->task_core;
    cfg.stack_in_ext = config->stack_in_ext;
    cfg.out_rb_size = config->out_rb_size;
    cfg.multi_out_rb_num = config->multi_out_num;
    cfg.tag = "iis";
    cfg.buffer_len = config->buffer_len;
@github-actions github-actions bot changed the title Problems with using examples\recorder\pipeline_recording_to_sdcard Problems with using examples\recorder\pipeline_recording_to_sdcard (AUD-5609) Aug 11, 2024
@hbler99
Copy link

hbler99 commented Aug 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants