1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef FEEDBACK_H_ 8 #define FEEDBACK_H_ 9 10 #include <stdint.h> 11 12 /* This sample is currently supporting only 48 kHz sample rate. */ 13 #define SAMPLE_RATE 48000 14 15 struct feedback_ctx *feedback_init(void); 16 void feedback_reset_ctx(struct feedback_ctx *ctx); 17 void feedback_process(struct feedback_ctx *ctx); 18 void feedback_start(struct feedback_ctx *ctx, int i2s_blocks_queued, 19 bool microframes); 20 21 /* Return offset between I2S block start and USB SOF in samples. 22 * 23 * Positive offset means that I2S block started at least 1 sample after SOF and 24 * to correct the situation, shorter than nominal buffers are needed. 25 * 26 * Negative offset means that I2S block started at least 1 sample before SOF and 27 * to correct the situation, larger than nominal buffers are needed. 28 * 29 * Offset 0 means that I2S block started within 1 sample around SOF. This is the 30 * dominant value expected during normal operation. 31 */ 32 int feedback_samples_offset(struct feedback_ctx *ctx); 33 34 #endif /* FEEDBACK_H_ */ 35