!2 同步-2023/1/2

Merge pull request !2 from bgArray/pkgver
This commit is contained in:
bgArray 2023-01-02 09:25:11 +00:00 committed by Gitee
commit 1103a06897
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 1179 additions and 841 deletions

12
.gitignore vendored
View File

@ -1,16 +1,18 @@
# sth. can't open
/msctPkgver/secrets/*.py
/msctPkgver/secrets/*.c
# mystuff
/.vscode
*.mid
*.midi
# Byte-compiled / optimized / DLL files
# Byte-compiled / optimized
__pycache__/
*.py[cod]
*.pyc
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/

View File

@ -1,3 +1,30 @@
**注意,以下条款或版权声明应当且必须是高于此项目中任何其他声明的**
1. 音·创的全部开发者享有其完整版权,其开发者可以在任一时刻终止以后音·创源代码开放,若经由其开发者授予特殊权利,则授权对象可以将源代码进行特定的被特殊授权的操作
2. 音·创或(及)其代码允许在 Apache2.0 协议的条款与说明下进行非商业使用
3. 除部分代码特殊声明外,音·创允许对其或(及)其代码进行商业化使用,但是需要经过音·创主要开发者(诸葛亮与八卦阵、金羿)的一致授权,同时,授权对象在商业化授权的使用过程中必须依照 Apache2.0 协议的条款与说明
4. 若存在对于音·创包含的部分代码的特殊开源声明,则此部分代码依照其特定的开源方式授权,但若此部分代码经由此部分代码的主要开发者一致特殊授权后商用,则授权对象在商用时依照此部分的开发者所准许的方式(或条款)进行商用,或默认依照 Apache2.0 协议进行商业化使用
5. Apache2.0 协议的英文原文副本可见下文
> The English Translation of the TERMS AND CONDITIONS above is listed below
>
> This translated version is for reference only and has no legal effect.
>
> The version with legal effect is the Chinese version above.
**Note, The TERMS AND CONDITIONS below should and must be above all others in this project**
1. *Musicreater* is fully copyrighted by all its developers, the developers have the right to make *Musicreater* close sourced at any time. Operations are permitted under specific terms instructed by its developer(s).
2. Non-commercial use of *Musicreater* and(or) its source code is permitted under Apache License 2.0.
3. Commercial use of *Musicreater* is permitted under Apache License 2.0 with the unanimous permission of the steering developers of *Musicreater* (*bgArray*诸葛亮与八卦阵 and *Eilles*金羿).
4. *Musicreater* is open sourced under priority given:
1. License granted by the core developer(s) of a section after negotiation.
2. Explicitly stated license.
3. Apache 2.0 License.
5. A copy of the original Apache Lisence 2.0 can be found below.
```text
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@ -189,4 +216,4 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View File

@ -29,7 +29,7 @@
**此分支为音·创的包版本即便于其他软件使用的可被import版本**
### **看这看这!看这看这!看这看这!教程:[教程链接](https://gitee.com/EillesWan/Musicreater/blob/pkgver/docs/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)**
### **看这看这!看这看这!看这看这!教程:[教程链接](./docs/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)**
## 软件作者✒
@ -45,9 +45,10 @@
- 感谢由 **Charlie_Ping “查理平”** 带来的bdx文件转换参考
以及mid转我的世界乐器参考表格
- 感谢由 **CMA_2401PT** 为我们的软件开发进行指导
- 感谢由 **Dislink Sforza**\<QQ1600515314\>带来的midi音色解析以及转换指令的算法我们将其改编并应用
- 感谢 **Touch “偷吃”**\<QQ1793537164\>提供的测试支持,并对程序的改进提供了丰富的意见
- 感谢由 **Dislink Sforza “断联·斯福尔扎”**\<QQ1600515314\>带来的midi音色解析以及转换指令的算法我们将其改编并应用;同时,感谢他的[网页版转换器](https://dislink.github.io/midi2bdx/)给我们的开发与更新带来巨大的压力和动力,让我们在原本一骑绝尘的摸鱼道路上转向开发
- 感谢 **Touch “偷吃”**\<QQ1793537164\>提供的测试支持,并对程序的改进提供了丰富的意见;同时也感谢他的不断尝试新的内容,使我们的排错更进一步
- 感谢 **Mono**\<QQ738893087\>反馈安装时的问题
- 感谢 **Ammelia** 敦促我们进行新的功能开发,并为新功能提出了非常优秀的大量建议
> 感谢广大群友为此程序提供的测试等支持
>

View File

@ -28,7 +28,7 @@ Musicreater pkgver(Package Version 音·创 库版) is a free open source librar
Welcome to join our QQ group: [861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)
### **SEEEEEEEEE Tutorials [HERE](https://gitee.com/EillesWan/Musicreater/blob/pkgver/docs/Use%20of%20Funtions.md)**
### **SEEEEEEEEE Tutorials [HERE](./docs/Use%20of%20Funtions.md)**
### Authors✒

View File

@ -4,26 +4,17 @@
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需转载或借鉴 请依照 Apache 2.0 许可证进行许可
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
"""
· 库版 MIDI转换展示程序
Musicreater Package Version : Demo for Midi Conversion
Copyright 2022 all the developers of Musicreater
Copyright 2023 all the developers of Musicreater
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
开源相关声明请见 ./Lisence.md
Terms & Conditions: ./Lisence.md
"""
from msctPkgver.main import *
@ -103,7 +94,8 @@ while True:
m = 1
'''采用的算法编号'''
if os.path.isdir(midipath):
@ -112,8 +104,8 @@ if os.path.isdir(midipath):
print(f'正在操作{i}')
convertion.convert(midipath + '/' + i, outpath + '/' + i[:-4])
if outFormat == 0:
convertion.tomcpack(
1,
print(convertion.tomcpack(
m,
isAutoReset
if isAutoReset != ''
else bool(int(input('是否自动重置计分板(1|0)'))),
@ -121,10 +113,10 @@ if os.path.isdir(midipath):
sbname if sbname != '' else input('请输入计分板名称:'),
volume if volume != '' else float(input('请输入音量0-1')),
speed if speed != '' else float(input('请输入速度倍率:')),
)
))
elif outFormat == 1:
convertion.toBDXfile(
1,
print(convertion.toBDXfile(
m,
author if author != '' else input('请输入作者:'),
isProgress,
maxHeight if maxHeight != '' else int(input('请输入指令结构最大生成高度:')),
@ -134,21 +126,21 @@ if os.path.isdir(midipath):
isAutoReset
if isAutoReset != ''
else bool(int(input('是否自动重置计分板(1|0)'))),
)
))
else:
convertion.convert(midipath, outpath)
if outFormat == 0:
convertion.tomcpack(
1,
print(convertion.tomcpack(
m,
isAutoReset if isAutoReset != '' else bool(int(input('是否自动重置计分板(1|0)'))),
isProgress,
sbname if sbname != '' else input('请输入计分板名称:'),
volume if volume != '' else float(input('请输入音量0-1')),
speed if speed != '' else float(input('请输入速度倍率:')),
)
))
elif outFormat == 1:
convertion.toBDXfile(
1,
print(convertion.toBDXfile(
m,
author if author != '' else input('请输入作者:'),
isProgress,
maxHeight if maxHeight != '' else int(input('请输入指令结构最大生成高度:')),
@ -156,4 +148,4 @@ else:
volume if volume != '' else float(input('请输入音量0-1')),
speed if speed != '' else float(input('请输入速度倍率:')),
isAutoReset if isAutoReset != '' else bool(int(input('是否自动重置计分板(1|0)'))),
)
))

View File

@ -1,5 +1,22 @@
# -*- coding: utf-8 -*-
# THIS PROGRAM IS ONLY A TEST EXAMPLE
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
"""
· 库版 MIDI转换展示程序
Musicreater Package Version : Demo for Midi Conversion
Copyright 2023 all the developers of Musicreater
开源相关声明请见 ./Lisence.md
Terms & Conditions: ./Lisence.md
"""
from msctPkgver.main import *

View File

@ -0,0 +1,167 @@
## 使用前的准备工作
### 安装终端工具
这里我们选用 **Termux** 作为我们的终端工具来安装这是一个强大的终端模拟器旨在安卓环境下模拟Linux的软件包环境。
1. 下载
下载可以通过 [GitHub源](https://github.com/termux/termux-app/releases) 或者 [F-Droid源](https://f-droid.org/en/packages/com.termux/) ,个人建议选择 F-Droid 源,因为在国内可以访问得到,而 GitHub 源就看运气。
2. 安装
下载*APK*包后直接安装,安装后打开可以看到一个类似这样的界面:
<img height="512" src="https://foruda.gitee.com/images/1665933025120627254/a0479618_9911226.jpeg">
3. 完成
恭喜你,你已经获得了一个极客般流畅地操作你手机的终端工具。
### 安装运行环境
1. 换源
接下来,我们就要来准备安装一下 **Python** 运行环境了,这是运行 **Python** 源代码必要的。
首先,我估计你等不了多久,急得要死,所以我们要让下载速度稍微快一点,先来换个源。在 **Termux** 中,输入以下指令:
```bash
echo "deb https://mirror.mwt.me/termux/main stable main" > /data/data/com.termux/files/usr/etc/apt/sources.list
```
*感谢 天如<QQ 3291691454>为我们带来的简单换源方法。*
- *非必要步骤*:手动编辑换源
如果你闲着没事,非要要手动编辑个文档来换源,那用啥?用普通的编辑器肯定可以,于是我们就让他更普通一点,用**nano**吧!
**Termux** 中,输入以下指令:
```bash
export EDITOR=nano
apt edit-sources
```
那么请把看到的如左下图的界面变为右下图吧:
<table><tr>
<td><img src="https://foruda.gitee.com/images/1665933104313107707/41108f03_9911226.jpeg"> </td>
<td><img src="https://foruda.gitee.com/images/1665933122534781330/3887a901_9911226.jpeg"></td>
</tr></table>
- 图片中的文件,最后应该加入的两行为:
```bash
deb https://mirrors.ustc.edu.cn/termux/apt/termux-main/ stable main
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main/ stable main
```
然后键入 `Ctrl`+`S`,再键入 `Ctrl`+`X`,退出`nano`。
在换源之后,你可能会见到类似的提示:
```bash
Your '/data/data/com.termux/files/usr/etc/apt/sources.list' file changed. Please run 'apt-get update'.
```
那就遵循它的指引,输入:
```bash
apt-get update
```
Alright.
2. 安装 **Python**
```bash
apt-get install python3
```
如果遇到提示问是否继续,那就输入`Y`表示是,如左下图,安装成功后,图若右下。
<table><tr>
<td><img src="https://foruda.gitee.com/images/1665933181440420034/7f0fb5fd_9911226.jpeg"></td>
<td><img src="https://foruda.gitee.com/images/1665933238339972260/a9f06f4f_9911226.jpeg"></td>
</tr></table>
接下来,我们来试一试 **Python** 是不是安装成了吧,输入
```bash
python3 -V
```
如果输出了形如 `Python 3.X.X` 的提示,则完成。
3. 安装依赖库
```bash
# 首先换源
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
# 然后安装
pip install mido
pip install brotli
```
- 如果出现以下情况,真是死了鬼的,我们要来再搞个设置:
<img height="512" src="https://foruda.gitee.com/images/1665933289612919459/b87b7804_9911226.jpeg">
我们来修改收信任的源设置:
```bash
pip config set global.trusted-host mirrors.aliyun.com/
```
之后再来安装即可
```bash
pip install mido
pip install brotli
```
安装成功后您可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
### 安装下载工具
既然已经有了运行环境,那么我们就需要下载下我们的**音·创库版示例代码**工具,我非常推崇**Git**这种方便快捷好用还能下载仓库的代码管理器,这个世界上你也找不到第二个,所以我们来安装一下:
```bash
pkg install git
```
安装完成后记得测试一下:
<img height="512" src="https://foruda.gitee.com/images/1665933331269483373/9374c85d_9911226.jpeg">
## 本代码库的下载与演示程序的使用
1. 使用Git下载本库及其示例代码
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git MSCTpkgver
```
当上述命令执行成功,你会在执行此命令的所在位置发现一个名为 `MSCTpkgver` 的文件夹,其中包含的正是我们心心念念下载的本程序和示例代码。
而我们要运行的也正是示例代码,因此,赶快进入下载到的文件夹:
```bash
cd MSCTpkgver
```
1. 开始使用演示程序
依照你的需要,执行以下命令之一:
```bash
python demo_convert.py #计分板播放器支持mcpack与BDX
python demo_convert_bdx_byDelay.py #延迟播放器仅支持BDX
```
运行成功了,哦耶!
<img height="512" src="https://foruda.gitee.com/images/1665933366784631363/db9f80f6_9911226.jpeg">

View File

@ -0,0 +1,104 @@
## 运行环境安装
### 检验Python运行环境
0. 一般的Linux发行版都有安装Python环境我们只需要保证其版本即可理论上 ≥Python3.6 都可以运行我们的库
我们可以使用
```bash
python -V
```
来查看 Python 版本,如下
<img src=https://foruda.gitee.com/images/1665120915821957090/429561fd_9911226.png>
1. *非必要环节*:回退版本
如果你跟作者一样,觉得 Python 3.10+ 太难用很烦人的话,那真是皆大欢喜,让我们一起来回退版本吧!
- pacman 包管理器多用于Arch Linux上
1. 让我们先来把 python3 加入忽略升级的列表中,使用`vim`修改`/etc/pacman.conf`,在`IgnorePkg`后加上`python3`
```bash
sudo vim /etc/pacman.conf
```
<img src=https://foruda.gitee.com/images/1665124611490335193/5e99ca26_9911226.png>
2. 然后我们开始从[Arch Achieve](https://archive.archlinux.org/packages/)上找Python的版本列表。*这里说明一下在Arch中Python默认指的是Python3而与其他某些Linux发行版中Python默认指代Python2不同所以在Arch Achieve中也是如此。*)我这里找到的是[Python3.8.6](https://archive.archlinux.org/packages/p/python/python-3.8.6-1-x86_64.pkg.tar.zst),于是我们用`pacman`把她下载下来并安装:
```bash
sudo pacman -U https://archive.archlinux.org/packages/p/python/python-3.8.6-1-x86_64.pkg.tar.zst
```
<img src=https://foruda.gitee.com/images/1665126362769399903/ea4b9598_9911226.png>
3. 完美!
- 其他包管理器
暂无
### 检查并安装pip包管理器依赖
1. 我们在安装依赖库之前应该确认一下Python自带的包管理器pip是否安装到位
```bash
python -m pip # 确认pip是否安装
# 当这个命令输入后有长段提示出现则为已经安装
# 如果返回如下那么则pip尚未安装
/usr/bin/python: No module named pip
# 可以使用如下命令来安装pip
sudo pacman -S python-pip
# 安装完成后记得验证
python -m pip
# 如果还是失败那么就需要用其他工具安装pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
# 安装完成后一定要验证!!!
python -m pip
```
2. 确认完成之后,我们来安装一下依赖库:
```bash
pip install mido -i https://mirrors.aliyun.com/pypi/simple/
pip install brotli -i https://mirrors.aliyun.com/pypi/simple/
```
3. 安装成功后可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
## 本代码库的下载与使用
1. 使用Git下载本库及其示例代码
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git MSCTpkgver
```
当上述命令执行成功,你会在执行此命令的所在位置发现一个名为 `MSCTpkgver` 的文件夹,其中包含的正是我们心心念念下载的本程序和示例代码。
而我们要运行的也正是示例代码,因此,赶快进入下载到的文件夹:
```bash
cd MSCTpkgver
```
1. 开始使用
在目录下打开终端,执行以下命令:(选择你需要的)
```bash
python demo_convert.py #计分板播放器支持mcpack与BDX
python demo_convert_bdx_byDelay.py #延迟播放器仅支持BDX
```

View File

@ -0,0 +1,89 @@
## 一、运行环境安装
### (一)安装 Python3.6+
1. 首先需要下载Python的安装包最好是 *Python3.8*,因为作者就用的是这个版本
> [下载64位Python安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe)
> [下载32位Python安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe)
2. 在安装时,最好需要勾选 `Add Python 3.X to PATH`,如下图所示,当然,如果您对自己非常自信,您也可以手动设置此项目:
<img src=https://foruda.gitee.com/images/1662736520757331846/e38efb81_9911226.png>
- 若您对Python一知半解或者不怎么了解、并对自己的系统盘通常是C盘有大约150*兆字节*(MB)的信心的话,您可以在安装时直接选择*快速安装*(Install Now)
3. 若您选择了*自定义安装*(Customize Installation),请务必勾选 `pip``py launcher` 便于后续安装依赖,如下图:
<img src=https://foruda.gitee.com/images/1662736621235871190/2ac3d98f_9911226.png>
4. 安装结束之后可以在*终端*(命令行/PowerShell/Bash/etc)中输入python 试试是否安装成功成功安装之后在终端中输入python会显示诸如如下图片的提示
<img src=https://foruda.gitee.com/images/1659972669907359295/cmd.png>
### (二)安装依赖
1. 请以管理员模式打开您的*终端*(命令行/PowerShell/Bash/etc)
例如,命令行,可以如此打开:在*视窗开始菜单*(Windows开始)中搜索 `cmd`, 并以管理员身份运行
<img src="https://foruda.gitee.com/images/1662736878650993886/62487dd8_9911226.png">
2. 打开了终端之后,请在终端中输入以下指令
```bash
pip install mido -i https://mirrors.aliyun.com/pypi/simple/
pip install brotli -i https://mirrors.aliyun.com/pypi/simple/
```
3. 安装成功后您可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
## 二、本工具的下载与使用
0. 下载本代码库以及演示程序
- 若您使用git请直接克隆本仓库
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git
```
- 若您不使用git可以在[*码云*(Gitee)](https://gitee.com/EillesWan/Musicreater.git)或[*GitHub*](https://github.com/EillesWan/Musicreater.git)下载zip包或者[加入QQ群聊861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr),在群文件中获取。
<img src="https://foruda.gitee.com/images/1669540786443169766/fabf0acd_9911226.png" >
值得注意的是这张图上有1、2两个数字虽然是手写的但确实是数字表示着要进行的步骤。希望眼尖得能找出我的口头禅的你们能够发现这两个用鼠标手写的数字并在安装时认真地执行。我认为这并不算十分的难移动鼠标并单击大约消耗不了多少卡路里不过我没有进行精确的计算我也不是十分的清楚这个活动对于一个常人来讲有多难但我怀疑它不难。
1. 开始使用
在目录下打开终端。
例如:打开命令行:请进入到目录下,在文件资源管理器的地址框内输入`cmd`
<img src=https://foruda.gitee.com/images/1659974437388532868/输入.png>
<img src=https://foruda.gitee.com/images/1659974754378201859/输入c.png>
执行以下命令:(选择你需要的)
```bash
python demo_convert.py #计分板播放器支持mcpack与BDX
python demo_convert_bdx_byDelay.py #延迟播放器仅支持BDX
```
## 三、安装时错误的补充说明
1. Microsoft Visual C++ Redistributable 环境出错
如果你遇到了类似以下这种情况:
<img src=https://foruda.gitee.com/images/1659972789779764953/bug.jpeg>
请下载最新的VCREDIST安装包可以参照[这个网页](https://docs.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist)的说明,也可以在这直接选择你需要的安装包下载:
> [下载64位VCREDIST安装包](https://aka.ms/vs/17/release/vc_redist.x64.exe)
> [下载32位VCREDIST安装包](https://aka.ms/vs/17/release/vc_redist.x86.exe)
感谢群友Mono帮我们发现这个问题。

View File

@ -12,353 +12,39 @@
*这是演示程序demo的使用教程将在这里提供演示程序的相应的使用教程*
## 视窗(Windows)操作系统
## 下载与启动教程
### 运行环境安装
### [视窗(Windows)操作系统](./download%26atart/Windows.md)
### [里纽克斯(Linux)操作系统](./download%26atart/Linux.md)
### [安卓(Android)与安卓衍生操作系统](./download%26atart/Android.md)
0. 安装 Python3.6+
## 演示程序使用教程
首先需要下载Python的安装包最好是 *Python3.8*,因为作者就用的是这个版本
1. 参数说明
> [下载64位Python安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe)
> [下载32位Python安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe)
<img src=https://foruda.gitee.com/images/1659974810147043475/运行.png>
在安装时,最好需要勾选 `Add Python 3.X to PATH`,如下图所示,当然,如果您对自己非常自信,您也可以手动设置此项目:
- midi路径含有mid文件路径、文件名、后缀的完整文件路径或者一个目录demo可接受批量转换。可以使用相对或绝对路径皆可
<img src=https://foruda.gitee.com/images/1662736520757331846/e38efb81_9911226.png>
- 输出路径:输出文件夹的路径,不需要指示文件名
若您对Python一知半解或者不怎么了解、并对自己的系统盘通常是C盘有大约150*兆字节*(MB)的信心的话,您可以在安装时直接选择*快速安装*(Install Now)
- 是否重置计分板:`1`或`0`(歌曲放完是否重置,推荐`1`
若您选择了*自定义安装*(Customize Installation),请务必勾选 `pip``py launcher` 便于后续安装依赖,如下图:
- 进度条:是否启用进度条,以及自定义进度条样式。输入`0`或`False`表示不启用进度条,输入`1`或`True`表示使用默认进度条,其余的输入均表示使用输入的格式作为自定义的进度条样式
<img src=https://foruda.gitee.com/images/1662736621235871190/2ac3d98f_9911226.png>
安装结束之后可以在*终端*(命令行/PowerShell/Bash/etc)中输入python 试试是否安装成功成功安装之后在终端中输入python会显示诸如如下图片的提示
<img src=https://foruda.gitee.com/images/1659972669907359295/cmd.png>
1. 安装依赖
请以管理员模式打开您的*终端*(命令行/PowerShell/Bash/etc)
例如,命令行,可以如此打开:在*视窗开始菜单*(Windows开始)中搜索 `cmd`, 并以管理员身份运行
<img src="https://foruda.gitee.com/images/1662736878650993886/62487dd8_9911226.png">
打开了终端之后,请在终端中输入以下指令
```bash
pip install mido -i https://mirrors.aliyun.com/pypi/simple/
pip install brotli -i https://mirrors.aliyun.com/pypi/simple/
```
安装成功后您可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
### 本工具的下载与使用
0. 下载本代码库以及演示程序
- 若您使用git请直接克隆本仓库
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git
```
- 若您不使用git可以在[*码云*(Gitee)](https://gitee.com/EillesWan/Musicreater.git)或[*GitHub*](https://github.com/EillesWan/Musicreater.git)下载zip包或者[加入QQ群聊861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr),在群文件中获取。
<img src="https://foruda.gitee.com/images/1669540786443169766/fabf0acd_9911226.png" >
1. 开始使用
在目录下打开终端,例如,打开命令行,请进入到目录下,在地址框内输入`cmd`
<img src=https://foruda.gitee.com/images/1659974437388532868/输入.png>
<img src=https://foruda.gitee.com/images/1659974754378201859/输入c.png>
执行以下命令:(选择你需要的)
```bash
python demo_convert.py
python demo_convert_bdx_byDelay.py
```
### 补充错误说明
1. Microsoft Visual C++ Redistributable 环境出错
如果你遇到了类似以下这种情况:
<img src=https://foruda.gitee.com/images/1659972789779764953/bug.jpeg>
请下载最新的VCREDIST安装包可以参照[这个网页](https://docs.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist)的说明,也可以在这直接选择你需要的安装包下载:
> [下载64位VCREDIST安装包](https://aka.ms/vs/17/release/vc_redist.x64.exe)
> [下载32位VCREDIST安装包](https://aka.ms/vs/17/release/vc_redist.x86.exe)
感谢群友Mono帮我们发现这个问题
## 里纽克斯(Linux)操作系统
### 运行环境安装
0. 安装并检验Python运行环境
一般的Linux发行版都有安装Python环境我们只需要保证其版本即可理论上 ≥Python3.6 都可以运行我们的库
我们可以使用
```bash
python -V
```
来查看 Python 版本,如下
<img src=https://foruda.gitee.com/images/1665120915821957090/429561fd_9911226.png>
- 非必要环节
如果你跟作者一样,觉得 Python 3.10+ 太难用很烦人的话,那真是皆大欢喜,让我们一起来回退版本吧!
- pacman 包管理器多用于Arch Linux上
让我们先来把 python3 加入忽略升级的列表中,使用`vim`修改`/etc/pacman.conf`,在`IgnorePkg`后加上`python3`
```bash
sudo vim /etc/pacman.conf
```
<img src=https://foruda.gitee.com/images/1665124611490335193/5e99ca26_9911226.png>
然后我们开始从[Arch Achieve](https://archive.archlinux.org/packages/)上找Python的版本列表。*这里说明一下在Arch中Python默认指的是Python3而与其他某些Linux发行版中Python默认指代Python2不同所以在Arch Achieve中也是如此。*)我这里找到的是[Python3.8.6](https://archive.archlinux.org/packages/p/python/python-3.8.6-1-x86_64.pkg.tar.zst),于是我们用`pacman`把她下载下来:
```bash
sudo pacman -U https://archive.archlinux.org/packages/p/python/python-3.8.6-1-x86_64.pkg.tar.zst
```
<img src=https://foruda.gitee.com/images/1665126362769399903/ea4b9598_9911226.png>
完美!
1. 检查并安装pip包管理器依赖
我们在安装依赖库之前应该确认一下Python自带的包管理器pip是否安装到位
```bash
python -m pip # 确认pip是否安装
# 当这个命令输入后有长段提示出现则为已经安装
# 如果返回如下那么则pip尚未安装
/usr/bin/python: No module named pip
# 可以使用如下命令来安装pip
sudo pacman -S python-pip
# 安装完成后记得验证
python -m pip
# 如果还是失败那么就需要用其他工具安装pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
# 安装完成后一定要验证!!!
python -m pip
```
确认完成之后,我们来安装一下依赖库:
```bash
pip install mido -i https://mirrors.aliyun.com/pypi/simple/
pip install brotli -i https://mirrors.aliyun.com/pypi/simple/
```
安装成功后您可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
### 本代码库的下载与使用
1. 使用Git下载本库及其示例代码
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git MSCTpkgver
```
当上述命令执行成功,你会在执行此命令的所在位置发现一个名为 `MSCTpkgver` 的文件夹,其中包含的正是我们心心念念下载的本程序和示例代码。
而我们要运行的也正是示例代码,因此,赶快进入下载到的文件夹:
```bash
cd MSCTpkgver
```
1. 开始使用
在目录下打开终端,执行以下命令:(选择你需要的)
```bash
python demo_convert.py
python demo_convert_bdx_byDelay.py
```
## 安卓(Android)与安卓衍生操作系统
### 使用前的准备工作
0. 安装终端工具
这里我们选用 **Termux** 作为我们的终端工具来安装这是一个强大的终端模拟器旨在安卓环境下模拟Linux的软件包环境。
下载可以通过 [GitHub](https://github.com/termux/termux-app/releases) 或者 [F-Droid](https://f-droid.org/en/packages/com.termux/) ,个人建议选择 F-Droid 源,因为在国内可以访问得到,而 GitHub 源就看运气。
下载后直接按照,打开后可以看到一个类似这样的界面:
<img src="https://foruda.gitee.com/images/1665933025120627254/a0479618_9911226.jpeg">
恭喜你,你已经获得了一个极客般流畅地操作你手机的终端工具。
1. 安装运行环境
接下来,我们就要来安装一下 **Python** 运行环境了,这是运行 **Python** 源代码必要的。
首先,我估计你等不了多久,急得要死,所以我们要让下载速度稍微快一点,先来换个源。换源要手动编辑个文档,那用啥?用普通的编辑器肯定可以,于是我们就让他更普通一点,用**nano**吧!
**Termux** 中,输入以下指令:
```bash
export EDITOR=nano
apt edit-sources
```
你可能会看到如下一个简单的界面:
<img src="https://foruda.gitee.com/images/1665933104313107707/41108f03_9911226.jpeg">
好,让我们动起你的双手,把它变成这样吧:
<img src="https://foruda.gitee.com/images/1665933122534781330/3887a901_9911226.jpeg">
- 图片中的文件,最后应该加入的两行为:
```bash
deb https://mirrors.ustc.edu.cn/termux/apt/termux-main/ stable main
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main/ stable main
```
然后键入 `Ctrl`+`S`,再键入 `Ctrl`+`X`,你会见到差不多如下的提示:
```text
Your '/data/data/com.termux/files/usr/etc/apt/sources.list' file changed. Please run 'apt-get update'.
```
那就遵循它的指引,输入:
```bash
apt-get update
```
然后就完美了,我们来安装 **Python** 吧!
```bash
apt-get install python3
```
如果遇到提示问是否继续,那就输入`Y`表示是,如图。
<img src="https://foruda.gitee.com/images/1665933181440420034/7f0fb5fd_9911226.jpeg">
如果你安装成功,应该是差不多这样的:
<img src="https://foruda.gitee.com/images/1665933238339972260/a9f06f4f_9911226.jpeg">
我们来试一试 **Python** 是不是安装成了吧,输入
```bash
python3 -V
```
如果输出了形如 `Python 3.X.X` 的提示,则完成。
确认完成之后,我们来安装一下依赖库:
```bash
# 首先换源
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
# 然后安装
pip install mido
pip install brotli
```
- 如果出现以下情况,真是死了鬼的,我们要来再搞个设置:
<img src="https://foruda.gitee.com/images/1665933289612919459/b87b7804_9911226.jpeg">
我们来修改收信任的源设置:
```bash
pip config set global.trusted-host mirrors.aliyun.com/
```
之后再来安装即可
```bash
pip install mido
pip install brotli
```
安装成功后您可能会见到类似下图的提示:
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
3. 安装下载工具
既然已经有了运行环境,那么我们就需要下载下我们的**音·创库版示例代码**工具,我非常推崇**Git**这种方便快捷好用还能下载仓库的代码管理器,这个世界上你也找不到第二个,所以我们来安装一下:
```bash
pkg install git
```
安装完成后记得测试一下:
<img src="https://foruda.gitee.com/images/1665933331269483373/9374c85d_9911226.jpeg">
### 本代码库的下载与使用
1. 使用Git下载本库及其示例代码
```bash
git clone -b pkgver https://gitee.com/EillesWan/Musicreater.git MSCTpkgver
```
当上述命令执行成功,你会在执行此命令的所在位置发现一个名为 `MSCTpkgver` 的文件夹,其中包含的正是我们心心念念下载的本程序和示例代码。
而我们要运行的也正是示例代码,因此,赶快进入下载到的文件夹:
```bash
cd MSCTpkgver
```
1. 开始使用
在目录下打开终端,执行以下命令:(选择你需要的)
```bash
python demo_convert.py
python demo_convert_bdx_byDelay.py
```
运行成功了,哦耶!
<img src="https://foruda.gitee.com/images/1665933366784631363/db9f80f6_9911226.jpeg">
若不支持自定义,则仅能输入`0`或`1`表示“关闭”或“开启”
- 计分板名称:游戏内的计分板名称
- 音量0-1之间的小数含01正常来说推荐`1`
- 速度倍率小数数据其值不可为0一般写`1`
- 玩家选择器:包括 `@x` 在内的全部选择器,即若要选择全部标签为`Holo`的玩家,则需要如此输入:`@a[tag=Holo]`
- 没有报错且在输出路径下找到mcpack或bdx即为生成成功
<img src=https://foruda.gitee.com/images/1659973655881460036/输出.png>
# 其他说明
@ -373,31 +59,6 @@
答2详见问1切换你所需要的播放器即可。
## 对于 参数 的补充说明
<img src=https://foruda.gitee.com/images/1659974810147043475/运行.png>
- midi路径含有mid文件路径、文件名、后缀的完整文件路径或者一个目录demo可接受批量转换。可以使用相对或绝对路径皆可
- 输出路径:输出文件夹的路径,不需要指示文件名
- 是否重置计分板1或0歌曲放完是否重置推荐1
- *进度条是否启用进度条以及自定义进度条样式。输入0或False表示不启用进度条输入1或True表示使用默认进度条其余的输入均表示使用输入的格式作为自定义的进度条样式
- 计分板名称:游戏内的计分板名称
- 音量0-1之间的小数含01正常来说推荐1
- 速度倍率小数数据不可为0一般写1
- 玩家选择器:包括 `@x` 在内的全部选择器,即若要选择全部标签为`Holo`的玩家,则需要如此输入:`@a[tag=Holo]`
- 没有报错且在输出路径下找到mcpack或bdx即为生成成功
<img src=https://foruda.gitee.com/images/1659973655881460036/输出.png>
## 对于 进度条自定义 功能的说明
因为我们提供了可以自动转换进度条的功能,因此在这里给出进度条自定义参数的详细解释。

180
docs/新手答疑指南.md Normal file
View File

@ -0,0 +1,180 @@
<h1 align="center">音·创 Musicreater</h1>
<h2 align="center">库版 Package Version</h2>
<p align="center">
<img width="128" height="128" src="https://s1.ax1x.com/2022/05/06/Ouhghj.md.png" >
</p>
# 新手答疑指南
**考虑到某些用户电脑技术不是特别先进,且对这个项目充满了好奇心,但是又了解的不是很充分,
为此,我特别在这里写一份文档,解答各位的好奇心。放心,本文件全程中文,英文版本随后更新!**
## 第一部分 关于音·创的作用
### 1.1 音·创简介
音·创 Musicreater 是一款免费开源的 **《我的世界:基岩版》** 音乐制作软件
音·创 库版 (Musicreater Package Version) 是一款免费开源的针对 **《我的世界:基岩版》** 的midi音乐转换库
音·创 采用的是**带有特殊条款的Apache2.0**开源协议,详情请见[这里](https://gitee.com/EillesWan/Musicreater/blob/master/LICENSE.md)。
音·创
目前已经具备较为完善的**教程**,如果你还不知道音·创有教程,请点击
[
这里](https://gitee.com/EillesWan/Musicreater/blob/pkgver/docs/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)。
### 1.2 音·创到底目前有什么功能?
* - [x] 支持导入.mid文件
* - [x] 支持写入.mcpack文件
* - [x] 支持写入.bdx文件
* 不支持导入.mp3 .mp4 .wav等音频流文件
## 第二部分 关于格式的问题
### 2.1 关于.mid格式
其实对于经常玩音乐电子制作的朋友们来说mid格式并不陌生这里我简单介绍一下。
> mid格式是由MIDI继承而来。MID文件并不是一段录制好的声音而是记录声音的信息然后再告诉声卡如何再现音乐的一组指令。
> 这样一个MIDI文件每存1分钟的音乐只用大约510KB。今天MID文件主要用于原始乐器作品、流行歌曲的业余表演、游戏音轨以及电子贺卡等。
>
> ——百度百科
>
> MIDI 音乐,保存在电脑上,就是 *.mid 类型的文件。和一般意义上的“音乐”不同mid 类型的音乐通常并不是可直接发行供大众欣赏的音乐,
> 它更像是一种音乐创作者使用的工程文件。它没有歌词,不含有人类语言。如果说五线谱是给人类阅读的乐谱,
> MIDI音乐文件便是给计算机或其他电子设备使用的乐谱。对于“音乐”这个世界来说它微不足道却又是现代数字音乐的基石。虽不为大众所知
> 但在 MIDI 音乐爱好者眼中,它却是非常有意思的东西。有了 MIDI 音乐技术和一台电脑,基本就等于拥有了一个乐队,加上相关的音乐知识,
> 就可以自己指挥这个“乐队”,创作音乐作品了!
> 同时MIDI 技术由于数据结构简单又与音乐有关也成为了部分技术极客的爱好。有人使用MIDI技术+Arduino开源硬件制作了架子鼓
> 有人通过分析大量MIDI乐曲结构设计了人工智能作曲软件还有更酷的人使用MIDI音乐制作了随节奏变幻的特斯拉线圈
> 在MIDI 音乐的世界里汇聚了一批喜欢音乐又热爱技术的人。我们有理由相信玩MIDI音乐的你定是多才多艺的。
>
> ——midishow.com
**所以mid文件的本质是电子乐谱而不是记录声音波形文件的.mp3/.wav/.m4a等等文件**
### 2.2 关于.mid格式的获取
通过刚刚的介绍,你可能已经发现,*.mid文件因为受众并不多而并没有被广泛熟知因而你之前可能完全没见过这个文件更何况要弄一首自己心仪的歌了。
这里介绍几个获取.mid格式的方法
1. 最简单的方法就是成为一个作编曲的人,当然,很多人做不到这一点,但是有必要提到这一点,当你在下面的渠道中都无法获得想要的文件时,
你应该考虑是不是需要自己创作内容,或者,请别人帮你创作内容。
2. 当你没有这样的文件时,问问别人或者从群里下在公告的免费的也是个思路,不过这个办法通常使用次数有限。
3. 自己找mid现在我将给你提供一个完整的找mid的方法请认真学习
**1.** 首先你需要在www.midishow.com中注册一个账号并不复杂你可能只需要一个QQ号。
**2.** 登录你的账号,主界面应该如下图所示:
<img src="https://foruda.gitee.com/images/1672644995747340749/36c9c143_10062986.png">
**3.** 在显眼的搜索框中,输入你想要的歌曲名称,接下来的教程,我以`夜空中最亮的星`这首歌及它的mid来演示下载流程。点击搜索框完成这一步。
<img src="https://foruda.gitee.com/images/1672645340943813483/44d0db69_10062986.png">
**4.** 接下来看到搜索结果如下,你可以点进去一个听听,决定你是否要下载;也有可能你什么都没搜到,那你就得换首歌或者换个途径了。
<img src="https://foruda.gitee.com/images/1672645574402099694/6b7e18e5_10062986.png">
**5.** 点击播放按钮试听,网站上的效果可能一般,但是会听音乐的人应该很快就能决定你是否需要下载这个音乐。如果需要下载,你可以进行到下一步,
如果不行,那你可以退回刚刚的页面换一个。
<img src="https://foruda.gitee.com/images/1672645752246438160/47cead78_10062986.png">
**6.** 翻到最下面,如图,你可以对这首歌进行打分,打分可以使积分+1建议打5分你可以对这首歌进行评论一次有意义的评论可以+3分。
下载一首歌需要-3积分如果你先完成了这两项操作再下载那你还会再赚1积分。所以推荐这样做
<img src="https://foruda.gitee.com/images/1672646433045265565/26ea29b2_10062986.png">
**完成后会像这样:**
<img src="https://foruda.gitee.com/images/1672646242419857480/5e8809b8_10062986.png">
**7.** 接下来下载,往上翻网页,找到这个标识,然后单击。
<img src="https://foruda.gitee.com/images/1672646275215822535/63b402db_10062986.png">
**8.** 确认完毕后点击下载。
<img src="https://foruda.gitee.com/images/1672646309787744490/f459adac_10062986.png">
**9.** 完成下载,如图:
<img src="https://foruda.gitee.com/images/1672646335942429563/2449ed0b_10062986.png">
4. 使用mp3转换为mid的工具不得不说科技的进步带来了许多便利让这样困难的事情也变得简单。如果上述方法仍然没有解决你的问题
那么你可以在下一章节中找到有关这个途径的说明。
### 2.3 .mp3格式转换为.mid格式
**注意,使用这个技术有一定难度,酌情使用!**
概述mp3转mid需要把**模拟的波形频谱信号转为数字乐谱信号**,这个过程**一定有损失**。
请各位以后不要在答疑群中问类似于我这个转换效果为什么不好这样的问题,谢谢。
如果直接用**widi**的话相当于对声音进行了**傅里叶变换**,你确实可以分离出其中的音高,但是效果在不同情况下差异较大,
尤其是有架子鼓啊啥的玩也的时候,比较**差**。
[widi工具链接](https://pan.baidu.com/s/1j_Jui0piQ6rMOXM0GJtqTg) 提取码b0lw
**如果只有钢琴的谱子需要分离,有一个完美的选择**[这里](https://zhuanlan.zhihu.com/p/270999354)
如果不然有其他的乐器也需要分离那么可能就有点困难像cakewalk就确实也可以吧音频变成mid但是可能要
**先把原MP3分离成人声音轨、贝斯音轨等再傅里叶变换。**
当然我也可能了解的不全,没准现在已经有传新的技术可以分离的更好了,那就太棒了!(〃'▽'〃)
另外我们开发者也象征性的找了一些mp3转mid的网站我们没使用过不担保效果。
[https://www.serocs.cn/transcription/](https://www.serocs.cn/transcription/)
同时midishow论坛里有一些大佬也提供了解决方案看看他们的发言也是一个不错的选择。
我就只给个论坛链接了,经常有人问这种问题,你可以去那里随便找到一篇帖子看看。
[论坛](https://www.midishow.com/question)
### 2.4 输出格式的问题
在前面说到,输出主要有`.mcpack`和`.bdx`文件的输出,接下来我会围绕这两个文件进行简单的说明。
#### 2.4.1 .mcpack是什么
输出.mcpack文件其实对于一个**资深基岩版我的世界玩家**应该并不陌生。
.mcpack文件其实就是我的世界基岩版的附加包里面一般分为行为包和材质包
我们生成的命令组属于**行为包** (下图就是一个例子)
<img src="https://foruda.gitee.com/images/1672647779755793187/884abaa9_10062986.png">
如果你是国际电脑版基岩玩家就像我一样,是可以直接打开这个文件,并将这个包导入我的世界的。
关于怎么使用,请看[**这里**](https://gitee.com/EillesWan/Musicreater/blob/pkgver/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)。
#### 2.4.2 .bdx是什么
.bdx 文件其实是FastBuilder这款软件的结构文件可以导入到我的世界。
由于这不属于官方文件且我并不是很熟悉这个结构所以请对这个格式有问题的好兄弟加一下QQ群问问群里负责导入的大佬。
## 第三部分 关于其他问题
**由于开发者们都很忙,群友们的耐心也都有限,所以恳请大家提出有意义的问题。这里附一个关于提问方法的链接,大家可以看看。**
[提问的智慧](https://github.com/tvvocold/How-To-Ask-Questions-The-Smart-Way)
希望不要我把这个文件在聊天中甩给你,那说明我可能已经没有耐心了。
看完这份说明,如果你打算开始使用我们的工具的话,请移步至[这里](https://gitee.com/EillesWan/Musicreater/blob/pkgver/docs/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)。
## 结尾
### 作者\<*金羿*\>(Eilles)联系方式
1. QQ 2647547478
2. 电邮 EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
3. 微信 WYI_DoctorYI
4. Telegram [@EillesWan](https://t.me/EillesWan)
### 作者\<*诸葛亮与八卦阵*\>(bgArray)联系方式
1. QQ 4740437765
**欢迎加群:[861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)**
**欢迎加群:[861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)**
**欢迎加群:[861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)**
(重要的事情说三遍)
**(有能力的同志麻烦给仓库star一下)**
**(有能力的同志麻烦给仓库star一下)**
**(有能力的同志麻烦给仓库star一下)**

View File

@ -4,26 +4,17 @@
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需转载或借鉴 请依照 Apache 2.0 许可证进行许可
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
"""
· 库版 MIDI转换示例程序
Musicreater Package Version : Demo for Midi Conversion
Copyright 2022 all the developers of Musicreater
Copyright 2023 all the developers of Musicreater
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
开源相关声明请见 ./Lisence.md
Terms & Conditions: ./Lisence.md
"""
languages = {
@ -42,6 +33,8 @@ languages = {
"ChoosePlayer": "请选择播放方式[计分板(1) 或 延迟(0)]",
"ChoosePath": "请输入MIDI路径或所在文件夹",
"WhetherArgEntering": "是否为文件夹内文件的转换统一参数[是(1) 或 否(0)]",
"EnterArgs": "请输入转换参数",
"noteofArgs": "文件夹内的全部midi将统一以此参数转换",
"ChooseSbReset": "是否自动重置计分板[是(1) 或 否(0)]",
"WhetherCstmProgressBar": "是否自定义进度条[是(1) 或 否(0)]",
"EnterProgressBarStyle": "请输入进度条样式",
@ -54,7 +47,7 @@ languages = {
"Re-Enter": "请重新输入",
"Dealing": "正在处理",
"FileNotFound": "文件(夹)不存在",
"ChooseOutPath": "请输入输出路径",
"ChooseOutPath": "请输入结果输出路径",
"EnterSelecter": "请输入播放者选择器",
"Saying": "言·论",
}
@ -63,7 +56,6 @@ languages = {
import sys
if sys.argv.__len__() > 0:
currentLang = sys.argv[0]
if not currentLang in languages.keys():
@ -74,54 +66,48 @@ else:
def _(__):
'''
:ChooseFileFormat 请输入输出格式[bdx(1)或mcpack(0)]
:ChoosePlayer 请选择播放方式[计分板(1) 延迟(0)]
:ChoosePath 请输入midi路径或所在文件夹
:WhetherArgEntering 是否为文件夹内文件的转换统一参数[是1 否0]
:ChooseSbReset 是否自动重置计分板[1或0]
:WhetherCstmProgressBar 是否自定义进度条
:EnterProgressBarStyle 请输入进度条样式
:EnterSbName 请输入计分板名称
:EnterVolume 请输入音量大小(0~1)
:EnterSpeed 请输入速度倍率
:EnterAuthor 请输入作者
:EnterMaxHeight 请输入指令结构最大生成高度
:ErrEnter 输入错误
:Re-Enter 请重新输入
:Dealing 正在处理
:FileNotFound 文件不存在
:ChooseOutPath 请输入输出路径
:EnterSelecter 请输入播放者选择器
:Saying 箴言
`languages`
'''
return languages[currentLang][__]
from msctPkgver.main import *
import os
import random
import datetime
from msctPkgver.main import *
try:
from rich.console import Console
except ModuleNotFoundError as E:
if input("您需要安装 Rich 模块才能使用这个样例\n请问是否安装?(y/n)").lower() in ('y','1'):
if input("您需要安装 Rich 模块才能使用这个样例\n请问是否安装?(y/n)").lower() in ('y', '1'):
os.system("pip install Rich -i https://mirrors.aliyun.com/pypi/")
from rich.console import Console
else:
raise E
MainConsole = Console()
try:
import zhdate
except ModuleNotFoundError as E:
if input("您需要安装 zhdate 模块才能使用这个样例\n请问是否安装?(y/n)").lower() in ('y', '1'):
os.system("pip install zhdate -i https://mirrors.aliyun.com/pypi/")
import zhdate
else:
raise E
try:
import requests
except ModuleNotFoundError as E:
if input("您需要安装 requests 模块才能使用这个样例\n请问是否安装?(y/n)").lower() in ('y','1'):
if input("您需要安装 requests 模块才能使用这个样例\n请问是否安装?(y/n)").lower() in ('y', '1'):
os.system("pip install requests -i https://mirrors.aliyun.com/pypi/")
import requests
else:
raise E
MainConsole = Console()
MainConsole.print(
"[#121110 on #F0F2F4] ",
style="#121110 on #F0F2F4",
@ -129,13 +115,14 @@ MainConsole.print(
)
# 显示大标题
MainConsole.rule(title="[bold #AB70FF]欢迎使用音·创独立转换器", characters="=", style="#26E2FF")
MainConsole.rule(
title="[bold #AB70FF]Welcome to Independent Musicreater Convernter", characters="-"
)
import random
# 显示箴言部分
MainConsole.print(
"[#121110 on #F0F2F4]"
+ random.choice(
@ -150,12 +137,12 @@ MainConsole.print(
)
from typing import Any, Optional, TextIO, Literal
from typing import Any, Literal, Optional, TextIO
JustifyMethod = Literal["default", "left", "center", "right", "full"]
OverflowMethod = Literal["fold", "crop", "ellipsis", "ignore"]
# 高级的打印函数
def prt(
*objects: Any,
sep: str = " ",
@ -211,7 +198,7 @@ def prt(
prt(f"{_('LangChd')}{_(':')}{_(currentLang)}")
# 高级的输入函数
def ipt(
*objects: Any,
sep: str = " ",
@ -275,14 +262,37 @@ def ipt(
return MainConsole.input("", password=password, stream=stream)
def formatipt(notice: str, fun, errnote: str = "", *extraArg):
'''循环输入,以某种格式
notice: 输入时的提示
fun: 格式函数
errnote: 输入不符格式时的提示
*extraArg: 对于函数的其他参数'''
while True:
result = ipt(notice)
try:
funresult = fun(result, *extraArg)
break
except:
prt(errnote)
continue
return result, funresult
# 获取midi列表
while True:
midipath = ipt(f"{_('ChoosePath')}{_(':')}").lower()
if os.path.exists(midipath):
if os.path.isfile(midipath):
midis = (midipath,)
elif os.path.isdir(midipath):
midis = tuple((os.path.join(midipath,i) for i in os.listdir(midipath) if i.lower().endswith('.mid') or i.lower().endswith('.midi')))
midis = tuple(
(
os.path.join(midipath, i)
for i in os.listdir(midipath)
if i.lower().endswith('.mid') or i.lower().endswith('.midi')
)
)
else:
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
continue
@ -291,30 +301,30 @@ while True:
continue
break
# 获取输出地址
outpath = formatipt(
f"{_('ChooseOutPath')}{_(':')}",
os.path.exists,
f"{_('FileNotFound')}{_(',')}{_('Re-Enter')}{_('.')}",
).lower()
# 选择输出格式
while True:
fileFormat = ipt(f"{_('ChooseFileFormat')}{_(':')}").lower()
if fileFormat in ('0','mcpack'):
if fileFormat in ('0', 'mcpack'):
fileFormat = 0
prt(_("EnterArgs"))
if len(midis) > 1:
while True:
isFirstArgs = ipt(f"{_('WhetherArgEntering')}{_(':')}").lower()
if isFirstArgs in ('0',''):
isFirstArgs = 0
elif isFirstArgs in ('1',''):
isFirstArgs = 1
else:
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
continue
break
elif fileFormat in ('1','bdx'):
prt(_("noteofArgs"))
elif fileFormat in ('1', 'bdx'):
fileFormat = 1
while True:
playerFormat = ipt(f"{_('ChoosePlayer')}{_(':')}").lower()
if playerFormat in ('0','延迟'):
if playerFormat in ('0', '延迟'):
playerFormat = 0
elif playerFormat in ('1','计分板'):
elif playerFormat in ('1', '计分板'):
playerFormat = 1
else:
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
@ -330,6 +340,4 @@ if fileFormat == 0:
pass
MainConsole.input()

View File

@ -4,34 +4,23 @@
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需转载或借鉴 请依照 Apache 2.0 许可证进行许可
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
__version__ = '0.0.1'
__version__ = '0.1.0'
__all__ = []
__author__ = (('金羿', 'Eilles Wan'), ('诸葛亮与八卦阵', 'bgArray'), ('鸣凤鸽子', 'MingFengPigeon'))
"""
· 库版 (Musicreater Package Version)
是一款免费开源的针对我的世界基岩版的midi音乐转换库
注意除了此源文件以外任何属于此仓库以及此项目的文件均依照Apache许可证进行许可
Musicreater pkgver (Package Version · 库版)
A free open source library used for convert midi file into formats that is suitable for **Minecraft: Bedrock Edition**.
Note! Except for this source file, all the files in this repository and this project are licensed under Apache License 2.0
Copyright © 2022 all the developers of Musicreater
Copyright 2023 all the developers of Musicreater
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
开源相关声明请见 ../Lisence.md
Terms & Conditions: ../Lisence.md
"""
@ -40,3 +29,6 @@ from .main import *
print('此Midi转换功能由音·创开发者开发版权归参与开发的人员共同所有。')
print('Copyright © 2022 all the developers of Musicreater')
print("小贴不妨试试Mid-BDX转换网页在线的多功能Midi转换器")
print("https://dislink.github.io/midi2bdx/")

View File

@ -4,30 +4,19 @@
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需使用或借鉴 请依照 Apache 2.0 许可证进行许可
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
"""
· 库版 (Musicreater Package Version)
是一款免费开源的针对我的世界基岩版的midi音乐转换库
注意除了此源文件以外任何属于此仓库以及此项目的文件均依照Apache许可证进行许可
Musicreater pkgver (Package Version · 库版)
A free open source library used for convert midi file into formats that is suitable for **Minecraft: Bedrock Edition**.
Note! Except for this source file, all the files in this repository and this project are licensed under Apache License 2.0
Copyright 2022 all the developers of Musicreater
Copyright 2023 all the developers of Musicreater
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
开源相关声明请见 ../Lisence.md
Terms & Conditions: ../Lisence.md
"""

View File

@ -4,30 +4,19 @@
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
# 若需使用或借鉴 请依照 Apache 2.0 许可证进行许可
# 若需转载或借鉴 许可声明请查看仓库目录下的 Lisence.md
"""
· 库版 (Musicreater Package Version)
是一款免费开源的针对我的世界基岩版的midi音乐转换库
注意除了此源文件以外任何属于此仓库以及此项目的文件均依照Apache许可证进行许可
Musicreater pkgver (Package Version · 库版)
A free open source library used for convert midi file into formats that is suitable for **Minecraft: Bedrock Edition**.
Note! Except for this source file, all the files in this repository and this project are licensed under Apache License 2.0
Copyright 2022 all the developers of Musicreater
Copyright 2023 all the developers of Musicreater
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
开源相关声明请见 ../Lisence.md
Terms & Conditions: ../Lisence.md
"""
import os
@ -64,7 +53,9 @@ def makeZip(sourceDir, outFilename, compression=8, exceptFile=None):
class SingleNote:
def __init__(self, instrument: int, pitch: int, velocity, startTime, lastTime):
def __init__(
self, instrument: int, pitch: int, velocity, startTime: int, lastTime: int
):
"""用于存储单个音符的类
:param instrument 乐器编号
:param pitch 音符编号
@ -73,17 +64,24 @@ class SingleNote:
此处的时间是用从乐曲开始到当前的毫秒数
:param lastTime 音符延续时间(ms)"""
self.instrument = instrument
'''乐器编号'''
self.note = pitch
'''音符编号'''
self.velocity = velocity
'''力度/响度'''
self.startTime = startTime
'''开始之时 ms'''
self.lastTime = lastTime
'''音符持续时间 ms'''
@property
def inst(self):
'''乐器编号'''
return self.instrument
@property
def pitch(self):
'''音符编号'''
return self.note
def __str__(self):
@ -118,6 +116,21 @@ tempo * amount_of_beats => 毫秒数
tempo * tick / ticks_per_beat => 毫秒数
###########
seconds per tick:
(tempo / 1000000.0) / ticks_per_beat
seconds:
tick * tempo / 1000000.0 / ticks_per_beat
microseconds:
tick * tempo / 1000.0 / ticks_per_beat
gameticks:
tick * tempo / 1000000.0 / ticks_per_beat * 一秒多少游戏刻
"""
@ -161,7 +174,7 @@ class midiConvert:
贝斯bass迪吉里杜管didgeridoo的时候为8
长笛flute牛铃cou_bell的时候为5
钟琴bell管钟chime木琴xylophone的时候为4
而存在一些打击乐器basedrumhatsnare没有音域则没有X那么我们返回7即可
而存在一些打击乐器bd(basedrum)hatsnare没有音域则没有X那么我们返回7即可
:param instrumentID: midi的乐器ID
default: 如果instrumentID不在范围内返回的默认我的世界乐器名称
:return: (str我的世界乐器名, int转换算法中的X)"""
@ -283,34 +296,99 @@ class midiConvert:
113: ("note.bell", 4),
114: ("note.harp", 6),
115: ("note.cow_bell", 5),
116: ("note.basedrum", 7), # 打击乐器无音域
116: ("note.bd", 7), # 打击乐器无音域
117: ("note.bass", 8),
118: ("note.bit", 6),
119: ("note.basedrum", 7), # 打击乐器无音域
119: ("note.bd", 7), # 打击乐器无音域
120: ("note.guitar", 7),
121: ("note.harp", 6),
122: ("note.harp", 6),
123: ("note.harp", 6),
124: ("note.harp", 6),
125: ("note.hat", 7), # 打击乐器无音域
126: ("note.basedrum", 7), # 打击乐器无音域
126: ("note.bd", 7), # 打击乐器无音域
127: ("note.snare", 7), # 打击乐器无音域
}[instrumentID]
except BaseException:
a = ("note.harp", 6)
a = ("note.flute", 5)
return a
def __bitInst2IDwithX(self, instrumentID):
try:
try:
return {
34: ('note.bd', 7),
35: ('note.bd', 7),
36: ('note.hat', 7),
37: ('note.snare', 7),
38: ('note.snare', 7),
39: ('note.snare', 7),
40: ('note.hat', 7),
41: ('note.snare', 7),
42: ('note.hat', 7),
43: ('note.snare', 7),
44: ('note.snare', 7),
45: ('note.bell', 4),
46: ('note.snare', 7),
47: ('note.snare', 7),
48: ('note.bell', 4),
49: ('note.hat', 7),
50: ('note.bell', 4),
51: ('note.bell', 4),
52: ('note.bell', 4),
53: ('note.bell', 4),
54: ('note.bell', 4),
55: ('note.bell', 4),
56: ('note.snare', 7),
57: ('note.hat', 7),
58: ('note.chime', 4),
59: ('note.iron_xylophone', 6),
60: ('note.bd', 7),
61: ('note.bd', 7),
62: ('note.xylophone', 4),
63: ('note.xylophone', 4),
64: ('note.xylophone', 4),
65: ('note.hat', 7),
66: ('note.bell', 4),
67: ('note.bell', 4),
68: ('note.hat', 7),
69: ('note.hat', 7),
70: ('note.flute', 5),
71: ('note.flute', 5),
72: ('note.hat', 7),
73: ('note.hat', 7),
74: ('note.xylophone', 4),
75: ('note.hat', 7),
76: ('note.hat', 7),
77: ('note.xylophone', 4),
78: ('note.xylophone', 4),
79: ('note.bell', 4),
80: ('note.bell', 4),
}[instrumentID]
except:
return ("note.bd", 7)
except:
print("WARN", "无法导入打击乐器列表动态链接库可能是不支持当前及其环境打击乐器使用Dislink算法代替。")
if instrumentID == 55:
return ("note.cow_bell", 5)
elif instrumentID in [41, 43, 45]:
return ("note.hat", 7)
elif instrumentID in [36, 37, 39]:
return ("note.snare", 7)
else:
return ("note.bd", 7)
def __score2time(self, score: int):
return str(int(int(score / 20) / 60)) + ":" + str(int(int(score / 20) % 60))
def __formProgressBar(
self,
maxscore: int,
scoreboardname: str,
progressbar: tuple = (
r"%%N [ %%s/%^s %%% __________ %%t|%^t ]",
("§e=§r", "§7=§r"),
),
self,
maxscore: int,
scoreboardname: str,
progressbar: tuple = (
r"%%N [ %%s/%^s %%% __________ %%t|%^t ]",
("§e=§r", "§7=§r"),
),
) -> list:
pgsstyle = progressbar[0]
@ -329,7 +407,7 @@ class midiConvert:
"""
def __replace(
s: str, tobeReplaced: str, replaceWith: str, times: int, other: str
s: str, tobeReplaced: str, replaceWith: str, times: int, other: str
):
if times == 0:
return s.replace(tobeReplaced, other)
@ -404,16 +482,16 @@ class midiConvert:
return finalprgsbar
def __formCMDblk(
self,
command: str,
particularValue: int,
impluse: int = 0,
condition: bool = False,
needRedstone: bool = True,
tickDelay: int = 0,
customName: str = "",
executeOnFirstTick: bool = False,
trackOutput: bool = True,
self,
command: str,
particularValue: int,
impluse: int = 0,
condition: bool = False,
needRedstone: bool = True,
tickDelay: int = 0,
customName: str = "",
executeOnFirstTick: bool = False,
trackOutput: bool = True,
):
"""
使用指定项目返回指定的指令方块放置指令项
@ -476,7 +554,7 @@ class midiConvert:
return block
def _toCmdList_m1(
self, scoreboardname: str = "mscplay", volume: float = 1.0, speed: float = 1.0
self, scoreboardname: str = "mscplay", volume: float = 1.0, speed: float = 1.0
) -> list:
"""
使用Dislink Sforza的转换思路将midi转换为我的世界命令列表
@ -518,40 +596,43 @@ class midiConvert:
except NameError:
raise NotDefineTempoError("计算当前分数时出错 未定义参量 Tempo")
maxscore = max(maxscore, nowscore)
soundID, _X = self.__Inst2soundIDwithX(instrumentID)
if msg.channel == 9:
soundID, _X = self.__bitInst2IDwithX(instrumentID)
else:
soundID, _X = self.__Inst2soundIDwithX(instrumentID)
# /playsound <sound: string> [player: target] [position: x y z]
# [volume: float] [pitch: float] [minimumVolume: float]
volume_d = 1 / volume - 1
if volume_d == 0.0:
volume_d = ""
command_now = "playsound {0} @a[scores={{{1}}}] ~ ~{2} ~ {3} {4}" \
.format(soundID, "{}={}".format(scoreboardname,
nowscore), volume_d,
msg.velocity, 2 ** ((msg.note - 60 - _X) / 12))
singleTrack.append(command_now)
# singleTrack.append(
# "execute @a[scores={"
# + str(scoreboardname)
# + "="
# + str(nowscore)
# + "}"
# + f"] ~ ~ ~ playsound {soundID} @s ~ ~{1 / volume - 1} ~ "
# f"{msg.velocity * (0.7 if msg.channel == 0 else 0.9)} {2 ** ((msg.note - 60 - _X) / 12)}"
# )
# volume_d = 1 / volume - 1
# if volume_d == 0.0:
# volume_d = ""
# command_now = "playsound {0} @a[scores={{{1}}}] ~ ~{2} ~ {3} {4}" \
# .format(soundID, "{}={}".format(scoreboardname,
# nowscore), volume_d,
# msg.velocity, 2 ** ((msg.note - 60 - _X) / 12))
# singleTrack.append(command_now)
singleTrack.append(
"execute @a[scores={"
+ str(scoreboardname)
+ "="
+ str(nowscore)
+ "}"
+ f"] ~ ~ ~ playsound {soundID} @s ~ ~{1 / volume - 1} ~ "
f"{msg.velocity * (0.7 if msg.channel == 0 else 0.9)} {2 ** ((msg.note - 60 - _X) / 12)}"
)
commands += 1
if len(singleTrack) != 0:
tracks.append(singleTrack)
return [tracks, commands, maxscore]
# 这与上面的算法几乎没有差别 甚至更慢了一点 但是是为了线性插值做准备
# 原本这个算法的转换效果应该和上面的算法相似的
def _toCmdList_m2(
self,
scoreboardname: str = "mscplay",
MaxVolume: float = 1.0,
speed: float = 1.0,
self,
scoreboardname: str = "mscplay",
MaxVolume: float = 1.0,
speed: float = 1.0,
) -> list:
"""
使用金羿的转换思路将midi转换为我的世界命令列表
@ -607,7 +688,7 @@ class midiConvert:
)
elif (msg.type == "note_on" and msg.velocity == 0) or (
msg.type == "note_off"
msg.type == "note_off"
):
channels[msg.channel].append(("NoteE", msg.note, microseconds))
@ -639,8 +720,12 @@ class midiConvert:
if channels.index(track) == 0:
CheckFirstChannel = True
SpecialBits = False
elif channels.index(track) == 9:
SpecialBits = True
else:
CheckFirstChannel = False
SpecialBits = False
nowTrack = []
@ -651,7 +736,10 @@ class midiConvert:
elif msg[0] == "NoteS":
soundID, _X = self.__Inst2soundIDwithX(InstID)
if SpecialBits:
soundID, _X = self.__bitInst2IDwithX(InstID)
else:
soundID, _X = self.__Inst2soundIDwithX(InstID)
score_now = round(msg[-1] / float(speed) / 50000)
maxScore = max(maxScore, score_now)
@ -670,19 +758,15 @@ class midiConvert:
return [tracks, cmdAmount, maxScore]
# 这才是加了线性插值的算法
# 此算法有巨大问题
# 暂时无法使用
# 已经经过验证 需要再次修改
# 等一段时间后我来通知
# 简单的单音填充
def _toCmdList_m3(
self,
scoreboardname: str = "mscplay",
MaxVolume: float = 1.0,
speed: float = 1.0,
self,
scoreboardname: str = "mscplay",
MaxVolume: float = 1.0,
speed: float = 1.0,
) -> list:
"""
使用金羿的转换思路将midi转换为我的世界命令列表并使用线性插值算法优化音量
使用金羿的转换思路将midi转换为我的世界命令列表并使用完全填充算法优化音感
:param scoreboardname: 我的世界的计分板名称
:param MaxVolume: 音量注意这里的音量范围为(0,1]如果超出将被处理为正确值其原理为在距离玩家 (1 / volume -1) 的地方播放音频
:param speed: 速度注意这里的速度指的是播放倍率其原理为在播放音频的时候每个音符的播放时间除以 speed
@ -735,7 +819,7 @@ class midiConvert:
)
elif (msg.type == "note_on" and msg.velocity == 0) or (
msg.type == "note_off"
msg.type == "note_off"
):
channels[msg.channel].append(("NoteE", msg.note, microseconds))
@ -799,11 +883,18 @@ class midiConvert:
result = []
totalCount = int(note.lastTime / 500000)
totalCount = int(note.lastTime / 500)
for i in range(totalCount):
result.append((note.startTime + i * 500000, note.instrument, note.pitch, note.velocity,
MaxVolume * ((totalCount - i) / totalCount)))
result.append(
(
note.startTime + i * 500,
note.instrument,
note.pitch,
note.velocity,
MaxVolume * ((totalCount - i) / totalCount),
)
)
return result
@ -815,8 +906,12 @@ class midiConvert:
if note_channels.index(track) == 0:
CheckFirstChannel = True
SpecialBits = False
elif note_channels.index(track) == 9:
SpecialBits = True
else:
CheckFirstChannel = False
SpecialBits = False
nowTrack = []
@ -826,11 +921,12 @@ class midiConvert:
# 应该是计算的时候出了点小问题
# 我们应该用一个MC帧作为时间单位而不是半秒
soundID, _X = self.__Inst2soundIDwithX(everynote[1])
if SpecialBits:
soundID, _X = self.__bitInst2IDwithX(InstID)
else:
soundID, _X = self.__Inst2soundIDwithX(InstID)
score_now = round(
everynote[0] / speed / 50000
)
score_now = round(everynote[0] / speed / 50000)
maxScore = max(maxScore, score_now)
@ -849,11 +945,11 @@ class midiConvert:
return [tracks, cmdAmount, maxScore]
def _toCmdList_withDelay_m1(
self,
volume: float = 1.0,
speed: float = 1.0,
player: str = "@a",
isMixedWithPrograssBar=False,
self,
volume: float = 1.0,
speed: float = 1.0,
player: str = "@a",
isMixedWithPrograssBar=False,
) -> list:
"""
使用Dislink Sforza的转换思路将midi转换为我的世界命令列表并输出每个音符之后的延迟
@ -925,7 +1021,7 @@ class midiConvert:
"""
def __replace(
s: str, tobeReplaced: str, replaceWith: str, times: int, other: str
s: str, tobeReplaced: str, replaceWith: str, times: int, other: str
):
if times == 0:
return s.replace(tobeReplaced, other)
@ -1026,13 +1122,13 @@ class midiConvert:
return math.ceil(math.sqrt(math.ceil(total / maxHeight)))
def tomcpack(
self,
method: int = 1,
isAutoReset: bool = False,
progressbar=None,
scoreboardname: str = "mscplay",
volume: float = 1.0,
speed: float = 1.0,
self,
method: int = 1,
isAutoReset: bool = False,
progressbar=None,
scoreboardname: str = "mscplay",
volume: float = 1.0,
speed: float = 1.0,
) -> bool or tuple:
"""
使用method指定的转换算法将midi转换为我的世界mcpack格式的包
@ -1060,7 +1156,7 @@ class midiConvert:
# 写入manifest.json
if not os.path.exists(f"{self.outputPath}/temp/manifest.json"):
with open(
f"{self.outputPath}/temp/manifest.json", "w", encoding="utf-8"
f"{self.outputPath}/temp/manifest.json", "w", encoding="utf-8"
) as f:
f.write(
'{\n "format_version": 1,\n "header": {\n "description": "'
@ -1077,7 +1173,7 @@ class midiConvert:
)
else:
with open(
f"{self.outputPath}/temp/manifest.json", "r", encoding="utf-8"
f"{self.outputPath}/temp/manifest.json", "r", encoding="utf-8"
) as manifest:
data = json.loads(manifest.read())
data["header"][
@ -1101,9 +1197,9 @@ class midiConvert:
"function mscplay/track" + str(cmdlist.index(track) + 1) + "\n"
)
with open(
f"{self.outputPath}/temp/functions/mscplay/track{cmdlist.index(track) + 1}.mcfunction",
"w",
encoding="utf-8",
f"{self.outputPath}/temp/functions/mscplay/track{cmdlist.index(track) + 1}.mcfunction",
"w",
encoding="utf-8",
) as f:
f.write("\n".join(track))
indexfile.writelines(
@ -1114,12 +1210,12 @@ class midiConvert:
+ scoreboardname
+ " 1\n",
(
"scoreboard players reset @a[scores={"
+ scoreboardname
+ "="
+ str(maxscore + 20)
+ "..}]"
+ f" {scoreboardname}\n"
"scoreboard players reset @a[scores={"
+ scoreboardname
+ "="
+ str(maxscore + 20)
+ "..}]"
+ f" {scoreboardname}\n"
)
if isAutoReset
else "",
@ -1130,18 +1226,18 @@ class midiConvert:
if progressbar:
if progressbar:
with open(
f"{self.outputPath}/temp/functions/mscplay/progressShow.mcfunction",
"w",
encoding="utf-8",
f"{self.outputPath}/temp/functions/mscplay/progressShow.mcfunction",
"w",
encoding="utf-8",
) as f:
f.writelines(
"\n".join(self.__formProgressBar(maxscore, scoreboardname))
)
else:
with open(
f"{self.outputPath}/temp/functions/mscplay/progressShow.mcfunction",
"w",
encoding="utf-8",
f"{self.outputPath}/temp/functions/mscplay/progressShow.mcfunction",
"w",
encoding="utf-8",
) as f:
f.writelines(
"\n".join(
@ -1162,15 +1258,15 @@ class midiConvert:
return (True, f"转换完成,总长度{maxlen}")
def toBDXfile(
self,
method: int = 1,
author: str = "Eilles",
progressbar=False,
maxheight: int = 64,
scoreboardname: str = "mscplay",
volume: float = 1.0,
speed: float = 1.0,
isAutoReset: bool = False,
self,
method: int = 1,
author: str = "Eilles",
progressbar=False,
maxheight: int = 64,
scoreboardname: str = "mscplay",
volume: float = 1.0,
speed: float = 1.0,
isAutoReset: bool = False,
):
"""
使用method指定的转换算法将midi转换为BDX结构文件
@ -1184,23 +1280,26 @@ class midiConvert:
:param isAutoReset: 是否自动重置计分板
:return 成功与否成功返回(True,未经过压缩的源,结构占用大小)失败返回(False,str失败原因)
"""
try:
cmdlist, totalcount, maxScore = self.methods[method - 1](
scoreboardname, volume, speed
)
except:
return (False, f"无法找到算法ID{method}对应的转换算法")
# try:
cmdlist, totalcount, maxScore = self.methods[method - 1](
scoreboardname, volume, speed
)
# except Exception as E:
# return (False, f"无法找到算法ID{method}对应的转换算法: {E}")
if not os.path.exists(self.outputPath):
os.makedirs(self.outputPath)
with open(os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")), "w+") as f:
with open(
os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")),
"w+",
) as f:
f.write("BD@")
_bytes = (
b"BDX\x00"
+ author.encode("utf-8")
+ b" & Musicreater\x00\x01command_block\x00"
b"BDX\x00"
+ author.encode("utf-8")
+ b" & Musicreater\x00\x01command_block\x00"
)
key = {
@ -1229,12 +1328,12 @@ class midiConvert:
if isAutoReset:
commands += (
"scoreboard players reset @a[scores={"
+ scoreboardname
+ "="
+ str(maxScore + 20)
+ "}] "
+ scoreboardname
"scoreboard players reset @a[scores={"
+ scoreboardname
+ "="
+ str(maxScore + 20)
+ "}] "
+ scoreboardname
)
# 此处是对于仅有 True 的参数和自定义参数的判断
@ -1251,13 +1350,13 @@ class midiConvert:
cmd,
(1 if yforward else 0)
if (
((nowy != 0) and (not yforward))
or ((yforward) and (nowy != maxheight))
((nowy != 0) and (not yforward))
or ((yforward) and (nowy != maxheight))
)
else (3 if zforward else 2)
if (
((nowz != 0) and (not zforward))
or ((zforward) and (nowz != _sideLength))
((nowz != 0) and (not zforward))
or ((zforward) and (nowz != _sideLength))
)
else 5,
impluse=2,
@ -1279,7 +1378,7 @@ class midiConvert:
nowz += 1 if zforward else -1
if ((nowz > _sideLength) and (zforward)) or (
(nowz < 0) and (not zforward)
(nowz < 0) and (not zforward)
):
nowz -= 1 if zforward else -1
zforward = not zforward
@ -1293,20 +1392,23 @@ class midiConvert:
_bytes += key[y][int(yforward)]
with open(os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")), "ab+") as f:
with open(
os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")),
"ab+",
) as f:
f.write(brotli.compress(_bytes + b"XE"))
return (True, _bytes, (nowx, maxheight, _sideLength))
return (True, totalcount, maxScore, _bytes, (nowx, maxheight, _sideLength))
def toBDXfile_withDelay(
self,
method: int = 1,
author: str = "Eilles",
progressbar=False,
maxheight: int = 64,
volume: float = 1.0,
speed: float = 1.0,
player: str = "@a",
self,
method: int = 1,
author: str = "Eilles",
progressbar=False,
maxheight: int = 64,
volume: float = 1.0,
speed: float = 1.0,
player: str = "@a",
):
"""
使用method指定的转换算法将midi转换为BDX结构文件
@ -1330,13 +1432,16 @@ class midiConvert:
if not os.path.exists(self.outputPath):
os.makedirs(self.outputPath)
with open(os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")), "w+") as f:
with open(
os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")),
"w+",
) as f:
f.write("BD@")
_bytes = (
b"BDX\x00"
+ author.encode("utf-8")
+ b" & Musicreater\x00\x01command_block\x00"
b"BDX\x00"
+ author.encode("utf-8")
+ b" & Musicreater\x00\x01command_block\x00"
)
key = {
@ -1363,13 +1468,13 @@ class midiConvert:
cmd,
(1 if yforward else 0)
if (
((nowy != 0) and (not yforward))
or ((yforward) and (nowy != maxheight))
((nowy != 0) and (not yforward))
or ((yforward) and (nowy != maxheight))
)
else (3 if zforward else 2)
if (
((nowz != 0) and (not zforward))
or ((zforward) and (nowz != _sideLength))
((nowz != 0) and (not zforward))
or ((zforward) and (nowz != _sideLength))
)
else 5,
impluse=2,
@ -1391,7 +1496,7 @@ class midiConvert:
nowz += 1 if zforward else -1
if ((nowz > _sideLength) and (zforward)) or (
(nowz < 0) and (not zforward)
(nowz < 0) and (not zforward)
):
nowz -= 1 if zforward else -1
zforward = not zforward
@ -1405,11 +1510,15 @@ class midiConvert:
_bytes += key[y][int(yforward)]
with open(os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")), "ab+") as f:
with open(
os.path.abspath(os.path.join(self.outputPath, f"{self.midFileName}.bdx")),
"ab+",
) as f:
f.write(brotli.compress(_bytes + b"XE"))
return (True, _bytes, (nowx, maxheight, _sideLength))
# def isProgressBar(pgbarLike:str):
# '''判断所输入数据是否为进度条式样数据
# 注意,使用本函数时不得直接放在 if 后,正确用法如下: