(self, pcm: bytes, frame_size: int)
| 405 | _lib.opus_encoder_ctl(self._state, CTL_SET_PLP, min(100, max(0, int(percentage * 100)))) |
| 406 | |
| 407 | def encode(self, pcm: bytes, frame_size: int) -> bytes: |
| 408 | max_data_bytes = len(pcm) |
| 409 | # bytes can be used to reference pointer |
| 410 | pcm_ptr = ctypes.cast(pcm, c_int16_ptr) # type: ignore |
| 411 | data = (ctypes.c_char * max_data_bytes)() |
| 412 | |
| 413 | ret = _lib.opus_encode(self._state, pcm_ptr, frame_size, data, max_data_bytes) |
| 414 | |
| 415 | return array.array('b', data[:ret]).tobytes() |
| 416 | |
| 417 | |
| 418 | class Decoder(_OpusStruct): |
no outgoing calls
no test coverage detected