mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-13 10:57:43 +08:00
今年就这样罢,我摆了,紧急更新,修复一点点小bug
This commit is contained in:
parent
7d6faebc5b
commit
e0557da3cf
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,7 +9,7 @@
|
|||||||
*.midi
|
*.midi
|
||||||
*.mcpack
|
*.mcpack
|
||||||
*.bdx
|
*.bdx
|
||||||
demo_config.json
|
*.json
|
||||||
|
|
||||||
# Byte-compiled / optimized
|
# Byte-compiled / optimized
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
14
magicDemo.py
14
magicDemo.py
@ -249,7 +249,7 @@ while True:
|
|||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
debug = False
|
||||||
# 真假字符串判断
|
# 真假字符串判断
|
||||||
def boolstr(sth: str) -> bool:
|
def boolstr(sth: str) -> bool:
|
||||||
try:
|
try:
|
||||||
@ -265,6 +265,9 @@ def boolstr(sth: str) -> bool:
|
|||||||
if os.path.exists("./demo_config.json"):
|
if os.path.exists("./demo_config.json"):
|
||||||
import json
|
import json
|
||||||
prompts = json.load(open("./demo_config.json",'r',encoding="utf-8"))
|
prompts = json.load(open("./demo_config.json",'r',encoding="utf-8"))
|
||||||
|
if prompts[-1] == "debug":
|
||||||
|
debug = True
|
||||||
|
prompts = prompts[:-1]
|
||||||
else:
|
else:
|
||||||
prompts = []
|
prompts = []
|
||||||
# 提示语 检测函数 错误提示语
|
# 提示语 检测函数 错误提示语
|
||||||
@ -317,10 +320,14 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
conversion = msctPkgver.midiConvert()
|
conversion = msctPkgver.midiConvert(debug)
|
||||||
for singleMidi in midis:
|
for singleMidi in midis:
|
||||||
prt("\n"f"{_('Dealing')} {singleMidi} {_(':')}")
|
prt("\n"f"{_('Dealing')} {singleMidi} {_(':')}")
|
||||||
conversion.convert(singleMidi, outpath)
|
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_result = (
|
||||||
conversion.tomcpack(2, *prompts)
|
conversion.tomcpack(2, *prompts)
|
||||||
if fileFormat == 0
|
if fileFormat == 0
|
||||||
@ -330,9 +337,6 @@ for singleMidi in midis:
|
|||||||
else conversion.toBDXfile_withDelay(1, *prompts)
|
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]:
|
if conversion_result[0]:
|
||||||
prt(
|
prt(
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
|
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
|
||||||
|
|
||||||
|
|
||||||
__version__ = '0.2.1'
|
__version__ = '0.2.1.1'
|
||||||
__all__ = []
|
__all__ = []
|
||||||
__author__ = (('金羿', 'Eilles Wan'), ('诸葛亮与八卦阵', 'bgArray'), ('鸣凤鸽子', 'MingFengPigeon'))
|
__author__ = (('金羿', 'Eilles Wan'), ('诸葛亮与八卦阵', 'bgArray'), ('鸣凤鸽子', 'MingFengPigeon'))
|
||||||
|
|
||||||
|
@ -628,7 +628,7 @@ class midiConvert:
|
|||||||
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
|
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
|
||||||
|
|
||||||
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
|
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
|
||||||
channels = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
|
channels = {}
|
||||||
|
|
||||||
microseconds = 0
|
microseconds = 0
|
||||||
|
|
||||||
@ -640,7 +640,10 @@ class midiConvert:
|
|||||||
microseconds += msg.time * tempo / self.midi.ticks_per_beat
|
microseconds += msg.time * tempo / self.midi.ticks_per_beat
|
||||||
# print(microseconds)
|
# print(microseconds)
|
||||||
except NameError:
|
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.is_meta:
|
||||||
if msg.type == "set_tempo":
|
if msg.type == "set_tempo":
|
||||||
@ -649,14 +652,12 @@ class midiConvert:
|
|||||||
self.prt(f"TEMPO更改:{tempo}(毫秒每拍)")
|
self.prt(f"TEMPO更改:{tempo}(毫秒每拍)")
|
||||||
else:
|
else:
|
||||||
|
|
||||||
try:
|
if self.debugMode:
|
||||||
msg.channel
|
try:
|
||||||
channelMsg = True
|
if msg.channel > 15:
|
||||||
except:
|
raise ChannelOverFlowError(f"当前消息 {msg} 的通道超限(≤15)")
|
||||||
channelMsg = False
|
except:
|
||||||
if channelMsg:
|
pass
|
||||||
if msg.channel > 15:
|
|
||||||
raise ChannelOverFlowError(f"当前消息 {msg} 的通道超限(≤15)")
|
|
||||||
|
|
||||||
if msg.type == "program_change":
|
if msg.type == "program_change":
|
||||||
channels[msg.channel].append(("PgmC", msg.program, microseconds))
|
channels[msg.channel].append(("PgmC", msg.program, microseconds))
|
||||||
@ -684,14 +685,14 @@ class midiConvert:
|
|||||||
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
|
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
|
||||||
|
|
||||||
if self.debugMode:
|
if self.debugMode:
|
||||||
self.prt(dict(enumerate(channels)))
|
self.prt(channels)
|
||||||
|
|
||||||
tracks = []
|
tracks = []
|
||||||
cmdAmount = 0
|
cmdAmount = 0
|
||||||
maxScore = 0
|
maxScore = 0
|
||||||
|
|
||||||
# 此处 我们把通道视为音轨
|
# 此处 我们把通道视为音轨
|
||||||
for i in range(len(channels)):
|
for i in channels.keys():
|
||||||
# 如果当前通道为空 则跳过
|
# 如果当前通道为空 则跳过
|
||||||
if not channels[i]:
|
if not channels[i]:
|
||||||
continue
|
continue
|
||||||
@ -1343,7 +1344,7 @@ class midiConvert:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
|
# 一个midi中仅有16通道 我们通过通道来识别而不是音轨
|
||||||
channels = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
|
channels = {}
|
||||||
microseconds = 0
|
microseconds = 0
|
||||||
|
|
||||||
# 我们来用通道统计音乐信息
|
# 我们来用通道统计音乐信息
|
||||||
@ -1353,23 +1354,14 @@ class midiConvert:
|
|||||||
try:
|
try:
|
||||||
microseconds += msg.time * tempo / self.midi.ticks_per_beat
|
microseconds += msg.time * tempo / self.midi.ticks_per_beat
|
||||||
# print(microseconds)
|
# print(microseconds)
|
||||||
except NameError:
|
except:
|
||||||
raise NotDefineTempoError("计算当前分数时出错 未定义参量 Tempo")
|
microseconds += msg.time * mido.midifiles.midifiles.DEFAULT_TEMPO / self.midi.ticks_per_beat
|
||||||
|
|
||||||
if msg.is_meta:
|
if msg.is_meta:
|
||||||
if msg.type == "set_tempo":
|
if msg.type == "set_tempo":
|
||||||
tempo = msg.tempo
|
tempo = msg.tempo
|
||||||
else:
|
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":
|
if msg.type == "program_change":
|
||||||
channels[msg.channel].append(("PgmC", msg.program, microseconds))
|
channels[msg.channel].append(("PgmC", msg.program, microseconds))
|
||||||
|
|
||||||
@ -1395,4 +1387,4 @@ class midiConvert:
|
|||||||
3 音符结束消息
|
3 音符结束消息
|
||||||
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
|
("NoteS", 结束的音符ID, 距离演奏开始的毫秒)"""
|
||||||
|
|
||||||
return dict(enumerate(channels))
|
return channels
|
Loading…
Reference in New Issue
Block a user