fix: song checking script and rm invalid songs

This commit is contained in:
GitBluub
2023-05-23 17:00:21 +09:00
committed by Clément Le Bihan
parent ce42aadd44
commit 58b8515471
35 changed files with 50 additions and 232 deletions

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=I Vow To Thee My Country
Artist=Gustav Holst
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Menuet in G major (BWV Anh. 114)
Artist=Johann Sebastian Bach
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Prelude I in C major, BWV 846 - Well Tempered Clavier [First Book]
Artist=Johann Sebastian Bach
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Ave Maria (Schubert-Liszt)
Artist=Franz Schubert
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=French National Anthem "La Marseillaise"
Artist=Misc Tunes
Genre=Solo
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Jazz Elite (1919)
Artist=Harry Potter
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Joyful, joyful, we adore thee
Artist=Ludwig Van Beethoven
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Rêverie :Debussy
Artist=Claude Debussy
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Tango La Cumparsita - Piano Solo (Tutorial Parte B)
Artist=Gerardo Matos Rodríguez
Genre=Classical
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Tico-Tico No Fubá Zequinha De Abreu
Artist=Zequinha De Abreu
Genre=World Music
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -1,21 +0,0 @@
[Metadata]
Name=Traditional music - Sally Goodin
Artist=Misc Tunes
Genre=Solo
Album=
[Difficulties]
TwoHands=0
Rhythm=0
NoteCombo=0
Arpeggio=0
Distance=0
LeftHand=0
RightHand=0
LeadHandChange=0
ChordComplexity=0
ChordTiming=0
Length=0
PedalPoint=0
Precision=0

View File

@@ -19,6 +19,7 @@ from chroma_case.Message import (
getMessage,
)
from chroma_case.Partition import Partition
from .song_check import getPartition
from mido import MidiFile
@@ -52,7 +53,7 @@ def send(o):
class Scorometer:
def __init__(self, mode: int, midiFile: str, song_id: int, user_id: int) -> None:
self.partition: Partition = self.getPartition(midiFile)
self.partition: Partition = getPartition(midiFile)
self.practice_partition: list[list[Key]] = self.getPracticePartition(mode)
logging.debug({"partition": self.partition.notes})
self.keys_down = []

48
scorometer/song_check.py Normal file
View File

@@ -0,0 +1,48 @@
import os
import glob
from chroma_case.Key import Key
from chroma_case.Partition import Partition
from mido import MidiFile
RATIO = 1.0
def getPartition(midiFile: str) -> Partition:
notes = []
s = 0
notes_on = {}
prev_note_on = {}
for msg in MidiFile(midiFile):
d = msg.dict()
s += d["time"] * 1000 * RATIO
if "velocity" not in d: continue
if d["type"] == "note_on" and d["velocity"] != 0:
prev_note_on[d["note"]] = 0
if d["note"] in notes_on:
prev_note_on[d["note"]] = notes_on[d["note"]] # 500
notes_on[d["note"]] = s # 0
if d["type"] == "note_off" or d["velocity"] == 0:
duration = s - notes_on[d["note"]]
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)
for file in glob.glob("../musics/**/*.ini", recursive=True):
print(f"File found: {file}")
path = os.path.splitext(file)[0]
midi_path = path + ".midi"
try:
p = getPartition(midi_path)
if len(p.notes) == 0: print(f"Empty partition: {midi_path}")
except:
print(f"Error: {midi_path}")
continue