今年就这样罢,我摆了,紧急更新,修复一点点小bug

This commit is contained in:
EillesWan 2023-01-20 22:26:04 +08:00
parent 7d6faebc5b
commit e0557da3cf
4 changed files with 28 additions and 32 deletions

2
.gitignore vendored
View File

@ -9,7 +9,7 @@
*.midi
*.mcpack
*.bdx
demo_config.json
*.json
# Byte-compiled / optimized
__pycache__/

View File

@ -249,7 +249,7 @@ while True:
continue
break
debug = False
# 真假字符串判断
def boolstr(sth: str) -> bool:
try:
@ -265,6 +265,9 @@ def boolstr(sth: str) -> bool:
if os.path.exists("./demo_config.json"):
import json
prompts = json.load(open("./demo_config.json",'r',encoding="utf-8"))
if prompts[-1] == "debug":
debug = True
prompts = prompts[:-1]
else:
prompts = []
# 提示语 检测函数 错误提示语
@ -317,10 +320,14 @@ else:
conversion = msctPkgver.midiConvert()
conversion = msctPkgver.midiConvert(debug)
for singleMidi in midis:
prt("\n"f"{_('Dealing')} {singleMidi} {_(':')}")
conversion.convert(singleMidi, outpath)
if debug:
with open("./records.json",'a',encoding="utf-8") as f:
json.dump(conversion.toDICT(),f)
f.write(5*"\n")
conversion_result = (
conversion.tomcpack(2, *prompts)
if fileFormat == 0
@ -330,9 +337,6 @@ for singleMidi in midis:
else conversion.toBDXfile_withDelay(1, *prompts)
)
)
if prompts[-1] == "debug":
with open("./records.json",'a',encoding="utf-8") as f:
json.dump(prompts,f)
if conversion_result[0]:
prt(

View File

@ -7,7 +7,7 @@
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
__version__ = '0.2.1'
__version__ = '0.2.1.1'
__all__ = []
__author__ = (('金羿', 'Eilles Wan'), ('诸葛亮与八卦阵', 'bgArray'), ('鸣凤鸽子', 'MingFengPigeon'))

View File

@ -628,7 +628,7 @@ class midiConvert:
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
channels = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
channels = {}
microseconds = 0
@ -640,7 +640,10 @@ class midiConvert:
microseconds += msg.time * tempo / self.midi.ticks_per_beat
# print(microseconds)
except NameError:
raise NotDefineTempoError("计算当前分数时出错 未定义参量 Tempo")
if self.debugMode:
raise NotDefineTempoError("计算当前分数时出错 未定义参量 Tempo")
else:
microseconds += msg.time * mido.midifiles.midifiles.DEFAULT_TEMPO / self.midi.ticks_per_beat
if msg.is_meta:
if msg.type == "set_tempo":
@ -649,14 +652,12 @@ class midiConvert:
self.prt(f"TEMPO更改{tempo}(毫秒每拍)")
else:
try:
msg.channel
channelMsg = True
except:
channelMsg = False
if channelMsg:
if msg.channel > 15:
raise ChannelOverFlowError(f"当前消息 {msg} 的通道超限(≤15)")
if self.debugMode:
try:
if msg.channel > 15:
raise ChannelOverFlowError(f"当前消息 {msg} 的通道超限(≤15)")
except:
pass
if msg.type == "program_change":
channels[msg.channel].append(("PgmC", msg.program, microseconds))
@ -684,14 +685,14 @@ class midiConvert:
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
if self.debugMode:
self.prt(dict(enumerate(channels)))
self.prt(channels)
tracks = []
cmdAmount = 0
maxScore = 0
# 此处 我们把通道视为音轨
for i in range(len(channels)):
for i in channels.keys():
# 如果当前通道为空 则跳过
if not channels[i]:
continue
@ -1343,7 +1344,7 @@ class midiConvert:
"""
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
channels = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
channels = {}
microseconds = 0
# 我们来用通道统计音乐信息
@ -1353,23 +1354,14 @@ class midiConvert:
try:
microseconds += msg.time * tempo / self.midi.ticks_per_beat
# print(microseconds)
except NameError:
raise NotDefineTempoError("计算当前分数时出错 未定义参量 Tempo")
except:
microseconds += msg.time * mido.midifiles.midifiles.DEFAULT_TEMPO / self.midi.ticks_per_beat
if msg.is_meta:
if msg.type == "set_tempo":
tempo = msg.tempo
else:
try:
msg.channel
channelMsg = True
except:
channelMsg = False
if channelMsg:
if msg.channel > 15:
raise ChannelOverFlowError(f"当前消息 {msg} 的通道超限(≤15)")
if msg.type == "program_change":
channels[msg.channel].append(("PgmC", msg.program, microseconds))
@ -1395,4 +1387,4 @@ class midiConvert:
3 音符结束消息
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
return dict(enumerate(channels))
return channels