modusa 0.4.27__py3-none-any.whl → 0.4.28__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
@@ -8,4 +8,6 @@ from modusa.tools import play, convert, record, save
8
8
  from modusa.tools import download
9
9
  from modusa.tools import load, load_ann
10
10
 
11
- __version__ = "0.4.27"
11
+ from modusa.tools import synth_f0
12
+
13
+ __version__ = "0.4.28"
modusa/tools/__init__.py CHANGED
@@ -9,4 +9,6 @@ from .ann_loader import load_ann
9
9
  from .audio_recorder import record
10
10
 
11
11
  from .plotter import Fig as fig
12
- from .plotter import dist_plot, hill_plot, plot
12
+ from .plotter import dist_plot, hill_plot, plot
13
+
14
+ from .synth import synth_f0
modusa/tools/synth.py ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #---------------------------------
4
+ # Author: Ankit Anand
5
+ # Date: 22/10/25
6
+ # Email: ankit0.anand0@gmail.com
7
+ #---------------------------------
8
+
9
+ def synth_f0(f0, f0t, sr, nharm=0):
10
+ """
11
+ Synthesize f0 contour so that you can
12
+ hear it back.
13
+
14
+ Parameters
15
+ ----------
16
+ f0: ndarray
17
+ - Fundamental frequency (f0) contour in Hz.
18
+ f0t: ndarray
19
+ - Timestamps in seconds
20
+ sr: int
21
+ - Sampling rate in Hz for the synthesized audio.
22
+ nharm: int
23
+ - Number of harmonics
24
+ - Default: 0 => Only fundamental frequency (No harmonics)
25
+
26
+ Returns
27
+ -------
28
+ ndarray
29
+ - Syntesized audio.
30
+ sr
31
+ - Sampling rate of the synthesized audio
32
+ """
33
+
34
+ # Create new time axis
35
+ t = np.arange(0, f0t[-1], 1 / sr)
36
+
37
+ # Interpolate the f0 to match the sampling time points
38
+ f0_interp = np.interp(t, f0t, f0)
39
+
40
+ # Compute phase by integrating frequency over time
41
+ phase = 2 * np.pi * np.cumsum(f0_interp) / sr
42
+
43
+ # Start with fundamental
44
+ y = np.sin(phase)
45
+
46
+ # Add harmonics if requested
47
+ for n in range(2, nharm + 2): # from 2nd to (nharm+1)th harmonic
48
+ y += np.sin(n * phase) / n**2 # dividing by n to reduce harmonic amplitude
49
+
50
+ # Normalize output to avoid clipping
51
+ y /= np.max(np.abs(y))
52
+
53
+ return y, sr
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.4.27
3
+ Version: 0.4.28
4
4
  Summary: A modular signal analysis python library.
5
5
  Author-Email: Ankit Anand <ankit0.anand0@gmail.com>
6
6
  License: MIT
@@ -1,10 +1,10 @@
1
1
  LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
2
2
  README.md,sha256=Ybe2rcDecfSCiUpec2n7btQvgyi4R9JG0bfdwSWijWk,981
3
- modusa-0.4.27.dist-info/METADATA,sha256=in1--mu4GEgZuM7EbaPi1y6VllJ5lFyYhTu1p2g1VBA,1442
4
- modusa-0.4.27.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
5
- modusa-0.4.27.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
6
- modusa-0.4.27.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
7
- modusa/__init__.py,sha256=JTwvzlog-zi87g4HYG1BD_gngzceaQJXeiR3h8pWg60,324
3
+ modusa-0.4.28.dist-info/METADATA,sha256=SbjrOO2aDmiL4sber_0ROvDBgfc54nFeN11oa_Up76w,1442
4
+ modusa-0.4.28.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
5
+ modusa-0.4.28.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
6
+ modusa-0.4.28.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
7
+ modusa/__init__.py,sha256=m0Vh3SouHLacDwiiEV8oJ2ehpbETV8J6u-CqYAJws5E,359
8
8
  modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
