mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2025-01-31 15:31:55 +08:00
修复了打击乐器转换时,注释部分format代码报错的问题
This commit is contained in:
parent
dbb3f4c83f
commit
99a7564648
@ -17,8 +17,8 @@ Terms & Conditions: License.md in the root directory
|
|||||||
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
||||||
|
|
||||||
|
|
||||||
__version__ = "1.7.1"
|
__version__ = "1.7.2"
|
||||||
__vername__ = "更高的自定义化程度—修复类型定义的重复问题"
|
__vername__ = "修复部分情况下的崩溃问题"
|
||||||
__author__ = (
|
__author__ = (
|
||||||
("金羿", "Eilles Wan"),
|
("金羿", "Eilles Wan"),
|
||||||
("诸葛亮与八卦阵", "bgArray"),
|
("诸葛亮与八卦阵", "bgArray"),
|
||||||
@ -33,7 +33,6 @@ __all__ = [
|
|||||||
"SingleCommand",
|
"SingleCommand",
|
||||||
"SingleNoteBox",
|
"SingleNoteBox",
|
||||||
# "TimeStamp", 未来功能
|
# "TimeStamp", 未来功能
|
||||||
|
|
||||||
# 默认值
|
# 默认值
|
||||||
"DEFAULT_PROGRESSBAR_STYLE",
|
"DEFAULT_PROGRESSBAR_STYLE",
|
||||||
"MM_INSTRUMENT_DEVIATION_TABLE",
|
"MM_INSTRUMENT_DEVIATION_TABLE",
|
||||||
|
@ -20,7 +20,11 @@ Terms & Conditions: License.md in the root directory
|
|||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .subclass import *
|
from .subclass import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .main import MidiConvert, MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
from .main import (
|
||||||
|
MidiConvert,
|
||||||
|
MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE,
|
||||||
|
MM_CLASSIC_PITCHED_INSTRUMENT_TABLE,
|
||||||
|
)
|
||||||
from .types import Tuple, List, Dict, ChannelType
|
from .types import Tuple, List, Dict, ChannelType
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +79,7 @@ class FutureMidiConvertM4(MidiConvert):
|
|||||||
lastime=int(_note.duration / totalCount),
|
lastime=int(_note.duration / totalCount),
|
||||||
track_number=_note.track_no,
|
track_number=_note.track_no,
|
||||||
is_percussion=_note.percussive,
|
is_percussion=_note.percussive,
|
||||||
extra_information=_note.extra_info
|
extra_information=_note.extra_info,
|
||||||
)
|
)
|
||||||
# (
|
# (
|
||||||
# _note.start_time + _i * _apply_time_division,
|
# _note.start_time + _i * _apply_time_division,
|
||||||
@ -120,8 +124,18 @@ class FutureMidiConvertM4(MidiConvert):
|
|||||||
# 此处 我们把通道视为音轨
|
# 此处 我们把通道视为音轨
|
||||||
for channel in self.to_music_note_channels().values():
|
for channel in self.to_music_note_channels().values():
|
||||||
for note in channel:
|
for note in channel:
|
||||||
note.set_info(note_to_command_parameters(note,self.percussion_note_referrence_table if note.percussive else self.pitched_note_reference_table, (max_volume) if note.track_no == 0 else (max_volume * 0.9),self.volume_processing_function,))
|
note.set_info(
|
||||||
|
note_to_command_parameters(
|
||||||
|
note,
|
||||||
|
(
|
||||||
|
self.percussion_note_referrence_table
|
||||||
|
if note.percussive
|
||||||
|
else self.pitched_note_reference_table
|
||||||
|
),
|
||||||
|
(max_volume) if note.track_no == 0 else (max_volume * 0.9),
|
||||||
|
self.volume_processing_function,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if not note.percussive:
|
if not note.percussive:
|
||||||
notes_list.extend(self._linear_note(note, note.extra_info[3] * 500))
|
notes_list.extend(self._linear_note(note, note.extra_info[3] * 500))
|
||||||
@ -239,7 +253,7 @@ class FutureMidiConvertM5(MidiConvert):
|
|||||||
self.channels: ChannelType = midi_channels
|
self.channels: ChannelType = midi_channels
|
||||||
# [print([print(no,tno,sum([True if i[0] == 'NoteS' else False for i in track])) for tno,track in cna.items()]) if cna else False for no,cna in midi_channels.items()]
|
# [print([print(no,tno,sum([True if i[0] == 'NoteS' else False for i in track])) for tno,track in cna.items()]) if cna else False for no,cna in midi_channels.items()]
|
||||||
return midi_channels
|
return midi_channels
|
||||||
|
|
||||||
# 神奇的偏移音
|
# 神奇的偏移音
|
||||||
def to_command_list_in_delay(
|
def to_command_list_in_delay(
|
||||||
self,
|
self,
|
||||||
@ -291,9 +305,13 @@ class FutureMidiConvertM5(MidiConvert):
|
|||||||
|
|
||||||
elif msg[0] == "NoteS":
|
elif msg[0] == "NoteS":
|
||||||
soundID, _X = (
|
soundID, _X = (
|
||||||
inst_to_sould_with_deviation(msg[1],MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
inst_to_sould_with_deviation(
|
||||||
|
msg[1], MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
if SpecialBits
|
if SpecialBits
|
||||||
else inst_to_sould_with_deviation(InstID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
else inst_to_sould_with_deviation(
|
||||||
|
InstID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
score_now = round(msg[-1] / float(speed) / 50)
|
score_now = round(msg[-1] / float(speed) / 50)
|
||||||
|
@ -30,16 +30,16 @@ Terms & Conditions: ../License.md
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============================
|
# ============================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import mido
|
import mido
|
||||||
|
|
||||||
|
|
||||||
class NoteMessage:
|
class NoteMessage:
|
||||||
def __init__(self, channel, pitch, velocity, startT, lastT, midi, now_bpm, change_bpm=None):
|
def __init__(
|
||||||
|
self, channel, pitch, velocity, startT, lastT, midi, now_bpm, change_bpm=None
|
||||||
|
):
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.note = pitch
|
self.note = pitch
|
||||||
self.velocity = velocity
|
self.velocity = velocity
|
||||||
@ -49,19 +49,39 @@ class NoteMessage:
|
|||||||
|
|
||||||
def mt2gt(mt, tpb_a, bpm_a):
|
def mt2gt(mt, tpb_a, bpm_a):
|
||||||
return mt / tpb_a / bpm_a * 60
|
return mt / tpb_a / bpm_a * 60
|
||||||
self.startTrueTime = mt2gt(self.startTime, midi.ticks_per_beat, self.tempo) # / 20
|
|
||||||
|
self.startTrueTime = mt2gt(
|
||||||
|
self.startTime, midi.ticks_per_beat, self.tempo
|
||||||
|
) # / 20
|
||||||
# delete_extra_zero(round_up())
|
# delete_extra_zero(round_up())
|
||||||
if change_bpm is not None:
|
if change_bpm is not None:
|
||||||
self.lastTrueTime = mt2gt(self.lastTime, midi.ticks_per_beat, change_bpm) # / 20
|
self.lastTrueTime = mt2gt(
|
||||||
|
self.lastTime, midi.ticks_per_beat, change_bpm
|
||||||
|
) # / 20
|
||||||
else:
|
else:
|
||||||
self.lastTrueTime = mt2gt(self.lastTime, midi.ticks_per_beat, self.tempo) # / 20
|
self.lastTrueTime = mt2gt(
|
||||||
|
self.lastTime, midi.ticks_per_beat, self.tempo
|
||||||
|
) # / 20
|
||||||
# delete_extra_zero(round_up())
|
# delete_extra_zero(round_up())
|
||||||
print((self.startTime * self.tempo) / (midi.ticks_per_beat * 50000))
|
print((self.startTime * self.tempo) / (midi.ticks_per_beat * 50000))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "noteMessage channel=" + str(self.channel) + " note=" + str(self.note) + " velocity=" + \
|
return (
|
||||||
str(self.velocity) + " startTime=" + str(self.startTime) + " lastTime=" + str(self.lastTime) + \
|
"noteMessage channel="
|
||||||
" startTrueTime=" + str(self.startTrueTime) + " lastTrueTime=" + str(self.lastTrueTime)
|
+ str(self.channel)
|
||||||
|
+ " note="
|
||||||
|
+ str(self.note)
|
||||||
|
+ " velocity="
|
||||||
|
+ str(self.velocity)
|
||||||
|
+ " startTime="
|
||||||
|
+ str(self.startTime)
|
||||||
|
+ " lastTime="
|
||||||
|
+ str(self.lastTime)
|
||||||
|
+ " startTrueTime="
|
||||||
|
+ str(self.startTrueTime)
|
||||||
|
+ " lastTrueTime="
|
||||||
|
+ str(self.lastTrueTime)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def load(mid: mido.MidiFile):
|
def load(mid: mido.MidiFile):
|
||||||
@ -75,7 +95,7 @@ def load(mid: mido.MidiFile):
|
|||||||
for msg in track:
|
for msg in track:
|
||||||
# print(msg)
|
# print(msg)
|
||||||
if msg.is_meta is not True:
|
if msg.is_meta is not True:
|
||||||
if msg.type == 'note_on' and msg.velocity == 0:
|
if msg.type == "note_on" and msg.velocity == 0:
|
||||||
type_[1] = True
|
type_[1] = True
|
||||||
elif msg.type == "note_off":
|
elif msg.type == "note_off":
|
||||||
type_[0] = True
|
type_[0] = True
|
||||||
@ -105,13 +125,13 @@ def load(mid: mido.MidiFile):
|
|||||||
print(ticks)
|
print(ticks)
|
||||||
if msg.is_meta is True and msg.type == "set_tempo":
|
if msg.is_meta is True and msg.type == "set_tempo":
|
||||||
recent_change_bpm = bpm
|
recent_change_bpm = bpm
|
||||||
bpm = 60000000 / msg.tempo
|
bpm = 60000000 / msg.tempo
|
||||||
is_change_bpm = True
|
is_change_bpm = True
|
||||||
|
|
||||||
if msg.type == 'note_on' and msg.velocity != 0:
|
if msg.type == "note_on" and msg.velocity != 0:
|
||||||
noteOn.append([msg, msg.note, ticks])
|
noteOn.append([msg, msg.note, ticks])
|
||||||
if type_[1] is True:
|
if type_[1] is True:
|
||||||
if msg.type == 'note_on' and msg.velocity == 0:
|
if msg.type == "note_on" and msg.velocity == 0:
|
||||||
for u in noteOn:
|
for u in noteOn:
|
||||||
index = 0
|
index = 0
|
||||||
if u[1] == msg.note:
|
if u[1] == msg.note:
|
||||||
@ -121,13 +141,31 @@ def load(mid: mido.MidiFile):
|
|||||||
index += 1
|
index += 1
|
||||||
print(lastTick)
|
print(lastTick)
|
||||||
if is_change_bpm and recent_change_bpm != 0:
|
if is_change_bpm and recent_change_bpm != 0:
|
||||||
trackS.append(NoteMessage(msg.channel, msg.note, lastMessage.velocity, lastTick, ticks - lastTick,
|
trackS.append(
|
||||||
mid, recent_change_bpm, bpm))
|
NoteMessage(
|
||||||
|
msg.channel,
|
||||||
|
msg.note,
|
||||||
|
lastMessage.velocity,
|
||||||
|
lastTick,
|
||||||
|
ticks - lastTick,
|
||||||
|
mid,
|
||||||
|
recent_change_bpm,
|
||||||
|
bpm,
|
||||||
|
)
|
||||||
|
)
|
||||||
is_change_bpm = False
|
is_change_bpm = False
|
||||||
else:
|
else:
|
||||||
trackS.append(
|
trackS.append(
|
||||||
NoteMessage(msg.channel, msg.note, lastMessage.velocity, lastTick, ticks - lastTick,
|
NoteMessage(
|
||||||
mid, bpm))
|
msg.channel,
|
||||||
|
msg.note,
|
||||||
|
lastMessage.velocity,
|
||||||
|
lastTick,
|
||||||
|
ticks - lastTick,
|
||||||
|
mid,
|
||||||
|
bpm,
|
||||||
|
)
|
||||||
|
)
|
||||||
# print(noteOn)
|
# print(noteOn)
|
||||||
# print(index)
|
# print(index)
|
||||||
try:
|
try:
|
||||||
@ -139,20 +177,19 @@ def load(mid: mido.MidiFile):
|
|||||||
print(j)
|
print(j)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
load(mido.MidiFile("test.mid"))
|
load(mido.MidiFile("test.mid"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============================
|
# ============================
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
from ..constants import x,y,z
|
from ..constants import x, y, z
|
||||||
|
|
||||||
|
|
||||||
# 不要用 没写完
|
# 不要用 没写完
|
||||||
def delay_to_note_blocks(
|
def delay_to_note_blocks(
|
||||||
baseblock: str = "stone",
|
baseblock: str = "stone",
|
||||||
position_forward: Literal['x','y','z'] = z,
|
position_forward: Literal["x", "y", "z"] = z,
|
||||||
):
|
):
|
||||||
"""传入音符,生成以音符盒存储的红石音乐
|
"""传入音符,生成以音符盒存储的红石音乐
|
||||||
:param:
|
:param:
|
||||||
@ -169,8 +206,7 @@ def delay_to_note_blocks(
|
|||||||
|
|
||||||
log = print
|
log = print
|
||||||
|
|
||||||
startpos = [0,0,0]
|
startpos = [0, 0, 0]
|
||||||
|
|
||||||
|
|
||||||
# 1拍 x 2.5 rt
|
# 1拍 x 2.5 rt
|
||||||
for i in notes:
|
for i in notes:
|
||||||
@ -180,7 +216,10 @@ def delay_to_note_blocks(
|
|||||||
[startpos[0], startpos[1] + 1, startpos[2]],
|
[startpos[0], startpos[1] + 1, startpos[2]],
|
||||||
form_note_block_in_NBT_struct(height2note[i[0]], instrument),
|
form_note_block_in_NBT_struct(height2note[i[0]], instrument),
|
||||||
)
|
)
|
||||||
struct.set_block(startpos, Block("universal_minecraft", instuments[i[0]][1]),)
|
struct.set_block(
|
||||||
|
startpos,
|
||||||
|
Block("universal_minecraft", instuments[i[0]][1]),
|
||||||
|
)
|
||||||
error = False
|
error = False
|
||||||
except ValueError:
|
except ValueError:
|
||||||
log("无法放置音符:" + str(i) + "于" + str(startpos))
|
log("无法放置音符:" + str(i) + "于" + str(startpos))
|
||||||
@ -222,4 +261,4 @@ def delay_to_note_blocks(
|
|||||||
struct.set_block(Block("universal_minecraft", baseblock), startpos)
|
struct.set_block(Block("universal_minecraft", baseblock), startpos)
|
||||||
startpos[0] += posadder[0]
|
startpos[0] += posadder[0]
|
||||||
startpos[1] += posadder[1]
|
startpos[1] += posadder[1]
|
||||||
startpos[2] += posadder[2]
|
startpos[2] += posadder[2]
|
||||||
|
@ -260,7 +260,9 @@ class MidiConvert:
|
|||||||
if r"%%%" in pgs_style:
|
if r"%%%" in pgs_style:
|
||||||
result.append(
|
result.append(
|
||||||
SingleCommand(
|
SingleCommand(
|
||||||
'scoreboard objectives add {}PercT dummy "百分比计算"'.format(sbn_pc),
|
'scoreboard objectives add {}PercT dummy "百分比计算"'.format(
|
||||||
|
sbn_pc
|
||||||
|
),
|
||||||
annotation="新增临时百分比变量",
|
annotation="新增临时百分比变量",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -325,13 +327,17 @@ class MidiConvert:
|
|||||||
if r"%%t" in pgs_style:
|
if r"%%t" in pgs_style:
|
||||||
result.append(
|
result.append(
|
||||||
SingleCommand(
|
SingleCommand(
|
||||||
'scoreboard objectives add {}TMinT dummy "时间计算:分"'.format(sbn_pc),
|
'scoreboard objectives add {}TMinT dummy "时间计算:分"'.format(
|
||||||
|
sbn_pc
|
||||||
|
),
|
||||||
annotation="新增临时分变量",
|
annotation="新增临时分变量",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result.append(
|
result.append(
|
||||||
SingleCommand(
|
SingleCommand(
|
||||||
'scoreboard objectives add {}TSecT dummy "时间计算:秒"'.format(sbn_pc),
|
'scoreboard objectives add {}TSecT dummy "时间计算:秒"'.format(
|
||||||
|
sbn_pc
|
||||||
|
),
|
||||||
annotation="新增临时秒变量",
|
annotation="新增临时秒变量",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -589,7 +595,9 @@ class MidiConvert:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise NoteOnOffMismatchError(
|
raise NoteOnOffMismatchError(
|
||||||
"当前的MIDI很可能有损坏之嫌……", msg, "无法在上文中找到与之匹配的音符开音消息。"
|
"当前的MIDI很可能有损坏之嫌……",
|
||||||
|
msg,
|
||||||
|
"无法在上文中找到与之匹配的音符开音消息。",
|
||||||
)
|
)
|
||||||
|
|
||||||
"""整合后的音乐通道格式
|
"""整合后的音乐通道格式
|
||||||
@ -663,27 +671,46 @@ class MidiConvert:
|
|||||||
mc_pitch,
|
mc_pitch,
|
||||||
) = note_to_command_parameters(
|
) = note_to_command_parameters(
|
||||||
note,
|
note,
|
||||||
self.percussion_note_referrence_table
|
(
|
||||||
if note.percussive
|
self.percussion_note_referrence_table
|
||||||
else self.pitched_note_reference_table,
|
if note.percussive
|
||||||
|
else self.pitched_note_reference_table
|
||||||
|
),
|
||||||
(max_volume) if note.track_no == 0 else (max_volume * 0.9),
|
(max_volume) if note.track_no == 0 else (max_volume * 0.9),
|
||||||
self.volume_processing_function,
|
self.volume_processing_function,
|
||||||
)
|
)
|
||||||
|
|
||||||
this_channel.append(
|
this_channel.append(
|
||||||
SingleCommand(
|
SingleCommand(
|
||||||
self.execute_cmd_head.format(
|
(
|
||||||
"@a[scores=({}={})]".format(scoreboard_name, score_now)
|
self.execute_cmd_head.format(
|
||||||
.replace("(", r"{")
|
"@a[scores=({}={})]".format(scoreboard_name, score_now)
|
||||||
.replace(")", r"}")
|
.replace("(", r"{")
|
||||||
)
|
.replace(")", r"}")
|
||||||
+ r"playsound {} @s ^ ^ ^{} {} {}".format(
|
)
|
||||||
mc_sound_ID, mc_distance_volume, volume_percentage, mc_pitch
|
+ r"playsound {} @s ^ ^ ^{} {}".format(
|
||||||
|
mc_sound_ID, mc_distance_volume, volume_percentage
|
||||||
|
)
|
||||||
|
if note.percussive
|
||||||
|
else r"playsound {} @s ^ ^ ^{} {} {}".format(
|
||||||
|
mc_sound_ID,
|
||||||
|
mc_distance_volume,
|
||||||
|
volume_percentage,
|
||||||
|
mc_pitch,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
annotation="在{}播放{}%的{}音".format(
|
annotation=(
|
||||||
mctick2timestr(score_now),
|
"在{}播放{}%的{}噪音".format(
|
||||||
max_volume * 100,
|
mctick2timestr(score_now),
|
||||||
"{}:{:.2f}".format(mc_sound_ID, mc_pitch),
|
max_volume * 100,
|
||||||
|
mc_sound_ID,
|
||||||
|
)
|
||||||
|
if note.percussive
|
||||||
|
else "在{}播放{}%的{}乐音".format(
|
||||||
|
mctick2timestr(score_now),
|
||||||
|
max_volume * 100,
|
||||||
|
"{}:{:.2f}".format(mc_sound_ID, mc_pitch),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -751,29 +778,45 @@ class MidiConvert:
|
|||||||
mc_pitch,
|
mc_pitch,
|
||||||
) = note_to_command_parameters(
|
) = note_to_command_parameters(
|
||||||
note,
|
note,
|
||||||
self.percussion_note_referrence_table
|
(
|
||||||
if note.percussive
|
self.percussion_note_referrence_table
|
||||||
else self.pitched_note_reference_table,
|
if note.percussive
|
||||||
|
else self.pitched_note_reference_table
|
||||||
|
),
|
||||||
(max_volume) if note.track_no == 0 else (max_volume * 0.9),
|
(max_volume) if note.track_no == 0 else (max_volume * 0.9),
|
||||||
self.volume_processing_function,
|
self.volume_processing_function,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.music_command_list.append(
|
self.music_command_list.append(
|
||||||
SingleCommand(
|
SingleCommand(
|
||||||
self.execute_cmd_head.format(player_selector)
|
command=(
|
||||||
+ r"playsound {} @s ^ ^ ^{} {} {}".format(
|
self.execute_cmd_head.format(player_selector)
|
||||||
mc_sound_ID,
|
+ r"playsound {} @s ^ ^ ^{} {}".format(
|
||||||
mc_distance_volume,
|
mc_sound_ID, mc_distance_volume, volume_percentage
|
||||||
volume_percentage,
|
)
|
||||||
mc_pitch,
|
if note.percussive
|
||||||
|
else r"playsound {} @s ^ ^ ^{} {} {}".format(
|
||||||
|
mc_sound_ID,
|
||||||
|
mc_distance_volume,
|
||||||
|
volume_percentage,
|
||||||
|
mc_pitch,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
annotation=(
|
||||||
|
"在{}播放{}%的{}噪音".format(
|
||||||
|
mctick2timestr(delaytime_now),
|
||||||
|
max_volume * 100,
|
||||||
|
mc_sound_ID,
|
||||||
|
)
|
||||||
|
if note.percussive
|
||||||
|
else "在{}播放{}%的{}乐音".format(
|
||||||
|
mctick2timestr(delaytime_now),
|
||||||
|
max_volume * 100,
|
||||||
|
"{}:{:.2f}".format(mc_sound_ID, mc_pitch),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
tick_delay=tickdelay,
|
tick_delay=tickdelay,
|
||||||
annotation="在{}播放{}%的{}音".format(
|
),
|
||||||
mctick2timestr(delaytime_now),
|
|
||||||
max_volume * 100,
|
|
||||||
"{}:{:.2f}".format(mc_sound_ID, mc_pitch),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
delaytime_previous = delaytime_now
|
delaytime_previous = delaytime_now
|
||||||
|
|
||||||
|
@ -102,15 +102,17 @@ def to_addon_pack_in_score(
|
|||||||
+ scoreboard_name
|
+ scoreboard_name
|
||||||
+ " 1\n",
|
+ " 1\n",
|
||||||
(
|
(
|
||||||
"scoreboard players reset @a[scores={"
|
(
|
||||||
+ scoreboard_name
|
"scoreboard players reset @a[scores={"
|
||||||
+ "="
|
+ scoreboard_name
|
||||||
+ str(maxscore + 20)
|
+ "="
|
||||||
+ "..}]"
|
+ str(maxscore + 20)
|
||||||
+ f" {scoreboard_name}\n"
|
+ "..}]"
|
||||||
)
|
+ f" {scoreboard_name}\n"
|
||||||
if auto_reset
|
)
|
||||||
else "",
|
if auto_reset
|
||||||
|
else ""
|
||||||
|
),
|
||||||
f"function mscplay/progressShow\n" if data_cfg.progressbar_style else "",
|
f"function mscplay/progressShow\n" if data_cfg.progressbar_style else "",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -150,18 +150,20 @@ def commands_to_BDX_bytes(
|
|||||||
for command in commands_list:
|
for command in commands_list:
|
||||||
_bytes += form_command_block_in_BDX_bytes(
|
_bytes += form_command_block_in_BDX_bytes(
|
||||||
command.command_text,
|
command.command_text,
|
||||||
(1 if y_forward else 0)
|
(
|
||||||
if (
|
(1 if y_forward else 0)
|
||||||
((now_y != 0) and (not y_forward))
|
|
||||||
or (y_forward and (now_y != (max_height - 1)))
|
|
||||||
)
|
|
||||||
else (
|
|
||||||
(3 if z_forward else 2)
|
|
||||||
if (
|
if (
|
||||||
((now_z != 0) and (not z_forward))
|
((now_y != 0) and (not y_forward))
|
||||||
or (z_forward and (now_z != _sideLength - 1))
|
or (y_forward and (now_y != (max_height - 1)))
|
||||||
|
)
|
||||||
|
else (
|
||||||
|
(3 if z_forward else 2)
|
||||||
|
if (
|
||||||
|
((now_z != 0) and (not z_forward))
|
||||||
|
or (z_forward and (now_z != _sideLength - 1))
|
||||||
|
)
|
||||||
|
else 5
|
||||||
)
|
)
|
||||||
else 5
|
|
||||||
),
|
),
|
||||||
impluse=2,
|
impluse=2,
|
||||||
condition=command.conditional,
|
condition=command.conditional,
|
||||||
|
@ -85,13 +85,22 @@ class ConvertConfig:
|
|||||||
"""进度条样式"""
|
"""进度条样式"""
|
||||||
return
|
return
|
||||||
elif isinstance(progressbar, tuple):
|
elif isinstance(progressbar, tuple):
|
||||||
if isinstance(progressbar[0],str) and isinstance(progressbar[1], tuple):
|
if isinstance(progressbar[0], str) and isinstance(
|
||||||
if isinstance(progressbar[1][0], str) and isinstance(progressbar[1][1], str):
|
progressbar[1], tuple
|
||||||
self.progressbar_style = ProgressBarStyle(progressbar[0],progressbar[1][0],progressbar[1][1])
|
):
|
||||||
|
if isinstance(progressbar[1][0], str) and isinstance(
|
||||||
|
progressbar[1][1], str
|
||||||
|
):
|
||||||
|
self.progressbar_style = ProgressBarStyle(
|
||||||
|
progressbar[0], progressbar[1][0], progressbar[1][1]
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if not ignore_progressbar_param_error:
|
if not ignore_progressbar_param_error:
|
||||||
raise TypeError("参数 {} 的类型 {} 与所需类型 Union[bool, Tuple[str, Tuple[str, str]], ProgressBarStyle] 不符。".format(progressbar,type(progressbar)))
|
raise TypeError(
|
||||||
|
"参数 {} 的类型 {} 与所需类型 Union[bool, Tuple[str, Tuple[str, str]], ProgressBarStyle] 不符。".format(
|
||||||
|
progressbar, type(progressbar)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.progressbar_style = None
|
self.progressbar_style = None
|
||||||
"""进度条样式组"""
|
"""进度条样式组"""
|
||||||
|
|
||||||
|
@ -189,9 +189,11 @@ def form_command_block_in_NBT_struct(
|
|||||||
|
|
||||||
return Block(
|
return Block(
|
||||||
"minecraft",
|
"minecraft",
|
||||||
"command_block"
|
(
|
||||||
if impluse == 0
|
"command_block"
|
||||||
else ("repeating_command_block" if impluse == 1 else "chain_command_block"),
|
if impluse == 0
|
||||||
|
else ("repeating_command_block" if impluse == 1 else "chain_command_block")
|
||||||
|
),
|
||||||
states={"conditional_bit": condition, "facing_direction": particularValue},
|
states={"conditional_bit": condition, "facing_direction": particularValue},
|
||||||
extra_data={
|
extra_data={
|
||||||
"block_entity_data": {
|
"block_entity_data": {
|
||||||
@ -257,18 +259,20 @@ def commands_to_structure(
|
|||||||
form_command_block_in_NBT_struct(
|
form_command_block_in_NBT_struct(
|
||||||
command=command.command_text,
|
command=command.command_text,
|
||||||
coordinate=coordinate,
|
coordinate=coordinate,
|
||||||
particularValue=(1 if y_forward else 0)
|
particularValue=(
|
||||||
if (
|
(1 if y_forward else 0)
|
||||||
((now_y != 0) and (not y_forward))
|
|
||||||
or (y_forward and (now_y != (max_height - 1)))
|
|
||||||
)
|
|
||||||
else (
|
|
||||||
(3 if z_forward else 2)
|
|
||||||
if (
|
if (
|
||||||
((now_z != 0) and (not z_forward))
|
((now_y != 0) and (not y_forward))
|
||||||
or (z_forward and (now_z != _sideLength - 1))
|
or (y_forward and (now_y != (max_height - 1)))
|
||||||
|
)
|
||||||
|
else (
|
||||||
|
(3 if z_forward else 2)
|
||||||
|
if (
|
||||||
|
((now_z != 0) and (not z_forward))
|
||||||
|
or (z_forward and (now_z != _sideLength - 1))
|
||||||
|
)
|
||||||
|
else 5
|
||||||
)
|
)
|
||||||
else 5
|
|
||||||
),
|
),
|
||||||
impluse=2,
|
impluse=2,
|
||||||
condition=False,
|
condition=False,
|
||||||
@ -357,20 +361,16 @@ def commands_to_redstone_delay_structure(
|
|||||||
for cmd in commands:
|
for cmd in commands:
|
||||||
# print("\r 正在进行处理:",end="")
|
# print("\r 正在进行处理:",end="")
|
||||||
if cmd.delay > 2:
|
if cmd.delay > 2:
|
||||||
a_max = max(a,a_max)
|
a_max = max(a, a_max)
|
||||||
total_cmd += (a := 1)
|
total_cmd += (a := 1)
|
||||||
else:
|
else:
|
||||||
a += 1
|
a += 1
|
||||||
|
|
||||||
struct = Structure(
|
struct = Structure(
|
||||||
size=(
|
size=(
|
||||||
round(delay_length / 2 + total_cmd)
|
round(delay_length / 2 + total_cmd) if extensioon_direction == x else a_max,
|
||||||
if extensioon_direction == x
|
|
||||||
else a_max,
|
|
||||||
3,
|
3,
|
||||||
round(delay_length / 2 + total_cmd)
|
round(delay_length / 2 + total_cmd) if extensioon_direction == z else a_max,
|
||||||
if extensioon_direction == z
|
|
||||||
else a_max,
|
|
||||||
),
|
),
|
||||||
fill=Block("minecraft", "air", compability_version=compability_version_),
|
fill=Block("minecraft", "air", compability_version=compability_version_),
|
||||||
compability_version=compability_version_,
|
compability_version=compability_version_,
|
||||||
|
@ -154,9 +154,13 @@ class ObsoleteMidiConvert(MidiConvert):
|
|||||||
)
|
)
|
||||||
maxscore = max(maxscore, nowscore)
|
maxscore = max(maxscore, nowscore)
|
||||||
if msg.channel == 9:
|
if msg.channel == 9:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
|
|
||||||
singleTrack.append(
|
singleTrack.append(
|
||||||
"execute @a[scores={"
|
"execute @a[scores={"
|
||||||
@ -214,9 +218,13 @@ class ObsoleteMidiConvert(MidiConvert):
|
|||||||
)
|
)
|
||||||
maxscore = max(maxscore, nowscore)
|
maxscore = max(maxscore, nowscore)
|
||||||
if msg.channel == 9:
|
if msg.channel == 9:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
singleTrack.append(
|
singleTrack.append(
|
||||||
"execute @a[scores={"
|
"execute @a[scores={"
|
||||||
+ str(scoreboardname)
|
+ str(scoreboardname)
|
||||||
@ -277,9 +285,13 @@ class ObsoleteMidiConvert(MidiConvert):
|
|||||||
|
|
||||||
elif msg[0] == "NoteS":
|
elif msg[0] == "NoteS":
|
||||||
soundID, _X = (
|
soundID, _X = (
|
||||||
inst_to_sould_with_deviation(msg[1],MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
inst_to_sould_with_deviation(
|
||||||
|
msg[1], MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
if SpecialBits
|
if SpecialBits
|
||||||
else inst_to_sould_with_deviation(InstID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
else inst_to_sould_with_deviation(
|
||||||
|
InstID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
)
|
)
|
||||||
score_now = round(msg[-1] / float(speed) / 50)
|
score_now = round(msg[-1] / float(speed) / 50)
|
||||||
maxScore = max(maxScore, score_now)
|
maxScore = max(maxScore, score_now)
|
||||||
@ -343,11 +355,15 @@ class ObsoleteMidiConvert(MidiConvert):
|
|||||||
(ticks * tempo)
|
(ticks * tempo)
|
||||||
/ ((self.midi.ticks_per_beat * float(speed)) * 50000)
|
/ ((self.midi.ticks_per_beat * float(speed)) * 50000)
|
||||||
)
|
)
|
||||||
|
|
||||||
if msg.channel == 9:
|
if msg.channel == 9:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
soundID, _X = inst_to_sould_with_deviation(instrumentID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
soundID, _X = inst_to_sould_with_deviation(
|
||||||
|
instrumentID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
tracks[now_tick].append(
|
tracks[now_tick].append(
|
||||||
self.execute_cmd_head.format(player)
|
self.execute_cmd_head.format(player)
|
||||||
@ -421,9 +437,13 @@ class ObsoleteMidiConvert(MidiConvert):
|
|||||||
|
|
||||||
elif msg[0] == "NoteS":
|
elif msg[0] == "NoteS":
|
||||||
soundID, _X = (
|
soundID, _X = (
|
||||||
inst_to_sould_with_deviation(msg[1],MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE)
|
inst_to_sould_with_deviation(
|
||||||
|
msg[1], MM_CLASSIC_PERCUSSION_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
if SpecialBits
|
if SpecialBits
|
||||||
else inst_to_sould_with_deviation(InstID,MM_CLASSIC_PITCHED_INSTRUMENT_TABLE)
|
else inst_to_sould_with_deviation(
|
||||||
|
InstID, MM_CLASSIC_PITCHED_INSTRUMENT_TABLE
|
||||||
|
)
|
||||||
)
|
)
|
||||||
score_now = round(msg[-1] / float(speed) / 50)
|
score_now = round(msg[-1] / float(speed) / 50)
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ class ProgressBarStyle:
|
|||||||
self.played_style = value
|
self.played_style = value
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
dst = ProgressBarStyle(self.base_style,self.to_play_style,self.played_style)
|
dst = ProgressBarStyle(self.base_style, self.to_play_style, self.played_style)
|
||||||
return dst
|
return dst
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,19 @@ Terms & Conditions: License.md in the root directory
|
|||||||
# Email TriM-Organization@hotmail.com
|
# Email TriM-Organization@hotmail.com
|
||||||
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
||||||
|
|
||||||
from typing import Any, Dict, List, Literal, Optional, Tuple, Union, Iterable, Sequence, Mapping, Callable
|
from typing import (
|
||||||
|
Any,
|
||||||
|
Dict,
|
||||||
|
List,
|
||||||
|
Literal,
|
||||||
|
Optional,
|
||||||
|
Tuple,
|
||||||
|
Union,
|
||||||
|
Iterable,
|
||||||
|
Sequence,
|
||||||
|
Mapping,
|
||||||
|
Callable,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
MidiNoteNameTableType = Mapping[int, Tuple[str, ...]]
|
MidiNoteNameTableType = Mapping[int, Tuple[str, ...]]
|
||||||
@ -32,8 +44,6 @@ Midi乐器对照表类型
|
|||||||
FittingFunctionType = Callable[[float], float]
|
FittingFunctionType = Callable[[float], float]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ChannelType = Dict[
|
ChannelType = Dict[
|
||||||
int,
|
int,
|
||||||
Dict[
|
Dict[
|
||||||
|
@ -21,7 +21,16 @@ import random
|
|||||||
from .constants import MM_INSTRUMENT_DEVIATION_TABLE, MC_INSTRUMENT_BLOCKS_TABLE
|
from .constants import MM_INSTRUMENT_DEVIATION_TABLE, MC_INSTRUMENT_BLOCKS_TABLE
|
||||||
from .subclass import SingleNote
|
from .subclass import SingleNote
|
||||||
|
|
||||||
from .types import Any, Dict, Tuple, Optional, Callable, Literal, Union, MidiInstrumentTableType
|
from .types import (
|
||||||
|
Any,
|
||||||
|
Dict,
|
||||||
|
Tuple,
|
||||||
|
Optional,
|
||||||
|
Callable,
|
||||||
|
Literal,
|
||||||
|
Union,
|
||||||
|
MidiInstrumentTableType,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def mctick2timestr(mc_tick: int) -> str:
|
def mctick2timestr(mc_tick: int) -> str:
|
||||||
@ -77,9 +86,11 @@ def inst_to_sould_with_deviation(
|
|||||||
instrumentID,
|
instrumentID,
|
||||||
(
|
(
|
||||||
default_instrument,
|
default_instrument,
|
||||||
default_deviation
|
(
|
||||||
if default_deviation
|
default_deviation
|
||||||
else MM_INSTRUMENT_DEVIATION_TABLE.get(default_instrument, -1),
|
if default_deviation
|
||||||
|
else MM_INSTRUMENT_DEVIATION_TABLE.get(default_instrument, -1)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -136,7 +147,12 @@ def note_to_command_parameters(
|
|||||||
reference_table: MidiInstrumentTableType,
|
reference_table: MidiInstrumentTableType,
|
||||||
volume_percentage: float = 1,
|
volume_percentage: float = 1,
|
||||||
volume_processing_method: Callable[[float], float] = natural_curve,
|
volume_processing_method: Callable[[float], float] = natural_curve,
|
||||||
) -> Tuple[str, float, float, Union[float, Literal[None]],]:
|
) -> Tuple[
|
||||||
|
str,
|
||||||
|
float,
|
||||||
|
float,
|
||||||
|
Union[float, Literal[None]],
|
||||||
|
]:
|
||||||
"""
|
"""
|
||||||
将音符转为播放的指令
|
将音符转为播放的指令
|
||||||
:param note_:int 音符对象
|
:param note_:int 音符对象
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
pip install --upgrade -i https://pypi.python.org/simple Musicreater
|
pip install --upgrade -i https://pypi.python.org/simple Musicreater
|
||||||
```
|
```
|
||||||
|
|
||||||
- 克隆仓库并安装(**不推荐**)
|
- 克隆仓库并安装(最新版本但**不推荐**)
|
||||||
```bash
|
```bash
|
||||||
git clone https://gitee.com/TriM-Organization/Musicreater.git
|
git clone https://gitee.com/TriM-Organization/Musicreater.git
|
||||||
cd Musicreater
|
cd Musicreater
|
||||||
|
@ -49,7 +49,7 @@ Welcome to join our QQ group: [861684859](https://jq.qq.com/?_wv=1027&k=hpeRxrYr
|
|||||||
pip install -i https://pypi.python.org/simple Musicreater --upgrade
|
pip install -i https://pypi.python.org/simple Musicreater --upgrade
|
||||||
```
|
```
|
||||||
|
|
||||||
- Clone repo and Install (**NOT RECOMMANDED**):
|
- Clone repo and Install (Latest but **NOT RECOMMANDED**):
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/TriM-Organization/Musicreater.git
|
git clone https://github.com/TriM-Organization/Musicreater.git
|
||||||
cd Musicreater
|
cd Musicreater
|
||||||
@ -75,7 +75,7 @@ Commands such as `python`、`pip` could be changed to some like `python3` or `pi
|
|||||||
|
|
||||||
**Touch (偷吃不是Touch)**: A man who is used to use command(s) in _Minecraft: Bedrock Edition_, who supported us of debugging and testing program and algorithm
|
**Touch (偷吃不是Touch)**: A man who is used to use command(s) in _Minecraft: Bedrock Edition_, who supported us of debugging and testing program and algorithm
|
||||||
|
|
||||||
## Thanks 🙏
|
## Acknowledgements 🙏
|
||||||
|
|
||||||
This list is not in any order.
|
This list is not in any order.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user