小改动、回档

This commit is contained in:
bgArray
2022-01-28 18:29:51 +08:00
parent 26ee16f071
commit 19bbb92cff
31 changed files with 285 additions and 29 deletions
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>
+46
View File
@@ -0,0 +1,46 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="LongLine" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyAugmentAssignmentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyCompatibilityInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ourVersions">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="3.10" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyMandatoryEncodingInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E501" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N803" />
<option value="N806" />
<option value="N813" />
<option value="N801" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="list.__getitem__" />
<option value="list.split" />
</list>
</option>
</inspection_tool>
</profile>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Musicreater.iml" filepath="$PROJECT_DIR$/.idea/Musicreater.iml" />
</modules>
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+129 -10
View File
@@ -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)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -1
View File
@@ -171,6 +171,10 @@ READABLETEXT = {
156: "[神羽资源包位置选择]:选择文件夹...",
157: "没有路径文件(.rpposi文件),请仔细阅读Readme或先试用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 方法添加路径文件吧!",
158: "有路径文件(.rpposi文件),但路径指示错误,请仔细阅读Readme或先用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 更改路径!",
159: "更改路径文件(.rpposi文件)成功!!"
159: "更改路径文件(.rpposi文件)成功!!",
160: "从midi导入音轨且用类方法解析",
161: "打开 类方法: 音·创项目...",
162: "保存为类方法项目",
163: "另存为类方法项...",
}
View File
+4
View File
@@ -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
+3
View File
@@ -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导入音乐并采用类读取方式
+5
View File
@@ -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 - 程序正常退出
+4
View File
@@ -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 - 程序正常退出
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+38 -4
View File
@@ -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
+11 -13
View File
@@ -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))
+1 -1
View File
@@ -1,2 +1,2 @@
from msctspt.bugReporter import version
version.installLibraries(version)
version.installLibraries(version)