playbeep 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: playbeep
3
+ Version: 0.1.0
4
+ Summary: Simple beeps.
5
+ Author-email: Slushyboy1212 <no@thank.you>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: numpy>=2.4.0
10
+ Requires-Dist: sounddevice>=0.5.5
11
+
12
+ # How To Use:
13
+ ```py
14
+ import playbeep, time
15
+ mixer = playbeep.play()
16
+ mixer.beep(500, 0.5)
17
+ time.sleep(1)
18
+ ```
@@ -0,0 +1,7 @@
1
+ # How To Use:
2
+ ```py
3
+ import playbeep, time
4
+ mixer = playbeep.play()
5
+ mixer.beep(500, 0.5)
6
+ time.sleep(1)
7
+ ```
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "playbeep"
7
+ version = "0.1.0"
8
+ description = "Simple beeps."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Slushyboy1212", email = "no@thank.you"}
14
+ ]
15
+ dependencies = [
16
+ "numpy>=2.4.0",
17
+ "sounddevice>=0.5.5"
18
+ ]
19
+
20
+ [project.urls]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,34 @@
1
+ import numpy as np
2
+ import sounddevice as sd
3
+ class play:
4
+ def __init__(self, fs=44100):
5
+ self.fs, self.active = fs, []
6
+ self.stream = sd.OutputStream(samplerate=fs, channels=1, callback=self._cb)
7
+ self.stream.start()
8
+ def _cb(self, out, frames, time, status):
9
+ out.fill(0)
10
+ for b in self.active[:]:
11
+ start_f = b['f']
12
+ end_f = start_f + frames
13
+ t = np.arange(start_f, end_f) / self.fs
14
+ wave = np.sin(2 * np.pi * b['hz'] * t)
15
+ full_t = np.arange(start_f, end_f) / b['total']
16
+ envelope = np.ones(frames)
17
+ fade_in_len = int(b['total'] * 0.1)
18
+ if start_f < fade_in_len:
19
+ local_fade = np.linspace(0, 1, fade_in_len)
20
+ needed = min(frames, fade_in_len - start_f)
21
+ envelope[:needed] = local_fade[start_f: start_f + needed]
22
+ fade_out_start = b['total'] - fade_in_len
23
+ if end_f > fade_out_start:
24
+ local_fade = np.linspace(1, 0, fade_in_len)
25
+ offset = max(0, fade_out_start - start_f)
26
+ remaining = frames - offset
27
+ if remaining > 0:
28
+ envelope[offset:] = local_fade[:remaining]
29
+ out[:, 0] += (wave * envelope * 0.02).astype(np.float32)
30
+ b['f'] += frames
31
+ if b['f'] >= b['total']: self.active.remove(b)
32
+ def beep(self, hz, duration):
33
+ if hz > 20:
34
+ self.active.append({'hz': hz, 'total': int(duration * self.fs), 'f': 0})
@@ -0,0 +1,13 @@
1
+ import numpy as np
2
+ import sounddevice as sd
3
+ class play:
4
+ """Initializes the playsound mixer."""
5
+ def __init__(self, fs=44100):
6
+ self.fs, self.active = None, None
7
+ self.stream = None
8
+ """Initializes the playsound mixer."""
9
+ def _cb(self, out, frames, time, status):
10
+ pass
11
+ def beep(self, hz, duration):
12
+ """Plays a sound with given hz and duration"""
13
+ pass
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: playbeep
3
+ Version: 0.1.0
4
+ Summary: Simple beeps.
5
+ Author-email: Slushyboy1212 <no@thank.you>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: numpy>=2.4.0
10
+ Requires-Dist: sounddevice>=0.5.5
11
+
12
+ # How To Use:
13
+ ```py
14
+ import playbeep, time
15
+ mixer = playbeep.play()
16
+ mixer.beep(500, 0.5)
17
+ time.sleep(1)
18
+ ```
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/playbeep/__init__.py
4
+ src/playbeep/__init__.pyi
5
+ src/playbeep.egg-info/PKG-INFO
6
+ src/playbeep.egg-info/SOURCES.txt
7
+ src/playbeep.egg-info/dependency_links.txt
8
+ src/playbeep.egg-info/requires.txt
9
+ src/playbeep.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ numpy>=2.4.0
2
+ sounddevice>=0.5.5
@@ -0,0 +1 @@
1
+ playbeep