mirror of
https://github.com/TriM-Organization/Linglun-Converter.git
synced 2024-12-01 09:34:53 +08:00
转换功能转移
This commit is contained in:
parent
b815e9f2bf
commit
5a7e43babe
8
.gitignore
vendored
8
.gitignore
vendored
@ -3,6 +3,14 @@ __pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# mystuff
|
||||
/.vscode
|
||||
*.mid
|
||||
*.midi
|
||||
*.mcpack
|
||||
*.bdx
|
||||
*.json
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<h1 align="center">伶伦</h1>
|
||||
<h1 align="center">伶伦转换器</h1>
|
||||
|
||||
<h3 align="center">一个免费开源的《我的世界》数字音频工作站</h3>
|
||||
<h3 align="center">一个免费开源的《我的世界》数字音频转换器</h3>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://forthebadge.com/images/badges/built-with-love.svg">
|
||||
@ -22,6 +22,8 @@
|
||||
|
||||
伶伦 是一款免费开源的 **《我的世界》** 数字音频工作站
|
||||
|
||||
伶伦转换器 是仅用于 **《我的世界》** 数字音频转换的工具
|
||||
|
||||
欢迎加群:[861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)
|
||||
|
||||
## 软件架构🏢
|
||||
|
78
docs/Use of Funtions.md
Normal file
78
docs/Use of Funtions.md
Normal file
@ -0,0 +1,78 @@
|
||||
<h1 align="center">Linglun Converter</h1>
|
||||
|
||||
# Instructions for Using Demo(s)
|
||||
|
||||
*This is a tutorial for using the demo(s) of this library, not the Development Guide.*
|
||||
|
||||
*Developing Documentation is now not translated yet, you can see here for the [Chinese Orignal Version](%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) if you understand Chinese*
|
||||
|
||||
## Instructions of Downloading and Starting using Demo
|
||||
|
||||
### [Windows OS](./download%26start_EN/Windows.md)
|
||||
### [Linux OS](./download%26start_EN/Linux.md)
|
||||
### [Android OS](./download%26start_EN/Android.md)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2. More Info for Parameters of Our Demo Program(s)
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659974810147043475/运行.png>
|
||||
|
||||
|Input Prompt|English Translation|Description|
|
||||
|----------------|----------------|-------|
|
||||
|请输入MIDI文件路径|Midi File Path|Path of a .mid file or a directory. While directory entered, our demo will convert all midi(s) in the directory|
|
||||
|请输入输出路径|Output Path|Where files converted in|
|
||||
|是否重置计分板|Whether Reset Scoreboard Automatically|Can only be 1 or 0(Recommanded 1)|
|
||||
|*进度条[注]|Progressbar|Whether to enable Progressbar and customize progressbar style. Type 0 or False to disable, 1 or True to use default style, or type using format taught in follow the Instructions below to customize one you like|
|
||||
|请输入计分板名称|Scoreboard Name|*Only not byDelay* The name of scoreboard that player using|
|
||||
|请输入音量|Volume|Only decimal in [0,1],(Recommanded 1)|
|
||||
|请输入速度倍率|Speed Multiplying Factor|Maybe you want to play it faster(>1) or slower(>0 <1)?|
|
||||
|请输入玩家选择器|Player Selector|Full Selector including `@x`. E.g: Play for players tagged `Holo`, enter `@a[tag=Holo]` on this parameter|
|
||||
|
||||
|
||||
|
||||
|
||||
# Instructions for **Customize Progress Bar**
|
||||
|
||||
We have supported the function of making progress bar in *Minecraft*'s music player. And also the method of customize them. So the following instructions are about the parameters of the Progress Bar Customizition.
|
||||
|
||||
A Progress Bar, of course, is composed of **changeless** parts and **changable** parts. And the changable parts include texts or *images*(these images are made up of texts, or we can say, character paintings 😁). That is, for *Minecraft*, a changable image in a progress bar is just the "bar" part(which is like a stripe).
|
||||
|
||||
We use a string to describe the style of progress bar you need, and it includes many **identifier**s to replace the changable parts.
|
||||
|
||||
There are the identifiers:
|
||||
|
||||
| Identifier | Changable Part |
|
||||
|--------------|------------------------------------------------------|
|
||||
| `%%N` | Music name(file name which is imported into program) |
|
||||
| `%%s` | Value of scoreboard of now |
|
||||
| `%^s` | Max value of scoreboard |
|
||||
| `%%t` | Current playback time |
|
||||
| `%^t` | Total music time |
|
||||
| `%%%` | Current playback progress |
|
||||
| `_` | To be replaced by the *Bar* part of the progress bar |
|
||||
|
||||
The `_` is a placeholder to identifying the *bar* part, yeah, just the changable image.
|
||||
|
||||
This is an example of **style description string**, and this is also the default style of *Musicreater*'s progress bar.
|
||||
|
||||
`▶ %%N [ %%s/%^s %%% __________ %%t|%^t]`
|
||||
|
||||
This is a progress bar with only one line, but it is possible if you want to give a multiline parameter into the style description string.
|
||||
|
||||
But the string above is only for style identification, but we also need to identifying the changable image's image(just what the bar's look).
|
||||
|
||||
A "bar", simply, included 2 parts: *Have Been Played* & *Not Been Played*. So we use a tuple to pass the parameter. It's under a simple format: `(str: played, str: not)`. For example, the default parameter is below:
|
||||
|
||||
`('§e=§r', '§7=§r')`
|
||||
|
||||
So it's time to combine what I said in one parameter now!
|
||||
|
||||
This is a default definder parameter:
|
||||
|
||||
`('▶ %%N [ %%s/%^s %%% __________ %%t|%^t]',('§e=§r', '§7=§r'))`
|
||||
|
||||
*Tip: To avoid errors, please not to use the identifiers as the other part of your style.*
|
166
docs/download&start/Android.md
Normal file
166
docs/download&start/Android.md
Normal file
@ -0,0 +1,166 @@
|
||||
## 使用前的准备工作
|
||||
|
||||
### 安装终端工具
|
||||
|
||||
这里我们选用 **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 magicDemo.py
|
||||
```
|
||||
|
||||
运行成功了,哦耶!
|
||||
|
||||
<img height="512" src="https://foruda.gitee.com/images/1665933366784631363/db9f80f6_9911226.jpeg">
|
||||
|
103
docs/download&start/Linux.md
Normal file
103
docs/download&start/Linux.md
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
## 运行环境安装
|
||||
|
||||
### 检验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 magicDemo.py
|
||||
```
|
||||
|
90
docs/download&start/Windows.md
Normal file
90
docs/download&start/Windows.md
Normal file
@ -0,0 +1,90 @@
|
||||
## 一、运行环境安装
|
||||
|
||||
### (一)安装 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/TriM-Organization/Musicreater.git
|
||||
```
|
||||
|
||||
- 若您不使用git,可以在[*码云*(Gitee)](https://gitee.com/TriM-Organization/Musicreater.git)或[*GitHub*](https://github.com/TriM-Organization/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. 开始使用
|
||||
|
||||
您可以直接双击 `magicDemo.py` 以运行演示程序,或者按照以下步骤使用终端应用运行。
|
||||
|
||||
在目录下打开终端。
|
||||
|
||||
例如:打开命令行:请进入到目录下,在文件资源管理器的地址框内输入`cmd`:
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659974437388532868/输入.png>
|
||||
<img src=https://foruda.gitee.com/images/1659974754378201859/输入c.png>
|
||||
|
||||
使用以下指令:
|
||||
|
||||
```bash
|
||||
python ./magicDemo.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*帮我们发现这个问题。
|
97
docs/download&start_EN/Android.md
Normal file
97
docs/download&start_EN/Android.md
Normal file
@ -0,0 +1,97 @@
|
||||
## Before we Use
|
||||
|
||||
### Installing Terminal APP
|
||||
|
||||
We choose **Termux** as the Terminal APP as it is the powerful Linux simulator.
|
||||
|
||||
1. Dowloading
|
||||
|
||||
From both [GitHub](https://github.com/termux/termux-app/releases) or [F-Droid](https://f-droid.org/en/packages/com.termux/) to download is OK.
|
||||
|
||||
2. Installing
|
||||
|
||||
*APK* file is easy to install and you must know it without my instruments, you can see something like below after opening this app.
|
||||
|
||||
<img height="512" src="https://foruda.gitee.com/images/1665933025120627254/a0479618_9911226.jpeg">
|
||||
|
||||
3. Finish
|
||||
|
||||
OK, congratulations for ok installing *Termux*.
|
||||
|
||||
### Installing Runtime Environment
|
||||
|
||||
1. Installing **Python**
|
||||
|
||||
```bash
|
||||
apt-get install python3
|
||||
```
|
||||
|
||||
The picture left below is while you may enter `Y` to continue.
|
||||
Aftering succeed in installing you will see as right bicture below.
|
||||
|
||||
<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>
|
||||
|
||||
OK, let try whether success installing **Python** via
|
||||
|
||||
```bash
|
||||
python3 -V
|
||||
```
|
||||
|
||||
Sth. like `Python 3.X.X` will occur if so.
|
||||
|
||||
3. Installing dependences
|
||||
|
||||
```bash
|
||||
pip install mido
|
||||
pip install brotli
|
||||
```
|
||||
|
||||
Sth. like below will occur if successful.
|
||||
|
||||
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
|
||||
|
||||
### Install Downloading Tool
|
||||
|
||||
Tired to translate, QwQ.....
|
||||
Sleep for a while and this can be a TO-DO.
|
||||
|
||||
既然已经有了运行环境,那么我们就需要下载下我们的**音·创库版示例代码**工具,我非常推崇**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 magicDemo.py
|
||||
```
|
||||
|
||||
运行成功了,哦耶!
|
||||
|
||||
<img height="512" src="https://foruda.gitee.com/images/1665933366784631363/db9f80f6_9911226.jpeg">
|
||||
|
102
docs/download&start_EN/Linux.md
Normal file
102
docs/download&start_EN/Linux.md
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
## Install Runtime Environment
|
||||
|
||||
### Install and Verify Python Runtime
|
||||
|
||||
0. Common Linux Distributions do include a Python Runtime Environment, what we should do is only to check whether it is a satisfied version to our program. If the version ≥Python3.6, theoretically our program can be run.
|
||||
|
||||
We can type:
|
||||
|
||||
```bash
|
||||
python -V
|
||||
```
|
||||
|
||||
To check the Python version, as the follows
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1665120915821957090/429561fd_9911226.png>
|
||||
|
||||
1. **Not Necessary**
|
||||
|
||||
If you want to change a Python version just as what I want to do, it is such a great fantastic action! Let do as the follows:
|
||||
|
||||
- pacman Package Manager(In Arch Linux Mostly)
|
||||
|
||||
1. Let's write python3 into the ingore list of updating. Via `vim` to edit `/etc/pacman.conf`, add `python3` after `IgnorePkg`.
|
||||
|
||||
```bash
|
||||
sudo vim /etc/pacman.conf
|
||||
```
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1665124611490335193/5e99ca26_9911226.png>
|
||||
|
||||
2. Then we can search for python releases in [Arch Achieve](https://archive.archlinux.org/packages/).(*HERE, under Arch, Python refers to Python3 defaultly, while some other Linux releases using Python2 as default. So dose Arch Achieve.*)What I find here is [Python3.8.6](https://archive.archlinux.org/packages/p/python/python-3.8.6-1-x86_64.pkg.tar.zst), so let's download she via `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. Perfect!
|
||||
|
||||
- Other Package Manager
|
||||
|
||||
None yet.
|
||||
|
||||
### Install and Verify pip Package Manager
|
||||
|
||||
1. Before installing, it is to be checked, wheather Python's pip is OK:
|
||||
|
||||
```bash
|
||||
python -m pip # To check is pip installed
|
||||
# If a long tip occured, it is OK
|
||||
|
||||
# If returned as this, then not.
|
||||
/usr/bin/python: No module named pip
|
||||
# We can install pip via:
|
||||
sudo pacman -S python-pip
|
||||
# Verfy, remember.
|
||||
python -m pip
|
||||
|
||||
|
||||
# If you did but failed, we should use other methods to install pip:
|
||||
wget https://bootstrap.pypa.io/get-pip.py
|
||||
sudo python get-pip.py
|
||||
# Verfy, must.
|
||||
python -m pip
|
||||
```
|
||||
|
||||
2. After checking, let's install the dependences.
|
||||
|
||||
```bash
|
||||
pip install mido -i
|
||||
pip install brotli -i
|
||||
```
|
||||
|
||||
3. See the tips below as successfully installed:
|
||||
|
||||
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
|
||||
|
||||
|
||||
## Download this lib's sources code and Using its demos.
|
||||
|
||||
1. Download via Git
|
||||
|
||||
```bash
|
||||
git clone -b pkgver https://github.com/TriM-Organization/Musicreater.git MSCTpkgver
|
||||
```
|
||||
|
||||
If succeed, a directory named `MSCTpkgver` well be found in the path you run this command, and inside it is the source code and demo(s) we wantted to download.
|
||||
What we want to use is the demo(s) so enter the folder via:
|
||||
|
||||
```bash
|
||||
cd MSCTpkgver
|
||||
```
|
||||
|
||||
1. Starting Using Demo(s)
|
||||
|
||||
Via
|
||||
|
||||
```bash
|
||||
python magicDemo.py
|
||||
```
|
92
docs/download&start_EN/Windows.md
Normal file
92
docs/download&start_EN/Windows.md
Normal file
@ -0,0 +1,92 @@
|
||||
## Install Runtime Environment
|
||||
|
||||
### Install Python 3.6+
|
||||
|
||||
1. First of all, you need to install the runtime environment of this library, *Python*. And a Installation Pack maybe the best choice:
|
||||
|
||||
> [Downloading Python 64-bit](https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe)
|
||||
> [Downloading Python 32-bit](https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe)
|
||||
|
||||
2. While installing, it's best to check `Add Python 3.X to PATH`(just as the screenshot showed below), otherwise it needs to be set manually which may cause some time wasting.
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1662736520757331846/e38efb81_9911226.png>
|
||||
|
||||
- If you are new to Python or not very familiar to Computer Programming, and having the disk space in your PC's System Partition (usually C:) of 150 *MB*, you can directly choose *Install Now*.
|
||||
|
||||
3. However, if you want to do it like a pro, choosing *Customize Installation*, it's necessary to be sure to check `pip` and `py launcher` will be installed on your computer(see screenshot below). The two options is required for the next step of installing the requirements.
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1662736621235871190/2ac3d98f_9911226.png>
|
||||
|
||||
4. After the installation, you can enter in your *Terminal*(CMD/PowerShell/Bash/etc): `python` to ensure whether the installation was successful. If it was, your terminal will show things like below:
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659972669907359295/cmd.png>
|
||||
|
||||
|
||||
### Installing Requirements
|
||||
|
||||
1. It's better to open your *Terminal*(CMD/PowerShell/Bash/etc) under Administrator Mode.
|
||||
|
||||
For example, if you want to use CMD in Administrator Mode, you can search `cmd` in the *Start Menu*, right click it and *Run as Administrator*
|
||||
|
||||
<img src="https://foruda.gitee.com/images/1662736878650993886/62487dd8_9911226.png">
|
||||
|
||||
2. Okay, after that, please enter in your Terminal:
|
||||
|
||||
```bash
|
||||
pip install mido
|
||||
pip install brotli
|
||||
```
|
||||
|
||||
3. If successful you will see something like below:
|
||||
|
||||
<img src="https://foruda.gitee.com/images/1662737676719454287/f61a70f7_9911226.png">
|
||||
|
||||
|
||||
## Downloading & Using of this tool
|
||||
|
||||
1. Download This Package and Demo(s)
|
||||
|
||||
- If you use Git, you can clone this lib via the following commands:
|
||||
|
||||
```bash
|
||||
git clone -b pkgver https://github.com/TriM-Organization/Musicreater.git
|
||||
```
|
||||
|
||||
- If Git is not installed, you can download the zip package from the code page(from [GitHub](https://github.com/TriM-Organization/Musicreater.git) or [Gitee](https://gitee.com/TriM-Organization/Musicreater.git)). Or you are a Chinese fan having a QQ account, you can [Join the QQ Group 861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr) and get it from our GroupFiles.
|
||||
|
||||
<img src="https://foruda.gitee.com/images/1669540786443169766/fabf0acd_9911226.png">
|
||||
|
||||
But it should be noticed that you're clear instructed to choose the branch "pkgver" first instead of downloading it directly from the "master" branch, the master branch is now under developing and has no practical use.
|
||||
|
||||
|
||||
2. Start Using Demo(s)
|
||||
|
||||
You can directly double click `magicDemo.py` to run the demo, or follow instructions below using Terminal APP to run it.
|
||||
|
||||
Open your terminal in the directory of this, taking CMD, for example, just enter the directory and enter `cmd` in the path box:
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659974437388532868/输入.png>
|
||||
<img src=https://foruda.gitee.com/images/1659974754378201859/输入c.png>
|
||||
|
||||
And enter the commands below:
|
||||
|
||||
```bash
|
||||
python ./magicDemo.py
|
||||
```
|
||||
|
||||
|
||||
## Addition for Error(s) Using or Installing
|
||||
|
||||
1. Environment Error of Microsoft Visual C++ Redistributable
|
||||
|
||||
If you meet this condition as the screenshot shows:
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659972789779764953/bug.jpeg>
|
||||
|
||||
Your MSVC Environment may be not installed, and you can download and install
|
||||
> [Here of 64-Bit VCREDIST](https://aka.ms/vs/17/release/vc_redist.x64.exe)
|
||||
> [Here of 32-Bit VCREDIST](https://aka.ms/vs/17/release/vc_redist.x86.exe)
|
||||
or follow [this page](https://learn.microsoft.com/en-gb/cpp/windows/latest-supported-vc-redist)'s instructions.
|
||||
|
||||
Thanks to our groupmate *Mono* for helping us finding this problem.
|
||||
|
46
docs/功能使用说明.md
Normal file
46
docs/功能使用说明.md
Normal file
@ -0,0 +1,46 @@
|
||||
<h1 align="center">伶伦转换器</h1>
|
||||
|
||||
# 使用教程
|
||||
|
||||
## 下载与启动教程
|
||||
|
||||
### [视窗(Windows)操作系统](./download%26start/Windows.md)
|
||||
### [里纽克斯(Linux)与其衍生操作系统](./download%26start/Linux.md)
|
||||
### [安卓(Android)与其衍生操作系统](./download%26start/Android.md)
|
||||
|
||||
## 使用教程
|
||||
|
||||
1. 参数说明
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1674146209644269990/26b53aa7_9911226.png>
|
||||
|
||||
- midi路径:含有mid文件路径、文件名、后缀的完整文件路径,或者一个目录(magicDemo可接受批量转换)。可以使用相对或绝对路径皆可
|
||||
|
||||
- 输出路径:输出文件夹的路径,不需要指示文件名
|
||||
|
||||
- 转换算法:新算法编号为2,旧算法编号为1。新算法在某些方面转换效果更好,但是如果新算法转换有误的话,请使用旧算法。
|
||||
|
||||
- 输出格式:目前的演示程序仅支持`BDX`结构和`MCPACK`包
|
||||
|
||||
- 播放方式:目前的转换库仅支持**计分板**和**延迟**的两种播放方式,具体地关于这些播放方式如何使用的问题,详见[生成文件的使用说明](./%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)
|
||||
|
||||
- 音量:小数数据,在0~1(包含首尾)的范围之内,用以表示播放音量大小。
|
||||
|
||||
- 速度倍率:小数数据,其值不可为0,用以表示游戏中播放此音乐的速度倍数。
|
||||
|
||||
- 进度条:是否启用进度条。目前的转换库已经支持自定义进度条,但是当前的演示程序并不能做到这一点。具体的有关进度条自定义的内容,可以看[功能文档](./%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#%E8%BF%9B%E5%BA%A6%E6%9D%A1%E8%87%AA%E5%AE%9A%E4%B9%89)中的相关部分自行修改参数。
|
||||
|
||||
- 计分板名称(仅计分板播放器):游戏内的计分板名称
|
||||
|
||||
- 是否重置计分板(仅计分板播放器):歌曲放完是否重置,推荐选择自动重置
|
||||
|
||||
- 玩家选择器(仅延迟播放器):包括 `@x` 在内的全部选择器。例:若要选择全部标签为`Holo`的玩家,则需要如此输入:`@a[tag=Holo]`
|
||||
|
||||
- 作者(仅BDX结构):音乐结构的生成作者
|
||||
|
||||
- 指令结构最大高度(仅结构输出):生成音乐结构的最大堆叠高度,可以查看相关[结构部分的开发文档](./%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#%E7%94%9F%E6%88%90%E6%96%87%E4%BB%B6%E7%BB%93%E6%9E%84##%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F)了解详细知识。
|
||||
|
||||
- 没有报错且在输出路径下找到对应的文件即为生成成功:
|
||||
|
||||
<img src=https://foruda.gitee.com/images/1659973655881460036/输出.png>
|
||||
|
183
docs/新手答疑指南.md
Normal file
183
docs/新手答疑指南.md
Normal file
@ -0,0 +1,183 @@
|
||||
<h1 align="center">伶伦转换器</h1>
|
||||
|
||||
# 新手答疑指南
|
||||
|
||||
**考虑到某些用户电脑技术不是特别先进,且对这个项目充满了好奇心,但是又了解的不是很充分,为此,我特别在这里写一份新手指南,以满足各位的好奇心。放心,本文件全程中文。**
|
||||
|
||||
## 第一部分 关于音·创的作用
|
||||
|
||||
### 1.1 音·创简介
|
||||
|
||||
音·创 Musicreater 是一款免费开源的 **《我的世界:基岩版》** 音乐制作软件
|
||||
|
||||
音·创 库版 (Musicreater Package Version) 是一款免费开源的针对 **《我的世界:基岩版》** 的midi音乐转换库
|
||||
|
||||
而能够与人交互,以达到转换功能的,是 音·创 库版 的演示程序。因此,各位所使用来转换音乐的工具实际上仅仅是一个功能的演示。
|
||||
|
||||
音·创库版 的演示程序目前已经具备较为完善的[**教程**](./%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md),其中包括了下载安装一类,使你能够方便地进行转换。
|
||||
|
||||
音·创 以及其库版本都是免费开源的,采用**带有特殊条款的Apache2.0**开源协议授权,详情请见[协议](../LICENSE.md)。
|
||||
|
||||
另外的,音·创的库版本并不是音·创的正式版本,其功能也并非是音·创本体所提供的主要功能。**音·创的开发,其目的是为了方便《我的世界:基岩版》的音乐作者,进行《我的世界》相关音乐的开发与创作**,而并不是转换MIDI文件!音·创库板的实现是在音·创主版本之前试行一定的技术探索,以更好地开发音·创。
|
||||
|
||||
### 1.2 音·创库版本到底目前有什么功能?
|
||||
* - [x] 支持导入`.mid`文件
|
||||
* - [x] 支持写入`.mcpack`文件
|
||||
* - [x] 支持写入`.bdx`文件
|
||||
|
||||
* 不支持导入.mp3 .mp4 .wav等音频流文件
|
||||
|
||||
## 第二部分 关于格式的问题
|
||||
|
||||
### 2.1 关于.mid格式
|
||||
|
||||
其实对于经常玩音乐电子制作的朋友们来说,`MIDI`格式并不陌生,这里我简单介绍一下。
|
||||
|
||||
**MIDI文件的本质是电子乐谱,而不是记录声音波形文件的.mp3/.wav/.m4a等等文件。**
|
||||
因此,我们将MIDI转换到《我的世界》播放器的过程,实际上就是把一类乐谱变为另一类乐谱的过程。而真正的演奏,是在游戏内实现的。
|
||||
|
||||
> mid格式是由MIDI继承而来。MID文件并不是一段录制好的声音,而是记录声音的信息,然后再告诉声卡如何再现音乐的一组指令。
|
||||
> 这样一个MIDI文件每存1分钟的音乐只用大约5~10KB。今天,MID文件主要用于原始乐器作品、流行歌曲的业余表演、游戏音轨以及电子贺卡等。
|
||||
>
|
||||
> ——百度百科
|
||||
>
|
||||
> MIDI 音乐,保存在电脑上,就是 *.mid 类型的文件。和一般意义上的“音乐”不同,mid 类型的音乐通常并不是可直接发行供大众欣赏的音乐,
|
||||
> 它更像是一种音乐创作者使用的工程文件。它没有歌词,不含有人类语言。如果说五线谱是给人类阅读的乐谱,
|
||||
> MIDI音乐文件便是给计算机或其他电子设备使用的乐谱。对于“音乐”这个世界来说,它微不足道,却又是现代数字音乐的基石。虽不为大众所知,
|
||||
> 但在 MIDI 音乐爱好者眼中,它却是非常有意思的东西。有了 MIDI 音乐技术和一台电脑,基本就等于拥有了一个乐队,加上相关的音乐知识,
|
||||
> 就可以自己指挥这个“乐队”,创作音乐作品了!
|
||||
> 同时,MIDI 技术由于数据结构简单,又与音乐有关,也成为了部分技术极客的爱好。有人使用MIDI技术+Arduino开源硬件制作了架子鼓,
|
||||
> 有人通过分析大量MIDI乐曲结构,设计了人工智能作曲软件,还有更酷的人使用MIDI音乐制作了随节奏变幻的特斯拉线圈!
|
||||
> 在MIDI 音乐的世界里,汇聚了一批喜欢音乐又热爱技术的人。我们有理由相信,玩MIDI音乐的你,定是多才多艺的。
|
||||
>
|
||||
> ——midishow.com
|
||||
|
||||
|
||||
### 2.2 关于.mid格式的获取
|
||||
|
||||
通过刚刚的介绍,你可能已经发现,`.MID`文件因为受众并不多而并没有被广泛熟知,因而你之前可能完全没见过这个文件,更何况要弄一首自己心仪的歌了。
|
||||
|
||||
这里介绍几个获取.mid格式的方法:
|
||||
|
||||
0. 最简单的方法是向你心仪的作编曲人投递一份申请,请求TA将其作编曲过程中的相关工程文件给你,这样,你就可以获得一首乐曲的电子曲谱,从而获得其MIDI文件。
|
||||
1. 如果无法向作曲人申请相关文件的话,成为一个作编曲人也许是一个不错的选择,当然,很多人做不到这一点,但是有必要提到这一点,当你在下面的渠道中都无法获得想要的文件时,你应该考虑是不是需要自己创作内容,或者,请别人帮你创作内容。
|
||||
2. 当你没有这样的文件时,问问别人或者从群里下载公开的文件也是个思路,不过这个办法通常使用次数有限且能找到的文件不多,不过,值得注意的是,**[音·创开发交流群](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)的群文件中所含的MIDI文件均为网友分享学习交流使用,请在下载后一个小时内删除。**
|
||||
3. 自己找MIDI:现在,我将给你提供一个完整的找mid的方法,请认真学习:
|
||||
|
||||
**1.** 首先你需要在[MidiShow](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. 使用音频(波形)转换MIDI的工具也是一个选择。不得不说,科技的进步带来了许多便利,让这样困难的事情也变得简单。如果上述方法仍然没有解决你的问题,那么你可以在下一章节中找到有关这个途径的说明。
|
||||
|
||||
### 2.3 波形格式转换为.mid格式
|
||||
|
||||
**注意,使用这个技术有一定难度,酌情使用!**
|
||||
|
||||
文件转换:此技术是将记录声音波形文件的.mp3/.wav/.m4a等等文件转换为.mid数字乐谱文件的。
|
||||
|
||||
概述:波形转mid需要把**模拟的波形频谱信号转为数字乐谱信号**,这个过程**一定有损失**,而且损失非常大。
|
||||
|
||||
请各位以后不要在答疑群中问类似于我这个转换效果为什么不好这样的问题,谢谢。
|
||||
|
||||
如果直接用**widi**的话相当于对声音进行了[**傅里叶变换**](https://baike.baidu.com/item/%E5%82%85%E9%87%8C%E5%8F%B6%E5%8F%98%E6%8D%A2/7119029),你确实可以分离出其中的音高,但是效果在不同情况下差异较大,尤其是有架子鼓啊啥的玩也的时候,比较**差**。
|
||||
([widi工具链接](https://pan.baidu.com/s/1j_Jui0piQ6rMOXM0GJtqTg) 提取码:b0lw )
|
||||
|
||||
如果**只有钢琴**的谱子需要分离,有一个完美的选择:[Giant MIDI-Piano](https://zhuanlan.zhihu.com/p/270999354)
|
||||
|
||||
如果不然有其他的乐器也需要分离,那么可能就有点困难,像**cakewalk**就确实也可以把音频变成mid,但是可能要
|
||||
**先把原MP3分离成人声音轨、贝斯音轨等再傅里叶变换。**
|
||||
|
||||
当然我也可能了解的不全,没准现在已经有船新的技术可以分离的更好了,那就太棒了!(〃'▽'〃)
|
||||
|
||||
另外,我们开发者也象征性的找了一些相关的网站,我们没使用过,不担保效果。
|
||||
[serocs.cn](https://www.serocs.cn/transcription/)
|
||||
|
||||
同时,midishow论坛里有一些大佬也提供了解决方案,看看他们的发言也是一个不错的选择。我就只给个论坛链接了,经常有人问这种问题,你可以去那里随便找到一篇帖子看看。[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">
|
||||
|
||||
如果你是使用桌面平台游玩基岩版,像我一样,是可以直接打开这个文件、并将这个包导入我的世界的。当然,移动平台也很简单,在游戏资源包界面有导入本地资源包的选项,便可将其导入。
|
||||
|
||||
资源包导入世界之后的使用方法,我们也制作了[**简单的教程**](./%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 文件其实是一个新型结构文件,利用一些标识符对结构进行标记,可以使用相关软件导入到《我的世界:中国版》。
|
||||
|
||||
由于这不属于官方文件,且我并不是很熟悉这个结构,所以请对这个格式有问题的好兄弟加一下[QQ群](https://jq.qq.com/?_wv=1027&k=hpeRxrYr),问问群里有导入经验的大佬。
|
||||
|
||||
## 第三部分 关于其他问题
|
||||
|
||||
如果你在仔细阅读以上内容之后,仍然感觉有所困惑,可以加我们的[QQ群](https://jq.qq.com/?_wv=1027&k=hpeRxrYr)来提问,但是请注意,**由于开发者们都很忙,群友们的耐心也都有限,所以恳请大家提出有意义的问题。**
|
||||
如果您在使用过程中遇到报错,希望你能够把完整的报错内容复制给我们,而不是截一半的屏幕或者在群内大呼小叫。以下两张图给了你很好的解释说明。
|
||||
|
||||
<table><tr><td><img src=https://foruda.gitee.com/images/1673053210913625261/37197693_9911226.png></td><td><img src=https://foruda.gitee.com/images/1673052430511255221/6a279fae_9911226.png></td></tr></table>
|
||||
|
||||
这里附一个关于[智慧地提问](https://github.com/tvvocold/How-To-Ask-Questions-The-Smart-Way)的文章,大家可以看看。
|
||||
|
||||
希望不要我把这个文件在聊天中甩给你,那说明我可能已经没有耐心了。
|
||||
|
||||
看完这份说明,如果你打算开始使用我们的工具的话,请移步至[演示程序使用教程](./%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. 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)**
|
||||
|
||||
**如果遇到问题,仔细地再次[阅读教程](./%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)很重要!!!!!**
|
||||
|
||||
**如果遇到问题,仔细地再次[阅读教程](./%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)很重要!!!!!**
|
||||
|
||||
**如果遇到问题,仔细地再次[阅读教程](./%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md)很重要!!!!!**
|
||||
|
||||
(重要的事情说三遍)
|
||||
|
||||
**(有能力的同志麻烦给仓库star一下)**
|
||||
|
||||
**(有能力的同志麻烦给仓库star一下)**
|
||||
|
||||
**(有能力的同志麻烦给仓库star一下)**
|
40
docs/生成文件的使用说明.md
Normal file
40
docs/生成文件的使用说明.md
Normal file
@ -0,0 +1,40 @@
|
||||
<h1 align="center">伶伦转换器</h1>
|
||||
|
||||
# 生成文件的使用
|
||||
|
||||
*这是本库所生成文件的使用声明,不是使用教程,点击[此处查看使用教程](%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md);若要查看有关文件结构的内容,可以点击[此处](./%E7%94%9F%E6%88%90%E6%96%87%E4%BB%B6%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E.md)*
|
||||
|
||||
## 附加包格式
|
||||
|
||||
支持的文件后缀:`.MCPACK`
|
||||
|
||||
1. 导入附加包
|
||||
2. 在一个循环方块中输入指令 `function index`
|
||||
3. 将需要聆听音乐的实体的播放所用计分板设置为 `1`
|
||||
4. 激活循环方块
|
||||
5. 若想要暂停播放,可以停止循环指令方块的激活状态
|
||||
6. 若想要重置某实体的播放,可以将其播放用的计分板重置
|
||||
|
||||
> 其中 步骤三 和 步骤四 的顺序可以调换。
|
||||
|
||||
## 结构格式
|
||||
|
||||
支持的文件后缀:`.MCSTRUCTURE`、`.BDX`
|
||||
|
||||
1. 将结构导入世界
|
||||
|
||||
- 延迟播放器
|
||||
|
||||
2. 将结构生成的第一个指令方块之模式更改为**脉冲**
|
||||
3. 激活脉冲方块
|
||||
4. 若欲重置播放,可以停止对此链的激活,例如停止区块加载
|
||||
5. 此播放器不支持暂停
|
||||
|
||||
- 计分板播放器
|
||||
|
||||
2. 在所生成的第一个指令方块前,放置一个循环指令方块,其朝向应当对着所生成的第一个方块
|
||||
3. 在循环指令方块中输入使播放对象的播放用计分板加分的指令,延迟为`0`,每次循环增加`1`分
|
||||
4. 激活循环方块
|
||||
5. 若想要暂停播放,可以停止循环指令方块的激活状态
|
||||
6. 若想要重置某实体的播放,可以将其播放用的计分板重置
|
||||
|
35
docs/问与答.md
Normal file
35
docs/问与答.md
Normal file
@ -0,0 +1,35 @@
|
||||
<h1 align="center">伶伦转换器</h1>
|
||||
|
||||
# 疑问与帮助
|
||||
|
||||
## 关于音·创与伶伦转换器
|
||||
|
||||
1. “伶伦”是什么?
|
||||
|
||||
伶伦是一个针对《我的世界》的数字音频工作站,用以创作、编辑《我的世界》风格的曲目。
|
||||
|
||||
2. “伶伦转换器”是什么?
|
||||
|
||||
伶伦转换器是一个用于将Midi文件转换至我的世界可读格式的工具。其使用音·创库作为转换工具库,其目的旨在方便midi创作者进行简单的音乐转换,同时也是音·创库的一个项目实现。
|
||||
|
||||
3. 为什么要将音·创库的功能迁移至伶伦转换器?
|
||||
|
||||
音·创库作为单独存在的转换工具库,如果每次更新都需要从源码下载更新可能对用户十分的不友好。而且,音·创库的实现本是为了其他程序的调用,而不是一个转换程序。经过一段时间的观察与开发后,我们发现如果是以一种“可以用来转换音乐”的工具出现在大众面前,那么音·创库不仅不能被人理解,反而可能会让人困惑于其的具体功用,因此将伶伦转换器作为音·创库的实现,将独立的转换功能用更加亲用户的形式展现在大众面前,是一个更好的选择。
|
||||
|
||||
4. 之前使用的“音·创库版本”的示例程序,现在还能用吗?
|
||||
|
||||
仍然可以使用,不过由于不再维护,已有的错误不会自动修复。
|
||||
|
||||
## 关于转换所需参数
|
||||
|
||||
1. 什么是延迟播放器?
|
||||
|
||||
播放音乐,不同的音符之间存在间隔,可以用不同的方式实现音符间空白的时间。其一是计分板,通过给计分板加分,对应分数播放对应的音符就可以间隔到,还有就是命令方块自带的延迟,这样也可以实现音符间空白。延迟播放器即后者,但是因为只能对命令方块写入这样的延迟数据,所以仅可以使用包含NBT的结构导出或者直接输出至世界。
|
||||
|
||||
2. 可不可以不要积分板?
|
||||
|
||||
详见问1,切换你所需要的播放器即可。
|
||||
|
||||
4. 转换算法是什么?怎么填?是越新越好吗?
|
||||
|
||||
转换算法是音·创库中所需要指定的内容,转换的算法都已经开源,可以在音·创仓库内找到。目前转换算法1对应的算法是将midi文件中的所有音轨单独提取并逐轨解析。而算法2是将所有音符单独提取出来,而后解析各个音符。算法的转换过程的差异可能会导致结果不同,但由于算法1已经不在进行主动维护,算法2的效果将会比1更好,所以建议使用算法2。算法3所对应的是尚在研究的插值算法,使用可能导致转换出错。
|
386
llc_cli.py
Normal file
386
llc_cli.py
Normal file
@ -0,0 +1,386 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
# 音·创 开发交流群 861684859
|
||||
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
|
||||
# 版权所有 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") & 鸣凤鸽子("MingFengPigeon")
|
||||
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
||||
|
||||
print("小贴:不妨试试Mid-BDX转换网页:在线的多功能Midi转换器")
|
||||
print("https://dislink.github.io/midi2bdx/")
|
||||
|
||||
"""
|
||||
音·创 库版 MIDI转换示例程序
|
||||
Musicreater Package Version : Demo for Midi Conversion
|
||||
|
||||
Copyright 2023 all the developers of Musicreater
|
||||
|
||||
开源相关声明请见 ./License.md
|
||||
Terms & Conditions: ./Lisense.md
|
||||
"""
|
||||
|
||||
__version__ = "0.0.1"
|
||||
|
||||
import datetime
|
||||
import random
|
||||
import os
|
||||
import sys
|
||||
|
||||
languages = {
|
||||
"ZH-CN": {
|
||||
"MSCT": "音·创",
|
||||
"ChooseLang": "选择语言",
|
||||
"LangChd": "当前语言已经切换为",
|
||||
"ZH-CN": "简体中文",
|
||||
"ZH-TW": "繁体中文(台湾)",
|
||||
"EN-GB": "英语(英国)",
|
||||
"EN-US": "英语(美国)",
|
||||
":": ":",
|
||||
",": ",",
|
||||
".": "。",
|
||||
"ChoosePath": "请输入MIDI路径或所在文件夹",
|
||||
"ChooseFileFormat": "请输入输出格式[BDX(1) 或 MCPACK(0)]",
|
||||
"EnterMethod": "请输入转换算法[{}~{}]",
|
||||
"MethodRangeErr": "输入的转换算法应为 [{},{}](首尾皆含)之间的一个整数。",
|
||||
"ChoosePlayer": "请选择播放方式[计分板(1) 或 延迟(0)]",
|
||||
"WhetherArgEntering": "是否为文件夹内文件的转换统一参数[是(1) 或 否(0)]",
|
||||
"EnterArgs": "请输入转换参数",
|
||||
"noteofArgs": "注:文件夹内的全部midi将统一以此参数转换",
|
||||
"EnterVolume": "请输入音量大小(0~1)",
|
||||
"EnterSpeed": "请输入速度倍率",
|
||||
"WhetherPgb": "是否自动生成进度条[是(1) 或 否(0)]",
|
||||
"WhetherCstmProgressBar": "是否自定义进度条[是(1) 或 否(0)]",
|
||||
"EnterProgressBarStyle": "请输入进度条样式",
|
||||
"EnterSbName": "请输入计分板名称",
|
||||
"EnterSelecter": "请输入播放者选择器",
|
||||
"WhetherSbReset": "是否自动重置计分板[是(1) 或 否(0)]",
|
||||
"EnterAuthor": "请输入作者",
|
||||
"EnterMaxHeight": "请输入指令结构最大生成高度",
|
||||
"ErrEnter": "输入错误",
|
||||
"Re-Enter": "请重新输入",
|
||||
"Dealing": "正在处理",
|
||||
"FileNotFound": "文件(夹)不存在",
|
||||
"ChooseOutPath": "请输入结果输出路径",
|
||||
"Saying": "言·论",
|
||||
"Failed": "失败",
|
||||
"CmdLength": "指令数量",
|
||||
"MaxDelay": "曲目时间(游戏刻)",
|
||||
"PlaceSize": "结构占用大小",
|
||||
"LastPos": "最末方块坐标",
|
||||
"PressEnterExit": "请按下回车键退出。",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
import Musicreater
|
||||
# import TrimLog
|
||||
# from TrimLog import object_constants
|
||||
except ModuleNotFoundError as E:
|
||||
if input("您需要安装 mido、Brotli 模块才能使用这个样例\n请问是否安装?(y/n):").lower() in ("y", "1"):
|
||||
os.system("pip install -r requirements.txt")
|
||||
import Musicreater
|
||||
# import TrimLog
|
||||
# from TrimLog import object_constants
|
||||
else:
|
||||
raise E
|
||||
|
||||
|
||||
try:
|
||||
from utils.magicBeing import *
|
||||
import requests
|
||||
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")
|
||||
os.system("pip install -r Demo_Requirements.txt")
|
||||
os.remove("./Demo_Requirements.txt")
|
||||
from utils.magicBeing import *
|
||||
import requests
|
||||
else:
|
||||
raise E
|
||||
|
||||
|
||||
MainConsole.print(
|
||||
"[#121110 on #F0F2F4] ",
|
||||
style="#121110 on #F0F2F4",
|
||||
justify="center",
|
||||
)
|
||||
|
||||
|
||||
# osc = object_constants.ObjectStateConstant()
|
||||
|
||||
# osc.project_name = "伶伦"
|
||||
# osc.version = __version__
|
||||
|
||||
|
||||
def go_for_args(
|
||||
languageChange: str = "ZH-CN", debugMode: str = False, logfile: str = True
|
||||
):
|
||||
global currentLang
|
||||
global logger
|
||||
currentLang = (
|
||||
languageChange.upper()
|
||||
if languageChange.upper() in languages.keys()
|
||||
else 'ZH-CN'
|
||||
)
|
||||
# osc.isRelease = False if debugMode.lower() in ("true", '1') else True
|
||||
# logger = TrimLog.Logger(
|
||||
# is_logging=True,
|
||||
# printing=not osc.isRelease,
|
||||
# writing=True if logfile.lower() in ("true", '1') else False,
|
||||
# in_suffix='.llc',
|
||||
# )
|
||||
|
||||
if len(sys.argv) > 0:
|
||||
go_for_args(*sys.argv)
|
||||
|
||||
def _(__):
|
||||
"""
|
||||
`languages`
|
||||
"""
|
||||
return languages[currentLang][__]
|
||||
|
||||
|
||||
# 显示大标题
|
||||
MainConsole.rule(title="[bold #AB70FF]欢迎使用伶伦独立转换器", characters="=", style="#26E2FF")
|
||||
MainConsole.rule(title="[bold #AB70FF]Welcome to Linglun Converter", characters="-")
|
||||
|
||||
nowYang = datetime.datetime.now()
|
||||
|
||||
if nowYang.month == 8 and nowYang.day == 6:
|
||||
# 诸葛八卦生日
|
||||
MainConsole.print(
|
||||
"[#7DB5F0 on #121110]今天可不是催更的日子!\n诸葛亮与八卦阵{}岁生日快乐!".format(nowYang.year - 2009),
|
||||
style="#7DB5F0 on #121110",
|
||||
justify="center",
|
||||
)
|
||||
elif nowYang.month == 4 and nowYang.day == 3:
|
||||
# 金羿生日快乐
|
||||
MainConsole.print(
|
||||
"[#0089F2 on #F0F2F4]今天就不要催更啦!\n金羿{}岁生日快乐!".format(nowYang.year - 2006),
|
||||
style="#0089F2 on #F0F2F4",
|
||||
justify="center",
|
||||
)
|
||||
else:
|
||||
# 显示箴言部分
|
||||
try:
|
||||
MainConsole.print(
|
||||
"[#121110 on #F0F2F4]{}".format(
|
||||
random.choice(
|
||||
requests.get(
|
||||
"https://gitee.com/TriM-Organization/LinglunStudio/raw/master/resources/myWords.txt"
|
||||
)
|
||||
.text.strip("\n")
|
||||
.split("\n")
|
||||
)
|
||||
),
|
||||
style="#121110 on #F0F2F4",
|
||||
justify="center",
|
||||
)
|
||||
except ConnectionError:
|
||||
MainConsole.print(
|
||||
"[#121110 on #F0F2F4]以梦想为驱使 创造属于自己的未来",
|
||||
style="#121110 on #F0F2F4",
|
||||
justify="center",
|
||||
)
|
||||
|
||||
prt(f"{_('LangChd')}{_(':')}{_(currentLang)}")
|
||||
|
||||
|
||||
def format_ipt(
|
||||
notice: str,
|
||||
fun,
|
||||
err_note: str = f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}",
|
||||
*extraArg,
|
||||
):
|
||||
"""循环输入,以某种格式
|
||||
notice: 输入时的提示
|
||||
fun: 格式函数
|
||||
err_note: 输入不符格式时的提示
|
||||
*extraArg: 对于函数的其他参数"""
|
||||
while True:
|
||||
result = ipt(notice)
|
||||
try:
|
||||
fun_result = fun(result, *extraArg)
|
||||
break
|
||||
except ValueError:
|
||||
prt(err_note)
|
||||
continue
|
||||
return result, fun_result
|
||||
|
||||
|
||||
# 获取midi列表
|
||||
while True:
|
||||
midi_path = ipt(f"{_('ChoosePath')}{_(':')}").lower()
|
||||
if os.path.exists(midi_path):
|
||||
if os.path.isfile(midi_path):
|
||||
midis = (midi_path,)
|
||||
elif os.path.isdir(midi_path):
|
||||
midis = tuple(
|
||||
(
|
||||
os.path.join(midi_path, i)
|
||||
for i in os.listdir(midi_path)
|
||||
if i.lower().endswith(".mid") or i.lower().endswith(".midi")
|
||||
)
|
||||
)
|
||||
else:
|
||||
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
|
||||
continue
|
||||
else:
|
||||
prt(f"{_('FileNotFound')}{_(',')}{_('Re-Enter')}{_('.')}")
|
||||
continue
|
||||
break
|
||||
|
||||
# 获取输出地址
|
||||
out_path = format_ipt(
|
||||
f"{_('ChooseOutPath')}{_(':')}",
|
||||
os.path.exists,
|
||||
f"{_('FileNotFound')}{_(',')}{_('Re-Enter')}{_('.')}",
|
||||
)[0].lower()
|
||||
|
||||
conversion = Musicreater.midiConvert()
|
||||
|
||||
|
||||
def isMethodOK(sth: str):
|
||||
if int(sth) in range(1, len(conversion.methods) + 1):
|
||||
return int(sth)
|
||||
else:
|
||||
raise ValueError
|
||||
|
||||
|
||||
convert_method = format_ipt(
|
||||
f"{_('EnterMethod').format(1, len(conversion.methods))}{_(':')}",
|
||||
isMethodOK,
|
||||
f"{_('MethodRangeErr').format(1, len(conversion.methods))}",
|
||||
)[1]
|
||||
|
||||
# 选择输出格式
|
||||
while True:
|
||||
fileFormat = ipt(f"{_('ChooseFileFormat')}{_(':')}").lower()
|
||||
if fileFormat in ("0", "mcpack"):
|
||||
fileFormat = 0
|
||||
playerFormat = 1
|
||||
break
|
||||
|
||||
elif fileFormat in ("1", "bdx"):
|
||||
fileFormat = 1
|
||||
while True:
|
||||
playerFormat = ipt(f"{_('ChoosePlayer')}{_(':')}").lower()
|
||||
if playerFormat in ("0", "延迟", "delay"):
|
||||
playerFormat = 0
|
||||
elif playerFormat in ("1", "计分板", "scoreboard"):
|
||||
playerFormat = 1
|
||||
else:
|
||||
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
|
||||
continue
|
||||
break
|
||||
else:
|
||||
prt(f"{_('ErrEnter')}{_(',')}{_('Re-Enter')}{_('.')}")
|
||||
continue
|
||||
break
|
||||
|
||||
debug = False
|
||||
|
||||
|
||||
# 真假字符串判断
|
||||
def bool_str(sth: str) -> bool:
|
||||
try:
|
||||
return bool(int(sth))
|
||||
except ValueError:
|
||||
if str(sth).lower() == "true":
|
||||
return True
|
||||
elif str(sth).lower() == "false":
|
||||
return False
|
||||
else:
|
||||
raise ValueError("布尔字符串啊?")
|
||||
|
||||
|
||||
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 = []
|
||||
# 提示语 检测函数 错误提示语
|
||||
for args in [
|
||||
(
|
||||
f'{_("EnterVolume")}{_(":")}',
|
||||
float,
|
||||
),
|
||||
(
|
||||
f'{_("EnterSpeed")}{_(":")}',
|
||||
float,
|
||||
),
|
||||
(
|
||||
f'{_("WhetherPgb")}{_(":")}',
|
||||
bool_str,
|
||||
),
|
||||
(
|
||||
f'{_("EnterSbName")}{_(":")}',
|
||||
str,
|
||||
)
|
||||
if playerFormat == 1
|
||||
else (
|
||||
f'{_("EnterSelecter")}{_(":")}',
|
||||
str,
|
||||
),
|
||||
(
|
||||
f'{_("WhetherSbReset")}{_(":")}',
|
||||
bool_str,
|
||||
)
|
||||
if playerFormat == 1
|
||||
else (),
|
||||
(
|
||||
f'{_("EnterAuthor")}{_(":")}',
|
||||
str,
|
||||
)
|
||||
if fileFormat == 1
|
||||
else (),
|
||||
(
|
||||
f'{_("EnterMaxHeight")}{_(":")}',
|
||||
int,
|
||||
)
|
||||
if fileFormat == 1
|
||||
else (),
|
||||
]:
|
||||
if args:
|
||||
prompts.append(format_ipt(*args)[1])
|
||||
|
||||
conversion = Musicreater.midiConvert(debug)
|
||||
for singleMidi in midis:
|
||||
prt("\n" f"{_('Dealing')} {singleMidi} {_(':')}")
|
||||
conversion.convert(singleMidi, out_path)
|
||||
if debug:
|
||||
with open("./records.json", "a", encoding="utf-8") as f:
|
||||
json.dump(conversion.toDICT(), f)
|
||||
f.write(5 * "\n")
|
||||
conversion_result = (
|
||||
conversion.to_mcpack(convert_method, *prompts)
|
||||
if fileFormat == 0
|
||||
else (
|
||||
conversion.to_BDX_file(convert_method, *prompts)
|
||||
if playerFormat == 1
|
||||
else conversion.to_BDX_file_with_delay(convert_method, *prompts)
|
||||
)
|
||||
)
|
||||
|
||||
if conversion_result[0]:
|
||||
prt(
|
||||
f" {_('CmdLength')}{_(':')}{conversion_result[1]}{_(',')}{_('MaxDelay')}{_(':')}{conversion_result[2]}{f'''{_(',')}{_('PlaceSize')}{_(':')}{conversion_result[3]}{_(',')}{_('LastPos')}{_(':')}{conversion_result[4]}''' if fileFormat == 1 else ''}"
|
||||
)
|
||||
else:
|
||||
prt(f"{_('Failed')}")
|
||||
|
||||
exitSth = ipt(_("PressEnterExit")).lower()
|
||||
if exitSth == "record":
|
||||
import json
|
||||
|
||||
with open("./demo_config.json", "w", encoding="utf-8") as f:
|
||||
json.dump(prompts, f)
|
||||
elif exitSth == "delrec":
|
||||
os.remove("./demo_config.json")
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Brotli>=1.0.9
|
||||
mido>=1.2.10
|
||||
Musicreater>=0.1.0
|
||||
TrimLog>=0.1.0
|
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
147
utils/magicBeing.py
Normal file
147
utils/magicBeing.py
Normal file
@ -0,0 +1,147 @@
|
||||
from rich.console import Console
|
||||
from typing import Any, Literal, Optional, TextIO
|
||||
|
||||
MainConsole = Console()
|
||||
|
||||
JustifyMethod = Literal["default", "left", "center", "right", "full"]
|
||||
OverflowMethod = Literal["fold", "crop", "ellipsis", "ignore"]
|
||||
|
||||
|
||||
# 高级的打印函数
|
||||
def prt(
|
||||
*objects: Any,
|
||||
sep: str = " ",
|
||||
end: str = "\n",
|
||||
justify: Optional[JustifyMethod] = None,
|
||||
overflow: Optional[OverflowMethod] = None,
|
||||
no_wrap: Optional[bool] = None,
|
||||
emoji: Optional[bool] = None,
|
||||
markup: Optional[bool] = None,
|
||||
highlight: Optional[bool] = None,
|
||||
width: Optional[int] = None,
|
||||
height: Optional[int] = None,
|
||||
crop: bool = True,
|
||||
soft_wrap: Optional[bool] = None,
|
||||
new_line_start: bool = False,
|
||||
) -> None:
|
||||
"""打印到控制台。
|
||||
|
||||
Args:
|
||||
objects (位置性的args): 要记录到终端的对象。
|
||||
sep (str, 可选): 要在打印数据之间写入的字符串。默认为""。
|
||||
end (str, optio可选nal): 在打印数据结束时写入的字符串。默认值为"\\\\n"。
|
||||
justify (str, 可选): 校正位置,可为"default", "left", "right", "center" 或 "full". 默认为`None`。
|
||||
overflow (str, 可选): 控制溢出:"ignore"忽略, "crop"裁剪, "fold"折叠, "ellipsis"省略号。默认为`None`。
|
||||
no_wrap (Optional[bool], 可选): 禁用文字包装。默认为`None`。
|
||||
emoji (Optional[bool], 可选): 启用表情符号代码,或使用控制台默认的`None`。默认为`None`。
|
||||
markup (Optional[bool], 可选): 启用标记,或`None`使用控制台默认值。默认为`None`。
|
||||
highlight (Optional[bool], 可选): 启用自动高亮,或`None`使用控制台默认值。默认为`None`。
|
||||
width (Optional[int], 可选): 输出的宽度,或`None`自动检测。默认为`None`。
|
||||
height
|
||||
crop (Optional[bool], 可选): 裁剪输出到终端的宽度。默认为`True`。
|
||||
soft_wrap (bool, 可选): 启用软包装模式,禁止文字包装和裁剪,或`None``用于 控制台默认值。默认为`None`。
|
||||
new_line_start (bool, False): 如果输出包含多行,在开始时插入一个新行。默认值为`False`。
|
||||
"""
|
||||
MainConsole.print(
|
||||
*objects,
|
||||
sep=sep,
|
||||
end=end,
|
||||
style="#F0F2F4 on #121110",
|
||||
justify=justify,
|
||||
overflow=overflow,
|
||||
no_wrap=no_wrap,
|
||||
emoji=emoji,
|
||||
markup=markup,
|
||||
highlight=highlight,
|
||||
width=width,
|
||||
height=height,
|
||||
crop=crop,
|
||||
soft_wrap=soft_wrap,
|
||||
new_line_start=new_line_start,
|
||||
)
|
||||
|
||||
|
||||
# 高级的输入函数
|
||||
def ipt(
|
||||
*objects: Any,
|
||||
sep: str = " ",
|
||||
justify: Optional[JustifyMethod] = None,
|
||||
overflow: Optional[OverflowMethod] = None,
|
||||
no_wrap: Optional[bool] = None,
|
||||
emoji: Optional[bool] = None,
|
||||
markup: Optional[bool] = None,
|
||||
highlight: Optional[bool] = None,
|
||||
width: Optional[int] = None,
|
||||
height: Optional[int] = None,
|
||||
crop: bool = True,
|
||||
soft_wrap: Optional[bool] = None,
|
||||
new_line_start: bool = False,
|
||||
password: bool = False,
|
||||
stream: Optional[TextIO] = None,
|
||||
) -> str:
|
||||
"""显示一个提示并等待用户的输入。
|
||||
|
||||
它的工作方式与Python内建的 :func:`input` 函数相同,如果Python内建的 :mod:`readline` 模块先前已经加载,则提供详细的行编辑和历史功能。
|
||||
|
||||
Args:
|
||||
objects (位置性的args): 要记录到终端的对象。
|
||||
sep (str, 可选): 要在打印数据之间写入的字符串。默认为""。
|
||||
justify (str, 可选): 校正位置,可为"default", "left", "right", "center" 或 "full". 默认为`None`。
|
||||
overflow (str, 可选): 控制溢出:"ignore"忽略, "crop"裁剪, "fold"折叠, "ellipsis"省略号。默认为`None`。
|
||||
no_wrap (Optional[bool], 可选): 禁用文字包装。默认为`None`。
|
||||
emoji (Optional[bool], 可选): 启用表情符号代码,或使用控制台默认的`None`。默认为`None`。
|
||||
markup (Optional[bool], 可选): 启用标记,或`None`使用控制台默认值。默认为`None`。
|
||||
highlight (Optional[bool], 可选): 启用自动高亮,或`None`使用控制台默认值。默认为`None`。
|
||||
width (Optional[int], 可选): 输出的宽度,或`None`自动检测。默认为`None`。
|
||||
crop (Optional[bool], 可选): 裁剪输出到终端的宽度。默认为`True`。
|
||||
height
|
||||
soft_wrap (bool, 可选): 启用软包装模式,禁止文字包装和裁剪,或`None``用于 控制台默认值。默认为`None`。
|
||||
new_line_start (bool, False): 如果输出包含多行,在开始时插入一个新行。默认值为`False`。
|
||||
password (bool, 可选): 隐藏已经输入的文案,默认值为`False`。
|
||||
stream (TextIO, 可选): 可选从文件中读取(而非控制台),默认为 `None`。
|
||||
|
||||
Returns:
|
||||
str: 从stdin读取的字符串
|
||||
"""
|
||||
MainConsole.print(
|
||||
*objects,
|
||||
sep=sep,
|
||||
end="",
|
||||
style="#F0F2F4 on #121110",
|
||||
justify=justify,
|
||||
overflow=overflow,
|
||||
no_wrap=no_wrap,
|
||||
emoji=emoji,
|
||||
markup=markup,
|
||||
highlight=highlight,
|
||||
width=width,
|
||||
height=height,
|
||||
crop=crop,
|
||||
soft_wrap=soft_wrap,
|
||||
new_line_start=new_line_start,
|
||||
)
|
||||
|
||||
return MainConsole.input(password=password, stream=stream)
|
||||
|
||||
|
||||
def format_ipt(
|
||||
notice: str,
|
||||
fun,
|
||||
err_note: str = "",
|
||||
*extraArg,
|
||||
):
|
||||
"""循环输入,以某种格式
|
||||
notice: 输入时的提示
|
||||
fun: 格式函数
|
||||
err_note: 输入不符格式时的提示
|
||||
*extraArg: 对于函数的其他参数"""
|
||||
while True:
|
||||
result = ipt(notice)
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
fun_result = fun(result, *extraArg)
|
||||
break
|
||||
except:
|
||||
prt(err_note)
|
||||
continue
|
||||
return result, fun_result
|
Loading…
Reference in New Issue
Block a user