mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-11 01:27:35 +08:00
修改算法,修正bug
This commit is contained in:
parent
7d814bcda2
commit
453ca745af
@ -111,7 +111,8 @@
|
||||
## 致谢🙏
|
||||
|
||||
- 感谢 昀梦\<QQ1515399885\> 找出指令生成错误bug并指正
|
||||
- 感谢由 Charlie_Ping “查理平” 带来的bdx文件转换参考
|
||||
- 感谢由 Charlie_Ping “查理平” 带来的bdx文件转换参考,
|
||||
以及mid转我的世界乐器参考表格
|
||||
- 感谢由 CMA_2401PT 为我们的软件开发进行指导
|
||||
- 感谢由 Dislink Sforza \<QQ1600515314\>带来的midi音色解析以及转换指令的算法,我们将其加入了我们众多算法之一
|
||||
- 感谢 Touch \<QQ1793537164\>提供的测试支持
|
||||
|
@ -123,7 +123,8 @@ This is a default definder parameter:
|
||||
- Thank [Fuckcraft](https://github.com/fuckcraft) *(“鸣凤鸽子” ,etc)* for the function of Creating the Websocket Server for Minecraft: Bedrock Edition.
|
||||
- *!! They have given me the rights to directly copy the lib into Musicreater*
|
||||
- Thank *昀梦*\<QQ1515399885\> for finding and correcting the bugs in the commands that *Musicreater* Created.
|
||||
- Thank *Charlie_Ping “查理平”* for bdx convert funtion.
|
||||
- Thank *Charlie_Ping “查理平”* for bdx convert function, and
|
||||
the data label that's used to convert the mid's instruments into minecraft's instruments.
|
||||
- Thank *CMA_2401PT* for BDXWorkShop as the .bdx structure's operation guide.
|
||||
- Thank *Miracle Plume “神羽”* \<QQshenyu40403\> for the Miracle Plume Bedrock Edition Audio Resource Pack
|
||||
- 感谢由 Dislink Sforza \<QQ1600515314\>带来的midi转换算法,我们将其加入了我们众多算法之一
|
||||
|
@ -13,3 +13,10 @@ convertion.tomcpack(
|
||||
float(input('请输入音量(0-1):')),
|
||||
float(input('请输入速度倍率:')),
|
||||
)
|
||||
|
||||
# for the test
|
||||
# if __name__ == '__main__':
|
||||
# convertion = midiConvert()
|
||||
# convertion.convert(r"C:\Users\lc\Documents\MuseScore3\乐谱\乐谱\victory.mid", ".")
|
||||
# convertion.tomcpack(
|
||||
# 1, True, True, "scb", 1, 1)
|
||||
|
51
msctPkgver/load_InstrumentLabel.py
Normal file
51
msctPkgver/load_InstrumentLabel.py
Normal file
@ -0,0 +1,51 @@
|
||||
from openpyxl import *
|
||||
|
||||
|
||||
def get():
|
||||
wb = load_workbook('program音色表.xlsx')
|
||||
|
||||
ws = wb.active
|
||||
# 所有行
|
||||
keys = []
|
||||
values = []
|
||||
for row in ws.iter_rows():
|
||||
for cell in row:
|
||||
# print(cell.value)
|
||||
try:
|
||||
keys.append(int(cell.value))
|
||||
except ValueError:
|
||||
values.append(cell.value)
|
||||
# # 所有列
|
||||
# for column in ws.iter_cols():
|
||||
# for cell in column:
|
||||
# print(cell.value)
|
||||
out = ""
|
||||
index = 0
|
||||
for i in keys:
|
||||
out += ", \"" + str(i) + "\": \"" + values[index] + "\""
|
||||
index += 1
|
||||
|
||||
print(out)
|
||||
|
||||
|
||||
idList = {"0": "harp", "1": "harp", "2": "pling", "3": "harp", "4": "pling", "5": "pling", "6": "harp", "7": "harp",
|
||||
"8": "share", "9": "harp", "10": "didgeridoo", "11": "harp", "12": "xylophone", "13": "chime", "14": "harp",
|
||||
"15": "harp", "16": "bass", "17": "harp", "18": "harp", "19": "harp", "20": "harp", "21": "harp",
|
||||
"22": "harp",
|
||||
"23": "guitar", "24": "guitar", "25": "guitar", "26": "guitar", "27": "guitar", "28": "guitar",
|
||||
"29": "guitar",
|
||||
"30": "guitar", "31": "bass", "32": "bass", "33": "bass", "34": "bass", "35": "bass", "36": "bass",
|
||||
"37": "bass",
|
||||
"38": "bass", "39": "bass", "40": "harp", "41": "harp", "42": "harp", "43": "harp", "44": "iron_xylophone",
|
||||
"45": "guitar", "46": "harp", "47": "harp", "48": "guitar", "49": "guitar", "50": "bit", "51": "bit",
|
||||
"52": "harp", "53": "harp", "54": "bit", "55": "flute", "56": "flute", "57": "flute", "58": "flute",
|
||||
"59": "flute", "60": "flute", "61": "flute", "62": "flute", "63": "flute", "64": "bit", "65": "bit",
|
||||
"66": "bit", "67": "bit", "68": "flute", "69": "harp", "70": "harp", "71": "flute", "72": "flute",
|
||||
"73": "flute", "74": "harp", "75": "flute", "76": "harp", "77": "harp", "78": "harp", "79": "harp",
|
||||
"80": "bit", "81": "bit", "82": "bit", "83": "bit", "84": "bit", "85": "bit", "86": "bit", "87": "bit",
|
||||
"88": "bit", "89": "bit", "90": "bit", "91": "bit", "92": "bit", "93": "bit", "94": "bit", "95": "bit",
|
||||
"96": "bit", "97": "bit", "98": "bit", "99": "bit", "100": "bit", "101": "bit", "102": "bit", "103": "bit",
|
||||
"104": "harp", "105": "banjo", "106": "harp", "107": "harp", "108": "harp", "109": "harp", "110": "harp",
|
||||
"111": "guitar", "112": "harp", "113": "bell", "114": "harp", "115": "cow_bell", "116": "basedrum",
|
||||
"117": "bass", "118": "bit", "119": "basedrum", "120": "guitar", "121": "harp", "122": "harp", "123": "harp",
|
||||
"124": "harp", "125": "hat", "126": "basedrum", "127": "snare"}
|
@ -88,37 +88,54 @@ class midiConvert:
|
||||
:param default: 如果instrumentID不在范围内,返回的默认我的世界乐器名称
|
||||
:return: (str我的世界乐器名, int转换算法中的X)"""
|
||||
|
||||
if instrumentID == 105:
|
||||
return 'note.banjo', 6
|
||||
if instrumentID in range(32, 40):
|
||||
return 'note.bass', 8
|
||||
if instrumentID in range(115, 119):
|
||||
return 'note.basedrum', 7 # 注意,这里是底鼓,打击乐器无音域
|
||||
if instrumentID == 9 or instrumentID == 14:
|
||||
return 'note.bell', 4
|
||||
if instrumentID == 80 or instrumentID == 81:
|
||||
return 'note.bit', 6
|
||||
if instrumentID == 112:
|
||||
return 'note.cow_bell', 5
|
||||
if instrumentID == -1:
|
||||
return 'note.didgeridoo', 8
|
||||
if instrumentID in range(72, 80):
|
||||
return 'note.flute', 5
|
||||
if instrumentID in range(24, 32):
|
||||
return 'note.guitar', 7
|
||||
if instrumentID == -2:
|
||||
return 'note.hat', 7 # 注意,这里是击鼓沿,打击乐器无音域
|
||||
if instrumentID == 14:
|
||||
return 'note.chime', 4
|
||||
if instrumentID == 8 or instrumentID == 11:
|
||||
return 'iron_xylophone', 6
|
||||
if instrumentID == 2:
|
||||
return 'note.pling', 6
|
||||
if instrumentID == 114:
|
||||
return 'note.snare', 7 # 注意,这里是小军鼓,打击乐器无音域
|
||||
if instrumentID == 13:
|
||||
return 'note.xylophone', 4
|
||||
return 'note.harp', 6
|
||||
import msctPkgver.load_InstrumentLabel
|
||||
X_Range = {"harp": 6, "pling": 6, "banjo": 6, "iron_xylophone": 6, "guitar": 7, "bass": 8,
|
||||
"didgeridoo": 8, "flute": 5, "xylophone": 4, "cou_bell": 5, "chime": 4, "bell": 4,
|
||||
"bit": 6, "basedrum": 7, "hat": 7, "snare": 7}
|
||||
|
||||
# 以下为旧版运算算法
|
||||
|
||||
# if instrumentID == 105:
|
||||
# return 'note.banjo', 6
|
||||
# if instrumentID in range(32, 40):
|
||||
# return 'note.bass', 8
|
||||
# if instrumentID in range(115, 119):
|
||||
# return 'note.basedrum', 7 # 注意,这里是底鼓,打击乐器无音域
|
||||
# if instrumentID == 9 or instrumentID == 14:
|
||||
# return 'note.bell', 4
|
||||
# if instrumentID == 80 or instrumentID == 81:
|
||||
# return 'note.bit', 6
|
||||
# if instrumentID == 112:
|
||||
# return 'note.cow_bell', 5
|
||||
# if instrumentID == -1:
|
||||
# return 'note.didgeridoo', 8
|
||||
# if instrumentID in range(72, 80):
|
||||
# return 'note.flute', 5
|
||||
# if instrumentID in range(24, 32):
|
||||
# return 'note.guitar', 7
|
||||
# if instrumentID == -2:
|
||||
# return 'note.hat', 7 # 注意,这里是击鼓沿,打击乐器无音域
|
||||
# if instrumentID == 14:
|
||||
# return 'note.chime', 4
|
||||
# if instrumentID == 8 or instrumentID == 11:
|
||||
# return 'iron_xylophone', 6
|
||||
# if instrumentID == 2:
|
||||
# return 'note.pling', 6
|
||||
# if instrumentID == 114:
|
||||
# return 'note.snare', 7 # 注意,这里是小军鼓,打击乐器无音域
|
||||
# if instrumentID == 13:
|
||||
# return 'note.xylophone', 4
|
||||
# return 'note.harp', 6
|
||||
|
||||
# 以下为新版运算算法
|
||||
|
||||
# print(instrumentID)
|
||||
# print("note." + msctPkgver.load_InstrumentLabel.idList.get(str(instrumentID)))
|
||||
# print(X_Range.get(msctPkgver.load_InstrumentLabel.idList.get(str(instrumentID))))
|
||||
|
||||
return "note." + msctPkgver.load_InstrumentLabel.idList.get(str(instrumentID)), \
|
||||
X_Range.get(msctPkgver.load_InstrumentLabel.idList.get(str(instrumentID)))
|
||||
|
||||
|
||||
def __score2time(self, score: int):
|
||||
return str(int(int(score / 20) / 60)) + ':' + str(int(int(score / 20) % 60))
|
||||
@ -322,12 +339,14 @@ class midiConvert:
|
||||
|
||||
for msg in track:
|
||||
ticks += msg.time
|
||||
# print(msg)
|
||||
if msg.is_meta:
|
||||
if msg.type == 'set_tempo':
|
||||
tempo = msg.tempo
|
||||
if msg.type == 'program_change':
|
||||
instrumentID = msg.program
|
||||
else:
|
||||
if msg.type == 'program_change':
|
||||
# print("TT")
|
||||
instrumentID = msg.program
|
||||
if msg.type == 'note_on' and msg.velocity != 0:
|
||||
nowscore = round(
|
||||
(ticks * tempo)
|
||||
|
BIN
msctPkgver/program音色表.xlsx
Normal file
BIN
msctPkgver/program音色表.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user