|
| 1 | +Sound Dose |
| 2 | + |
| 3 | +The purpose of this component is to calculate with DSP offload the |
| 4 | +headphone audio playback MEL values (momentary sound exposure level). |
| 5 | +The calculated MEL values are notified to user space to be available |
| 6 | +every one second. The user space should respond to notification with |
| 7 | +bytes control get to get the data. The MEL values are used to |
| 8 | +calculate the CSD value (cumulative sound dose). Low enough CSD value |
| 9 | +ensures the music listening is safe the user's hearing. |
| 10 | + |
| 11 | +The calculation of MEL values and CSD values is defined in EN 50332-3 |
| 12 | +stadard. The implementation in the Android OS is described in |
| 13 | +https://source.android.com/docs/core/audio/sound-dose . |
| 14 | + |
| 15 | +The SOF Sound Dose component should be placed in topology as last |
| 16 | +component before playback dai-copier. |
| 17 | + |
| 18 | +Currently it can be tested with next test topologies: |
| 19 | +- sof-hda-benchmark-sound_dose32.tplg |
| 20 | +- sof-mtl-sdw-benchmark-sound_dose32-sdw0.tplg |
| 21 | +- sof-mtl-sdw-benchmark-sound_dose32-simplejack.tplg |
| 22 | + |
| 23 | +E.g. in the sdw topologies the controls for setting it up can be |
| 24 | +seen with command: |
| 25 | + |
| 26 | +$ amixer -c0 controls | grep "Jack Out Sound Dose" |
| 27 | +numid=33,iface=MIXER,name='Jack Out Sound Dose data bytes' |
| 28 | +numid=32,iface=MIXER,name='Jack Out Sound Dose gain bytes' |
| 29 | +numid=30,iface=MIXER,name='Jack Out Sound Dose setup bytes' |
| 30 | +numid=31,iface=MIXER,name='Jack Out Sound Dose volume bytes' |
| 31 | + |
| 32 | +The above topologies program the setup bytes for acoustical |
| 33 | +sensitivity of acoustical 100 dBSPL for 0 dBFS digital level. |
| 34 | +The gain is set to 0 dB and volume to 0 dB. |
| 35 | + |
| 36 | +To test the basics copy a compatible test topology over the |
| 37 | +normal topology file. Or alternative use module options |
| 38 | +tplg_filename and tplg_path for module snd_sof. |
| 39 | + |
| 40 | +Get kcontrol_events from https://github.com/ujfalusi/kcontrol_events |
| 41 | +and build and install it. |
| 42 | + |
| 43 | +Start playback of some music or test signal. Note that there is no SOF |
| 44 | +volume control component in the test topology, so it plays out at max |
| 45 | +volume. |
| 46 | + |
| 47 | +Start in other console kcontrol_events. The control 'Jack Out Sound |
| 48 | +Dose data bytes' should get updates every one second. The structures |
| 49 | +are defined in src/include/user/audio_feature.h and |
| 50 | +src/include/user/sound_dose.h. |
| 51 | + |
| 52 | +The next steps require build of blobs for sof-ctl. The blobs can be |
| 53 | +rebuilt with command |
| 54 | + |
| 55 | +cd src/audio/sound_dose/tune; octave --quiet --no-window-system sof_sound_dose_blobs.m |
| 56 | + |
| 57 | +To simulate effect of initial sensitivity setup, try command |
| 58 | + |
| 59 | +sof-ctl -c name='Jack Out Sound Dose setup bytes' -s <path>/sound_dose/setup_sens_0db.txt |
| 60 | +sof-ctl -c name='Jack Out Sound Dose setup bytes' -s <path>/sound_dose/setup_sens_100db.txt |
| 61 | + |
| 62 | +To simulate adjusting codec volume control down 10 dB and up again 10 dB |
| 63 | + |
| 64 | +sof-ctl -c name='Jack Out Sound Dose volume bytes' -s ctl4/sound_dose/setup_vol_-10db.txt |
| 65 | +sof-ctl -c name='Jack Out Sound Dose volume bytes' -s ctl4/sound_dose/setup_vol_0db.txt |
| 66 | + |
| 67 | +To force user's listening level 10 dB down after observing too large dose per the MSD value |
| 68 | + |
| 69 | +sof-ctl -c name='Jack Out Sound Dose gain bytes' -s ctl4/sound_dose/setup_gain_-10db.txt |
| 70 | + |
| 71 | +To restore user's listening level to non-attenuated |
| 72 | + |
| 73 | +sof-ctl -c name='Jack Out Sound Dose gain bytes' -s ctl4/sound_dose/setup_gain_0db.txt |
| 74 | + |
| 75 | +The above commands have impact to data shown by kcontrol_events. |
0 commit comments