modusa 0.4.31__py3-none-any.whl → 0.4.32__py3-none-any.whl

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.
modusa/__init__.py CHANGED
@@ -9,9 +9,9 @@ from modusa.tools import load_ann, save_ann
9
9
  from modusa.tools import dist_plot, hill_plot, plot, fig
10
10
 
11
11
  # Synthsizing related
12
- from modusa.tools import synth_f0
12
+ from modusa.tools import synth_f0, synth_clicks
13
13
 
14
14
  # Audio features related
15
15
  from modusa.tools import stft
16
16
 
17
- __version__ = "0.4.31" # This is dynamically used by the documentation, and pyproject.toml; Only need to change it here; rest gets taken care of.
17
+ __version__ = "0.4.32" # This is dynamically used by the documentation, and pyproject.toml; Only need to change it here; rest gets taken care of.
modusa/tools/__init__.py CHANGED
@@ -16,7 +16,7 @@ from .plotter import Fig as fig
16
16
  from .plotter import dist_plot, hill_plot, plot
17
17
 
18
18
  # Synthesizing related
19
- from .synth import synth_f0
19
+ from .synth import synth_f0, synth_clicks
20
20
 
21
21
  # Audio features
22
22
  from .audio_stft import stft
modusa/tools/synth.py CHANGED
@@ -52,4 +52,61 @@ def synth_f0(f0, f0t, sr, nharm=0):
52
52
  # Normalize output to avoid clipping
53
53
  y /= np.max(np.abs(y))
54
54
 
55
- return y, sr
55
+ return y, sr
56
+
57
+ def synth_clicks(event_times, sr, freq=500, nharm=4, click_duration_ms=5):
58
+ """
59
+ Generate a train of short sine wave clicks with harmonics at specified event times.
60
+
61
+ Parameters
62
+ ----------
63
+ event_times : array-like
64
+ - Times of events in seconds where clicks should be placed.
65
+ sr : int
66
+ - Sampling rate in Hz.
67
+ freq : float, optional
68
+ - Fundamental frequency of the sine click in Hz. Default is 500 Hz.
69
+ nharm : int | None
70
+ - Number of harmonics to include (including fundamental). Default is 4.
71
+ click_duration_ms : float | None
72
+ - Duration of each click in milliseconds. Default is 5 ms.
73
+
74
+ Returns
75
+ -------
76
+ np.ndarray
77
+ - Audio signal with sine wave clicks (with harmonics) at event times.
78
+ int
79
+ - Sampling rate of the generated click audio.
80
+ """
81
+
82
+ n_samples = int(np.ceil(sr * event_times[-1]))
83
+ y = np.zeros(n_samples, dtype=np.float32)
84
+
85
+ # Single click length
86
+ click_len = int(sr * click_duration_ms / 1000)
87
+ if click_len < 1:
88
+ click_len = 1
89
+
90
+ t = np.arange(click_len) / sr
91
+ window = np.hanning(click_len)
92
+
93
+ # Generate harmonic sine click
94
+ sine_click = np.zeros(click_len)
95
+ for n in range(1, nharm+2):
96
+ sine_click += (1 / n**2) * np.sin(2 * np.pi * freq * n * t)
97
+
98
+ # Apply window
99
+ sine_click = sine_click * window**2
100
+
101
+ for event_time in event_times:
102
+ start_sample = int(event_time * sr)
103
+ end_sample = start_sample + click_len
104
+ if end_sample > n_samples:
105
+ end_sample = n_samples
106
+ y[start_sample:end_sample] += sine_click[:end_sample - start_sample]
107
+
108
+ # Normalize to avoid clipping if clicks overlap
109
+ y /= np.max(np.abs(y))
110
+
111
+ return y, sr
112
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.4.31
3
+ Version: 0.4.32
4
4
  Summary: A modular signal analysis python library.
5
5
  Author-Email: Ankit Anand <ankit0.anand0@gmail.com>
6
6
  License: MIT
@@ -1,13 +1,13 @@
1
1
  LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
