Skip to content

[Bug?] Custom voice alerts assume contiguous and ascending ordering in voice.iniΒ #999

@somewhatlurker

Description

@somewhatlurker

Not necessarily a huge issue, but I noticed it when playing around in emulator.
Custom alerts in voice_map seem to be created by writing to indexes 200+ in the order alerts are found in the file, not corresponding to the key in voice.ini.
While the firmware seems to handle this fine internally (the order of alerts in the selector changes, but they're played using the correct id from voice_map), model files just store the internally used index and will break if voice.ini is merely reordered.

For example, two voice.ini files containing 200=0,300\n201=1,300 and 201=1,300\n200=0,300 in the custom section are handled differently. (In the second case, alert 200 in model files is actually 1 (mp3 file 201) and alert 201 is 0 (mp3 file 200))
It's a very non-intuitive behaviour and I assume it's not intentional.

γ€€

It seems pretty simple to fix; ids in the model file should just have to be converted to the proper internal id:

when saving: (src/config/model.c line 1385 -- near fprintf(fh, "[%s]\n", SECTION_VOICE); ?)
look up the correct id of music in voice_map

when loading: (src/config/model.c line 1030 -- near if (MATCH_SECTION(SECTION_VOICE)) { ?)
iterate on voice_map until an entry with id == val is found (a little slow, but probably fine)
if no match return 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions