-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_make_practice.py
executable file
·146 lines (139 loc) · 5.2 KB
/
new_make_practice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# -*- coding: utf-8 -*-
from make_ly import *
from config import *
from module import *
def repeat(func,repeat_inside,repeat_outside):
# 音频重复
def repeat_midi(midi):
new_midi=''
for i in range(midi_repeat):
new_midi+=midi+' '
return new_midi
# 主重复流程
def repeat_main():
note_all,lyric_all,note_back_all,lyric_back_all='','','',''
for o in range(repeat_outside):
note_row,lyric_row,note_back_row,lyric_back_row='','','',''
for i in range(repeat_inside):
note,lyric,note_back,lyric_back=func()
note_row+=note
lyric_row+=lyric
note_back_row+=note_back
lyric_back_row+=lyric_back
# 行数
row_name= " \\break \set Score.currentBarNumber = #%s " %(o+2)
note_all+=note_row+row_name
lyric_all+=lyric_row
lyric_back_all+=lyric_back_row
# midi文件的重复|可能是midi可能是题目答案
note_back_all+=repeat_midi(note_back_row)+row_name
return note_all,lyric_all,note_back_all,lyric_back_all
return repeat_main()
def pitch_Mm(important_note_list=[[],0]):
def step1():
def random_func():
# 生成一个大调或小调的音组
note_list,Mm_t=random_Mm_note_list(range_low_c,range_high_c,key_num_l,sharp_flat_l,modal_l)
note_list=random_select_note(note_list,space_l,list_num,important_note_list)
# 答案上体现的音符
note_l=[v1.note_all() for v1 in note_list]
note='1 '.join(note_l)
# 给到midi软件的音符
# b站投稿临时 note=note+'1 '
note_midi=' \skip1 '+note+' \skip1 ' # b站投稿 #' \skip1 '+note+note+note+' \skip1'
return note,'',note_midi,''
return random_func
def step2():
# 生成
repeat_inside=1
repeat_outside=100
file_name='pitch_Mm'
note,lyric,note_back,lyric_back=repeat(step1(),repeat_inside,repeat_outside)
# 生成ly文件
ly_t=ly_set(note,lyric,note_back,lyric_back,clef)
ly_t.pitch_Mm(file_name)
return '运行完成'
return step2()
def interval():
def step1():
def random_func():
# 生成一个音程实例
interval_t=random_interval_t(range_low_c,range_high_c,accidental_l,interval_num_l,property_l)
# 音程里面的两个音
note_t1,note_t2=interval_t.note_t1,interval_t.note_t2
interval=" < "+note_t1.note_all()+' '+note_t2.note_all()+" >1 "
# 音程的名字
interval_name=interval_t.interval_name()[0]
# 答案
note=interval+' '
lyric=interval_name+'1 '
# midi
note_midi=interval # b站投稿 重复三次 # ' \skip1 '+interval+interval+interval+' \skip1 '
return note,lyric,note_midi,''
return random_func
def step2():
# 生成
repeat_inside=1
repeat_outside=100
file_name='interval'
note,lyric,note_back,lyric_back=repeat(step1(),repeat_inside,repeat_outside)
# 生成ly文件
ly_t=ly_set(note,lyric,note_back,lyric_back,clef)
ly_t.interval(file_name)
return '运行完成'
return step2()
def rythem(time_sign):
t=module_rythem(time_sign)
# 拍号
time_ly=t.time_ly()
# beam连杆设置
beam=t.beam(irregular_mode)
def step1():
def random_func():
# 生成一组节奏型
rythem_list,rythem_t=random_rythem_list(time_sign)
rythem=' '.join(rythem_list)
# 输出准备
note=rythem+' '
note_midi=' \\time 2/4 \skip2 '+time_ly+rythem+' \\time 2/4 \skip2 '
return note,'',note_midi,''
return random_func
def step2():
# 生成
repeat_inside=1
repeat_outside=100
file_name='rythem'
note,lyric,note_back,lyric_back=repeat(step1(),repeat_inside,repeat_outside)
# 生成ly文件
ly_t=ly_set(note,lyric,note_back,lyric_back,clef)
ly_t.rythem(file_name,time_ly,beam)
return '运行完成'
return step2()
def rythem_b(time_sign):
t=module_rythem(time_sign)
# 拍号
time_ly=t.time_ly()
# beam连杆设置
beam=t.beam(irregular_mode)
def step1():
def random_func():
# 生成一组节奏型
rythem_list,rythem_t=random_rythem_list(time_sign)
rythem=' '.join(rythem_list)
# 输出准备
note=rythem+' \skip1*2 '
note_midi=' \\time 2/4 \skip2 \skip2'+time_ly+rythem+' \\time 2/4 \skip2 '+time_ly+rythem+' \\time 2/4 \skip2 '+time_ly+rythem+' \\time 2/4 \skip2 \skip2 '
return note,'',note_midi,''
return random_func
def step2():
# 生成
repeat_inside=1
repeat_outside=100
file_name='rythem'
note,lyric,note_back,lyric_back=repeat(step1(),repeat_inside,repeat_outside)
# 生成ly文件
ly_t=ly_set(note,lyric,note_back,lyric_back,clef)
ly_t.rythem_b(file_name,time_ly,beam)
return '运行完成'
return step2()
pitch_Mm()