claritychallenge / clarity

Clarity Challenge toolkit - software for building Clarity Challenge systems
https://claritychallenge.github.io/clarity
MIT License
121 stars 51 forks source link

Added clipping when writing audio in PCM_16 format #312

Closed jonbarker68 closed 1 year ago

jonbarker68 commented 1 year ago

When writing audio signals with PCM_16 there is a conversion from floating point with signals expected to be in the range [-1.0, 1.0). Where outside the range, signals currently silently overflow (unless the 'strict' option is set).

This PR ensures values are clipped to the range -32768 to 32767 rather than being allowed to overflow. A warning is logged when this happens.

Closes issue #311

codecov[bot] commented 1 year ago

Codecov Report

Merging #312 (5ab8f0a) into main (601a982) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #312   +/-   ##
=======================================
  Coverage   92.97%   92.98%           
=======================================
  Files          40       40           
  Lines        3771     3775    +4     
=======================================
+ Hits         3506     3510    +4     
  Misses        265      265           
Impacted Files Coverage Δ
clarity/utils/file_io.py 100.00% <100.00%> (ø)