2
2
  README.md,sha256=Ybe2rcDecfSCiUpec2n7btQvgyi4R9JG0bfdwSWijWk,981
3
- modusa-0.4.31.dist-info/METADATA,sha256=6xtxTdA9YYiKzG3pMSmeMk8C18gvlWS7ZJ0GuddrESY,1443
4
- modusa-0.4.31.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
5
- modusa-0.4.31.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
6
- modusa-0.4.31.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
7
- modusa/__init__.py,sha256=OlPmjLOhldc42ytXjXkv0zMoJd8B4lndGcG2Pt2olLc,506
3
+ modusa-0.4.32.dist-info/METADATA,sha256=FpyrNdZ-RNYXR2bP9VBcEjJROVAilRGeeRFQm6DB1AE,1443
4
+ modusa-0.4.32.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
5
+ modusa-0.4.32.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
6
+ modusa-0.4.32.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
7
+ modusa/__init__.py,sha256=OBgGLMPzXgtssSpH8N2Thmdcomig7FR17bPLf7UnrQI,520
8
8
  modusa/fonts/NotoSansDevanagari-Regular.ttf,sha256=CEqU2J61Sq-5OgVuFUJcNP2Fn2NCh1Fl0wSDezvPwtI,221084
9
9
  modusa/images/icon.png,sha256=UgGXlL4xjdIYxqO1en3iQfNN1BFsazxpT7NiPZSDu70,13321
10
- modusa/tools/__init__.py,sha256=08f7kU1ZTuvYuMTYodv_OK_29AeCspPu4FzTVbbnPm4,500
10
+ modusa/tools/__init__.py,sha256=1Oryj_Kw1ZgzxMeD4bfzf890sDwgeysGmNJoRxrxfn4,514
11
11
  modusa/tools/ann_loader.py,sha256=m6Qu6jXnQ8LfUhKItoHSaHlGxUyzUJlGEyu4_50qJ8w,3099
12
12
  modusa/tools/ann_saver.py,sha256=rB2gP1rD69PkSnBZrzc_83ylb7eAyqyCMjn9Bh16VaM,650
13
13
  modusa/tools/audio_converter.py,sha256=415qBoPm2sBIuBSI7m1XBKm0AbmVmPydIPPr-uO8D3c,1778
@@ -16,7 +16,7 @@ modusa/tools/audio_player.py,sha256=kyBUnodkOE9Ox-hKHkfPeGAQ1RPTddbZYXO1ezz6-9w,
16
16
  modusa/tools/audio_recorder.py,sha256=cADeeUpPcDIYBIuuVZvWqulDkv7TavkpL3o3SO9QyKc,2787
17
17
  modusa/tools/audio_stft.py,sha256=vy1J-qFUVIkOh5Y1-dyy3zAh26n0IaMtO2D9EMbtITU,1742
18
18
  modusa/tools/plotter.py,sha256=QfF8kCi79nS-J5lQyEuH_BbAmTo-PdfjDbnK9yTAmRE,30863
19
- modusa/tools/synth.py,sha256=tfCjTAucTDwb0yOHHnrNO7EFsuH7tNb1PwvS2xwmhK0,1222
19
+ modusa/tools/synth.py,sha256=qVAxXRz2tK2OBfsYtQJxUHNEFDD-_cCQtzVjb3-bXjA,2795
20
20
  modusa/tools/youtube_downloader.py,sha256=Ij7fipSlRpsf0pFOwRY-j7Yf2PMp0kpWMhyMQchR0e0,1574
21
- pyproject.toml,sha256=fCgN1j7fzWdYCCNut4pUfqpSfGccBEeGc8pjRXyz0RM,1414
22
- modusa-0.4.31.dist-info/RECORD,,
21
+ pyproject.toml,sha256=v0k6ker6OK_uwN08B5XX3WplB8CyPWei0Tp9zMbrTyQ,1414
22
+ modusa-0.4.32.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -16,7 +16,7 @@ dependencies = [
16
16
  ]
17
17
  requires-python = ">=3.11"
18
18
  readme = "README.md"
19
- version = "0.4.31"
19
+ version = "0.4.32"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"