mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2026-04-17 06:08:00 +00:00
完善部分文档
This commit is contained in:
@@ -6,8 +6,4 @@
|
||||
|
||||
**此为开发相关文档,内容包括:库的简单调用、所生成文件结构的详细说明、特殊参数的详细解释**
|
||||
|
||||
# [main.py](../Musicreater/main.py)
|
||||
|
||||
## [类] MidiConvert
|
||||
|
||||
### [类函数] from_midi_file
|
||||
音·创 v3 的文档还在编纂过程中,请耐心等待。
|
||||
@@ -4,9 +4,9 @@
|
||||
<img width="128" height="128" src="https://gitee.com/TriM-Organization/Musicreater/raw/master/resources/msctIcon.png" >
|
||||
</p>
|
||||
|
||||
# 生成文件的使用
|
||||
# 生成文件的使用(正在考虑转移该文档)
|
||||
|
||||
*这是本库所生成文件的使用声明,不是使用本库的教程,若要查看**本库的文档**,可点击[此处](./%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%E8%AF%B4%E6%98%8E.md)*
|
||||
*这是本库所生成文件的使用声明,不是使用本库的教程,若要查看**本库的文档**,可点击此处(暂未推出)*
|
||||
|
||||
## 附加包格式
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 音乐序列文件格式
|
||||
# 音乐序列文件格式(已过时)
|
||||
|
||||
音·创 库的音符序列文件格式包含两种,一种是常规的音乐序列存储采用的 MSQ 格式,另一种是为了流式读取音符而采用的 FSQ 格式。
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ Email [TriM-Organization@hotmail.com](mailto:TriM-Organization@hotmail.com)
|
||||
本声明仅限于包含此声明的本文件,本声明与项目内其他文件无关。
|
||||
```
|
||||
|
||||
本教程文档的关联文件是[exp_importdata_plugin.py](./exp_importdata_plugin.py)
|
||||
|
||||
## 新建文件夹 · 基础模块知识
|
||||
|
||||
|
||||
@@ -28,7 +30,7 @@ Email [TriM-Organization@hotmail.com](mailto:TriM-Organization@hotmail.com)
|
||||
这就意味着,承载插件的模块本质上可以是多个 Python 的 `.py` 文件组成的,带有 `__init__.py` 的一个文件夹;
|
||||
或者是一个简单的 `.py` 文件。
|
||||
|
||||
我们有这种共识:你已经知道了模块的相关知识,我后面无需赘述插件和模块的区别。
|
||||
我们有这种共识:大家已经知道了模块的相关知识,后面的教程中你已经理解 **音·创 v3** 插件和 Python 模块的区别。
|
||||
|
||||
## 开始编写插件 · 插件基础
|
||||
|
||||
@@ -103,23 +105,26 @@ class ExampleImportPlugin(MusicInputPluginBase):
|
||||
version=(0, 0, 1), # 插件版本
|
||||
type=PluginTypes.FUNCTION_MUSIC_IMPORT, # 插件类型
|
||||
license="The Unlicense", # 插件许可证
|
||||
dependencies=("something_convertion_library") # 插件对于其他插件的依赖项
|
||||
dependencies=("something_convertion_library") # 插件对于其他插件的依赖项(此功能尚未实现)
|
||||
)
|
||||
|
||||
# 导入导出插件支持的数据格式,大小写皆可
|
||||
# 导入导出插件支持的数据格式,大小写皆可,无需加后缀名前的那个点
|
||||
supported_formats = ("EXP", "example_format")
|
||||
|
||||
# 定义 loadbytes 方法,从字节流中导入数据
|
||||
def loadbytes(
|
||||
self, bytes_buffer_in: BinaryIO, config: ExampleImportConfig
|
||||
self, bytes_buffer_in: BinaryIO, config: Optional[ExampleImportConfig]
|
||||
) -> "SingleMusic":
|
||||
...
|
||||
|
||||
# 插件可选地定义 load 方法,从文件导入数据
|
||||
# 插件可选地定义 load 方法,从文件导入数据。下面展示的是不定义 load 方法时候的实现方式
|
||||
def load(
|
||||
self, file_path: Path, config: ExampleImportConfig
|
||||
self, file_path: Path, config: Optional[ExampleImportConfig]
|
||||
) -> "SingleMusic":
|
||||
...
|
||||
with file_path.open("rb") as f:
|
||||
return self.loadbytes(f, config)
|
||||
```
|
||||
|
||||
至此,一个插件的编写已经完成。
|
||||
至此,一个插件的编写已经完成。
|
||||
|
||||
同时,如果有不清楚的地方,可以查看我们的[内置插件](../Musicreater/builtin_plugins/),说不定会给你一些启发。
|
||||
@@ -24,7 +24,7 @@ Copyright © 2026 Eilles
|
||||
本声明仅限于包含此声明的本文件,本声明与项目内其他文件无关。
|
||||
"""
|
||||
|
||||
from typing import BinaryIO
|
||||
from typing import BinaryIO, Optional
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -54,17 +54,19 @@ class ExampleImportPlugin(MusicInputPluginBase):
|
||||
version=(0, 0, 1),
|
||||
type=PluginTypes.FUNCTION_MUSIC_IMPORT,
|
||||
license="The Unlicense",
|
||||
dependencies=("something_convertion_library")
|
||||
dependencies=("something_convertion_library"),
|
||||
)
|
||||
|
||||
supported_formats = ("EXP", "example_format")
|
||||
|
||||
def loadbytes(
|
||||
self, bytes_buffer_in: BinaryIO, config: ExampleImportConfig
|
||||
self, bytes_buffer_in: BinaryIO, config: Optional[ExampleImportConfig]
|
||||
) -> "SingleMusic":
|
||||
return SingleMusic()
|
||||
|
||||
# 插件可选地定义 load 方法,从文件导入数据。下面展示的是不定义 load 方法时候的实现方式
|
||||
def load(
|
||||
self, file_path: Path, config: ExampleImportConfig
|
||||
self, file_path: Path, config: Optional[ExampleImportConfig]
|
||||
) -> "SingleMusic":
|
||||
return SingleMusic()
|
||||
with file_path.open("rb") as f:
|
||||
return self.loadbytes(f, config)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
dependencies = [
|
||||
"tomli >= 2.4.0, < 3.0 ; python_version < '3.11'",
|
||||
"tomli-w >= 1.0.0, < 2.0",
|
||||
"xxhash >= 3, < 4.0",
|
||||
"xxhash >= 3.0, < 4.0",
|
||||
]
|
||||
|
||||
authors = [
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.6 MiB After Width: | Height: | Size: 130 KiB |
Reference in New Issue
Block a user