Repository navigation
wavetool.py: add THD+N and RMS calculation for wave analysis - #524
aiChaoSONG wants to merge 2 commits into
Conversation
Signed-off-by: Amery Song <chao.song@intel.com>
Signed-off-by: Amery Song <chao.song@intel.com>
| if cmd.analyze == 'wov': | ||
| analyze_wav_wov(wave, fs_wav) | ||
| if cmd.analyze == 'thdn': | ||
| analyze_wav_thdn(wave, fs_wav) |
There was a problem hiding this comment.
Could you add DC offset calculation? Take average value of the clip to analyse and report as dBFS (repeat for every channel). You can omit the start transient. The fail criteria default should be > -60 dBFS. With 16 bit audio it should be normally around -90 dBFS.
| filtered_cut = filtered[samples_skip:,:] | ||
| return 10 * np.log10(np.mean(np.power(filtered_cut, 2), axis=0)) | ||
| filtered_cut = filtered[samples_skip:] | ||
| return 10 * np.log10(np.mean(np.power(filtered_cut, 2), axis=0) + eps) |
There was a problem hiding this comment.
I think we should call this "THD+N ratio" since it was measured with sine wave input. Extracts from AES spec:
"The test signal shall be a sine wave. The analyzer shall include the standard low-pass filter (see 5.2.5). The total
signal level at the EUT output is measured and recorded. The fundamental component of the test signal present
in the output shall be removed with the standard notch filter (see 5.2.8), and the unweighted level of the residual
shall be measured. The THD+N ratio shall be the difference between the residual level and the total signal
level, expressed in dB."
and
"The test signal level shall be a sine wave at -1 dB relative to the maximum input level (see 6.2.1). "
So, the used sine level should be subtracted from the result. E.g. -81 - (-1) dB gives -80 dB.
Edit: Thinking more I think the "total signal level" above means the RMS level level of output (dBFS) with all the distortion and noise included, so it should be measured too in step. It's simpler to do since you don't need to pass or hard code it here.
There was a problem hiding this comment.
The test signal level shall be a sine wave at -1 dB relative to the maximum input level
I think we may not use the THD+N ratio here, because our test signal is not a standard -1 dB sine wave. our loopback wave varies in level, so an absolute value (thdn) is better than a relative value (thdn ratio)
I just realized that we may get a lower THD+N from a wave with lower level, the THD+N ratio is less impacted by this. Thanks.
There was a problem hiding this comment.
The problem without ratio is that a muted / a lot attenuated test might achieve a really good THD+N value. You need to set the limit to such that an OK performing system passes it. I would never pass a result worse than -60 dB (equivalent to 10 bits performance - our implementation is 16/24/32 bits).
There was a problem hiding this comment.
@singalsu For a good quality sine wave with -30dB level, and -80dB thdn, the THD+N ratio is on -50dB. it is hard to maintain a 0 dB volume control in our loopback route, how can we deal with this condition? maybe we should keep the calculation of thdn and thdn ratio, and let user to choose what they want to use?
There was a problem hiding this comment.
With current test system (headphone out -> headset adapter mic in) I think it's not expected to get any better performance. Could the pass criteria be something like -48 dB until the CI hardware can be upgraded? Testing it is much better than nothing though small issues will be left unnoticed. The THD+N alone is not good because a broken system can get a good result.
@mengdonglin The -50 dB THD+N ratio is performance of a 80's C-cassette player. Please try to escalate the need for better audio validation hardware. We really should be able to use something like -70 to -80 dB THD+N ratio as automatic test pass/fail criteria.
|
@aiChaoSONG @singalsu is this still relevant or should we close this? |
|
@plbossart we can close this first, no time to come back now |
@keyonjie @keqiaozhang @xiulipan Please help to review, you can try this PR with any wave you have:
wavetool.py -a thdn -R your-wave-file-path