修复了部分midi文件无法读取的错误

This commit is contained in:
2022-02-01 18:20:14 +08:00
parent 9093a66639
commit 882ce96b90
13 changed files with 34 additions and 50 deletions

View File

@ -40,11 +40,11 @@ def midiNewReader(midfile: str):
isPercussion = False
try:
mid = mido.MidiFile(midfile)
except FileNotFoundError:
except Exception:
log("找不到文件或无法读取文件" + midfile)
return False
tpb = mid.ticks_per_beat
bpm = get(midfile)
bpm = get(mid)
# 解析
# def loadMidi(track1):
for track in mid.tracks:
@ -127,12 +127,13 @@ def midiClassReader(midfile: str):
Notes = []
tracks = []
try:
mid = mido.MidiFile(midfile)
except FileNotFoundError:
mid = mido.MidiFile(filename=midfile,clip=True)
except Exception:
log("找不到文件或无法读取文件" + midfile)
return False
log("midi已经载入了。")
tpb = mid.ticks_per_beat
bpm = get(midfile)
bpm = get(mid)
for track in mid.tracks:
overallTime = 0.0
instrument = 0