use cursor to create partition

This commit is contained in:
GitBluub
2024-01-18 03:42:21 +01:00
committed by Zoe Roux
parent 0bd12bbf34
commit 5d78d8b5dd
2 changed files with 9 additions and 2 deletions

View File

@@ -9,8 +9,12 @@ from mido import MidiFile
RATIO = 1.0
def getPartition(midiFile: str) -> Partition:
def getPartition(midiFile: str, cursors) -> Partition:
notes = []
for cursor in cursors:
for i in cursor["notes"]:
notes += [Key(i["note"], cursor["timestamp"], i["duration"])]
'''
s = 0
notes_on = {}
prev_note_on = {}
@@ -29,6 +33,7 @@ def getPartition(midiFile: str) -> Partition:
note_start = notes_on[d["note"]]
notes.append(Key(d["note"], note_start, duration - 10))
notes_on[d["note"]] = s # 500
'''
return Partition(midiFile, notes)

View File

@@ -85,7 +85,9 @@ def send(o):
class Scorometer:
def __init__(self, mode: int, midiFile: str, song_id: int, user_id: int) -> None:
self.partition: Partition = getPartition(midiFile)
r = requests.get(f"{BACK_URL}/song/{song_id}/assets/cursors", headers=auth_header).json()
cursors = r["cursors"]
self.partition: Partition = getPartition(midiFile, cursors)
self.practice_partition: list[list[Key]] = self.getPracticePartition(mode)
# the log generated is so long that it's longer than the stderr buffer resulting in a crash
# logging.debug({"partition": self.partition.notes})