Skip to content

Commit 300db71

Browse files
authored
Update 0.5.12 (#12)
- Refactoring function `__callback__(...)` - Update function `recofigurate(...)` - Fixed typing
2 parents a304143 + 5b5e316 commit 300db71

File tree

14 files changed

+210
-126
lines changed

14 files changed

+210
-126
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "seaplayer-audio"
3-
version = "0.5.5"
3+
version = "0.5.12"
44
description = "A library for async/sync playback audio."
55
repository = "https://github.com/romanin-rf/seaplayer-audio"
66
authors = ["Romanin <60302782+romanin-rf@users.noreply.github.com>"]

seaplayer_audio/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
AsyncStreamerBase, StreamerBase, StreamerState,
44
AsyncSoundDeviceStreamerBase, SoundDeviceStreamerBase
55
)
6-
from .audiosources import FileAudioSource, AsyncFileAudioSource
6+
from .audiosources import (
7+
FileAudioSource, AsyncFileAudioSource
8+
)
79
from .streamers import (
810
ThreadSoundDeviceStreamer, AsyncThreadSoundDeviceStreamer,
9-
CallbackSoundDeviceStreamer, AsyncCallbackSoundDeviceStreamer
11+
CallbackSoundDeviceStreamer, AsyncCallbackSoundDeviceStreamer, CallbackSettingsFlag
1012
)
1113
from ._types import AudioSamplerate, AudioChannels, AudioDType, AudioFormat, AudioSubType, AudioEndians
1214

15+
1316
__all__ = [
1417
'AsyncAudioSourceBase', 'AudioSourceBase', 'AudioSourceMetadata',
1518
'AsyncStreamerBase', 'StreamerBase', 'StreamerState',
1619
'AsyncSoundDeviceStreamerBase', 'SoundDeviceStreamerBase',
1720
'ThreadSoundDeviceStreamer', 'AsyncThreadSoundDeviceStreamer',
18-
'CallbackSoundDeviceStreamer', 'AsyncCallbackSoundDeviceStreamer',
21+
'CallbackSoundDeviceStreamer', 'AsyncCallbackSoundDeviceStreamer', 'CallbackSettingsFlag',
1922
'FileAudioSource', 'AsyncFileAudioSource',
2023
'AudioSamplerate', 'AudioChannels', 'AudioDType', 'AudioFormat', 'AudioSubType', 'AudioEndians'
2124
]

seaplayer_audio/_types.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import numpy as np
12
from pathlib import Path
23
from email.message import Message
34
from io import BufferedReader
45
from http.client import HTTPResponse
6+
from numpy import ndarray
7+
# > Typing
58
from typing_extensions import (
69
Tuple, Any,
710
Coroutine, Awaitable, Callable,
@@ -25,13 +28,17 @@
2528
'float32', 'float64', 'float80', 'float96', 'float128', 'float256'
2629
]
2730

31+
# ! Numpy Types
32+
33+
SupportNDArray = ndarray[Any, Union[np.int16, np.int32, np.float32, np.float64]]
34+
2835
# ! IO Types
2936

3037
FilePathType: TypeAlias = Union[str, Path]
3138

3239
# ! Audio Types
3340

34-
AudioChannels: TypeAlias = Literal[1, 2]
41+
AudioChannels: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]
3542
AudioSamplerate: TypeAlias = Literal[
3643
8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000, 192000
3744
]
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
from .fileaudiosource import FileAudioSource, AsyncFileAudioSource
2-
from .urlio import URLIO
2+
from .urlio import URLIO
3+
4+
5+
__all__ = [
6+
'FileAudioSource', 'AsyncFileAudioSource',
7+
'URLIO'
8+
]

seaplayer_audio/audiosources/urlio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,18 @@ def seek(self, offset: int, whence: int=0, /) -> int:
213213

214214
# ^ IO Methods (NOT IMPLEMENTED)
215215

216-
@deprecated('!!! NOT IMPLEMENTED !!!')
216+
@deprecated('NOT IMPLEMENTED')
217217
def write(self):
218218
raise OSError
219219

