修bug,准备合并

This commit is contained in:
EillesWan 2023-02-01 19:19:40 +08:00
parent 53fda9c986
commit 5cce59135a
7 changed files with 72 additions and 41 deletions

View File

@ -23,6 +23,12 @@
欢迎加群[861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)
## 文档📄
[生成文件的使用](./docs/%E7%94%9F%E6%88%90%E6%96%87%E4%BB%B6%E7%9A%84%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)
[仓库API文档](./docs/%E5%BA%93%E7%9A%84%E7%94%9F%E6%88%90%E4%B8%8E%E5%8A%9F%E8%83%BD%E6%96%87%E6%A1%A3.md)
## 作者✒
金羿 Eilles我的世界基岩版指令师个人开发者B站不知名UP主江西在校高中生
@ -40,7 +46,8 @@
- 感谢 **Mono**\<QQ738893087\> 反馈安装时的问题辅助我们找到了视窗操作系统下的兼容性问题
- 感谢 **Ammelia 艾米利亚**\<QQ2838334637\> 敦促我们进行新的功能开发并为新功能提出了非常优秀的大量建议以及提供的BDX导入测试支持为我们的新结构生成算法提供了大量的实际理论支持
- 感谢 **[神羽](https://gitee.com/snowykami) [SnowyKami](https://github.com/snowyfirefly)** 对我们项目的支持与宣传
- 感谢 **playjuice123 指令师_苦力怕**\<QQ240667197\>为我们的程序找出错误并提醒我们修复一个一直存在的大bug
- 感谢 **指令师_苦力怕 playjuice123**\<QQ240667197\>为我们的程序找出错误并提醒我们修复一个一直存在的大bug
- 感谢 **雷霆**\<QQ3555268519\>为我们的程序找出错误并提醒修复bug
> 感谢广大群友为此程序提供的测试等支持
>

View File

@ -36,7 +36,7 @@ languages = {
".": "",
"ChoosePath": "请输入MIDI路径或所在文件夹",
"ChooseFileFormat": "请输入输出格式[BDX(1) 或 MCPACK(0)]",
"EnterMethod": "请输入转换算法",
"EnterMethod": "请输入转换算法[{}~{}]",
"MethodRangeErr": "输入的转换算法应为 [{},{}](首尾皆含)之间的一个整数。",
"ChoosePlayer": "请选择播放方式[计分板(1) 或 延迟(0)]",
"WhetherArgEntering": "是否为文件夹内文件的转换统一参数[是(1) 或 否(0)]",
@ -98,9 +98,7 @@ except ModuleNotFoundError as E:
if input(
"您需要安装以下模块才能使用这个样例\nrequests==2.28.1\nrich==12.6.0\nzhdate==0.1\n请问是否安装?(y/n)"
).lower() in ("y", "1"):
open("Demo_Requirements.txt", "w").write(
"requests==2.28.1\nrich==12.6.0"
)
open("Demo_Requirements.txt", "w").write("requests==2.28.1\nrich==12.6.0")
os.system("pip install -r Demo_Requirements.txt")
os.remove("./Demo_Requirements.txt")
from msctPkgver.magicBeing import *
@ -144,8 +142,8 @@ else:
requests.get(
"https://gitee.com/TriM-Organization/LinglunStudio/raw/master/resources/myWords.txt"
)
.text.strip("\r\n")
.split("\r\n")
.text.strip("\n")
.split("\n")
)
),
style="#121110 on #F0F2F4",
@ -216,9 +214,11 @@ def isMethodOK(sth: str):
raise ValueError
convert_method = \
format_ipt(f"{_('EnterMethod')}{_(':')}", isMethodOK, f"{_('MethodRangeErr').format(1, len(conversion.methods))}")[
1]
convert_method = format_ipt(
f"{_('EnterMethod').format(1, len(conversion.methods))}{_(':')}",
isMethodOK,
f"{_('MethodRangeErr').format(1, len(conversion.methods))}",
)[1]
# 选择输出格式
while True:

View File

@ -1,3 +1 @@
import brotli
input(brotli.decompress(open(input("BDX文件"), "rb").read()[3:]))
import brotli;input(brotli.decompress(open(input("BDX文件"), "rb").read()[3:]))

