Skip to content
On this page

Format Conversion

minispeaker.processor.convert

sampleformat_to_dtype

python
def sampleformat_to_dtype(
        sample_format: SampleFormat) -> Union[uint8, int16, int32, float32]

[🔗]

Converts a SampleFormat to the numpy equivalent dtype.

Arguments:

  • sample_format SampleFormat - miniaudio SampleFormat of the audio sample.

Returns:

Union[uint8, int16, int32, float32]: A corresponding numpy dtype.

dtype_to_sampleformat

python
def dtype_to_sampleformat(
        dtype: Union[None, uint8, int16, int32, float32]) -> SampleFormat

[🔗]

Converts a numpy dtype to an equivalent SampleFormat.

Arguments:

  • dtype Union[None, uint8, int16, int32, float32] - Numpy dtype of the audio sample.

Raises:

  • ValueError - When a inconvertible dtype is given

Returns:

  • SampleFormat - Corresponding miniaudio SampleFormat.