mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-11 01:27:35 +08:00
修复了部分midi文件无法读取的错误
This commit is contained in:
parent
9093a66639
commit
882ce96b90
@ -700,25 +700,16 @@ def __main__():
|
||||
del midfile
|
||||
|
||||
def midiSPT(th_):
|
||||
try:
|
||||
try:
|
||||
for i in th_.getResult():
|
||||
datas = DMM()
|
||||
datas['notes'] = i
|
||||
dataset[0]['musics'].append(datas)
|
||||
del th_
|
||||
global is_save
|
||||
is_save = False
|
||||
global NowMusic
|
||||
RefreshMain()
|
||||
RefreshMusic(NowMusic)
|
||||
except OSError:
|
||||
tkinter.messagebox.showerror(READABLETEXT[0], READABLETEXT[167])
|
||||
except AttributeError:
|
||||
try:
|
||||
tkinter.messagebox.showerror(READABLETEXT[0], READABLETEXT[167])
|
||||
except OSError:
|
||||
tkinter.messagebox.showerror(READABLETEXT[0], READABLETEXT[167])
|
||||
for i in th_.getResult():
|
||||
datas = DMM()
|
||||
datas['notes'] = i
|
||||
dataset[0]['musics'].append(datas)
|
||||
del th_
|
||||
global is_save
|
||||
is_save = False
|
||||
global NowMusic
|
||||
RefreshMain()
|
||||
RefreshMusic(NowMusic)
|
||||
threading.Thread(target=midiSPT, args=(th,)).start()
|
||||
del th
|
||||
dataset[0]['mainset']['ReadMethod'] = "class"
|
||||
|
Binary file not shown.
BIN
bgArrayLib/__pycache__/pitchStrConstant.cpython-38.pyc
Normal file
BIN
bgArrayLib/__pycache__/pitchStrConstant.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -6,8 +6,8 @@ def mt2gt(mt, tpb_a, bpm_a):
|
||||
return round(mt / tpb_a / bpm_a * 60)
|
||||
|
||||
|
||||
def get(mf):
|
||||
mid = mido.MidiFile(mf)
|
||||
def get(mid:mido.MidiFile):
|
||||
# mid = mido.MidiFile(mf)
|
||||
long = mid.length
|
||||
tpb = mid.ticks_per_beat
|
||||
bpm = 20
|
||||
@ -45,13 +45,13 @@ def get(mf):
|
||||
return list(last_dic.keys())[0]
|
||||
|
||||
|
||||
def compute(mf):
|
||||
mid = mido.MidiFile(mf)
|
||||
def compute(mid:mido.MidiFile):
|
||||
answer = 60000000/mid.ticks_per_beat
|
||||
print(answer)
|
||||
return answer
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
get(r"C:\Users\lc\Documents\MuseScore3\乐谱\乐谱\Bad style - Time back.mid")
|
||||
compute(r"C:\Users\lc\Documents\MuseScore3\乐谱\乐谱\Bad style - Time back.mid")
|
||||
mid = mido.MidiFile(r"C:\Users\lc\Documents\MuseScore3\乐谱\乐谱\Bad style - Time back.mid")
|
||||
get(mid)
|
||||
compute(mid)
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -97,7 +97,7 @@ class version:
|
||||
)
|
||||
"""当前所需库,有一些是开发用的,用户不需要安装"""
|
||||
|
||||
version = ('0.1.5', 'Delta',)
|
||||
version = ('0.1.5.1', 'Delta',)
|
||||
"""当前版本"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
@ -1,35 +1,22 @@
|
||||
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||
# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:9个--未解决1个
|
||||
|
||||
|
||||
|
||||
import threading
|
||||
|
||||
|
||||
class NewThread(threading.Thread):
|
||||
"""新建一个进程来运行函数,函数运行完毕后可以使用.getResult方法获取其返回值"""
|
||||
|
||||
'''新建一个进程来运行函数,函数运行完毕后可以使用.getResult方法获取其返回值'''
|
||||
def __init__(self, func, args=()):
|
||||
super(NewThread, self).__init__()
|
||||
self.func = func
|
||||
self.args = args
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
self.result = self.func(*self.args)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.result = self.func(*self.args)
|
||||
def getResult(self):
|
||||
threading.Thread.join(self) # 等待线程执行完毕
|
||||
try:
|
||||
try:
|
||||
try:
|
||||
return self.result
|
||||
except OSError:
|
||||
return None
|
||||
except IOError:
|
||||
return None
|
||||
except ValueError:
|
||||
return self.result
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
#
|
||||
@ -37,4 +24,4 @@ class NewThread(threading.Thread):
|
||||
# 版权声明:上面的类NewThread修改自CSDN博主「星火燎愿」的原创文章中的内容,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
|
||||
# 原文链接:https://blog.csdn.net/xpt211314/article/details/109543014
|
||||
# ————————————————
|
||||
#
|
||||
#
|
@ -35,6 +35,11 @@ Copyright © W-YI 2022
|
||||
|
||||
新更新日志
|
||||
|
||||
|
||||
Delta 0.1.5.1
|
||||
2022 2 1 农历大年初一
|
||||
1.修复了部分midi文件无法读取的错误
|
||||
|
||||
Delta 0.1.5
|
||||
2022 2 1 农历大年初一
|
||||
1.修复所有用户在使用过程中可遇到的bug
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user