From 70674ec6f7f460545b8d94a2969e4877e3318e60 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Mon, 31 Jul 2023 22:28:14 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E4=BA=8E=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E8=A7=84Midi=E5=85=BC=E5=AE=B9=E6=80=A7=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E9=81=BF=E5=85=8D=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E6=83=85=E5=86=B5=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Musicreater/__init__.py | 4 ++-- Musicreater/main.py | 20 ++++++++------------ upload.bat | 2 +- upload.sh | 4 ---- upload_bgArray.bat | 3 --- 5 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 upload.sh delete mode 100644 upload_bgArray.bat diff --git a/Musicreater/__init__.py b/Musicreater/__init__.py index 3d27e5f..f538afc 100644 --- a/Musicreater/__init__.py +++ b/Musicreater/__init__.py @@ -17,8 +17,8 @@ Terms & Conditions: License.md in the root directory # 若需转载或借鉴 许可声明请查看仓库目录下的 License.md -__version__ = "1.2.0" -__vername__ = "更高效的算法管理" +__version__ = "1.2.1" +__vername__ = "扩大对有问题的Midi文件的兼容性" __author__ = (("金羿", "Eilles Wan"), ("诸葛亮与八卦阵", "bgArray"), ("鸣凤鸽子", "MingFengPigeon")) __all__ = [ # 主要类 diff --git a/Musicreater/main.py b/Musicreater/main.py index 3dbea68..c6dcf98 100644 --- a/Musicreater/main.py +++ b/Musicreater/main.py @@ -183,7 +183,7 @@ class MidiConvert: """文件名,不含路径且不含后缀""" try: - return cls(mido.MidiFile(midi_file_path), midi_music_name, old_exe_format) + return cls(mido.MidiFile(midi_file_path,clip=True), midi_music_name, old_exe_format) except (ValueError, TypeError) as E: raise MidiDestroyedError(f"文件{midi_file_path}损坏:{E}") except FileNotFoundError as E: @@ -537,18 +537,14 @@ class MidiConvert: midi_channels: ChannelType = empty_midi_channels() tempo = mido.midifiles.midifiles.DEFAULT_TEMPO - # a = 0 # 我们来用通道统计音乐信息 # 但是是用分轨的思路的 for track_no, track in enumerate(self.midi.tracks): - # print(track_no,track) microseconds = 0 if not track: continue - # print(track_no,"="*20) for msg in track: - # print("+++",msg) if msg.time != 0: microseconds += msg.time * tempo / self.midi.ticks_per_beat / 1000 @@ -556,9 +552,13 @@ class MidiConvert: if msg.type == "set_tempo": tempo = msg.tempo else: - - if not track_no in midi_channels[msg.channel].keys(): - midi_channels[msg.channel][track_no] = [] + + try: + if not track_no in midi_channels[msg.channel].keys(): + midi_channels[msg.channel][track_no] = [] + except AttributeError as E: + print(msg,E) + if msg.type == "program_change": midi_channels[msg.channel][track_no].append( ("PgmC", msg.program, microseconds) @@ -568,7 +568,6 @@ class MidiConvert: midi_channels[msg.channel][track_no].append( ("NoteS", msg.note, msg.velocity, microseconds) ) - # a+=1 elif (msg.type == "note_on" and msg.velocity == 0) or ( msg.type == "note_off" @@ -577,7 +576,6 @@ class MidiConvert: ("NoteE", msg.note, microseconds) ) - # print(a) """整合后的音乐通道格式 每个通道包括若干消息元素其中逃不过这三种: @@ -638,8 +636,6 @@ class MidiConvert: # 第十通道是打击乐通道 SpecialBits = True if i == 9 else False - # nowChannel = [] - for track_no, track in self.channels[i].items(): nowTrack = [] diff --git a/upload.bat b/upload.bat index e2e85a9..75ac19a 100644 --- a/upload.bat +++ b/upload.bat @@ -1,3 +1,3 @@ -python -m build +python setup.py sdist bdist_wheel python -m twine upload dist/* python clean_update.py diff --git a/upload.sh b/upload.sh deleted file mode 100644 index b2a59ec..0000000 --- a/upload.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -python -m build -python -m twine upload dist/* -python clean_update.py diff --git a/upload_bgArray.bat b/upload_bgArray.bat deleted file mode 100644 index 75ac19a..0000000 --- a/upload_bgArray.bat +++ /dev/null @@ -1,3 +0,0 @@ -python setup.py sdist bdist_wheel -python -m twine upload dist/* -python clean_update.py