View File

@ -65,3 +65,9 @@ class NotDefineProgramError(MSCTBaseException):
"""没有Program设定导致没有乐器可以选择的错误"""
pass
class ZeroSpeedError(MSCTBaseException):
"""以0作为播放速度的错误"""
pass

View File

@ -415,6 +415,10 @@ class midiConvert:
"""
# :param volume: 音量,注意:这里的音量范围为(0,1],如果超出将被处理为正确值,其原理为在距离玩家 (1 / volume -1) 的地方播放音频
tracks = []
if speed <= 0:
if self.debugMode:
raise ZeroSpeedError("播放速度仅可为正实数")
speed = 0.00001
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
commands = 0
@ -481,6 +485,10 @@ class midiConvert:
:return: tuple(命令列表, 命令个数, 计分板最大值)
"""
if speed <= 0:
if self.debugMode:
raise ZeroSpeedError("播放速度仅可为正实数")
speed = 0.00001
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
# 一个midi中仅有16个通道 我们通过通道来识别而不是音轨
@ -635,6 +643,10 @@ class midiConvert:
"""
# TODO: 这里的时间转换不知道有没有问题
if speed <= 0:
if self.debugMode:
raise ZeroSpeedError("播放速度仅可为正实数")
speed = 0.00001
if MaxVolume > 1:
MaxVolume = 1.0
if MaxVolume <= 0:
@ -819,6 +831,10 @@ class midiConvert:
"""
# :param volume: 音量,注意:这里的音量范围为(0,1],如果超出将被处理为正确值,其原理为在距离玩家 (1 / volume -1) 的地方播放音频
tracks = {}
if speed <= 0:
if self.debugMode:
raise ZeroSpeedError("播放速度仅可为正实数")
speed = 0.00001
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
@ -887,6 +903,10 @@ class midiConvert:
"""
# :param volume: 音量,注意:这里的音量范围为(0,1],如果超出将被处理为正确值,其原理为在距离玩家 (1 / volume -1) 的地方播放音频
tracks = {}
if speed <= 0:
if self.debugMode:
raise ZeroSpeedError("播放速度仅可为正实数")
speed = 0.00001
MaxVolume = 1 if MaxVolume > 1 else (0.001 if MaxVolume <= 0 else MaxVolume)
@ -1165,7 +1185,7 @@ class midiConvert:
if os.path.exists(f"{self.outputPath}/{self.midFileName}.mcpack"):
os.remove(f"{self.outputPath}/{self.midFileName}.mcpack")
compressZipFile(
compress_zipfile(
f"{self.outputPath}/temp/", f"{self.outputPath}/{self.midFileName}.mcpack"
)

View File

@ -35,7 +35,7 @@ def move(axis: str, value: int):
return key[axis][pointer] + value.to_bytes(2 ** (pointer - 2), "big", signed=True)
def compressZipFile(sourceDir, outFilename, compression=8, exceptFile=None):
def compress_zipfile(sourceDir, outFilename, compression=8, exceptFile=None):
"""使用compression指定的算法打包目录为zip文件\n
默认算法为DEFLATED(8),可用算法如下\n
STORED = 0\n
@ -129,7 +129,7 @@ def form_command_block_in_BDX_bytes(
return block
def __fillSquareSideLength(total: int, maxHeight: int):
def bottem_side_length_of_smallest_square_bottom_box(total: int, maxHeight: int):
"""给定总方块数量和最大高度,返回所构成的图形外切正方形的边长
:param total: 总方块数量
:param maxHeight: 最大高度
@ -147,7 +147,7 @@ def to_BDX_bytes(
:return 成功与否成功返回(True,未经过压缩的源,结构占用大小)失败返回(False,str失败原因)
"""
_sideLength = __fillSquareSideLength(len(commands), max_height)
_sideLength = bottem_side_length_of_smallest_square_bottom_box(len(commands), max_height)
_bytes = b""
y_forward = True

View File

@ -359,7 +359,7 @@ def format_ipt(notice: str, fun, err_note: str = "", *extraArg):
try:
fun_result = fun(result, *extraArg)
break
except BaseError:
except ValueError:
print(err_note)
continue
return result, fun_result