| 1 |
from typing import Any, Union |
| 2 |
|
| 3 |
import numpy as np |
| 4 |
|
| 5 |
from av.frame import Frame |
| 6 |
|
| 7 |
from .format import AudioFormat |
| 8 |
from .layout import AudioLayout |
| 9 |
from .plane import AudioPlane |
| 10 |
|
| 11 |
format_dtypes: dict[str, str] |
| 12 |
_SupportedNDarray = Union[ |
| 13 |
np.ndarray[Any, np.dtype[np.float64]], # f8 |
| 14 |
np.ndarray[Any, np.dtype[np.float32]], # f4 |
| 15 |
np.ndarray[Any, np.dtype[np.int32]], # i4 |
| 16 |
np.ndarray[Any, np.dtype[np.int16]], # i2 |
| 17 |
np.ndarray[Any, np.dtype[np.uint8]], # u1 |
| 18 |
] |
| 19 |
|
| 20 |
class _Format: |
| 21 |
def __get__(self, i: object | None, owner: type | None = None) -> AudioFormat: ... |
| 22 |
def __set__(self, instance: object, value: AudioFormat | str) -> None: ... |
| 23 |
|
| 24 |
class _Layout: |
| 25 |
def __get__(self, i: object | None, owner: type | None = None) -> AudioLayout: ... |
| 26 |
def __set__(self, instance: object, value: AudioLayout | str) -> None: ... |
| 27 |
|
| 28 |
class AudioFrame(Frame): |
| 29 |
planes: tuple[AudioPlane, ...] |
| 30 |
samples: int |
| 31 |
sample_rate: int |
| 32 |
rate: int |
| 33 |
format: _Format |
| 34 |
layout: _Layout |
| 35 |
|
| 36 |
def __init__( |
| 37 |
self, |
| 38 |
format: AudioFormat | str = "s16", |
| 39 |
layout: AudioLayout | str = "stereo", |
| 40 |
samples: int = 0, |
| 41 |
align: int = 1, |
| 42 |
) -> None: ... |
| 43 |
@staticmethod |
| 44 |
def from_ndarray( |
| 45 |
array: _SupportedNDarray, |
| 46 |
format: AudioFormat | str = "s16", |
| 47 |
layout: AudioLayout | str = "stereo", |
| 48 |
) -> AudioFrame: ... |
| 49 |
def to_ndarray(self) -> _SupportedNDarray: ... |