pysspm-rhythia 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Daveed
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,2 @@
1
+ include README.md
2
+ include LICENSE
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.1
2
+ Name: pysspm-rhythia
3
+ Version: 0.1.0
4
+ Summary: A Python library dedicated to reading, writing, and modifying the Rhythia SSPM file format
5
+ Home-page: https://github.com/David-Jed/pysspm
6
+ Author: David Jedlovsky
7
+ Author-email: Dev.DavidJed@gmail.com
8
+ Keywords: Rhythia,Sound space,SSPM,Rhythm game,pysspm-rhythia
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+
19
+ # pysspm-rhythia
20
+
21
+ The official python library dedicated to reading, writing, and modifying the SSPM file format from the video game "Rhythia".
22
+
23
+ ## SSPM libray information
24
+
25
+ The library includes these features:
26
+
27
+ > 1. Reading .SSPM files
28
+ > 2. Modifying SSPM data
29
+ > 3. Writing .SSPM files
30
+
31
+ ## How to install/use
32
+
33
+ To install the library, run:
34
+
35
+ ```ps
36
+ pip install pysspm-rythia
37
+ ```
38
+
39
+ to start using it load up SSPMParser from the library.
40
+
41
+ ```python
42
+ from pysspm import SSPMParser
43
+
44
+
45
+ parser = SSPMParser()
46
+
47
+ # Example of loading a SSPMfile
48
+ parser.ReadSSPM("*.sspm")
49
+
50
+ # Example of turning it into a roblox sound space file
51
+
52
+ with open("output.txt", "w") as f:
53
+ f.write(parser.NOTES2TEXT())
54
+
55
+ ```
56
+
57
+ > *Functionality does not end there. When reading files, you have full access to all the metadata, and other information stored in the variables.*
58
+
59
+ **Some common variables you will find are:**
60
+
61
+ 1. `coverBytes` the byteform of the image if cover was found
62
+ 2. `audioBytes` the byteform of the audio in `.mp3` form if audio was found
63
+ 3. `Header`: {"Signature": ..., "Version": ...}
64
+ 4. `Hash`: a SHA-1 hash of the markers (notes) in the map
65
+ 5. `mapID`: A unique combination using the mappers and map name*
66
+ 6. `mappers`: a list containing each mapper.
67
+ 7. `mapName`: The name given to the map.
68
+ 8. `songName`: The original name of the audio before imported. Usually left as artist name - song name
69
+ 9. `customValues`: NOT IMPLEMENTED | will return a dictionary of found custom blocks.
70
+ 10. `isQuantum`: Determins if the level contains ANY float value notes.
71
+ 11. `Notes`: A list of tuples containing all notes. | Example of what it Notes is: `[(x, y, ms), (x, y, ms), (x, y, ms) . . .]`
72
+
73
+ ```python
74
+ from pysspm import SSPMParser
75
+
76
+
77
+ parser = SSPMParser()
78
+
79
+ # Example of loading a SSPMfile
80
+ parser.ReadSSPM("*.sspm")
81
+
82
+ # changing the decal to be a different image
83
+ if parser.hasCover[0] == 0: # hasCover is originally in byteform | Can be 0x00 or 0x01
84
+ with open("cover.png", 'rb') as f:
85
+ parser.coverBytes = f.read() # reading the BYTES of the image
86
+
87
+ # Finally save the sspm file with the newly configured settings
88
+ sspmFileBytes = parser.WriteSSPM()
89
+
90
+ with open('sspmfile.sspm', "wb") as f:
91
+ f.write(sspmFileBytes)
92
+
93
+ ```
94
+
95
+ Alternativly, you can pass in arguments into WriteSSPM function directly
96
+
97
+ ```py
98
+ from pysspm import SSPMParser
99
+
100
+ parser = SSPMParser()
101
+ parser.ReadSSPM("*.sspm")
102
+
103
+ mappers = parser.Mappers.extend('DigitalDemon') # adding another mapper to the mapper list
104
+ parser.WriteSSPM('./SSPMFile.sspm', mappers=mappers)
105
+ ```
106
+
107
+ ## Advanced guide
108
+
109
+ This shows the more advanced things you can do by giving examples of custom written code.
110
+
111
+ ```python
112
+ from pysspm import SSPMParser()
113
+ from random import randint
114
+
115
+ parser = SSPMParser()
116
+
117
+ parser.ReadSSPM("*.sspm") # reading the sspm file
118
+
119
+ sigHeader = parser.Header.get("Signature") # 4 byte header | should always be: b"\x53\x53\x2b\x6d"
120
+ ver = parser.Header.get("Version") # stored as 2 or 1
121
+ sspmHash = parser.Hash # Storing the hash
122
+
123
+ if randint(0, 5) == 5:
124
+ parser.Notes = parser.Notes.extend((1, 1, (parser.Notes[-1][2]+200))) # adding a center note (1,1), with ms of last note + 200
125
+
126
+ newSSPM = parser.WriteSSPM(mappers=["DigitalDemon", "Someone else"], mapName="Possibly modified map haha")
127
+
128
+ # comparing the note hashes
129
+ newSSPMHash = parser.Hash
130
+ if newSSPMHash == sspmhash:
131
+ with open("UnmodifiedMap.sspm", 'wb') as f:
132
+ f.write(newSSPM)
133
+ else:
134
+ raise Warning("Map does not match original hash. Map notes were modified from the original!!!")
135
+
136
+
137
+ ```
138
+
139
+ > Code shows off how hashes are calculated to prevent changes between levels. Could be used for security and integrity of the notes.
140
+
141
+ ***In 0.1.5 and above, a new function, calcHash will be added***
142
+
143
+ *More advanced documentation will be added in the near future...*
144
+
145
+ ## Function Documentation
146
+
147
+ A in-depth list of things you can do with this library
148
+
149
+ ```py
150
+ SSPMParser()
151
+ ```
152
+
153
+ > Initializes the sspm library parser
154
+
155
+ ```py
156
+ def WriteSSPM(self, filename: str = None, debug: bool = False, **kwargs) -> bytearray | None:
157
+ ```
158
+
159
+ > Creates a SSPM v2 file based on variables passed in, or already set.
160
+
161
+ *If no filepath is passed in, it will return file as bytes*
162
+
163
+
164
+ **Variables that need to be covered:**
165
+
166
+ 1. `coverImage`: Cover image in bytes form, or None
167
+ 2. `audioBytes`: Audio in bytes form, or None
168
+ 3. `Difficulty`: one of Difficulties dictionary options, or 0x00 - 05 OR "N/A", "Easy", "Medium", "Hard", "Logic", "Tasukete"
169
+ 4. `mapName`: The name of the map. Rhythia guidelines suggests `artist name - song name`
170
+ 5. `mappers`: a list of strings containing the mapper(s)
171
+ 6. `notes`: a list of tuples as shown below
172
+
173
+ <br>
174
+
175
+ ```python
176
+ # (x, y, ms)
177
+ self.notes = [
178
+ (1, 2, 1685), # X, Y, MS
179
+ (1.22521, 0.156781, 2000)
180
+ ]#...
181
+ ```
182
+
183
+ <br>
184
+
185
+ `**kwargs`: pass in any of the variables shown above.
186
+
187
+ Example usage:
188
+
189
+ ```python
190
+ from sspmLib import SSPMParser
191
+
192
+ sspm = SSPMParser()
193
+ sspm.ReadSSPM("*.sspm") # reads
194
+ sspm.Difficulty = 5 # changes difficulty to Tasukete
195
+
196
+ with open(output_path+".sspm", "wb") as f:
197
+ f.write(sspm.WriteSSPM())
198
+ ```
199
+
200
+ **ReadSSPM**
201
+
202
+ ```py
203
+ def ReadSSPM(self, file: str | BinaryIO, debug: bool = False):
204
+ ```
205
+
206
+ > Reads and processes any SSPM file. <br>
207
+
208
+ `File:` Takes in directory of sspm, or BinaryIO object stored in memory.
209
+ `debug:` Useful for getting readable outputs of steps taken.
210
+
211
+ #### Warning
212
+
213
+ ***SSPM (Sound space plus map file) version 1 is not supported at this time. loading this file may raise errors***
214
+
215
+
216
+
217
+ #### Returns
218
+
219
+ 1. `coverBytes` if cover was found
220
+ 2. `audioBytes` if audio was found
221
+ 3. `Header`: {"Signature": ..., "Version": ...}
222
+ 4. `Hash`: a SHA-1 hash of the markers in the map
223
+ 5. `mapID`: A unique combination using the mappers and map name*
224
+ 6. `mappers`: a list containing each mapper.
225
+ 7. `mapName`: The name given to the map.
226
+ 8. `songName`: The original name of the audio before imported. Usually left as artist name - song name
227
+ 9. `customValues`: NOT IMPLEMENTED | will return a dictionary of found custom blocks.
228
+ 10. `isQuantum`: Determins if the level contains ANY float value notes.
229
+ 11. `Notes`: A list of tuples containing all notes.
230
+
231
+ Example of what it Notes is: `[(x, y, ms), (x, y, ms), (x, y, ms) . . .]`
232
+
233
+
234
+ > ***Returns itself***
235
+
236
+ ## Roadmap
237
+
238
+ TODO: (In order of priority)
239
+
240
+ - Add typing support for library ✔️
241
+ - add proper documentation on github
242
+ - add proper documentation in code ✔️
243
+ - add loading of sspmV2 ✔️
244
+ - add support for creating sspmV2 ✔️
245
+ - clean up unused variables from @self ✔️
246
+ - add support for sspmv1 loading
247
+ - support multiple version of sspm
248
+ - add custom block support in loading
249
+ - Drop numpy dependency
250
+
251
+ Made with 💖 by DigitalDemon (David Jed)
252
+
253
+ >Documentation last updated: `2024-08-17` | `V0.1.0`
@@ -0,0 +1,235 @@
1
+ # pysspm-rhythia
2
+
3
+ The official python library dedicated to reading, writing, and modifying the SSPM file format from the video game "Rhythia".
4
+
5
+ ## SSPM libray information
6
+
7
+ The library includes these features:
8
+
9
+ > 1. Reading .SSPM files
10
+ > 2. Modifying SSPM data
11
+ > 3. Writing .SSPM files
12
+
13
+ ## How to install/use
14
+
15
+ To install the library, run:
16
+
17
+ ```ps
18
+ pip install pysspm-rythia
19
+ ```
20
+
21
+ to start using it load up SSPMParser from the library.
22
+
23
+ ```python
24
+ from pysspm import SSPMParser
25
+
26
+
27
+ parser = SSPMParser()
28
+
29
+ # Example of loading a SSPMfile
30
+ parser.ReadSSPM("*.sspm")
31
+
32
+ # Example of turning it into a roblox sound space file
33
+
34
+ with open("output.txt", "w") as f:
35
+ f.write(parser.NOTES2TEXT())
36
+
37
+ ```
38
+
39
+ > *Functionality does not end there. When reading files, you have full access to all the metadata, and other information stored in the variables.*
40
+
41
+ **Some common variables you will find are:**
42
+
43
+ 1. `coverBytes` the byteform of the image if cover was found
44
+ 2. `audioBytes` the byteform of the audio in `.mp3` form if audio was found
45
+ 3. `Header`: {"Signature": ..., "Version": ...}
46
+ 4. `Hash`: a SHA-1 hash of the markers (notes) in the map
47
+ 5. `mapID`: A unique combination using the mappers and map name*
48
+ 6. `mappers`: a list containing each mapper.
49
+ 7. `mapName`: The name given to the map.
50
+ 8. `songName`: The original name of the audio before imported. Usually left as artist name - song name
51
+ 9. `customValues`: NOT IMPLEMENTED | will return a dictionary of found custom blocks.
52
+ 10. `isQuantum`: Determins if the level contains ANY float value notes.
53
+ 11. `Notes`: A list of tuples containing all notes. | Example of what it Notes is: `[(x, y, ms), (x, y, ms), (x, y, ms) . . .]`
54
+
55
+ ```python
56
+ from pysspm import SSPMParser
57
+
58
+
59
+ parser = SSPMParser()
60
+
61
+ # Example of loading a SSPMfile
62
+ parser.ReadSSPM("*.sspm")
63
+
64
+ # changing the decal to be a different image
65
+ if parser.hasCover[0] == 0: # hasCover is originally in byteform | Can be 0x00 or 0x01
66
+ with open("cover.png", 'rb') as f:
67
+ parser.coverBytes = f.read() # reading the BYTES of the image
68
+
69
+ # Finally save the sspm file with the newly configured settings
70
+ sspmFileBytes = parser.WriteSSPM()
71
+
72
+ with open('sspmfile.sspm', "wb") as f:
73
+ f.write(sspmFileBytes)
74
+
75
+ ```
76
+
77
+ Alternativly, you can pass in arguments into WriteSSPM function directly
78
+
79
+ ```py
80
+ from pysspm import SSPMParser
81
+
82
+ parser = SSPMParser()
83
+ parser.ReadSSPM("*.sspm")
84
+
85
+ mappers = parser.Mappers.extend('DigitalDemon') # adding another mapper to the mapper list
86
+ parser.WriteSSPM('./SSPMFile.sspm', mappers=mappers)
87
+ ```
88
+
89
+ ## Advanced guide
90
+
91
+ This shows the more advanced things you can do by giving examples of custom written code.
92
+
93
+ ```python
94
+ from pysspm import SSPMParser()
95
+ from random import randint
96
+
97
+ parser = SSPMParser()
98
+
99
+ parser.ReadSSPM("*.sspm") # reading the sspm file
100
+
101
+ sigHeader = parser.Header.get("Signature") # 4 byte header | should always be: b"\x53\x53\x2b\x6d"
102
+ ver = parser.Header.get("Version") # stored as 2 or 1
103
+ sspmHash = parser.Hash # Storing the hash
104
+
105
+ if randint(0, 5) == 5:
106
+ parser.Notes = parser.Notes.extend((1, 1, (parser.Notes[-1][2]+200))) # adding a center note (1,1), with ms of last note + 200
107
+
108
+ newSSPM = parser.WriteSSPM(mappers=["DigitalDemon", "Someone else"], mapName="Possibly modified map haha")
109
+
110
+ # comparing the note hashes
111
+ newSSPMHash = parser.Hash
112
+ if newSSPMHash == sspmhash:
113
+ with open("UnmodifiedMap.sspm", 'wb') as f:
114
+ f.write(newSSPM)
115
+ else:
116
+ raise Warning("Map does not match original hash. Map notes were modified from the original!!!")
117
+
118
+
119
+ ```
120
+
121
+ > Code shows off how hashes are calculated to prevent changes between levels. Could be used for security and integrity of the notes.
122
+
123
+ ***In 0.1.5 and above, a new function, calcHash will be added***
124
+
125
+ *More advanced documentation will be added in the near future...*
126
+
127
+ ## Function Documentation
128
+
129
+ A in-depth list of things you can do with this library
130
+
131
+ ```py
132
+ SSPMParser()
133
+ ```
134
+
135
+ > Initializes the sspm library parser
136
+
137
+ ```py
138
+ def WriteSSPM(self, filename: str = None, debug: bool = False, **kwargs) -> bytearray | None:
139
+ ```
140
+
141
+ > Creates a SSPM v2 file based on variables passed in, or already set.
142
+
143
+ *If no filepath is passed in, it will return file as bytes*
144
+
145
+
146
+ **Variables that need to be covered:**
147
+
148
+ 1. `coverImage`: Cover image in bytes form, or None
149
+ 2. `audioBytes`: Audio in bytes form, or None
150
+ 3. `Difficulty`: one of Difficulties dictionary options, or 0x00 - 05 OR "N/A", "Easy", "Medium", "Hard", "Logic", "Tasukete"
151
+ 4. `mapName`: The name of the map. Rhythia guidelines suggests `artist name - song name`
152
+ 5. `mappers`: a list of strings containing the mapper(s)
153
+ 6. `notes`: a list of tuples as shown below
154
+
155
+ <br>
156
+
157
+ ```python
158
+ # (x, y, ms)
159
+ self.notes = [
160
+ (1, 2, 1685), # X, Y, MS
161
+ (1.22521, 0.156781, 2000)
162
+ ]#...
163
+ ```
164
+
165
+ <br>
166
+
167
+ `**kwargs`: pass in any of the variables shown above.
168
+
169
+ Example usage:
170
+
171
+ ```python
172
+ from sspmLib import SSPMParser
173
+
174
+ sspm = SSPMParser()
175
+ sspm.ReadSSPM("*.sspm") # reads
176
+ sspm.Difficulty = 5 # changes difficulty to Tasukete
177
+
178
+ with open(output_path+".sspm", "wb") as f:
179
+ f.write(sspm.WriteSSPM())
180
+ ```
181
+
182
+ **ReadSSPM**
183
+
184
+ ```py
185
+ def ReadSSPM(self, file: str | BinaryIO, debug: bool = False):
186
+ ```
187
+
188
+ > Reads and processes any SSPM file. <br>
189
+
190
+ `File:` Takes in directory of sspm, or BinaryIO object stored in memory.
191
+ `debug:` Useful for getting readable outputs of steps taken.
192
+
193
+ #### Warning
194
+
195
+ ***SSPM (Sound space plus map file) version 1 is not supported at this time. loading this file may raise errors***
196
+
197
+
198
+
199
+ #### Returns
200
+
201
+ 1. `coverBytes` if cover was found
202
+ 2. `audioBytes` if audio was found
203
+ 3. `Header`: {"Signature": ..., "Version": ...}
204
+ 4. `Hash`: a SHA-1 hash of the markers in the map
205
+ 5. `mapID`: A unique combination using the mappers and map name*
206
+ 6. `mappers`: a list containing each mapper.
207
+ 7. `mapName`: The name given to the map.
208
+ 8. `songName`: The original name of the audio before imported. Usually left as artist name - song name
209
+ 9. `customValues`: NOT IMPLEMENTED | will return a dictionary of found custom blocks.
210
+ 10. `isQuantum`: Determins if the level contains ANY float value notes.
211
+ 11. `Notes`: A list of tuples containing all notes.
212
+
213
+ Example of what it Notes is: `[(x, y, ms), (x, y, ms), (x, y, ms) . . .]`
214
+
215
+
216
+ > ***Returns itself***
217
+
218
+ ## Roadmap
219
+
220
+ TODO: (In order of priority)
221
+
222
+ - Add typing support for library ✔️
223
+ - add proper documentation on github
224
+ - add proper documentation in code ✔️
225
+ - add loading of sspmV2 ✔️
226
+ - add support for creating sspmV2 ✔️
227
+ - clean up unused variables from @self ✔️
228
+ - add support for sspmv1 loading
229
+ - support multiple version of sspm
230
+ - add custom block support in loading
231
+ - Drop numpy dependency
232
+
233
+ Made with 💖 by DigitalDemon (David Jed)
234
+
235
+ >Documentation last updated: `2024-08-17` | `V0.1.0`
File without changes
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"