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