diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..eaf91e2
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/Musicreater.iml b/.idea/Musicreater.iml
new file mode 100644
index 0000000..2946dc0
--- /dev/null
+++ b/.idea/Musicreater.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..a2a5d19
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..8d93904
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b125bed
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..9661ac7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Musicreater.py b/Musicreater.py
index 6629b00..f6a61fe 100644
--- a/Musicreater.py
+++ b/Musicreater.py
@@ -219,6 +219,15 @@ def __main__():
else:
return k
+ def MidiAnalysisClass(midfile: str):
+ from nmcsup.nmcreader import midiClassReader
+ k = midiClassReader(midfile)
+ if k is False:
+ tk.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[105].format(midfile))
+ return
+ else:
+ return k
+
print('完成!')
# 菜单命令
@@ -285,13 +294,13 @@ def __main__():
global is_save
is_save = True
except TypeError:
- SaveNewProject()
+ SaveClassProject()
return
def SaveNewProject():
if is_new_file:
# 新的项目相等于另存为
- SaveAsNewProject()
+ SaveAsClassProject() # SaveAsNewProject()
return
else:
save_list = [dataset]
@@ -306,6 +315,18 @@ def __main__():
global is_save
is_save = True
+ def SaveClassProject():
+ if is_new_file:
+ # 新的项目相等于另存为
+ SaveAsClassProject()
+ return
+ else:
+ with open(ProjectName, 'wb') as f:
+ pickle.dump(dataset, f)
+ tkinter.messagebox.showinfo(title=READABLETEXT[4], message=READABLETEXT[107].format(ProjectName))
+ global is_save
+ is_save = True
+
print('保存项目命令加载完成!')
def SaveAsProject():
@@ -349,6 +370,19 @@ def __main__():
global is_save
is_save = True
+ def SaveAsClassProject():
+ fn = tkinter.filedialog.asksaveasfilename(title=READABLETEXT[5], initialdir=r'./',
+ filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[109], '*')],
+ defaultextension='Noname.msct')
+ if fn is None or fn == '':
+ return
+ Project_Name = fn
+ with open(Project_Name, 'wb') as f:
+ pickle.dump(dataset, f)
+ tkinter.messagebox.showinfo(title=READABLETEXT[4], message=READABLETEXT[107].format(Project_Name))
+ global is_save
+ is_save = True
+
print('另存项目命令加载完成!')
def openOldProject():
@@ -447,6 +481,51 @@ def __main__():
RefreshMain()
RefreshMusic(NowMusic)
+ def openClassProject():
+ global is_save
+ if is_save is not True:
+ result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
+ if result:
+ SaveProject()
+ fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
+ filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
+ multiple=True)
+ if fn is None or fn == '':
+ return
+ else:
+ # print(fn)
+ fn = fn[0]
+ # print(fn)
+ log("尝试打开:" + fn)
+ try:
+ try:
+ with open(fn, 'rb') as C:
+ global dataset
+ # print(pickle.load(C))
+ read = pickle.load(C) # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
+ # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
+ # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
+ # print(read)
+ dataset = read
+ log("读取新文件成功")
+ except KeyError:
+ with open(fn, 'rb') as C:
+ dataset[0] = pickle.load(C)
+ log("读取新文件成功")
+ except pickle.UnpicklingError: # 程序规范修改:根据新的语法标准:except后面不能没有错误类型,测试后改为:
+ # pickle.UnpicklingError
+ print(READABLETEXT[8].format(fn))
+ log('无法打开{}'.format(fn))
+ return
+ global is_new_file
+ global ProjectName
+ is_new_file = False
+ ProjectName = fn
+ del fn
+ global NowMusic
+ RefreshMain()
+ RefreshMusic(NowMusic)
+
print('打开项目命令加载完成!')
def appabout():
@@ -557,8 +636,41 @@ def __main__():
threading.Thread(target=midiSPT, args=(th,)).start()
del th
- def MidiClass():
- log('从midi导入音乐并采用新读取方式')
+ def NewFromMidi():
+ try:
+ tkinter.messagebox.showinfo("开发提示", "因为一些原因这个功能暂时取消")
+ except tkinter.TclError:
+ log('从midi导入音乐并采用新读取方式')
+ midfile = tkinter.filedialog.askopenfilename(title=READABLETEXT[21], initialdir=r'./',
+ filetypes=[(READABLETEXT[114], '.mid .midi'),
+ (READABLETEXT[112], '*')], multiple=True)
+ if midfile is None or midfile == '':
+ log('取消')
+ return
+ else:
+ midfile = midfile[0]
+ th = NewThread(LoadMidi, (midfile,))
+ th.start()
+ del midfile
+
+ def midiSPT(th_):
+ for i in th_.getResult():
+ datas = DMM()
+ datas['notes'] = i
+ dataset[0]['musics'].append(datas)
+ del th_
+ global is_save
+ is_save = False
+ global NowMusic
+ RefreshMain()
+ RefreshMusic(NowMusic)
+
+ threading.Thread(target=midiSPT, args=(th,)).start()
+ del th
+ dataset[0]['mainset']['ReadMethod'] = "new"
+
+ def FromMidiClass():
+ log('从midi导入音乐并采用类读取方式')
midfile = tkinter.filedialog.askopenfilename(title=READABLETEXT[21], initialdir=r'./',
filetypes=[(READABLETEXT[114], '.mid .midi'),
(READABLETEXT[112], '*')], multiple=True)
@@ -567,7 +679,7 @@ def __main__():
return
else:
midfile = midfile[0]
- th = NewThread(LoadMidi, (midfile,))
+ th = NewThread(MidiAnalysisClass, (midfile,))
th.start()
del midfile
@@ -585,7 +697,7 @@ def __main__():
threading.Thread(target=midiSPT, args=(th,)).start()
del th
- dataset[0]['mainset']['ReadMethod'] = "new"
+ dataset[0]['mainset']['ReadMethod'] = "class"
print('读midi命令加载完成!')
@@ -1407,11 +1519,17 @@ def __main__():
filemenu.add_command(label=READABLETEXT[55], command=SaveProject)
filemenu.add_command(label=READABLETEXT[56], command=SaveAsProject)
+ # filemenu.add_separator()
+ #
+ # filemenu.add_command(label=READABLETEXT[149], command=openNewProject)
+ # filemenu.add_command(label=READABLETEXT[150], command=SaveNewProject)
+ # filemenu.add_command(label=READABLETEXT[151], command=SaveAsNewProject)
+
filemenu.add_separator()
- filemenu.add_command(label=READABLETEXT[149], command=openNewProject)
- filemenu.add_command(label=READABLETEXT[150], command=SaveNewProject)
- filemenu.add_command(label=READABLETEXT[151], command=SaveAsNewProject)
+ filemenu.add_command(label=READABLETEXT[161], command=openClassProject)
+ filemenu.add_command(label=READABLETEXT[162], command=SaveClassProject)
+ filemenu.add_command(label=READABLETEXT[163], command=SaveAsClassProject)
filemenu.add_separator() # 分隔符
@@ -1427,7 +1545,8 @@ def __main__():
editmenu.add_command(label=READABLETEXT[61], command=FromForm)
editmenu.add_command(label=READABLETEXT[62], command=FromText)
editmenu.add_separator()
- editmenu.add_command(label=READABLETEXT[148], command=MidiClass)
+ editmenu.add_command(label=READABLETEXT[160], command=FromMidiClass)
+ editmenu.add_command(label=READABLETEXT[148], command=NewFromMidi)
# 将子菜单加入到菜单条中
main_menu_bar.add_cascade(label=READABLETEXT[63], menu=editmenu)
diff --git a/bgArrayLib/__pycache__/__init__.cpython-39.pyc b/bgArrayLib/__pycache__/__init__.cpython-39.pyc
index fe1e90c..33ba708 100644
Binary files a/bgArrayLib/__pycache__/__init__.cpython-39.pyc and b/bgArrayLib/__pycache__/__init__.cpython-39.pyc differ
diff --git a/bgArrayLib/__pycache__/bpm.cpython-39.pyc b/bgArrayLib/__pycache__/bpm.cpython-39.pyc
index 5c12cda..433a7f9 100644
Binary files a/bgArrayLib/__pycache__/bpm.cpython-39.pyc and b/bgArrayLib/__pycache__/bpm.cpython-39.pyc differ
diff --git a/languages/__pycache__/__init__.cpython-39.pyc b/languages/__pycache__/__init__.cpython-39.pyc
index 7ebf6f0..8e57f6d 100644
Binary files a/languages/__pycache__/__init__.cpython-39.pyc and b/languages/__pycache__/__init__.cpython-39.pyc differ
diff --git a/languages/__pycache__/lang.cpython-39.pyc b/languages/__pycache__/lang.cpython-39.pyc
index db46249..6437691 100644
Binary files a/languages/__pycache__/lang.cpython-39.pyc and b/languages/__pycache__/lang.cpython-39.pyc differ
diff --git a/languages/__pycache__/zhCN.cpython-39.pyc b/languages/__pycache__/zhCN.cpython-39.pyc
index c7edc2e..b6b415c 100644
Binary files a/languages/__pycache__/zhCN.cpython-39.pyc and b/languages/__pycache__/zhCN.cpython-39.pyc differ
diff --git a/languages/zhCN.py b/languages/zhCN.py
index 3af1d06..09f2b34 100644
--- a/languages/zhCN.py
+++ b/languages/zhCN.py
@@ -171,6 +171,10 @@ READABLETEXT = {
156: "[神羽资源包位置选择]:选择文件夹...",
157: "没有路径文件(.rpposi文件),请仔细阅读Readme或先试用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 方法添加路径文件吧!",
158: "有路径文件(.rpposi文件),但路径指示错误,请仔细阅读Readme或先用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 更改路径!",
- 159: "更改路径文件(.rpposi文件)成功!!"
+ 159: "更改路径文件(.rpposi文件)成功!!",
+ 160: "从midi导入音轨且用类方法解析",
+ 161: "打开 类方法: 音·创项目...",
+ 162: "保存为类方法项目",
+ 163: "另存为类方法项...",
}
diff --git a/log/2022-01-28 17_43_56.logger b/log/2022-01-28 17_43_56.logger
new file mode 100644
index 0000000..e69de29
diff --git a/log/2022-01-28 18_19_20.logger b/log/2022-01-28 18_19_20.logger
new file mode 100644
index 0000000..bad3b7f
--- /dev/null
+++ b/log/2022-01-28 18_19_20.logger
@@ -0,0 +1,4 @@
+2022-01-28 18:19:20,019 - nmcsup.log - INFO - ִλãǰļλ L:\0WorldMusicCreater-MFMS new edition\\v0.5.3\Musicreater\Musicreater.py
+2022-01-28 18:19:20,503 - nmcsup.log - INFO - root.mainloopڣ
+2022-01-28 18:19:48,827 - nmcsup.log - INFO - midiֲȡʽ
+2022-01-28 18:19:57,915 - nmcsup.log - INFO - ˢ0
diff --git a/log/2022-01-28 18_20_50.logger b/log/2022-01-28 18_20_50.logger
new file mode 100644
index 0000000..a4a36bb
--- /dev/null
+++ b/log/2022-01-28 18_20_50.logger
@@ -0,0 +1,3 @@
+2022-01-28 18:20:50,054 - nmcsup.log - INFO - ִλãǰļλ L:\0WorldMusicCreater-MFMS new edition\\v0.5.3\Musicreater\Musicreater.py
+2022-01-28 18:20:50,293 - nmcsup.log - INFO - root.mainloopڣ
+2022-01-28 18:20:54,018 - nmcsup.log - INFO - midiֲȡʽ
diff --git a/log/2022-01-28 18_21_33.logger b/log/2022-01-28 18_21_33.logger
new file mode 100644
index 0000000..2998450
--- /dev/null
+++ b/log/2022-01-28 18_21_33.logger
@@ -0,0 +1,5 @@
+2022-01-28 18:21:33,187 - nmcsup.log - INFO - ִλãǰļλ L:\0WorldMusicCreater-MFMS new edition\\v0.5.3\Musicreater\Musicreater.py
+2022-01-28 18:21:33,383 - nmcsup.log - INFO - root.mainloopڣ
+2022-01-28 18:21:36,770 - nmcsup.log - INFO - midiֲȡʽ
+2022-01-28 18:21:48,289 - nmcsup.log - INFO - ˳
+2022-01-28 18:21:51,019 - nmcsup.log - INFO - ˳
diff --git a/log/2022-01-28 18_27_50.logger b/log/2022-01-28 18_27_50.logger
new file mode 100644
index 0000000..95d1634
--- /dev/null
+++ b/log/2022-01-28 18_27_50.logger
@@ -0,0 +1,4 @@
+2022-01-28 18:27:50,902 - nmcsup.log - INFO - ִλãǰļλ L:\0WorldMusicCreater-MFMS new edition\\v0.5.3\Musicreater\Musicreater.py
+2022-01-28 18:27:51,150 - nmcsup.log - INFO - root.mainloopڣ
+2022-01-28 18:28:04,248 - nmcsup.log - INFO - ˳
+2022-01-28 18:28:04,248 - nmcsup.log - INFO - ˳
diff --git a/msctspt/__pycache__/__init__.cpython-39.pyc b/msctspt/__pycache__/__init__.cpython-39.pyc
index 5ed360f..35e5198 100644
Binary files a/msctspt/__pycache__/__init__.cpython-39.pyc and b/msctspt/__pycache__/__init__.cpython-39.pyc differ
diff --git a/msctspt/__pycache__/bugReporter.cpython-39.pyc b/msctspt/__pycache__/bugReporter.cpython-39.pyc
index 4f78f75..e7caaa2 100644
Binary files a/msctspt/__pycache__/bugReporter.cpython-39.pyc and b/msctspt/__pycache__/bugReporter.cpython-39.pyc differ
diff --git a/msctspt/__pycache__/funcOpera.cpython-39.pyc b/msctspt/__pycache__/funcOpera.cpython-39.pyc
new file mode 100644
index 0000000..f286fbb
Binary files /dev/null and b/msctspt/__pycache__/funcOpera.cpython-39.pyc differ
diff --git a/msctspt/__pycache__/threadOpera.cpython-39.pyc b/msctspt/__pycache__/threadOpera.cpython-39.pyc
index 7c778a0..b8aa54e 100644
Binary files a/msctspt/__pycache__/threadOpera.cpython-39.pyc and b/msctspt/__pycache__/threadOpera.cpython-39.pyc differ
diff --git a/nmcsup/__pycache__/__init__.cpython-39.pyc b/nmcsup/__pycache__/__init__.cpython-39.pyc
index fb15f92..8cf72dc 100644
Binary files a/nmcsup/__pycache__/__init__.cpython-39.pyc and b/nmcsup/__pycache__/__init__.cpython-39.pyc differ
diff --git a/nmcsup/__pycache__/const.cpython-39.pyc b/nmcsup/__pycache__/const.cpython-39.pyc
index fa93dcd..04e9454 100644
Binary files a/nmcsup/__pycache__/const.cpython-39.pyc and b/nmcsup/__pycache__/const.cpython-39.pyc differ
diff --git a/nmcsup/__pycache__/log.cpython-39.pyc b/nmcsup/__pycache__/log.cpython-39.pyc
index 44d2b05..59b44c5 100644
Binary files a/nmcsup/__pycache__/log.cpython-39.pyc and b/nmcsup/__pycache__/log.cpython-39.pyc differ
diff --git a/nmcsup/__pycache__/nmcreader.cpython-39.pyc b/nmcsup/__pycache__/nmcreader.cpython-39.pyc
index 7c4025e..550246a 100644
Binary files a/nmcsup/__pycache__/nmcreader.cpython-39.pyc and b/nmcsup/__pycache__/nmcreader.cpython-39.pyc differ
diff --git a/nmcsup/__pycache__/vers.cpython-39.pyc b/nmcsup/__pycache__/vers.cpython-39.pyc
index 4475b85..dd0ae25 100644
Binary files a/nmcsup/__pycache__/vers.cpython-39.pyc and b/nmcsup/__pycache__/vers.cpython-39.pyc differ
diff --git a/nmcsup/nmcreader.py b/nmcsup/nmcreader.py
index c0f07dc..6fa31f5 100644
--- a/nmcsup/nmcreader.py
+++ b/nmcsup/nmcreader.py
@@ -92,6 +92,7 @@ def midi_conversion(midfile: str):
def Time(mt, tpb_a, bpm_a):
return round(mt / tpb_a / bpm_a * 60 * 20)
+
Notes = []
tracks = []
note_list = []
@@ -117,7 +118,8 @@ def midi_conversion(midfile: str):
try:
if i.channel != 9:
# try:
- # log("event_type(事件): " + str(i.type) + " channel(音轨): " + str(i.channel) + " note/pitch(音高): " +
+ # log("event_type(事件): " + str(i.type) + " channel(音轨): " + str(i.channel) +
+ # " note/pitch(音高): " +
# str(i[2]) +
# " velocity(力度): " + str(i.velocity) + " time(间隔时间): " + str(i.time) +
# " overallTime/globalTime/timePosition: " + str(overallTime) + " \n")
@@ -133,14 +135,17 @@ def midi_conversion(midfile: str):
print(i)
# print(i.note)
# print([Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
- tracks.append([Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
- note_list.append([i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument])
+ tracks.append(
+ [Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
+ note_list.append(
+ [i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument])
on.append([i.note, Time(overallTime, tpb, bpm)])
# return [Note(i.channel, i, i.velocity, i.time, Time(overallTime, tpb, bpm))]
if 'note_off' in str(i) or 'note_on' in str(i) and i.velocity == 0:
# print(i)
# print([Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm))])
- close.append([Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
+ close.append(
+ [Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
off.append([i.note, Time(overallTime, tpb, bpm)])
# return [Note(i.channel, i, i.velocity, i.time, Time(overallTime, tpb, bpm))]
except AttributeError:
@@ -175,6 +180,35 @@ def midi_conversion(midfile: str):
# return [Notes, note_list]
+def midiClassReader(midfile: str):
+ import mido
+ from bgArrayLib.bpm import get
+
+ def Time(mt, tpb_a, bpm_a):
+ return round(mt / tpb_a / bpm_a * 60 * 20)
+ Notes = []
+ tracks = []
+ try:
+ mid = mido.MidiFile(midfile)
+ except FileNotFoundError:
+ log("找不到文件或无法读取文件" + midfile)
+ return False
+ tpb = mid.ticks_per_beat
+ bpm = get(midfile)
+ for track in mid.tracks:
+ overallTime = 0.0
+ instrument = 0
+ for i in track:
+ overallTime += i.time
+ if 'note_on' in str(i) and i.velocity > 0:
+ print(i)
+ tracks.append(
+ [Note(i.channel, i.note, i.velocity, i.time, Time(overallTime, tpb, bpm), instrument)])
+ Notes.append(tracks)
+ print(Notes.__len__())
+ return Notes
+
+
def ReadOldProject(fn: str): # -> list
import json
from nmcsup.trans import note2list
diff --git a/查看代码数.py b/查看代码数.py
index fdf509a..9683985 100644
--- a/查看代码数.py
+++ b/查看代码数.py
@@ -1,27 +1,25 @@
# -*- conding: utf8 -*-
-import os
+import os
from msctspt.funcOpera import keepart
+m = 0
-l = 0
-
-for path,dir_list,file_list in os.walk(r"./") :
- for file_name in file_list:
- if keepart(file_name,'.',None) == '.py':
+for path, dir_list, file_list in os.walk(r"./"):
+ for file_name in file_list:
+ if keepart(file_name, '.', None) == '.py':
file = os.path.join(path, file_name)
- print("得到文件名:"+str(file))
- for i in open(file,'r',encoding="utf-8"):
- code = i.replace(' ','').replace('\n','')
+ print("得到文件名:" + str(file))
+ for i in open(file, 'r', encoding="utf-8"):
+ code = i.replace(' ', '').replace('\n', '')
try:
code -= code[code.index('#'):]
except:
pass
if code:
- print("\t"+code)
- l+=1
+ print("\t" + code)
+ m += 1
else:
pass
-input("\n最终代码行数为:"+str(l))
-
+input("\n最终代码行数为:" + str(m))
diff --git a/补全库.py b/补全库.py
index ecad380..136e76c 100644
--- a/补全库.py
+++ b/补全库.py
@@ -1,2 +1,2 @@
from msctspt.bugReporter import version
-version.installLibraries(version)
\ No newline at end of file
+version.installLibraries(version)