切换为UV进行包管理

This commit is contained in:
EillesWan 2025-04-15 20:01:43 +08:00
parent 048b631bd6
commit 3739138059
11 changed files with 1408 additions and 54 deletions

1
.gitignore vendored
View File

@ -51,6 +51,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.pdm-build/
# PyInstaller
# Usually these files are written by a python script from a template

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.10

View File

@ -1,13 +0,0 @@
recursive-include *.md
exclude fcwslib/*
exclude bgArrayLib/*
exclude Packer/*
exclude ./*.mid
exclude ./*.MSQ
exclude ./MSCT_Packer.py
exclude resources/poem.md
exclude resources/*
include LICENSE.md
include requirements.txt
include README_EN.md
include README.md

View File

@ -22,7 +22,7 @@ The Licensor of Musicreater("this project") is Eilles Wan, bgArray.
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
__version__ = "2.3.0"
__version__ = "2.3.0.1"
__vername__ = "FSQ完全流式音符读写适配"
__author__ = (
("金羿", "Eilles"),

View File

@ -745,7 +745,7 @@ class MusicSequence:
return bytes_buffer
def set_min_volume(self, volume_value: int):
def set_min_volume(self, volume_value: float):
"""重新设置全曲最小音量"""
if volume_value > 1 or volume_value <= 0:
raise IllegalMinimumVolumeError(
@ -753,7 +753,7 @@ class MusicSequence:
)
self.minimum_volume = volume_value
def set_deviation(self, deviation_value: int):
def set_deviation(self, deviation_value: float):
"""重新设置全曲音调偏移"""
self.music_deviation = deviation_value
@ -1025,13 +1025,14 @@ class MidiConvert(MusicSequence):
return cls.from_mido(
mido_file=midi_obj,
midi_music_name=midi_name,
mismatch_error_ignorance=ignore_mismatch_error,
speed_multiplier=playment_speed,
default_tempo=default_tempo_value,
pitched_note_referance_table=pitched_note_rtable,
percussion_note_referance_table=percussion_note_rtable,
minimum_vol=minimum_volume,
volume_processing_function=vol_processing_function,
default_tempo=default_tempo_value,
mismatch_error_ignorance=ignore_mismatch_error,
deviation=0, # 加么?感觉不加也没问题……?
note_referance_table_replacement=note_rtable_replacement,
)
@ -1644,14 +1645,19 @@ class MidiConvert(MusicSequence):
return command_dict, notes_list[-1].start_tick, max_multi
def copy_important(self):
dst = MidiConvert.from_mido_obj(
midi_obj=mido.MidiFile(),
midi_name=self.music_name,
enable_old_exe_format=self.enable_old_exe_format,
pitched_note_rtable={},
percussion_note_rtable={},
vol_processing_function=lambda a: a,
dst = MidiConvert(
name_of_music=self.music_name,
channels_of_notes={},
music_note_count=0,
note_used_per_instrument={},
minimum_volume_of_music=self.minimum_volume,
deviation_value=self.music_deviation,
# enable_old_exe_format=self.enable_old_exe_format,
# pitched_note_rtable={},
# percussion_note_rtable={},
# vol_processing_function=lambda a: a,
)
dst.enable_old_exe_format = self.enable_old_exe_format
dst.music_command_list = [i.copy() for i in self.music_command_list]
dst.progress_bar_command = [i.copy() for i in self.progress_bar_command]
return dst

View File

@ -331,12 +331,14 @@ def midi_msgs_to_minenote(
# )
def is_in_diapason(note_pitch: int, instrument: str) -> bool:
def is_in_diapason(note_pitch: float, instrument: str) -> bool:
note_range = MM_INSTRUMENT_RANGE_TABLE.get(instrument, ((-1, 128), 0))[0]
return note_pitch >= note_range[0] and note_pitch <= note_range[1]
def is_note_in_diapason(note_: MineNote) -> bool:
def is_note_in_diapason(
note_: MineNote,
) -> bool:
note_range = MM_INSTRUMENT_RANGE_TABLE.get(note_.sound_name, ((-1, 128), 0))[0]
return note_.note_pitch >= note_range[0] and note_.note_pitch <= note_range[1]

View File

@ -14,6 +14,7 @@ from typing import Optional, Tuple
import Musicreater.experiment
from Musicreater.plugin.archive import compress_zipfile
from Musicreater.utils import guess_deviation, is_in_diapason
def to_zip_pack_in_score(
@ -120,27 +121,52 @@ def to_zip_pack_in_score(
return maxlen, maxscore
print(
to_zip_pack_in_score(
Musicreater.experiment.FutureMidiConvertJavaE.from_midi_file(
input("midi路径"),
play_speed=float(input("播放速度:")),
old_exe_format=True,
note_table_replacement={
"note.iron_xylophone": "note.xylophone",
"note.cow_bell": "note.xylophone",
"note.didgeridoo": "note.guitar",
"note.bit": "note.harp",
"note.banjo": "note.flute",
"note.pling": "note.harp",
},
# pitched_note_table=Musicreater.MM_NBS_PITCHED_INSTRUMENT_TABLE,
),
input("输出路径:"),
Musicreater.experiment.ProgressBarStyle(),
# Musicreater.plugin.ConvertConfig(input("输出路径:"),),
scoreboard_name=input("计分板名称:"),
sound_source=input("发音源:"),
auto_reset=True,
msc_cvt = Musicreater.experiment.FutureMidiConvertJavaE.from_midi_file(
input("midi路径"),
play_speed=float(input("播放速度:")),
old_exe_format=True,
note_table_replacement={
"note.iron_xylophone": "note.xylophone",
"note.cow_bell": "note.xylophone",
"note.didgeridoo": "note.guitar",
"note.bit": "note.harp",
"note.banjo": "note.flute",
"note.pling": "note.harp",
},
# pitched_note_table=Musicreater.MM_NBS_PITCHED_INSTRUMENT_TABLE,
)
msc_cvt.set_deviation(
guess_deviation(
msc_cvt.total_note_count,
len(msc_cvt.note_count_per_instrument),
msc_cvt.note_count_per_instrument,
music_channels=msc_cvt.channels,
)
)
in_diapason_count = 0
for this_note in [k for j in msc_cvt.channels.values() for k in j]:
if is_in_diapason(
this_note.note_pitch + msc_cvt.music_deviation, this_note.sound_name
):
in_diapason_count += 1
zip_res = to_zip_pack_in_score(
msc_cvt,
input("输出路径:"),
Musicreater.experiment.ProgressBarStyle(),
# Musicreater.plugin.ConvertConfig(input("输出路径:"),),
scoreboard_name=input("计分板名称:"),
sound_source=input("发音源:"),
auto_reset=True,
)
print(
"符合音符播放音高的音符数量:{}/{}({:.2f}%)".format(
in_diapason_count,
msc_cvt.total_note_count,
in_diapason_count * 100 / msc_cvt.total_note_count,
),
"\n指令数量:{};音乐总延迟:{}".format(*zip_res),
)

View File

@ -1,2 +1,93 @@
[project]
name = "Musicreater"
dynamic = ["version"]
requires-python = ">= 3.8, < 4.0"
dependencies = [
"mido >= 1.3",
"xxhash >= 3",
]
authors = [
{ name = "金羿Eilles" },
{ name = "玉衡Alioth" },
{ name = "鱼旧梦ElapsingDreams" },
{ name = "睿乐组织 TriMO", email = "TriM-Organization@hotmail.com" },
]
maintainers = [
{ name = "金羿Eilles", email = "EillesWan@outlook.com" },
]
description = "A free open source library used for dealing with **Minecraft** digital musics."
readme = "README_EN.md"
license = { file = "LICENSE.md" }
keywords = ["midi", "minecraft", "minecraft: bedrock edition"]
classifiers = [
"Intended Audience :: Developers",
"Natural Language :: Chinese (Simplified)",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Multimedia",
"Topic :: Multimedia :: Sound/Audio :: MIDI",
]
[project.urls]
# Homepage = "https://example.com"
# Documentation = "https://readthedocs.org"
Repository = "https://gitee.com/TriM-Organization/Musicreater"
Issues = "https://gitee.com/TriM-Organization/Musicreater/issues"
Mirror-Repository = "https://github.com/TriM-Organization/Musicreater"
Mirror-Issues = "https://github.com/TriM-Organization/Musicreater/issues"
[project.optional-dependencies]
full = [
"TrimMCStruct <= 0.0.5.9",
"brotli >= 1.0.0",
]
dev = [
"TrimMCStruct <= 0.0.5.9",
"brotli >= 1.0.0",
"rich",
"pyinstaller",
"twine",
]
[build-system]
requires = ["setuptools", "wheel",]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
# https://backend.pdm-project.org/build_config/#build-configurations
[tool.pdm.build]
# includes = [
# # "README_EN.md",
# # "README.md",
# # "LICENSE.md",
# # "Musicreater/",
# # "docs/",
# ]
source-includes = [
"README_EN.md",
"README.md",
"LICENSE.md",
]
excludes = [
"fcwslib/",
"bgArrayLib/",
"Packer/",
"resources/",
"./*.mid",
"./*.msq",
"./*.fsq",
"./MSCT_Packer.py",
"resources/poem.md",
]
[tool.pdm.version]
source = "file"
path = "Musicreater/__init__.py"

View File

@ -1,2 +0,0 @@
mido>=1.3
xxhash>=3

View File

@ -1,7 +1,7 @@
python -m build
uv build
python -m twine check dist/*
pause
python -m twine upload dist/* --verbose
uv publish
pause
python clean_update.py
pause

1242
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff