diff --git a/demo_convert.py b/demo_convert.py index 6719c85..cd4039f 100644 --- a/demo_convert.py +++ b/demo_convert.py @@ -88,7 +88,7 @@ if os.path.isdir(midipath): for i in os.listdir(midipath): if i.endswith('.mid'): print(f'正在操作{i}') - convertion.convert(midipath + '/' + i, outpath + '/' + i[:-4] + '.mcpack') + convertion.convert(midipath + '/' + i, outpath + '/' + i[:-4] ) if outFormat == 0: convertion.tomcpack( 1, diff --git a/demo_convert_bdx_byDelay.py b/demo_convert_bdx_byDelay.py new file mode 100644 index 0000000..45e48aa --- /dev/null +++ b/demo_convert_bdx_byDelay.py @@ -0,0 +1,67 @@ +# THIS PROGRAM IS ONLY A TEST EXAMPLE + + +from msctPkgver.main import * + +convertion = midiConvert() + +while True: + midipath = input('请输入midi文件路径:') + if os.path.exists(midipath): + break + else: + print('文件不存在,请重新输入') + +outpath = input('请输入输出路径:') + +if not os.path.exists(outpath): + os.makedirs(outpath) + +while True: + try: + authorname = input('请输入作者:') + isProgress = input('是否开启进度条(1|0):') + if isProgress != '': + isProgress = bool(int(isProgress)) + volume = input('请输入音量(0-1):') + if volume != '': + volume = float(volume) + speed = input('请输入速度倍率:') + if speed != '': + speed = float(speed) + player = input('请输入玩家选择器:') + heightmax = input('请输入指令结构最大生成高度:') + if heightmax != '': + heightmax = int(heightmax) + break + + except: + print('输入错误,请重新输入') + + +if os.path.isdir(midipath): + for i in os.listdir(midipath): + if i.endswith('.mid'): + print(f'正在操作{i}') + convertion.convert(midipath + '/' + i, outpath) + convertion.toBDXfile_withDelay( + 1, + authorname if authorname != '' else input('请输入作者:'), + isProgress if isProgress != '' else bool(int(input('是否开启进度条(1|0):'))), + heightmax if heightmax != '' else int(input('请输入指令结构最大生成高度:')), + volume if volume != '' else float(input('请输入音量(0-1]:')), + speed if speed != '' else float(input('请输入速度倍率:')), + player if player != '' else input('请输入玩家选择器:'), + ) + +else: + convertion.convert(midipath, outpath) + convertion.toBDXfile_withDelay( + 1, + authorname if authorname != '' else input('请输入作者:'), + isProgress if isProgress != '' else bool(int(input('是否开启进度条(1|0):'))), + heightmax if heightmax != '' else int(input('请输入指令结构最大生成高度:')), + volume if volume != '' else float(input('请输入音量(0-1]:')), + speed if speed != '' else float(input('请输入速度倍率:')), + player if player != '' else input('请输入玩家选择器:'), + ) \ No newline at end of file diff --git a/example_convert_bdx_byDelay.py b/example_convert_bdx_byDelay.py deleted file mode 100644 index a73fb46..0000000 --- a/example_convert_bdx_byDelay.py +++ /dev/null @@ -1,17 +0,0 @@ -# THIS PROGRAM IS ONLY A TEST EXAMPLE - - -from msctPkgver.main import * - -convertion = midiConvert() -convertion.convert(input('请输入midi文件路径:'), input('请输入输出路径:')) -for i in convertion.toBDXfile_withDelay( - 1, - input('请输入作者:'), - bool(int(input('是否开启进度条(1|0):'))), - int(input('请输入指令结构最大生成高度:')), - float(input('请输入音量(0-1]:')), - float(input('请输入速度倍率:')), - input('请输入玩家选择器(例@a[tag=ply]):'), -): - print(i) diff --git a/msctPkgver/main.py b/msctPkgver/main.py index 25903b5..255649a 100644 --- a/msctPkgver/main.py +++ b/msctPkgver/main.py @@ -31,6 +31,8 @@ Note! Except for this source file, all the files in this repository and this pro """ import os +import mido +import brotli def makeZip(sourceDir, outFilename, compression=8, exceptFile=None): @@ -63,8 +65,6 @@ class midiConvert: def convert(self, midiFile: str, outputPath: str): '''转换前需要先运行此函数来获取基本信息''' - import mido - self.midiFile = midiFile '''midi文件路径''' self.midi = mido.MidiFile(self.midiFile) @@ -672,8 +672,6 @@ class midiConvert: :return 成功与否,成功返回(True,未经过压缩的源,结构占用大小),失败返回(False,str失败原因) """ - import brotli - if method == 1: cmdlist, totalcount, maxScore = self._toCmdList_m1( scoreboardname, volume, speed @@ -809,8 +807,6 @@ class midiConvert: :return 成功与否,成功返回(True,未经过压缩的源,结构占用大小),失败返回(False,str失败原因) """ - import brotli - if method == 1: cmdlist = self._toCmdList_withDelay_m1(volume, speed, player, progressbar) else: