M2-PT-DRP/source/utils/audio/audio.py

19 lines
No EOL
458 B
Python

import numpy
def sample_width_to_type(sample_width: int):
"""
Return the numpy type to use depending on the sample width used in an audio sample
:param sample_width: the sample width
:return: the corresponding numpy type
"""
match sample_width:
case 1:
return numpy.int8
case 2:
return numpy.int16
case 4:
return numpy.int32
case _:
return numpy.int16