diff --git a/Musicreater/main.py b/Musicreater/main.py index a3352c8..728860e 100644 --- a/Musicreater/main.py +++ b/Musicreater/main.py @@ -321,23 +321,23 @@ class MusicSequence: bytes_buffer = ( b"MSQ@" + ( - (len(r := self.music_name.encode("GB18030")) << 10) - + round(self.minimum_volume * 1000) + (len(r := self.music_name.encode("GB18030")) << 10) # 音乐名称长度 + + round(self.minimum_volume * 1000) # 最小音量 ).to_bytes(2, "big") + ( ( ( - (high_time_precision << 1) - + (1 if (k := round(self.music_deviation * 1000)) < 0 else 0) + (high_time_precision << 1) # 是否启用“高精度”音符时间控制 + + (1 if (k := round(self.music_deviation * 1000)) < 0 else 0) # 总音调偏移的正负位 ) << 14 ) - + abs(k) + + abs(k) # 总音调偏移 ).to_bytes(2, "big", signed=False) + r ) - # 若启用“高精度”,则在每个音符前添加一个字节,用于存储音符时间控制精度偏移 + # 若启用“高精度”,则每个音符皆添加一个字节,用于存储音符时间控制精度偏移 # 此值每增加 1,则音符向后播放时长增加 1/1250 秒 for channel_index, note_list in self.channels.items(): bytes_buffer += len(note_list).to_bytes(4, "big") diff --git a/README.md b/README.md index fac51bf..f8b7e79 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ **诸葛亮与八卦阵 bgArray**:我的世界基岩版玩家,喜欢编程和音乐,深圳学生。 -**偷吃不是Touch Touch**:我的世界基岩版指令师,提供 BDX 导入测试支持 +**偷吃不是Touch Touch**:我的世界基岩版指令制作者,提供测试支持 ## 致谢 🙏 @@ -89,7 +89,7 @@ - 感谢 **指令师\_苦力怕 playjuice123**\ 为我们的程序找出错误,并提醒我们修复一个一直存在的大 bug。 - 感谢 **雷霆**\ 用他那令所有开发者都大为光火的操作方法为我们的程序找出错误,并提醒修复 bug。 - 感谢 **小埋**\ 反馈附加包生成时缺少描述和标题的问题。 --
感谢 **油炸**\ 激励我们不断开发新的内容。
+-
感谢 **油炸**<QQ2836146704> 激励我们不断开发新的内容。
- 感谢 **雨**\ 反馈在新版本的指令格式下,计分板播放器的附加包无法播放的问题。 > 感谢广大群友为此库提供的测试和建议等 diff --git a/README_EN.md b/README_EN.md index eafa0fb..fc26128 100644 --- a/README_EN.md +++ b/README_EN.md @@ -38,24 +38,24 @@ Welcome to join our QQ group: [861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr ## Installation 🔳 -- Via pypi +- Via pypi - ```bash - pip install Musicreater --upgrade - ``` + ```bash + pip install Musicreater --upgrade + ``` -- If above command cannot fetch latest version, try: +- If above command cannot fetch latest version, try: - ```bash - pip install -i https://pypi.python.org/simple Musicreater --upgrade - ``` + ```bash + pip install -i https://pypi.python.org/simple Musicreater --upgrade + ``` -- Clone repo and Install (Latest but **NOT RECOMMANDED**): - ```bash - git clone https://github.com/TriM-Organization/Musicreater.git - cd Musicreater - python setup.py install - ``` +- Clone repo and Install (Latest but **NOT RECOMMANDED**): + ```bash + git clone https://github.com/TriM-Organization/Musicreater.git + cd Musicreater + python setup.py install + ``` Commands such as `python`、`pip` could be changed to some like `python3` or `pip3` according to the difference of platforms. @@ -73,24 +73,24 @@ Commands such as `python`、`pip` could be changed to some like `python3` or `pi **bgArray (诸葛亮与八卦阵)**: A student, player of _Minecraft: Bedrock Edition_, which is a fan of music and programming. -**Touch (偷吃不是Touch)**: A man who is good at using command(s) in _Minecraft: Bedrock Edition_, who supported us of debugging and testing program and algorithm +**Touch (偷吃不是 Touch)**: A man who is good at using command(s) in _Minecraft: Bedrock Edition_, who supported us of debugging and testing program and algorithm ## Acknowledgements 🙏 This list is not in any order. -- Thank _昀梦_\ for finding and correcting the bugs in the commands that _Musicreater_ generated. -- Thank _Charlie_Ping “查理平”_ for the bdx convert function for reference, and the reference chart that's used to convert the mid's instruments into Minecraft's instruments. -- Thank _[CMA_2401PT](https://github.com/CMA2401PT)_ for BDXWorkShop for reference of the .bdx structure's operation, and his guidance in some aspects of our development. -- Thank _[Dislink Sforza](https://github.com/Dislink) “断联·斯福尔扎”_ \ for his midi analysis algorithm brought to us, we had adapted it and made it applied in one of our working method; Also, thank him for the [WebConvertor](https://dislink.github.io/midi2bdx/) which brought us so much pressure and power to develop as well as update our projects better, instead of loaf on our project. -- Thank _Mono_\ for reporting problems while installing -- Thank _Ammelia “艾米利亚”_\ for urging us to develop new functions, and put forward a lot of excellent suggestions for new functions, as well as the BDX file's importing test support provided, which has given a lot of practical theoretical support for our new Structure Generating Algorithm -- Thank _[神羽](https://gitee.com/snowykami) “[SnowyKami](https://github.com/snowyfirefly)”_ for supporting and promoting our project, and also thanks him for his server which given us to use for free. -- Thank **指令师\_苦力怕 playjuice123**\ for finding bugs within our code, and noticed us to repair a big problem. -- Thank **雷霆**\ for his annoying and provoking operations which may awake some problems within the program by chance and reminding us to repair. -- Thank **小埋**\ for reporting the empty add-on packs title and description problem. --
Thank **油炸**\ for inspiring us to constantly develop something new.The groupmate on the picture was saying that our convert-QQ-bot had once brought him great convinience but now it closed down by some reason so he was feeling regretful."It was once, a convert-QQ-bot is just in front my eyes"
"Until lose, I finally know cannot chase back what I needs"
-- Thank **雨**\ for give us report that under the new `execute` command format that the scoreboard player's add-on packs cannot play correctly. +- Thank _昀梦_\ for finding and correcting the bugs in the commands that _Musicreater_ generated. +- Thank _Charlie_Ping “查理平”_ for the bdx convert function for reference, and the reference chart that's used to convert the mid's instruments into Minecraft's instruments. +- Thank _[CMA_2401PT](https://github.com/CMA2401PT)_ for BDXWorkShop for reference of the .bdx structure's operation, and his guidance in some aspects of our development. +- Thank _[Dislink Sforza](https://github.com/Dislink) “断联·斯福尔扎”_ \ for his midi analysis algorithm brought to us, we had adapted it and made it applied in one of our working method; Also, thank him for the [WebConvertor](https://dislink.github.io/midi2bdx/) which brought us so much pressure and power to develop as well as update our projects better, instead of loaf on our project. +- Thank _Mono_\ for reporting problems while installing +- Thank _Ammelia “艾米利亚”_\ for urging us to develop new functions, and put forward a lot of excellent suggestions for new functions, as well as the BDX file's importing test support provided, which has given a lot of practical theoretical support for our new Structure Generating Algorithm +- Thank _[神羽](https://gitee.com/snowykami) “[SnowyKami](https://github.com/snowyfirefly)”_ for supporting and promoting our project, and also thanks him for his server which given us to use for free. +- Thank _指令师\_苦力怕 “playjuice123”_\ for finding bugs within our code, and noticed us to repair a big problem. +- Thank _雷霆_\ for his annoying and provoking operations which may awake some problems within the program by chance and reminding us to repair. +- Thank _小埋_\ for reporting the empty add-on packs title and description problem. +-
Thank 油炸 <QQ2836146704> for inspiring us to constantly develop something new.The groupmate on the picture was saying that our convert-QQ-bot had once brought him great convinience but now it closed down by some reason so he was feeling regretful."It was once, a convert-QQ-bot is just in front my eyes"
"Until lose, I finally know cannot chase back what I needs"
+- Thank _雨_\ for give us report that under the new `execute` command format that the scoreboard player's add-on packs cannot play correctly. > Thanks for the support and help of a lot of groupmates > @@ -120,7 +120,7 @@ NOT APPROVED BY OR ASSOCIATED WITH NETEASE. “Minecraft”是 Mojang Synergies AB 的商标,此项目中所有对于“我的世界”、“Minecraft”等相关称呼均为必要的介绍性使用 -- 上文提及的 网易 公司,指代的是在中国大陆运营《我的世界:中国版》的上海网之易璀璨网络科技有限公司 +- 上文提及的 网易 公司,指代的是在中国大陆运营《我的世界:中国版》的上海网之易璀璨网络科技有限公司 [Bilibili: Eilles]: https://img.shields.io/badge/Bilibili-%E9%87%91%E7%BE%BFELS-00A1E7?style=for-the-badge [Bilibili: bgArray]: https://img.shields.io/badge/Bilibili-%E8%AF%B8%E8%91%9B%E4%BA%AE%E4%B8%8E%E5%85%AB%E5%8D%A6%E9%98%B5-00A1E7?style=for-the-badge diff --git a/docs/MSQ文件格式.md b/docs/MSQ文件格式.md new file mode 100644 index 0000000..b2b2e01 --- /dev/null +++ b/docs/MSQ文件格式.md @@ -0,0 +1,42 @@ +# MSQ 文件格式 + +MSQ 文件是 音·创 存储音符序列的一种格式,取自 MusicSeQuence。 + +## MSQ 第二版 + +第二版的码头是 MSQ@ ,这一版中,所有的**字符串**以 _**GB18030**_ 编码进行编解码,**数值**以**_大端序_**存储。 + +码头是文件前四个字节的内容,这一部分内容是可读的 ASCII 字串。因此,第二版的文件前四个字节的内容必为 MSQ@。 + +取 MSQ@ 是因为美式键盘上 @ 是 Shift+2 键 按下取得的,故代表 MSQ 第二版。 + +### 元信息 + +| 信息名称 | 西文代号 | 位长(多少个 0 或 1) | 支持说明 | +| ------------------------------ | -------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **音乐名称长度** | music_name_length | 6 位 | 支持数值 0~63 | +| **最小音量** | minimum_volume | 10 位 | 支持数值 0~1023,注意,这里每个 1 代表最小音量的 0.001 个单位,即取值是此处表示数字的千分倍 | +| **是否启用高精度音符时间控制** | enable_high_precision_time | 1 位 | 1 是启用,反之同理 | +| **总音调偏移** | music_deviation | 15 位 | 支持数值 -16383~16383,这里也是表示三位小数的,和最小音量一样。这里 15 位中的第一位(从左往右)是正负标记,若为 1 则为负数,反之为正数,后面的 14 位是数值 | +| **音乐名称** | music_name | 依据先前定义 | 最多可支持 31 个中文字符 或 63 个西文字符,其长度取决于先前获知的 “音乐名称长度” 的定义 | + +在这一元信息中,**音乐名称长度**和**最小音量**合计共 2 字节;**高精度音符时间控制启用**和**总音调偏移**合计共 2 字节;因此,除**音乐名称**为任意长度,前四字节内容均为固定。 + +### 音符序列 + +每个序列前 4 字节为一个用以表示当前通道中音符数量的值,也就是**通道音符数**(notes_count)。也即是说,一个通道内的音符可以是 0~4294967295 个。 + +在这之后,就是这些数量的音符了,其中每个音符的信息存储方式如下 + +| 信息名称 | 西文代号 | 位长 | 支持说明 | +| ---------------------------- | ------------------------ | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **乐器名称长度** | name_length | 6 位 | 支持数值 0~63 | +| **Midi 音高** | note_pitch | 7 位 | 支持数值 0~127 | +| **开始时刻** | start_tick | 17 位 | 单位 二十分之一秒,即约为 1 命令刻;支持数值 0~131071 即 109.22583 分钟 合 1.8204305 小时 | +| **音符持续刻数** | duration | 17 位 | 同上 | +| **是否作为打击乐器** | percussive | 1 位 | 1 是启用,反之同理 | +| **响度(力度)** | velocity | 7 位 | 支持数值 0~127 | +| **是否启用声像位移** | is_displacement_included | 1 位 | 1 是启用,反之同理 | +| **时间精度提升值**(非必含) | high_time_precision | 8 位 | 支持数值 0~255,若在 元信息 中启用**高精度音符时间控制**,则此值启用,代表音符时间控制精度偏移,此值每增加 1,则音符开始时刻向后增加 1/1250 秒 | +| **乐器名称** | sound_name | 依据先前定义 | 最多可支持 31 个中文字符 或 63 个西文字符,其长度取决于先前获知的 “乐器名称长度” 的定义 | +| **声像位移**(非必含) | position_displacement | 共三个值,每个值 16 位 共 48 位 | 若前述**是否启用声像位移**已启用,则此值启用;三个值分别代表 x、y、z 轴上的便宜,每个值支持数值 0~65535,注意,这里每个 1 代表最小音量的 0.001 个单位,即取值是此处表示数字的千分倍 |