diff --git a/.gitignore b/.gitignore index e98820f..acc23ef 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/LICENSE b/LICENSE.md similarity index 82% rename from LICENSE rename to LICENSE.md index 01813e0..c8abe70 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,192 +1,219 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - - Copyright 2022 Team-Ryoun 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") - - 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. - +**注意,以下条款或版权声明应当且必须是高于此项目中任何其他声明的** + +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/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + + Copyright 2022 Team-Ryoun 金羿("Eilles Wan") & 诸葛亮与八卦阵("bgArray") + + 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. +``` \ No newline at end of file diff --git a/README.md b/README.md index 282af61..d96a16f 100644 --- a/README.md +++ b/README.md @@ -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**\带来的midi音色解析以及转换指令的算法,我们将其改编并应用 -- 感谢 **Touch “偷吃”**\提供的测试支持,并对程序的改进提供了丰富的意见 +- 感谢由 **Dislink Sforza “断联·斯福尔扎”**\带来的midi音色解析以及转换指令的算法,我们将其改编并应用;同时,感谢他的[网页版转换器](https://dislink.github.io/midi2bdx/)给我们的开发与更新带来巨大的压力和动力,让我们在原本一骑绝尘的摸鱼道路上转向开发 +- 感谢 **Touch “偷吃”**\提供的测试支持,并对程序的改进提供了丰富的意见;同时也感谢他的不断尝试新的内容,使我们的排错更进一步 - 感谢 **Mono**\反馈安装时的问题 +- 感谢 **Ammelia** 敦促我们进行新的功能开发,并为新功能提出了非常优秀的大量建议 > 感谢广大群友为此程序提供的测试等支持 > diff --git a/README_EN.md b/README_EN.md index b392195..edda995 100644 --- a/README_EN.md +++ b/README_EN.md @@ -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✒ diff --git a/demo_convert.py b/demo_convert.py index 02cc805..c0fafbd 100644 --- a/demo_convert.py +++ b/demo_convert.py @@ -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):'))), - ) + )) diff --git a/demo_convert_bdx_byDelay.py b/demo_convert_bdx_byDelay.py index 4e4b5b4..13f47dc 100644 --- a/demo_convert_bdx_byDelay.py +++ b/demo_convert_bdx_byDelay.py @@ -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 * diff --git a/docs/download&atart/Android.md b/docs/download&atart/Android.md new file mode 100644 index 0000000..f4e885e --- /dev/null +++ b/docs/download&atart/Android.md @@ -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*包后直接安装,安装后打开可以看到一个类似这样的界面: + + + +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 + ``` + + *感谢 天如为我们带来的简单换源方法。* + + - *非必要步骤*:手动编辑换源 + + 如果你闲着没事,非要要手动编辑个文档来换源,那用啥?用普通的编辑器肯定可以,于是我们就让他更普通一点,用**nano**吧! + + 在 **Termux** 中,输入以下指令: + + ```bash + export EDITOR=nano + apt edit-sources + ``` + + 那么请把看到的如左下图的界面变为右下图吧: + + + + +
+ + - 图片中的文件,最后应该加入的两行为: + + ```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`表示是,如左下图,安装成功后,图若右下。 + + + + +
+ + 接下来,我们来试一试 **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 + ``` + + - 如果出现以下情况,真是死了鬼的,我们要来再搞个设置: + + + + 我们来修改收信任的源设置: + + ```bash + pip config set global.trusted-host mirrors.aliyun.com/ + ``` + + 之后再来安装即可 + + ```bash + pip install mido + pip install brotli + ``` + + 安装成功后您可能会见到类似下图的提示: + + + +### 安装下载工具 + +既然已经有了运行环境,那么我们就需要下载下我们的**音·创库版示例代码**工具,我非常推崇**Git**这种方便快捷好用还能下载仓库的代码管理器,这个世界上你也找不到第二个,所以我们来安装一下: + +```bash +pkg install git +``` + +安装完成后记得测试一下: + + + +## 本代码库的下载与演示程序的使用 + +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 + ``` + + 运行成功了,哦耶! + + + diff --git a/docs/download&atart/Linux.md b/docs/download&atart/Linux.md new file mode 100644 index 0000000..3158b97 --- /dev/null +++ b/docs/download&atart/Linux.md @@ -0,0 +1,104 @@ + +## 运行环境安装 + +### 检验Python运行环境 + +0. 一般的Linux发行版都有安装Python环境,我们只需要保证其版本即可,理论上 ≥Python3.6 都可以运行我们的库 + + 我们可以使用 + + ```bash + python -V + ``` + + 来查看 Python 版本,如下 + + + +1. *非必要环节*:回退版本 + + 如果你跟作者一样,觉得 Python 3.10+ 太难用很烦人的话,那真是皆大欢喜,让我们一起来回退版本吧! + + - pacman 包管理器(多用于Arch Linux上) + + 1. 让我们先来把 python3 加入忽略升级的列表中,使用`vim`修改`/etc/pacman.conf`,在`IgnorePkg`后加上`python3` + + ```bash + sudo vim /etc/pacman.conf + ``` + + + + 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 + ``` + + + + 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. 安装成功后可能会见到类似下图的提示: + + + + +## 本代码库的下载与使用 + +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 + ``` + diff --git a/docs/download&atart/Windows.md b/docs/download&atart/Windows.md new file mode 100644 index 0000000..38c8ddb --- /dev/null +++ b/docs/download&atart/Windows.md @@ -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`,如下图所示,当然,如果您对自己非常自信,您也可以手动设置此项目: + + + + - 若您对Python一知半解或者不怎么了解、并对自己的系统盘(通常是C盘)有大约150*兆字节*(MB)的信心的话,您可以在安装时直接选择*快速安装*(Install Now) + +3. 若您选择了*自定义安装*(Customize Installation),请务必勾选 `pip` 和 `py launcher` 便于后续安装依赖,如下图: + + + +4. 安装结束之后可以在*终端*(命令行/PowerShell/Bash/etc)中输入:python 试试是否安装成功,成功安装之后,在终端中输入python会显示诸如如下图片的提示: + + + + +### (二)安装依赖 + +1. 请以管理员模式打开您的*终端*(命令行/PowerShell/Bash/etc) + + 例如,命令行,可以如此打开:在*视窗开始菜单*(Windows开始)中搜索 `cmd`, 并以管理员身份运行 + + + +2. 打开了终端之后,请在终端中输入以下指令 + + ```bash + pip install mido -i https://mirrors.aliyun.com/pypi/simple/ + pip install brotli -i https://mirrors.aliyun.com/pypi/simple/ + ``` + +3. 安装成功后您可能会见到类似下图的提示: + + + +## 二、本工具的下载与使用 + +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),在群文件中获取。 + + + + 值得注意的是,这张图上有1、2两个数字,虽然是手写的,但确实是数字,表示着要进行的步骤。希望眼尖得能找出我的口头禅的你们能够发现这两个用鼠标手写的数字并在安装时认真地执行。我认为这并不算十分的难,移动鼠标并单击大约消耗不了多少卡路里,不过我没有进行精确的计算,我也不是十分的清楚这个活动对于一个常人来讲有多难,但我怀疑它不难。 + + +1. 开始使用 + + 在目录下打开终端。 + + 例如:打开命令行:请进入到目录下,在文件资源管理器的地址框内输入`cmd`: + + + + + 执行以下命令:(选择你需要的) + + ```bash + python demo_convert.py #计分板播放器,支持mcpack与BDX + python demo_convert_bdx_byDelay.py #延迟播放器,仅支持BDX + ``` + +## 三、安装时错误的补充说明 + +1. Microsoft Visual C++ Redistributable 环境出错 + + 如果你遇到了类似以下这种情况: + + + + 请下载最新的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帮我们发现这个问题。 \ No newline at end of file diff --git a/docs/功能使用说明.md b/docs/功能使用说明.md index 40b30d1..0ac6879 100644 --- a/docs/功能使用说明.md +++ b/docs/功能使用说明.md @@ -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) + + +- midi路径:含有mid文件路径、文件名、后缀的完整文件路径,或者一个目录(demo可接受批量转换)。可以使用相对或绝对路径皆可 + +- 输出路径:输出文件夹的路径,不需要指示文件名 + +- 是否重置计分板:`1`或`0`(歌曲放完是否重置,推荐`1`) + +- 进度条:是否启用进度条,以及自定义进度条样式。输入`0`或`False`表示不启用进度条,输入`1`或`True`表示使用默认进度条,其余的输入均表示使用输入的格式作为自定义的进度条样式 - 在安装时,最好需要勾选 `Add Python 3.X to PATH`,如下图所示,当然,如果您对自己非常自信,您也可以手动设置此项目: - - - - 若您对Python一知半解或者不怎么了解、并对自己的系统盘(通常是C盘)有大约150*兆字节*(MB)的信心的话,您可以在安装时直接选择*快速安装*(Install Now) - - 若您选择了*自定义安装*(Customize Installation),请务必勾选 `pip` 和 `py launcher` 便于后续安装依赖,如下图: - - - - 安装结束之后可以在*终端*(命令行/PowerShell/Bash/etc)中输入:python 试试是否安装成功,成功安装之后,在终端中输入python会显示诸如如下图片的提示: - - - - -1. 安装依赖 - - 请以管理员模式打开您的*终端*(命令行/PowerShell/Bash/etc) - - 例如,命令行,可以如此打开:在*视窗开始菜单*(Windows开始)中搜索 `cmd`, 并以管理员身份运行 - - - - 打开了终端之后,请在终端中输入以下指令 - - ```bash - pip install mido -i https://mirrors.aliyun.com/pypi/simple/ - pip install brotli -i https://mirrors.aliyun.com/pypi/simple/ - ``` - - 安装成功后您可能会见到类似下图的提示: - - - -### 本工具的下载与使用 - -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),在群文件中获取。 - - - - -1. 开始使用 - - 在目录下打开终端,例如,打开命令行,请进入到目录下,在地址框内输入`cmd`: - - - - - 执行以下命令:(选择你需要的) - - ```bash - python demo_convert.py - python demo_convert_bdx_byDelay.py - ``` - -### 补充错误说明 - -1. Microsoft Visual C++ Redistributable 环境出错 - - 如果你遇到了类似以下这种情况: - - - - 请下载最新的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 版本,如下 - - - - - 非必要环节 - - 如果你跟作者一样,觉得 Python 3.10+ 太难用很烦人的话,那真是皆大欢喜,让我们一起来回退版本吧! - - - pacman 包管理器(多用于Arch Linux上) - - 让我们先来把 python3 加入忽略升级的列表中,使用`vim`修改`/etc/pacman.conf`,在`IgnorePkg`后加上`python3` - - ```bash - sudo vim /etc/pacman.conf - ``` - - - - 然后我们开始从[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 - ``` - - - - 完美! - -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/ - ``` - - 安装成功后您可能会见到类似下图的提示: - - - - -### 本代码库的下载与使用 - -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 源就看运气。 - - 下载后直接按照,打开后可以看到一个类似这样的界面: - - - - 恭喜你,你已经获得了一个极客般流畅地操作你手机的终端工具。 - -1. 安装运行环境 - - 接下来,我们就要来安装一下 **Python** 运行环境了,这是运行 **Python** 源代码必要的。 - - 首先,我估计你等不了多久,急得要死,所以我们要让下载速度稍微快一点,先来换个源。换源要手动编辑个文档,那用啥?用普通的编辑器肯定可以,于是我们就让他更普通一点,用**nano**吧! - - 在 **Termux** 中,输入以下指令: - - ```bash - export EDITOR=nano - apt edit-sources - ``` - - 你可能会看到如下一个简单的界面: - - - - 好,让我们动起你的双手,把它变成这样吧: - - - - - 图片中的文件,最后应该加入的两行为: - - ```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`表示是,如图。 - - - - 如果你安装成功,应该是差不多这样的: - - - - 我们来试一试 **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 - ``` - - - 如果出现以下情况,真是死了鬼的,我们要来再搞个设置: - - - - 我们来修改收信任的源设置: - - ```bash - pip config set global.trusted-host mirrors.aliyun.com/ - ``` - - 之后再来安装即可 - - ```bash - pip install mido - pip install brotli - ``` - - 安装成功后您可能会见到类似下图的提示: - - - -3. 安装下载工具 - - 既然已经有了运行环境,那么我们就需要下载下我们的**音·创库版示例代码**工具,我非常推崇**Git**这种方便快捷好用还能下载仓库的代码管理器,这个世界上你也找不到第二个,所以我们来安装一下: - - ```bash - pkg install git - ``` - - 安装完成后记得测试一下: - - - -### 本代码库的下载与使用 - -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 - ``` - - 运行成功了,哦耶! - - + 若不支持自定义,则仅能输入`0`或`1`表示“关闭”或“开启” +- 计分板名称:游戏内的计分板名称 +- 音量:0-1之间的小数(含0,1)正常来说推荐`1` +- 速度倍率:小数数据,其值不可为0,一般写`1` +- 玩家选择器:包括 `@x` 在内的全部选择器,即若要选择全部标签为`Holo`的玩家,则需要如此输入:`@a[tag=Holo]` +- 没有报错且在输出路径下找到mcpack或bdx即为生成成功: + # 其他说明 @@ -373,31 +59,6 @@ 答2:详见问1,切换你所需要的播放器即可。 -## 对于 参数 的补充说明 - - - -- midi路径:含有mid文件路径、文件名、后缀的完整文件路径,或者一个目录(demo可接受批量转换)。可以使用相对或绝对路径皆可 - -- 输出路径:输出文件夹的路径,不需要指示文件名 - -- 是否重置计分板:1或0(歌曲放完是否重置,推荐1) - -- *进度条:是否启用进度条,以及自定义进度条样式。输入0或False表示不启用进度条,输入1或True表示使用默认进度条,其余的输入均表示使用输入的格式作为自定义的进度条样式 - -- 计分板名称:游戏内的计分板名称 - -- 音量:0-1之间的小数(含0,1)正常来说推荐1 - -- 速度倍率:小数数据,不可为0,一般写1 - -- 玩家选择器:包括 `@x` 在内的全部选择器,即若要选择全部标签为`Holo`的玩家,则需要如此输入:`@a[tag=Holo]` - -- 没有报错且在输出路径下找到mcpack或bdx即为生成成功: - - - - ## 对于 进度条自定义 功能的说明 因为我们提供了可以自动转换进度条的功能,因此在这里给出进度条自定义参数的详细解释。 diff --git a/docs/新手答疑指南.md b/docs/新手答疑指南.md new file mode 100644 index 0000000..f0b3900 --- /dev/null +++ b/docs/新手答疑指南.md @@ -0,0 +1,180 @@ +

