mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2025-09-04 03:16:23 +00:00
代码架构升级,功能分割,减少强制性依赖,API全新换代,文档全面更新,新一代音·创,音·创1.0.0
This commit is contained in:
@ -10,19 +10,104 @@
|
||||
|
||||
# 库的简单调用
|
||||
|
||||
参见[example.py的相关部分](../example.py#L120),使用此库进行MIDI转换非常简单。
|
||||
参见[example.py的相关部分](../example.py),使用此库进行MIDI转换非常简单。
|
||||
|
||||
- 在导入转换库后,使用 MidiConvert 类建立转换对象(读取Midi文件)
|
||||
|
||||
音·创库支持新旧两种execute语法,需要在对象实例化时指定
|
||||
```python
|
||||
# 导入音·创库
|
||||
import Musicreater
|
||||
|
||||
# 指定是否使用旧的execute指令语法(即1.18及以前的《我的世界:基岩版》语法)
|
||||
old_execute_format = False
|
||||
|
||||
# 可以通过文件地址自动读取
|
||||
cvt_mid = Musicreater.MidiConvert.from_midi_file(
|
||||
"Midi文件地址",
|
||||
old_exe_format=old_execute_format
|
||||
)
|
||||
|
||||
# 也可以导入Mido对象
|
||||
cvt_mid = Musicreater.MidiConvert(
|
||||
mido.MidiFile("Midi文件地址"),
|
||||
"音乐名称",
|
||||
old_exe_format=old_execute_format
|
||||
)
|
||||
```
|
||||
|
||||
- 获取 Midi 音乐经转换后的播放指令
|
||||
|
||||
```python
|
||||
# 通过函数 to_command_list_in_score, to_command_list_in_delay
|
||||
# 分别可以得到
|
||||
# 以计分板作为播放器的指令对象列表、以延迟作为播放器的指令对象列表
|
||||
# 数据不仅存储在对象本身内,也会以返回值的形式返回,详见代码内文档
|
||||
|
||||
# 使用 to_command_list_in_score 函数进行转换之后,返回值有三个
|
||||
# 值得注意的是第一个返回值返回的是依照midi频道存储的指令对象列表
|
||||
# 也就是列表套列表
|
||||
# 但是,在对象内部所存储的数据却不会如此嵌套
|
||||
command_channel_list, command_count, max_score = cvt_mid.to_command_list_in_score(
|
||||
"计分板名称",
|
||||
1.0, # 音量比率
|
||||
1.0, # 速度倍率
|
||||
)
|
||||
|
||||
# 使用 to_command_list_in_delay 转换后的返回值只有两个
|
||||
# 但是第一个返回值没有列表套列表
|
||||
command_list, max_delay = cvt_mid.to_command_list_in_delay(
|
||||
1.0, # 音量比率
|
||||
1.0, # 速度倍率
|
||||
"@a", # 玩家选择器
|
||||
)
|
||||
|
||||
# 运行之后,指令和总延迟会存储至对象内
|
||||
print(
|
||||
"音乐长度:{}/游戏刻".format(
|
||||
cvt_mid.music_tick_num
|
||||
)
|
||||
)
|
||||
print(
|
||||
"指令如下:\n{}".format(
|
||||
cvt_mid.music_command_list
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
- 除了获取播放指令外,还可以获取进度条指令
|
||||
|
||||
```python
|
||||
# 通过函数 form_progress_bar 可以获得
|
||||
# 以计分板为载体所生成的进度条的指令对象列表
|
||||
# 数据不仅存储在对象本身内,也会以返回值的形式返回,详见代码内文档
|
||||
|
||||
# 使用 form_progress_bar 函数进行转换之后,返回值有三个
|
||||
# 值得注意的是第一个返回值返回的是依照midi频道存储的指令对象列表
|
||||
# 也就是列表套列表
|
||||
cvt_mid.form_progress_bar(
|
||||
max_score, # 音乐时长游戏刻
|
||||
scoreboard_name, # 进度条使用的计分板名称
|
||||
progressbar_style, # 进度条样式组(详见下方)
|
||||
)
|
||||
|
||||
# 同上面生成播放指令的理,进度条指令也混存储至对象内
|
||||
print(
|
||||
"进度条指令如下:\n{}".format(
|
||||
cvt_mid.progress_bar_command
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
在上面的代码中,进度条样式是可以自定义的,详见[下方说明](%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#进度条自定义)。
|
||||
|
||||
- 转换成指令是一个方面,接下来是再转换为可以导入MC的格式
|
||||
|
||||
***诶哟我好累不想写了,等有时间再写,你们就看样例程序的用法吧,无量天尊***
|
||||
|
||||
***这后面一直到下一个小节的内容全是没改的旧内容,肯定有问题***
|
||||
|
||||
```python
|
||||
import Musicreater # 导入转换库
|
||||
|
||||
old_execute_format = False # 指定是否使用旧的execute指令语法(即1.18及以前的《我的世界:基岩版》语法)
|
||||
|
||||
# 首先新建转换对象。
|
||||
conversion = Musicreater.midiConvert(enable_old_exe_format = old_execute_format)
|
||||
# 值得注意的是,一个转换对象可以转换多个文件。
|
||||
# 也就是在实例化的时候不进行对文件的绑定。
|
||||
# 如果有调试需要,可以在实例化时传入参数 debug = True
|
||||
# 如:conversion = Musicreater.midiConvert(debug=True)
|
||||
|
||||
# 设置输入输出地址,并指定execute指令语法
|
||||
# 地址都为字符串类型,不能传入文件流
|
||||
@ -51,7 +136,7 @@ convertion_result = conversion.to_BDX_file(method_id,*prompts)
|
||||
convertion_result = conversion.to_BDX_file_with_delay(method_id,*prompts)
|
||||
|
||||
# 转换结果是一个元组。
|
||||
# 若其转换成功,则前三位必为
|
||||
# 若其转换成功,则前二位必为
|
||||
# True, 指令数量, 最大延迟
|
||||
# 其中,最大延迟可以理解为计分板的最大值
|
||||
# 如果转换失败,暂时还没有定返回值的规则
|
||||
@ -101,11 +186,11 @@ print(convertion_result)
|
||||
|
||||
所以,结构的生成形状依照给定的高度和内含指令的数量决定。其 $Z$ 轴延伸长度为指令方块数量对于给定高度之商的向下取整结果的平方根的向下取整。用数学公式的方式表达,则是:
|
||||
|
||||
$$MaxZ = \left\lfloor\sqrt{\left\lfloor{\frac{NoC}{MaxH}}\right\rfloor}\right\rfloor$$
|
||||
$$ MaxZ = \left\lfloor\sqrt{\left\lfloor{\frac{NoC}{MaxH}}\right\rfloor}\right\rfloor $$
|
||||
|
||||
其中,$MaxZ$即生成结构的$Z$轴最大延伸长度,$NoC$表示链结构中所含指令方块的个数,$MaxH$表示给定的生成结构的最大高度。
|
||||
其中,$MaxZ$ 即生成结构的$Z$轴最大延伸长度,$NoC$ 表示链结构中所含指令方块的个数,$MaxH$ 表示给定的生成结构的最大高度。
|
||||
|
||||
我们的结构生成器在生成指令链时,将首先以相对坐标系 $(0, 0, 0)$ (即相对原点)开始,自下向上堆叠高度轴(即 $Y$ 轴)的长,当高度轴达到了限制的高度时,便将 $Z$ 轴向正方向堆叠`1`个方块,并开始自上向下重新堆叠,直至高度轴坐标达到相对为`0`。若当所生成结构的 $Z$ 轴长达到了其最大延伸长度,则此结构生成器将反转 $Z$ 轴的堆叠方向,直至 $Z$ 轴坐标相对为`0`。如此往复,直至指令链堆叠完成。
|
||||
我们的结构生成器在生成指令链时,将首先以相对坐标系 $(0, 0, 0)$ (即相对原点)开始,自下向上堆叠高度轴(即 $Y$ 轴)的长,当高度轴达到了限制的高度时,便将 $Z$ 轴向正方向堆叠`1`个方块,并开始自上向下重新堆叠,直至高度轴坐标达到相对为 `0`。若当所生成结构的 $Z$ 轴长达到了其最大延伸长度,则此结构生成器将反转 $Z$ 轴的堆叠方向,直至 $Z$ 轴坐标相对为 `0`。如此往复,直至指令链堆叠完成。
|
||||
|
||||
## 播放器
|
||||
|
||||
@ -200,5 +285,5 @@ print(convertion_result)
|
||||
|
||||
`(r'▶ %%N [ %%s/%^s %%% __________ %%t|%^t]',('§e=§r', '§7=§r'))`
|
||||
|
||||
*对了!为了避免生成错误,请尽量避免使用标识符作为定义样式字符串的其他部分*
|
||||
*为了避免生成错误,请尽量避免使用标识符作为定义样式字符串的其他部分*
|
||||
|
||||
|
@ -16,14 +16,24 @@
|
||||
|
||||
支持的文件后缀:`.MCPACK`
|
||||
|
||||
1. 导入附加包
|
||||
2. 在一个循环方块中输入指令 `function index`
|
||||
3. 将需要聆听音乐的实体的播放所用计分板设置为 `1`
|
||||
4. 激活循环方块
|
||||
5. 若想要暂停播放,可以停止循环指令方块的激活状态
|
||||
6. 若想要重置某实体的播放,可以将其播放用的计分板重置
|
||||
- 计分板播放器
|
||||
|
||||
> 其中 步骤三 和 步骤四 的顺序可以调换。
|
||||
1. 导入附加包
|
||||
2. 在一个循环方块中输入指令 `function index`
|
||||
3. 将需要聆听音乐的实体的播放所用计分板设置为 `1`
|
||||
4. 激活循环方块
|
||||
5. 若想要暂停播放,可以停止循环指令方块的激活状态
|
||||
6. 若想要重置某实体的播放,可以将其播放用的计分板重置
|
||||
|
||||
> 其中 步骤三 和 步骤四 的顺序可以调换。
|
||||
|
||||
- 延迟播放器
|
||||
|
||||
1. 导入附加包
|
||||
2. 在聊天框输入指令 `function index`
|
||||
3. 同时激活所生成的循环和脉冲指令方块
|
||||
|
||||
> 需要注意的是,循环指令方块需要一直激活直到音乐结束
|
||||
|
||||
## 结构格式
|
||||
|
||||
@ -41,7 +51,7 @@
|
||||
- 计分板播放器
|
||||
|
||||
2. 在所生成的第一个指令方块前,放置一个循环指令方块,其朝向应当对着所生成的第一个方块
|
||||
3. 在循环指令方块中输入使播放对象的播放用计分板加分的指令,延迟为`0`,每次循环增加`1`分
|
||||
3. 在循环指令方块中输入使播放对象的播放用计分板加分的指令,延迟为 `0`,每次循环增加 `1` 分
|
||||
4. 激活循环方块
|
||||
5. 若想要暂停播放,可以停止循环指令方块的激活状态
|
||||
6. 若想要重置某实体的播放,可以将其播放用的计分板重置
|
||||
|
198
docs/转换乐器对照表.md
198
docs/转换乐器对照表.md
@ -1,2 +1,198 @@
|
||||
**_注意!本文档中的对照表,版权归属于音·创作者,并按照本仓库根目录下 LICENSE.md 中规定开源_**
|
||||
|
||||
# 暂无
|
||||
**_使用时请遵循规定_**
|
||||
|
||||
- 版权所有 © 2023 音·创 开发者
|
||||
- Copyright © 2023 all the developers of Musicreater
|
||||
|
||||
* 开源相关声明请见 仓库根目录下的 License.md
|
||||
* Terms & Conditions: License.md in the root directory
|
||||
|
||||
音·创 开发交流群 861684859\
|
||||
Email TriM-Organization@hotmail.com\
|
||||
若需转载或借鉴 许可声明请查看仓库根目录下的 License.md
|
||||
|
||||
# 乐音乐器
|
||||
|
||||
| Midi 乐器值 | 我的世界音符名称 | 我的世界音调偏移参数 |
|
||||
| ----------- | ------------------- | -------------------- |
|
||||
| 0 | note.harp | 6 |
|
||||
| 1 | note.harp | 6 |
|
||||
| 2 | note.pling | 6 |
|
||||
| 3 | note.harp | 6 |
|
||||
| 4 | note.pling | 6 |
|
||||
| 5 | note.pling | 6 |
|
||||
| 6 | note.harp | 6 |
|
||||
| 7 | note.harp | 6 |
|
||||
| 8 | note.share | 7 |
|
||||
| 9 | note.harp | 6 |
|
||||
| 10 | note.didgeridoo | 8 |
|
||||
| 11 | note.harp | 6 |
|
||||
| 12 | note.xylophone | 4 |
|
||||
| 13 | note.chime | 4 |
|
||||
| 14 | note.harp | 6 |
|
||||
| 15 | note.harp | 6 |
|
||||
| 16 | note.bass | 8 |
|
||||
| 17 | note.harp | 6 |
|
||||
| 18 | note.harp | 6 |
|
||||
| 19 | note.harp | 6 |
|
||||
| 20 | note.harp | 6 |
|
||||
| 21 | note.harp | 6 |
|
||||
| 22 | note.harp | 6 |
|
||||
| 23 | note.guitar | 7 |
|
||||
| 24 | note.guitar | 7 |
|
||||
| 25 | note.guitar | 7 |
|
||||
| 26 | note.guitar | 7 |
|
||||
| 27 | note.guitar | 7 |
|
||||
| 28 | note.guitar | 7 |
|
||||
| 29 | note.guitar | 7 |
|
||||
| 30 | note.guitar | 7 |
|
||||
| 31 | note.bass | 8 |
|
||||
| 32 | note.bass | 8 |
|
||||
| 33 | note.bass | 8 |
|
||||
| 34 | note.bass | 8 |
|
||||
| 35 | note.bass | 8 |
|
||||
| 36 | note.bass | 8 |
|
||||
| 37 | note.bass | 8 |
|
||||
| 38 | note.bass | 8 |
|
||||
| 39 | note.bass | 8 |
|
||||
| 40 | note.harp | 6 |
|
||||
| 41 | note.harp | 6 |
|
||||
| 42 | note.harp | 6 |
|
||||
| 43 | note.harp | 6 |
|
||||
| 44 | note.iron_xylophone | 6 |
|
||||
| 45 | note.guitar | 7 |
|
||||
| 46 | note.harp | 6 |
|
||||
| 47 | note.harp | 6 |
|
||||
| 48 | note.guitar | 7 |
|
||||
| 49 | note.guitar | 7 |
|
||||
| 50 | note.bit | 6 |
|
||||
| 51 | note.bit | 6 |
|
||||
| 52 | note.harp | 6 |
|
||||
| 53 | note.harp | 6 |
|
||||
| 54 | note.bit | 6 |
|
||||
| 55 | note.flute | 5 |
|
||||
| 56 | note.flute | 5 |
|
||||
| 57 | note.flute | 5 |
|
||||
| 58 | note.flute | 5 |
|
||||
| 59 | note.flute | 5 |
|
||||
| 60 | note.flute | 5 |
|
||||
| 61 | note.flute | 5 |
|
||||
| 62 | note.flute | 5 |
|
||||
| 63 | note.flute | 5 |
|
||||
| 64 | note.bit | 6 |
|
||||
| 65 | note.bit | 6 |
|
||||
| 66 | note.bit | 6 |
|
||||
| 67 | note.bit | 6 |
|
||||
| 68 | note.flute | 5 |
|
||||
| 69 | note.harp | 6 |
|
||||
| 70 | note.harp | 6 |
|
||||
| 71 | note.flute | 5 |
|
||||
| 72 | note.flute | 5 |
|
||||
| 73 | note.flute | 5 |
|
||||
| 74 | note.harp | 6 |
|
||||
| 75 | note.flute | 5 |
|
||||
| 76 | note.harp | 6 |
|
||||
| 77 | note.harp | 6 |
|
||||
| 78 | note.harp | 6 |
|
||||
| 79 | note.harp | 6 |
|
||||
| 80 | note.bit | 6 |
|
||||
| 81 | note.bit | 6 |
|
||||
| 82 | note.bit | 6 |
|
||||
| 83 | note.bit | 6 |
|
||||
| 84 | note.bit | 6 |
|
||||
| 85 | note.bit | 6 |
|
||||
| 86 | note.bit | 6 |
|
||||
| 87 | note.bit | 6 |
|
||||
| 88 | note.bit | 6 |
|
||||
| 89 | note.bit | 6 |
|
||||
| 90 | note.bit | 6 |
|
||||
| 91 | note.bit | 6 |
|
||||
| 92 | note.bit | 6 |
|
||||
| 93 | note.bit | 6 |
|
||||
| 94 | note.bit | 6 |
|
||||
| 95 | note.bit | 6 |
|
||||
| 96 | note.bit | 6 |
|
||||
| 97 | note.bit | 6 |
|
||||
| 98 | note.bit | 6 |
|
||||
| 99 | note.bit | 6 |
|
||||
| 100 | note.bit | 6 |
|
||||
| 101 | note.bit | 6 |
|
||||
| 102 | note.bit | 6 |
|
||||
| 103 | note.bit | 6 |
|
||||
| 104 | note.harp | 6 |
|
||||
| 105 | note.banjo | 6 |
|
||||
| 106 | note.harp | 6 |
|
||||
| 107 | note.harp | 6 |
|
||||
| 108 | note.harp | 6 |
|
||||
| 109 | note.harp | 6 |
|
||||
| 110 | note.harp | 6 |
|
||||
| 111 | note.guitar | 7 |
|
||||
| 112 | note.harp | 6 |
|
||||
| 113 | note.bell | 4 |
|
||||
| 114 | note.harp | 6 |
|
||||
| 115 | note.cow_bell | 5 |
|
||||
| 116 | note.bd | 7 |
|
||||
| 117 | note.bass | 8 |
|
||||
| 118 | note.bit | 6 |
|
||||
| 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.bd | 7 |
|
||||
| 127 | note.snare | 7 |
|
||||
|
||||
# 打击乐器
|
||||
|
||||
| Midi 打击乐器值 | 我的世界音符名称 | 我的世界音调偏移参数 |
|
||||
| --------------- | ------------------- | -------------------- |
|
||||
| 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 |
|
||||
|
Reference in New Issue
Block a user