libmogra 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.
libmogra-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Neeraja Abhyankar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.1
2
+ Name: libmogra
3
+ Version: 0.1.0
4
+ Summary: "A Python Toolbox for Indian (Classical) Music"
5
+ Home-page: https://github.com/neerajaabhyankar/libmogra
6
+ License: MIT
7
+ Keywords: music,indian classical music,raga,raag,taal,swar,indian music,classical music,hindustani classical music
8
+ Author: Neeraja Abhyankar
9
+ Author-email: neeraja.abhyankar@gmail.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Project-URL: Repository, https://github.com/neerajaabhyankar/libmogra
16
+ Description-Content-Type: text/markdown
17
+
18
+ # libmogra
19
+
20
+ A Python Toolbox for Indian (Classical) Music
21
+
22
+ ## The Why
23
+
24
+ For playing around (understanding, modifying, etc.) with music & audio specifically in the Indian context. Music theory standardization as well as tool development has been done extensively for western music, but other music cultures lag behind. This library will start with small features, but the dream is to have a Photoshop for Indian music.
25
+
26
+ ## The What
27
+
28
+ This is intended to be a higher-level layer on top of the widely used [librosa](https://github.com/librosa/librosa).
29
+ If you must have an acronym, here it is: a LIBrary for the Manipulation, Organization, Generation, and Raag-aware Analysis of music. If that's too much, think of [mogra](https://en.wikipedia.org/wiki/Jasminum_sambac) the flower `:)`
30
+
@@ -0,0 +1,12 @@
1
+ # libmogra
2
+
3
+ A Python Toolbox for Indian (Classical) Music
4
+
5
+ ## The Why
6
+
7
+ For playing around (understanding, modifying, etc.) with music & audio specifically in the Indian context. Music theory standardization as well as tool development has been done extensively for western music, but other music cultures lag behind. This library will start with small features, but the dream is to have a Photoshop for Indian music.
8
+
9
+ ## The What
10
+
11
+ This is intended to be a higher-level layer on top of the widely used [librosa](https://github.com/librosa/librosa).
12
+ If you must have an acronym, here it is: a LIBrary for the Manipulation, Organization, Generation, and Raag-aware Analysis of music. If that's too much, think of [mogra](https://en.wikipedia.org/wiki/Jasminum_sambac) the flower `:)`
@@ -0,0 +1 @@
1
+ from .datatypes import *
@@ -0,0 +1,128 @@
1
+ from dataclasses import dataclass
2
+ from collections import OrderedDict
3
+ from enum import Enum
4
+ from typing import List, Dict, Tuple, Optional
5
+ import bisect
6
+
7
+
8
+ class Swar(Enum):
9
+ S = 0
10
+ r = 1
11
+ R = 2
12
+ g = 3
13
+ G = 4
14
+ m = 5 # shuddha!
15
+ M = 6 # teevra!
16
+ P = 7
17
+ d = 8
18
+ D = 9
19
+ n = 10
20
+ N = 11
21
+
22
+
23
+ SAPTAK_MARKS = OrderedDict({",,": -2, ",": -1, "": 0, "`": 1, "``": 2})
24
+
25
+
26
+ class Saptak(Enum):
27
+ ati_mandra = -2
28
+ mandra = -1
29
+ madhya = 0
30
+ taara = 1
31
+ ati_taara = 2
32
+
33
+
34
+ class SSwar(object):
35
+ def __init__(self, saptak_mark="", swar_name="S"):
36
+ self.saptak = Saptak(SAPTAK_MARKS[saptak_mark])
37
+ try:
38
+ self.swar = Swar[swar_name]
39
+ except:
40
+ print(f"WARNING: NO SWAR {swar_name}")
41
+ if swar_name in "ps":
42
+ print(f"trying {swar_name.upper()}")
43
+ self.swar = Swar[swar_name.upper()]
44
+
45
+ def __str__(self):
46
+ return list(SAPTAK_MARKS)[self.saptak.value + 2] + self.swar.name
47
+
48
+ def __repr__(self) -> str:
49
+ return self.__str__()
50
+
51
+ def __eq__(self, other):
52
+ return self.swar == other.swar
53
+
54
+
55
+ def normalize_frequency(ff):
56
+ while ff < 1:
57
+ ff *= 2
58
+ while ff >= 2:
59
+ ff /= 2
60
+ return float(ff)
61
+
62
+
63
+ SWAR_BOUNDARIES = [
64
+ 1.026749,
65
+ 1.088889,
66
+ 1.155093,
67
+ 1.225,
68
+ 1.299479,
69
+ 1.378125,
70
+ 1.452655,
71
+ 1.540123,
72
+ 1.633333,
73
+ 1.732639,
74
+ 1.8375,
75
+ 1.949219,
76
+ ]
77
+
78
+
79
+ def ratio_to_swar(ff: float):
80
+ """
81
+ Per the swar boundaries, returns the coarse-grained Swar symbol that ff may map to
82
+ """
83
+ si = bisect.bisect_left(SWAR_BOUNDARIES, ff)
84
+ return Swar(si % 12).name
85
+
86
+
87
+ PRIMES = [3, 5, 7, 11]
88
+
89
+
90
+ class Shruti:
91
+ def __init__(
92
+ self,
93
+ num_denom: Optional[Tuple[int, int]] = None,
94
+ powers: Optional[Tuple] = None,
95
+ ) -> None:
96
+ self.ratio = 1
97
+ if num_denom is not None:
98
+ self.ratio = num_denom[0] / num_denom[1]
99
+ elif powers is not None:
100
+ for ii, pp in enumerate(powers):
101
+ self.ratio *= PRIMES[ii] ** pp
102
+
103
+ self.frequency = normalize_frequency(self.ratio)
104
+ self.swar = ratio_to_swar(self.frequency)
105
+
106
+
107
+ class Samooha:
108
+ def __init__(self, string) -> None:
109
+ self.list = []
110
+ ii = 0
111
+ while ii < len(string):
112
+ if (ii < len(string) - 1) and string[ii + 1] in SAPTAK_MARKS:
113
+ self.list.append(SSwar(string[ii + 1], string[ii]))
114
+ ii += 1
115
+ else:
116
+ try:
117
+ self.list.append(SSwar("", string[ii]))
118
+ except Exception as e:
119
+ print("skipping char", string[ii], "; ", e)
120
+ ii += 1
121
+
122
+
123
+ # @dataclass
124
+ # class Raag:
125
+ # name: str
126
+ # alt_names: List[str]
127
+ # aaroha: List[Swar]
128
+ # avaroha: List[Swar]
@@ -0,0 +1,28 @@
1
+ [tool.poetry]
2
+ name = "libmogra"
3
+ version = "0.1.0"
4
+ description = "\"A Python Toolbox for Indian (Classical) Music\""
5
+ authors = ["Neeraja Abhyankar <neeraja.abhyankar@gmail.com>"]
6
+ license = "MIT License"
7
+ readme = "README.md"
8
+ homepage = "https://github.com/neerajaabhyankar/libmogra"
9
+ repository = "https://github.com/neerajaabhyankar/libmogra"
10
+ keywords=["music", "indian classical music", "raga", "raag", "taal", "swar", "indian music", "classical music", "hindustani classical music"]
11
+ classifiers=[
12
+ "Programming Language :: Python :: 3",
13
+ "Operating System :: OS Independent",
14
+ ]
15
+ include = ["LICENSE"]
16
+
17
+
18
+ [tool.poetry.dependencies]
19
+ python = "^3.11"
20
+
21
+
22
+ [tool.poetry.group.dev.dependencies]
23
+ pytest = "^8.3.3"
24
+ black = "^24.10.0"
25
+
26
+ [build-system]
27
+ requires = ["poetry-core"]
28
+ build-backend = "poetry.core.masonry.api"