Skip to content

Commit 388502f

Browse files
lrgirdwoclaude
andcommitted
audio: refine multi-slot WOV detector linkage and trigger stability
- Retrieve exact downstream WOV detector via comp_buffer_get_sink_component(sink) in kpb_copy(). - Broadcast RESUME on wov_arbiter prepare so all detector slots start active. - Map IPC4 pipeline IDs 101/102/103 to slot IDs 0/1/2 in detect_test. - Require 30ms sustained frequency match (consec_match_count >= 3) and energy > 500 to filter out ambient room noise transients. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d56f4c commit 388502f

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/audio/kpb.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,14 +1375,13 @@ static int kpb_copy(struct comp_dev *dev)
13751375
else
13761376
comp_update_buffer_produce(sink, produced_bytes);
13771377

1378-
uint32_t ppl_id = dev->pipeline ? dev->pipeline->pipeline_id : (dev_comp_id(dev) >> 16);
1379-
struct comp_dev *wov_comp = get_wov_detector_comp(ppl_id);
1378+
struct comp_dev *wov_comp = sink ? comp_buffer_get_sink_component(sink) : NULL;
13801379
if (wov_comp) {
13811380
comp_err(dev, "kpb_copy: produced=%u bytes, triggering wov=0x%x",
13821381
copy_bytes, dev_comp_id(wov_comp));
13831382
comp_copy(wov_comp);
13841383
} else {
1385-
comp_err(dev, "kpb_copy: get_wov_detector_comp(%u) returned NULL!", ppl_id);
1384+
comp_err(dev, "kpb_copy: downstream sink_comp returned NULL!");
13861385
}
13871386

13881387
comp_update_buffer_consume(source, copy_bytes);

src/audio/wov_arbiter/wov_arbiter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ static int wov_arb_prepare(struct comp_dev *dev)
214214
cd->detect_uuid_id = AMS_INVALID_MSG_TYPE;
215215
return ret;
216216
}
217+
/* Broadcast RESUME so all WOV detector slots start unpaused */
218+
arb_send_ctrl(dev, WOV_CTRL_CMD_RESUME, WOV_ARB_NO_ACTIVE);
217219
#endif
218220

219221
return comp_set_state(dev, COMP_TRIGGER_PREPARE);

src/samples/audio/detect_test.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
#define KWD_NN_BUFF_ALIGN 64
6767

6868
static const struct comp_driver comp_keyword;
69-
static struct comp_dev *wov_detect_devs[16];
69+
static struct comp_dev *wov_detect_devs[256];
7070

7171
struct comp_dev *get_wov_detector_comp(uint32_t ppl_id)
7272
{
73-
if (ppl_id < 16)
73+
if (ppl_id < 256)
7474
return wov_detect_devs[ppl_id];
7575
return NULL;
7676
}
@@ -102,6 +102,7 @@ struct comp_data {
102102
int32_t prev_sample;
103103
uint32_t zc_count;
104104
uint32_t zc_sample_count;
105+
uint32_t consec_match_count;
105106

106107
#if CONFIG_KWD_NN_SAMPLE_KEYPHRASE
107108
int16_t *input;
@@ -371,13 +372,19 @@ static void default_detect_test(struct comp_dev *dev,
371372
break;
372373
}
373374

375+
if (freq_match) {
376+
cd->consec_match_count++;
377+
} else {
378+
cd->consec_match_count = 0;
379+
}
380+
374381
if (freq_hz > 0) {
375-
comp_err(dev, "kd_test eval: slot=%u (%s), freq=%u Hz, energy=%d, preamble=%u",
376-
slot_id, voice_type, freq_hz, cd->activation, cd->detect_preamble);
382+
comp_err(dev, "kd_test eval: slot=%u (%s), freq=%u Hz, energy=%d, match_cnt=%u",
383+
slot_id, voice_type, freq_hz, cd->activation, cd->consec_match_count);
377384
}
378385

379386
if (cd->detect_preamble >= cd->keyphrase_samples) {
380-
if (freq_match && (cd->activation >= activation_threshold || cd->activation > 10)) {
387+
if (cd->consec_match_count >= 3 && (cd->activation >= activation_threshold || cd->activation > 500)) {
381388
comp_err(dev, "kd_test: SLOT %u TRIGGERED on %s Voice! (freq=%u Hz, energy=%d)",
382389
slot_id, voice_type, freq_hz, cd->activation);
383390
cd->drain_req = 0;
@@ -873,7 +880,7 @@ static struct comp_dev *test_keyword_new(const struct comp_driver *drv,
873880

874881
comp_err(dev, "test_keyword_new: dev_id=0x%x pipeline_id=%u",
875882
dev_comp_id(dev), dev->ipc_config.pipeline_id);
876-
if (dev->ipc_config.pipeline_id < 16) {
883+
if (dev->ipc_config.pipeline_id < 256) {
877884
wov_detect_devs[dev->ipc_config.pipeline_id] = dev;
878885
}
879886

@@ -1003,11 +1010,12 @@ static int test_keyword_params(struct comp_dev *dev,
10031010
cd->kpd_uuid_id = AMS_INVALID_MSG_TYPE;
10041011
cd->wov_detect_uuid_id = AMS_INVALID_MSG_TYPE;
10051012
cd->wov_ctrl_uuid_id = AMS_INVALID_MSG_TYPE;
1006-
if (dev->ipc_config.pipeline_id == 1)
1013+
uint32_t ppl_id = dev->ipc_config.pipeline_id;
1014+
if (ppl_id == 101 || ppl_id == 1)
10071015
cd->wov_slot_id = 0;
1008-
else if (dev->ipc_config.pipeline_id == 3)
1016+
else if (ppl_id == 102 || ppl_id == 3)
10091017
cd->wov_slot_id = 1;
1010-
else if (dev->ipc_config.pipeline_id == 4)
1018+
else if (ppl_id == 103 || ppl_id == 4)
10111019
cd->wov_slot_id = 2;
10121020
else
10131021
cd->wov_slot_id = WOV_SLOT_INVALID;

0 commit comments

Comments
 (0)