9
9
  modusa/decorators.py,sha256=8zeNX_wE37O6Vp0ysR4-WCZaEL8mq8dyCF_I5DHOzks,5905
10
10
  modusa/devtools/generate_docs_source.py,sha256=UDflHsk-Yh9-3YJTVBzKL32y8hcxiRgAlFEBTMiDqwM,3301
@@ -42,7 +42,7 @@ modusa/models/t_ax.py,sha256=ZUhvZPUW1TkdZYuUd6Ucm-vsv0JqtZ9yEe3ab67Ma6w,8022
42
42
  modusa/models/tds.py,sha256=FAGfibjyyE_lkEuQp-vSCuqQnopOjmy_IXqUjRlg9kc,11677
43
43
  modusa/plugins/__init__.py,sha256=r1Bf5mnrVKRIwxboutY1iGzDy4EPQhqpk1kSW7iJj_Q,54
44
44
  modusa/plugins/base.py,sha256=Bh_1Bja7fOymFsCgwhXDbV6ys3D8muNrPwrfDrG_G_A,2382
45
- modusa/tools/__init__.py,sha256=S7P1uYckyUdkha2UX9uj4P7mqpF6cc5SHqiW6NEupgs,342
45
+ modusa/tools/__init__.py,sha256=YWbsQ40Pcu3Md2lNoKe4JnFtvpMGUVEwE92PoDkc6v4,371
46
46
  modusa/tools/_plotter_old.py,sha256=KGow7mihA2H1WNq7s5bpivhCgGo2qVIeDaO6iabpsrg,19294
47
47
  modusa/tools/ann_loader.py,sha256=m6Qu6jXnQ8LfUhKItoHSaHlGxUyzUJlGEyu4_50qJ8w,3099
48
48
  modusa/tools/audio_converter.py,sha256=415qBoPm2sBIuBSI7m1XBKm0AbmVmPydIPPr-uO8D3c,1778
@@ -53,6 +53,7 @@ modusa/tools/audio_saver.py,sha256=ldzfr_AydsHTnKbxmBLJblN-hLzTmOlppOm306xI4Ug,5
53
53
  modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
54
54
  modusa/tools/math_ops.py,sha256=ZZ7U4DgqT7cOeE7_Lzi_Qq-48WYfwR9_osbZwTmE9eg,8690
55
55
  modusa/tools/plotter.py,sha256=QfF8kCi79nS-J5lQyEuH_BbAmTo-PdfjDbnK9yTAmRE,30863
56
+ modusa/tools/synth.py,sha256=-oaCQbz21ZaleIxJ4uZP-c8b9Wjrwhi33STDKu9uLDg,1202
56
57
  modusa/tools/youtube_downloader.py,sha256=hB_X8-7nOHXOlxg6vv3wyhBLoAsWyomrULP6_uCQL7s,1698
57
58
  modusa/utils/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
58
59
  modusa/utils/config.py,sha256=cuGbqbovx5WDQq5rw3hIKcv3CnE5NttjacSOWnP1yu4,576
@@ -60,5 +61,5 @@ modusa/utils/excp.py,sha256=L9vhaGjKpv9viJYdmC9n5ndmk2GVbUBuFyZyhAQZmWY,906
60
61
  modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
61
62
  modusa/utils/np_func_cat.py,sha256=TyIFgRc6bARRMDnZxlVURO5Z0I-GWhxRONYyIv-Vwxs,1007
62
63
  modusa/utils/plot.py,sha256=s_vNdxvKfwxEngvJPgrF1PcmxZNnNaaXPViHWjyjJ-c,5335
63
- pyproject.toml,sha256=19Ne5cd7ykQB99LyXBiJYV71N0yyySJPwejXBdc8WTk,1413
64
- modusa-0.4.27.dist-info/RECORD,,
64
+ pyproject.toml,sha256=jsT7XGIUHSiP4RZosRROYMuLhngW6uHfTcwYtAgAZNw,1413
65
+ modusa-0.4.28.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.27"
19
+ version = "0.4.28"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"