|
| 1 | +from collections.abc import Callable |
| 2 | +from typing import TypeVar |
| 3 | + |
| 4 | +from pygame.typing import FileLike |
| 5 | +from typing_extensions import Buffer |
| 6 | + |
| 7 | +# TODO: Support SDL3 stubchecking without failing when on SDL2 builds |
| 8 | +# Right now this module is unconditionally skipped in mypy_allow_list.txt |
| 9 | + |
| 10 | +def init() -> None: ... |
| 11 | + |
| 12 | +# def quit() -> None: ... |
| 13 | +def get_init() -> bool: ... |
| 14 | +def get_current_driver() -> str: ... |
| 15 | +def get_drivers() -> list[str]: ... |
| 16 | +def get_playback_devices() -> list[AudioDevice]: ... |
| 17 | +def get_recording_devices() -> list[AudioDevice]: ... |
| 18 | + |
| 19 | +# def mix_audio(dst: Buffer, src: Buffer, format: AudioFormat, volume: float) -> None: ... |
| 20 | +def load_wav(file: FileLike) -> tuple[AudioSpec, bytes]: ... |
| 21 | + |
| 22 | +# def convert_samples( |
| 23 | +# src_spec: AudioSpec, src_data: Buffer, dst_spec: AudioSpec |
| 24 | +# ) -> bytes: ... |
| 25 | + |
| 26 | +DEFAULT_PLAYBACK_DEVICE: AudioDevice |
| 27 | +DEFAULT_RECORDING_DEVICE: AudioDevice |
| 28 | + |
| 29 | +# T = TypeVar("T") |
| 30 | +# stream_callback = Callable[[T, AudioStream, int, int], None] |
| 31 | +# post_mix_callback = Callable[[T, AudioStream, Buffer], None] |
| 32 | +# iteration_callback = Callable[[T, AudioDevice, bool], None] |
| 33 | + |
| 34 | +class AudioFormat: |
| 35 | + @property |
| 36 | + def bitsize(self) -> int: ... |
| 37 | + @property |
| 38 | + def bytesize(self) -> int: ... |
| 39 | + @property |
| 40 | + def is_float(self) -> bool: ... |
| 41 | + @property |
| 42 | + def is_int(self) -> bool: ... |
| 43 | + @property |
| 44 | + def is_big_endian(self) -> bool: ... |
| 45 | + @property |
| 46 | + def is_little_endian(self) -> bool: ... |
| 47 | + @property |
| 48 | + def is_signed(self) -> bool: ... |
| 49 | + @property |
| 50 | + def is_unsigned(self) -> bool: ... |
| 51 | + @property |
| 52 | + def name(self) -> str: ... |
| 53 | + @property |
| 54 | + def silence_value(self) -> bytes: ... |
| 55 | + def __index__(self) -> int: ... |
| 56 | + def __repr__(self) -> str: ... |
| 57 | + |
| 58 | +UNKNOWN: AudioFormat |
| 59 | +U8: AudioFormat |
| 60 | +S8: AudioFormat |
| 61 | +S16LE: AudioFormat |
| 62 | +S16BE: AudioFormat |
| 63 | +S32LE: AudioFormat |
| 64 | +S32BE: AudioFormat |
| 65 | +F32LE: AudioFormat |
| 66 | +F32BE: AudioFormat |
| 67 | +S16: AudioFormat |
| 68 | +S32: AudioFormat |
| 69 | +F32: AudioFormat |
| 70 | + |
| 71 | +class AudioSpec: |
| 72 | + def __init__(self, format: AudioFormat, channels: int, frequency: int) -> None: ... |
| 73 | + @property |
| 74 | + def format(self) -> AudioFormat: ... |
| 75 | + @property |
| 76 | + def channels(self) -> int: ... |
| 77 | + @property |
| 78 | + def frequency(self) -> int: ... |
| 79 | + @property |
| 80 | + def framesize(self) -> int: ... |
| 81 | + def __repr__(self) -> str: ... |
| 82 | + |
| 83 | +class AudioDevice: |
| 84 | + def open(self, spec: AudioSpec | None = None) -> LogicalAudioDevice: ... |
| 85 | + # def open_stream( |
| 86 | + # self, |
| 87 | + # spec: AudioSpec | None, |
| 88 | + # callback: stream_callback | None, |
| 89 | + # userdata: T | None, |
| 90 | + # ) -> AudioStream: ... |
| 91 | + @property |
| 92 | + def is_playback(self) -> bool: ... |
| 93 | + @property |
| 94 | + def name(self) -> str: ... |
| 95 | + # Need something for https://wiki.libsdl.org/SDL3/SDL_GetAudioDeviceFormat |
| 96 | + @property |
| 97 | + def channel_map(self) -> list[int] | None: ... |
| 98 | + |
| 99 | +class LogicalAudioDevice(AudioDevice): |
| 100 | + def pause(self) -> None: ... |
| 101 | + def resume(self) -> None: ... |
| 102 | + @property |
| 103 | + def paused(self) -> bool: ... |
| 104 | + @property |
| 105 | + def gain(self) -> float: ... |
| 106 | + @gain.setter |
| 107 | + def gain(self, value: float) -> None: ... |
| 108 | + # def set_iteration_callbacks( |
| 109 | + # self, |
| 110 | + # start: iteration_callback | None, |
| 111 | + # end: iteration_callback | None, |
| 112 | + # userdata: T, |
| 113 | + # ) -> None: ... |
| 114 | + # def set_post_mix_callback( |
| 115 | + # self, callback: post_mix_callback | None, userdata: T |
| 116 | + # ) -> None: ... |
| 117 | + |
| 118 | +class AudioStream: |
| 119 | + def __init__(self, src_spec: AudioSpec, dst_spec: AudioSpec) -> None: ... |
| 120 | + def bind(self, device: LogicalAudioDevice) -> None: ... |
| 121 | + def unbind(self) -> None: ... |
| 122 | + def clear(self) -> None: ... |
| 123 | + def flush(self) -> None: ... |
| 124 | + @property |
| 125 | + def num_available_bytes(self) -> int: ... |
| 126 | + @property |
| 127 | + def num_queued_bytes(self) -> int: ... |
| 128 | + def get_data(self, size: int) -> bytes: ... |
| 129 | + def put_data(self, data: Buffer) -> None: ... |
| 130 | + def pause_device(self) -> None: ... |
| 131 | + def resume_device(self) -> None: ... |
| 132 | + @property |
| 133 | + def device_paused(self) -> bool: ... |
| 134 | + @property |
| 135 | + def device(self) -> LogicalAudioDevice | None: ... |
| 136 | + @property |
| 137 | + def src_spec(self) -> AudioSpec: ... |
| 138 | + @src_spec.setter |
| 139 | + def src_spec(self, value: AudioSpec) -> None: ... |
| 140 | + @property |
| 141 | + def dst_spec(self) -> AudioSpec: ... |
| 142 | + @dst_spec.setter |
| 143 | + def dst_spec(self, value: AudioSpec) -> None: ... |
| 144 | + @property |
| 145 | + def gain(self) -> float: ... |
| 146 | + @gain.setter |
| 147 | + def gain(self, value: float) -> None: ... |
| 148 | + @property |
| 149 | + def frequency_ratio(self) -> float: ... |
| 150 | + @frequency_ratio.setter |
| 151 | + def frequency_ratio(self, value: float) -> None: ... |
| 152 | + # def set_input_channel_map(self, channel_map: list[int] | None) -> None: ... |
| 153 | + # def get_input_channel_map(self) -> list[int] | None: ... |
| 154 | + # def set_output_channel_map(self, channel_map: list[int] | None) -> None: ... |
| 155 | + # def get_output_channel_map(self) -> list[int] | None: ... |
| 156 | + def lock(self) -> None: ... |
| 157 | + def unlock(self) -> None: ... |
| 158 | + # def set_get_callback( |
| 159 | + # self, callback: stream_callback | None, userdata: T |
| 160 | + # ) -> None: ... |
| 161 | + # def set_put_callback( |
| 162 | + # self, callback: stream_callback | None, userdata: T |
| 163 | + # ) -> None: ... |
| 164 | + def __repr__(self) -> str: ... |
0 commit comments