modusa 0.4.27__py3-none-any.whl → 0.4.29__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.29"
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,55 @@
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
+ import numpy as np
10
+
11
+ def synth_f0(f0, f0t, sr, nharm=0):
12
+ """
13
+ Synthesize f0 contour so that you can
14
+ hear it back.
15
+
16
+ Parameters
17
+ ----------
18
+ f0: ndarray
19
+ - Fundamental frequency (f0) contour in Hz.
20
+ f0t: ndarray
21
+ - Timestamps in seconds
22
+ sr: int
23
+ - Sampling rate in Hz for the synthesized audio.
24
+ nharm: int
25
+ - Number of harmonics
26
+ - Default: 0 => Only fundamental frequency (No harmonics)
27
+
28
+ Returns
29
+ -------
30
+ ndarray
31
+ - Syntesized audio.
32
+ sr
33
+ - Sampling rate of the synthesized audio
34
+ """
35
+
36
+ # Create new time axis
37
+ t = np.arange(0, f0t[-1], 1 / sr)
38
+
39
+ # Interpolate the f0 to match the sampling time points
40
+ f0_interp = np.interp(t, f0t, f0)
41
+
42
+ # Compute phase by integrating frequency over time
43
+ phase = 2 * np.pi * np.cumsum(f0_interp) / sr
44
+
45
+ # Start with fundamental
46
+ y = np.sin(phase)
47
+
48
+ # Add harmonics if requested
49
+ for n in range(2, nharm + 2): # from 2nd to (nharm+1)th harmonic
50
+ y += np.sin(n * phase) / n**2 # dividing by n to reduce harmonic amplitude
51
+
52
+ # Normalize output to avoid clipping
53
+ y /= np.max(np.abs(y))
54
+
55
+ 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.29
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.29.dist-info/METADATA,sha256=w3Ounw63-5pcA2jlrzHptInjFOboEqvj1xDLy9GWSmk,1442
4
+ modusa-0.4.29.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
5
+ modusa-0.4.29.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
6
+ modusa-0.4.29.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
7
+ modusa/__init__.py,sha256=96xDqsDInWHPGL6zgax7NY_p0IVtEtReyKORnL97dlY,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=tfCjTAucTDwb0yOHHnrNO7EFsuH7tNb1PwvS2xwmhK0,1222
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=qtq7gqezVAXHCMMLYQbQGdIJT1g7A0CgavxR1RhHJFo,1413
65
+ modusa-0.4.29.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.29"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"