音·创 Musicreater

+ +

库版 Package Version

+ +

+ +

+ +# 新手答疑指南 + +**考虑到某些用户电脑技术不是特别先进,且对这个项目充满了好奇心,但是又了解的不是很充分, +为此,我特别在这里写一份文档,解答各位的好奇心。放心,本文件全程中文,英文版本随后更新!** + +## 第一部分 关于音·创的作用 + +### 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分钟的音乐只用大约5~10KB。今天,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.** 登录你的账号,主界面应该如下图所示: + + **3.** 在显眼的搜索框中,输入你想要的歌曲名称,接下来的教程,我以`夜空中最亮的星`这首歌及它的mid来演示下载流程。点击搜索框,完成这一步。 + + **4.** 接下来看到搜索结果如下,你可以点进去一个听听,决定你是否要下载;也有可能你什么都没搜到,那你就得换首歌或者换个途径了。 + + **5.** 点击播放按钮试听,网站上的效果可能一般,但是会听音乐的人应该很快就能决定你是否需要下载这个音乐。如果需要下载,你可以进行到下一步, + 如果不行,那你可以退回刚刚的页面换一个。 + + **6.** 翻到最下面,如图,你可以对这首歌进行打分,打分可以使积分+1,建议打5分;你可以对这首歌进行评论,一次有意义的评论可以+3分。 + 下载一首歌需要-3积分,如果你先完成了这两项操作再下载,那你还会再赚1积分。所以推荐这样做! + + **完成后会像这样:** + + **7.** 接下来下载,往上翻网页,找到这个标识,然后单击。 + + **8.** 确认完毕后点击下载。 + + **9.** 完成下载,如图: + +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文件其实就是我的世界基岩版的附加包,里面一般分为行为包和材质包 + +我们生成的命令组属于**行为包** (下图就是一个例子) + + + +如果你是国际电脑版基岩玩家就像我一样,是可以直接打开这个文件,并将这个包导入我的世界的。 + +关于怎么使用,请看[**这里**](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一下)** diff --git a/magicDemo.py b/magicDemo.py index 6c54c48..6a7c239 100644 --- a/magicDemo.py +++ b/magicDemo.py @@ -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() diff --git a/msctPkgver/__init__.py b/msctPkgver/__init__.py index a2bef6c..41c8a17 100644 --- a/msctPkgver/__init__.py +++ b/msctPkgver/__init__.py @@ -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/") + diff --git a/msctPkgver/exceptions.py b/msctPkgver/exceptions.py index 23ec562..dfddf46 100644 --- a/msctPkgver/exceptions.py +++ b/msctPkgver/exceptions.py @@ -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 """ diff --git a/msctPkgver/main.py b/msctPkgver/main.py index 42484c0..a69ea23 100644 --- a/msctPkgver/main.py +++ b/msctPkgver/main.py @@ -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 - 而存在一些打击乐器basedrum、hat、snare,没有音域,则没有X,那么我们返回7即可 + 而存在一些打击乐器bd(basedrum)、hat、snare,没有音域,则没有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 [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 后,正确用法如下: