解决一些小问题

This commit is contained in:
EillesWan 2024-05-02 02:00:04 +08:00
parent 382b0e1601
commit fe7c11636b
5 changed files with 43 additions and 28 deletions

View File

@ -17,7 +17,7 @@ Terms & Conditions: License.md in the root directory
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
__version__ = "2.1.0"
__version__ = "2.1.0.1"
__vername__ = "Websocket支持"
__author__ = (
("金羿", "Eilles Wan"),

View File

@ -153,7 +153,7 @@ class MusicSequence:
@classmethod
def from_mido(
cls,
mido_file: mido.MidiFile,
mido_file: Optional[mido.MidiFile],
midi_music_name: str,
mismatch_error_ignorance: bool = True,
speed_multiplier: float = 1,
@ -190,19 +190,24 @@ class MusicSequence:
deviation: float
全曲音调偏移值
"""
(
note_channels,
note_count_total,
inst_note_count,
) = cls.to_music_note_channels(
midi=mido_file,
speed=speed_multiplier,
pitched_note_rtable=pitched_note_referance_table,
percussion_note_rtable=percussion_note_referance_table,
default_tempo_value=default_tempo,
vol_processing_function=volume_processing_function,
ignore_mismatch_error=mismatch_error_ignorance,
)
if mido_file:
(
note_channels,
note_count_total,
inst_note_count,
) = cls.to_music_note_channels(
midi=mido_file,
speed=speed_multiplier,
pitched_note_rtable=pitched_note_referance_table,
percussion_note_rtable=percussion_note_referance_table,
default_tempo_value=default_tempo,
vol_processing_function=volume_processing_function,
ignore_mismatch_error=mismatch_error_ignorance,
)
else:
note_channels = {}
note_count_total = 0
inst_note_count = {}
return cls(
name_of_music=midi_music_name,
channels_of_notes=note_channels,
@ -549,7 +554,7 @@ class MidiConvert(MusicSequence):
@classmethod
def from_mido_obj(
cls,
midi_obj: mido.MidiFile,
midi_obj: Optional[mido.MidiFile],
midi_name: str,
ignore_mismatch_error: bool = True,
playment_speed: float = 1,

View File

@ -87,28 +87,33 @@ def to_websocket_server(
if music_to_play in musics.keys():
self.check_play = True
delay_of_now = 0
for cmd in musics[music_to_play][0]:
now_played_cmd = 0
_time = time.time()
for i in range(musics[music_to_play][1]):
if not self.check_play:
break
await asyncio.sleep((0.05 - (time.time() - _time)) % 0.05)
_time = time.time()
if progressbar_style:
await self.send_command(
"title {} actionbar {}".format(
whom_to_play,
progressbar_style.play_output(
played_delays=delay_of_now,
played_delays=i,
total_delays=musics[music_to_play][1],
music_name=music_to_play,
),
),
callback=self.cmd_feedback,
)
await self.send_command(
cmd.command_text.replace(replacement, whom_to_play),
callback=self.cmd_feedback,
)
delay_of_now += cmd.delay
await asyncio.sleep((time.time() - _time) + cmd.delay / 20)
delay_of_now += 1
if delay_of_now >= (cmd := musics[music_to_play][0][now_played_cmd]).delay:
await self.send_command(
cmd.command_text.replace(replacement, whom_to_play),
callback=self.cmd_feedback,
)
now_played_cmd += 1
delay_of_now = 0
else:
await self.send_command(
@ -125,6 +130,11 @@ def to_websocket_server(
):
self.check_play = False
elif response["body"]["message"].startswith(
("。终止连接", ".terminate", ".endconnection")
):
await self.disconnect()
server = fcwslib.Server(server=server_dist, port=server_port, debug_mode=True)
server.add_plugin(Plugin)
asyncio.run(server.run_forever())

View File

@ -736,7 +736,7 @@ class ProgressBarStyle:
.replace(r"%^s", str(total_delays))
.replace(r"%%t", mctick2timestr(played_delays))
.replace(r"%^t", mctick2timestr(total_delays))
.replace(r"%%%", str(int(10000 * played_delays / total_delays) / 100) + "%")
.replace(r"%%%", "{:0>5.2f}%".format(int(10000 * played_delays / total_delays) / 100))
.replace(
"_",
self.played_style,

View File

@ -3,7 +3,7 @@
</h1>
<p align="center">
<img width="128" height="128" src="https://gitee.com/TriM-Organization/Musicreater/raw/master/resources/msctIcon.ico">
<img width="128" height="128" src="https://gitee.com/TriM-Organization/Musicreater/raw/master/resources/msctIcon.png">
</img>
</p>
@ -69,9 +69,9 @@
## 作者 ✒
**金羿 Eilles**我的世界基岩版指令个人开发者B 站不知名 UP 江西在校高中生
**金羿 Eilles**我的世界基岩版指令作者个人开发者B 站不知名 UP 江西老表
**诸葛亮与八卦阵 bgArray**我的世界基岩版玩家喜欢编程和音乐深圳初二学生
**诸葛亮与八卦阵 bgArray**我的世界基岩版玩家喜欢编程和音乐深圳学生
**偷吃不是Touch Touch**我的世界基岩版指令师提供 BDX 导入测试支持