220-
@deprecated('!!! NOT IMPLEMENTED !!!')
220+
@deprecated('NOT IMPLEMENTED')
221221
def writelines(self, lines: Iterable[bytes], /):
222222
raise OSError
223223

224-
@deprecated('!!! NOT IMPLEMENTED !!!')
224+
@deprecated('NOT IMPLEMENTED')
225225
def fileno(self):
226226
raise OSError
227227

228-
@deprecated('!!! NOT IMPLEMENTED !!!')
228+
@deprecated('NOT IMPLEMENTED')
229229
def flush(self):
230230
raise NotImplementedError

seaplayer_audio/base/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .sndstreamer import SoundDeviceStreamerBase, AsyncSoundDeviceStreamerBase
33
from .audiosource import AudioSourceBase, AsyncAudioSourceBase, AudioSourceMetadata
44

5+
56
__all__ = [
67
'AudioSourceBase', 'AsyncAudioSourceBase', 'AudioSourceMetadata',
78
'StreamerState', 'StreamerBase', 'AsyncStreamerBase',

seaplayer_audio/base/audiosource.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,89 +41,89 @@ class AudioSourceBase(IOBase, Reprable):
4141

4242
# ^ Methods
4343

44-
@deprecated('!!! NOT IMPLEMENTED !!!')
44+
@deprecated('NOT IMPLEMENTED')
4545
def __iter__(self) -> NoReturn:
46-
"""!!! NOT IMPLEMENTED !!!"""
46+
"""NOT IMPLEMENTED"""
4747
raise NotImplementedError
4848

49-
@deprecated('!!! NOT IMPLEMENTED !!!')
49+
@deprecated('NOT IMPLEMENTED')
5050
def __next__(self) -> NoReturn:
51-
"""!!! NOT IMPLEMENTED !!!"""
51+
"""NOT IMPLEMENTED"""
5252
raise NotImplementedError
5353

5454
def writable(self) -> bool:
5555
return False
5656

57-
@deprecated('!!! NOT IMPLEMENTED !!!')
57+
@deprecated('NOT IMPLEMENTED')
5858
def write(self, *args, **kwargs) -> NoReturn:
59-
"""!!! NOT IMPLEMENTED !!!"""
59+
"""NOT IMPLEMENTED"""
6060
raise OSError
6161

62-
@deprecated('!!! NOT IMPLEMENTED !!!')
62+
@deprecated('NOT IMPLEMENTED')
6363
def writelines(self, lines: Iterable[Any]) -> NoReturn:
64-
"""!!! NOT IMPLEMENTED !!!"""
64+
"""NOT IMPLEMENTED"""
6565
raise OSError
6666

67-
@deprecated('!!! NOT IMPLEMENTED !!!')
67+
@deprecated('NOT IMPLEMENTED')
6868
def truncate(self, size: Optional[int]=None) -> NoReturn:
69-
"""!!! NOT IMPLEMENTED !!!"""
69+
"""NOT IMPLEMENTED"""
7070
raise NotImplementedError
7171

7272
def isatty(self) -> bool:
7373
return False
7474

75-
@deprecated('!!! NOT IMPLEMENTED !!!')
75+
@deprecated('NOT IMPLEMENTED')
7676
def flush(self) -> NoReturn:
77-
"""!!! NOT IMPLEMENTED !!!"""
77+
"""NOT IMPLEMENTED"""
7878
raise NotImplementedError
7979

80-
@deprecated('!!! NOT IMPLEMENTED !!!')
80+
@deprecated('NOT IMPLEMENTED')
8181
def fileno(self) -> NoReturn:
82-
"""!!! NOT IMPLEMENTED !!!"""
82+
"""NOT IMPLEMENTED"""
8383
raise OSError
8484

8585
# ! Audio Source Class (async)
8686

8787
class AsyncAudioSourceBase(AudioSourceBase):
8888
"""Base class for working with audio sources (async)."""
8989

90-
@deprecated('!!! NOT IMPLEMENTED !!!')
90+
@deprecated('NOT IMPLEMENTED')
9191
async def __aiter__(self) -> NoReturn:
92-
"""!!! NOT IMPLEMENTED !!!"""
92+
"""NOT IMPLEMENTED"""
9393
raise NotImplementedError
9494

95-
@deprecated('!!! NOT IMPLEMENTED !!!')
95+
@deprecated('NOT IMPLEMENTED')
9696
async def __anext__(self) -> NoReturn:
97-
"""!!! NOT IMPLEMENTED !!!"""
97+
"""NOT IMPLEMENTED"""
9898
raise NotImplementedError
9999

100100
def writable(self) -> bool:
101101
return False
102102

103-
@deprecated('!!! NOT IMPLEMENTED !!!')
103+
@deprecated('NOT IMPLEMENTED')
104104
async def write(self, *args, **kwargs) -> NoReturn:
105-
"""!!! NOT IMPLEMENTED !!!"""
105+
"""NOT IMPLEMENTED"""
106106
raise OSError
107107

108-
@deprecated('!!! NOT IMPLEMENTED !!!')
108+
@deprecated('NOT IMPLEMENTED')
109109
async def writelines(self, lines: Iterable[Any]) -> NoReturn:
110-
"""!!! NOT IMPLEMENTED !!!"""
110+
"""NOT IMPLEMENTED"""
111111
raise OSError
112112

113-
@deprecated('!!! NOT IMPLEMENTED !!!')
113+
@deprecated('NOT IMPLEMENTED')
114114
async def truncate(self, size = ...) -> NoReturn:
115-
"""!!! NOT IMPLEMENTED !!!"""
115+
"""NOT IMPLEMENTED"""
116116
raise NotImplementedError
117117

118118
async def isatty(self) -> bool:
119119
return False
120120

121-
@deprecated('!!! NOT IMPLEMENTED !!!')
121+
@deprecated('NOT IMPLEMENTED')
122122
async def flush(self) -> NoReturn:
123-
"""!!! NOT IMPLEMENTED !!!"""
123+
"""NOT IMPLEMENTED"""
124124
raise NotImplementedError
125125

126-
@deprecated('!!! NOT IMPLEMENTED !!!')
126+
@deprecated('NOT IMPLEMENTED')
127127
async def fileno(self) -> NoReturn:
128-
"""!!! NOT IMPLEMENTED !!!"""
128+
"""NOT IMPLEMENTED"""
129129
raise OSError

seaplayer_audio/base/sndstreamer.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ def __init__(
1818
) -> None:
1919
super().__init__(samplerate, channels, dtype, closefd)
2020
self.device = device
21+
22+
def reconfigure(self,
23+
samplerate: Optional[AudioSamplerate]=None,
24+
channels: Optional[AudioChannels]=None,
25+
dtype: Optional[AudioDType]=None,
26+
device: Optional[int]=None,
27+
) -> None:
28+
super().reconfigure(samplerate, channels, dtype)
29+
self.device = device if (device is not None) else self.device
2130

2231
# ^ Async SoundDevice Streamer Base
2332

@@ -34,4 +43,13 @@ def __init__(
3443
device: Optional[int]=None
3544
) -> None:
3645
super().__init__(samplerate, channels, dtype, closefd, loop)
37-
self.device = device
46+
self.device = device
47+
48+
def reconfigure(self,
49+
samplerate: Optional[AudioSamplerate]=None,
50+
channels: Optional[AudioChannels]=None,
51+
dtype: Optional[AudioDType]=None,
52+
device: Optional[int]=None,
53+
) -> None:
54+
super().reconfigure(samplerate, channels, dtype)
55+
self.device = device if (device is not None) else self.device

seaplayer_audio/base/streamer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def reconfigure(self,
6262
channels: Optional[AudioChannels]=None,
6363
dtype: Optional[AudioDType]=None,
6464
) -> None:
65-
self.samplerate = samplerate or 44100
66-
self.channels = channels or 2
67-
self.dtype = dtype or 'float32'
65+
self.samplerate = samplerate if (samplerate is not None) else self.samplerate
66+
self.channels = channels if (channels is not None) else self.channels
67+
self.dtype = dtype if (dtype is not None) else self.dtype
6868

6969
def run(self) -> None:
7070
raise NotImplementedError

seaplayer_audio/exceptions.py

Whitespace-only changes.

0 commit comments

Comments
 (0)