-
Notifications
You must be signed in to change notification settings - Fork 349
Audio: Sound Dose: Add new component #10058
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91d324b
Audio: EQIIR: Tune: Add missing include to generated C header
singalsu fdea2f7
Audio: EQIIR: Tune: Drop TLV header from exported C header
singalsu f82fac3
Audio: Sound Dose: Add Octave script to export A-weight filter
singalsu 732105c
Audio: EQIIR: Tune: Add plot for equalizer response error
singalsu cb2c0c7
Tools: Topology: Add test topology for sound dose component
singalsu b940776
Audio: Sound Dose: Add new component
singalsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| if(CONFIG_COMP_SOUND_DOSE STREQUAL "m") | ||
| add_subdirectory(llext ${PROJECT_BINARY_DIR}/sound_dose_llext) | ||
| add_dependencies(app sound_dose) | ||
| else() | ||
| add_local_sources(sof sound_dose.c) | ||
| add_local_sources(sof sound_dose-generic.c) | ||
| add_local_sources(sof sound_dose-ipc4.c) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| config COMP_SOUND_DOSE | ||
| tristate "Sound Dose module" | ||
| default m if LIBRARY_DEFAULT_MODULAR | ||
| depends on COMP_MODULE_ADAPTER | ||
| depends on IPC_MAJOR_4 | ||
| select MATH_IIR | ||
| select MATH_IIR_DF1 | ||
| select MATH_EXP | ||
| help | ||
| Select this for Sound Dose SOF module. The purpose is | ||
| to calculate for audio playback MEL values (momentary | ||
| sound exposure level) to provide to user space the data | ||
| to compute the sound dose CSD as defined in EN 50332-3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| Sound Dose | ||
|
|
||
| The purpose of this component is to calculate with DSP offload the | ||
| headphone audio playback MEL values (momentary sound exposure level). | ||
| The calculated MEL values are notified to user space to be available | ||
| every one second. The user space should respond to notification with | ||
| bytes control get to get the data. The MEL values are used to | ||
| calculate the CSD value (cumulative sound dose). Low enough CSD value | ||
| ensures the music listening is safe the user's hearing. | ||
|
|
||
| The calculation of MEL values and CSD values is defined in EN 50332-3 | ||
| stadard. The implementation in the Android OS is described in | ||
| https://source.android.com/docs/core/audio/sound-dose . | ||
|
|
||
| The SOF Sound Dose component should be placed in topology as last | ||
| component before playback dai-copier. | ||
|
|
||
| Currently it can be tested with next test topologies: | ||
| - sof-hda-benchmark-sound_dose32.tplg | ||
| - sof-mtl-sdw-benchmark-sound_dose32-sdw0.tplg | ||
| - sof-mtl-sdw-benchmark-sound_dose32-simplejack.tplg | ||
|
|
||
| E.g. in the sdw topologies the controls for setting it up can be | ||
| seen with command: | ||
|
|
||
| $ amixer -c0 controls | grep "Jack Out Sound Dose" | ||
| numid=33,iface=MIXER,name='Jack Out Sound Dose data bytes' | ||
| numid=32,iface=MIXER,name='Jack Out Sound Dose gain bytes' | ||
| numid=30,iface=MIXER,name='Jack Out Sound Dose setup bytes' | ||
| numid=31,iface=MIXER,name='Jack Out Sound Dose volume bytes' | ||
|
|
||
| The above topologies program the setup bytes for acoustical | ||
| sensitivity of acoustical 100 dBSPL for 0 dBFS digital level. | ||
| The gain is set to 0 dB and volume to 0 dB. | ||
|
|
||
| To test the basics copy a compatible test topology over the | ||
| normal topology file. Or alternative use module options | ||
| tplg_filename and tplg_path for module snd_sof. | ||
|
|
||
| Get kcontrol_events from https://github.com/ujfalusi/kcontrol_events | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ujfalusi please upstream this test too in here in a follow up PR. Thanks ! |
||
| and build and install it. | ||
|
|
||
| Start playback of some music or test signal. Note that there is no SOF | ||
| volume control component in the test topology, so it plays out at max | ||
| volume. | ||
|
|
||
| Start in other console kcontrol_events. The control 'Jack Out Sound | ||
| Dose data bytes' should get updates every one second. The structures | ||
| are defined in src/include/user/audio_feature.h and | ||
| src/include/user/sound_dose.h. | ||
|
|
||
| The next steps require build of blobs for sof-ctl. The blobs can be | ||
| rebuilt with command | ||
|
|
||
| cd src/audio/sound_dose/tune; octave --quiet --no-window-system sof_sound_dose_blobs.m | ||
|
|
||
| To simulate effect of initial sensitivity setup, try command | ||
|
|
||
| sof-ctl -c name='Jack Out Sound Dose setup bytes' -s <path>/sound_dose/setup_sens_0db.txt | ||
| sof-ctl -c name='Jack Out Sound Dose setup bytes' -s <path>/sound_dose/setup_sens_100db.txt | ||
|
|
||
| To simulate adjusting codec volume control down 10 dB and up again 10 dB | ||
|
|
||
| sof-ctl -c name='Jack Out Sound Dose volume bytes' -s ctl4/sound_dose/setup_vol_-10db.txt | ||
| sof-ctl -c name='Jack Out Sound Dose volume bytes' -s ctl4/sound_dose/setup_vol_0db.txt | ||
|
|
||
| To force user's listening level 10 dB down after observing too large dose per the MSD value | ||
|
|
||
| sof-ctl -c name='Jack Out Sound Dose gain bytes' -s ctl4/sound_dose/setup_gain_-10db.txt | ||
|
|
||
| To restore user's listening level to non-attenuated | ||
|
|
||
| sof-ctl -c name='Jack Out Sound Dose gain bytes' -s ctl4/sound_dose/setup_gain_0db.txt | ||
|
|
||
| The above commands have impact to data shown by kcontrol_events. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Copyright (c) 2025 Intel Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| sof_llext_build("sound_dose" | ||
| SOURCES ../sound_dose.c | ||
| ../sound_dose-generic.c | ||
| ../sound_dose-ipc4.c | ||
| LIB openmodules | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include <tools/rimage/config/platform.toml> | ||
| #define LOAD_TYPE "2" | ||
| #include "../sound_dose.toml" | ||
|
|
||
| [module] | ||
| count = __COUNTER__ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.