import score
import wave_form

UPPER_REPEAT1 = [
    ["e5",16],["e-5",16],
    ["e5",16],["e-5",16],["e5",16],["b4",16],["d5",16],["c5",16],
    ["a4",8],["r",16],["c4",16],["e4",16],["a4",16],
    ["b4",8],["r",16],["e4",16],["a-4",16],["b4",16],
    ["c5",8],["r",16],["e4",16],["e5",16],["e-5",16],
    ["e5",16],["e-5",16],["e5",16],["b4",16],["d5",16],["c5",16], # 第5小節終わり
    ["a4",8],["r",16],["c4",16],["e4",16],["a4",16],
    ["b4",8],["r",16],["e4",16],["c5",16],["b4",16]
]

LOWER_REPEAT1 = [
    ["r",8],
    ["r",8],["r",8],["r",8],
    ["a3",16],["e4",16],["a4",16],["r",16],["r",8],
    ["e3",16],["e4",16],["g+4",16],["r",16],["r",8],
    ["a3",16],["e4",16],["a4",16],["r",16],["r",8],
    ["r",8],["r",8],["r",8], # 第5小節終わり
    ["a3",16],["e4",16],["a4",16],["r",16],["r",8],
    ["e3",16],["e4",16],["g+4",16],["r",16],["r",8],
]

UPPER_sono1_after_REPEAT1 = [ ["a4",4] ]
LOWER_sono1_after_REPEAT1 = [ ["a3",16],["e4",16],["a4",16],["r",16] ]

UPPER_sono2_after_REPEAT1 = [ ["a4",8],["r",16],["b4",16],["c5",16],["d5",16] ]
LOWER_sono2_after_REPEAT1 = [ ["a3",16],["e4",16],["a4",16],["r",16],["r",8] ]

UPPER_REPEAT2 = [
    ["e5",8,"."],["g4",16],["f5",16],["e5",16],
    ["d5",8,"."],["f4",16],["e5",16],["d5",16],
    ["c5",8,"."],["e4",16],["d5",16],["c5",16], # 第13小節終わり
    ["b4",8],["r",16],["e4",16],["e5",16],["r",16],
    ["r",16],["e5",16],["e6",16],["r",16],["r",16],["d+5",16],
    ["e5",16],["r",16],["r",16],["d+5",16],["e5",16],["d+5",16],
    ["e5",16],["d+5",16],["e5",16],["b4",16],["d5",16],["c5",16],
    ["a4",8],["r",16],["c4",16],["e4",16],["a4",16],
    ["b4",8],["r",16],["e4",16],["g+4",16],["b4",16], # 第19小節終わり
    ["c5",8],["r",16],["e4",16],["e5",16],["d+5",16],
    ["e5",16],["d+5",16],["e5",16],["b4",16],["d5",16],["c5",16],
    ["a4",8],["r",16],["c4",16],["e4",16],["a4",16],
    ["b4",8],["r",16],["e4",16],["c5",16],["b4",16],
]

LOWER_REPEAT2 = [
    ["c3",16],["g3",16],["c4",16],["r",16],["r",8],
    ["g2",16],["g3",16],["b3",16],["r",16],["r",8],
    ["a2",16],["e3",16],["a3",16],["r",16],["r",8], # 第13小節終わり
    ["e2",16],["e3",16],["e4",16],["r",16],["r",16],["e4",16],
    ["e5",16],["r",16],["r",16],["d+5",16],["e5",16],["r",16],
    ["r",16],["d+5",16],["e5",16],["r",16],["r",8],
    ["r",8],["r",8],["r",8],
    ["a2",16],["e3",16],["a3",16],["r",16],["r",8],
    ["e2",16],["e3",16],["g+3",16],["r",16],["r",8], # 第19小節終わり
    ["a2",16],["e3",16],["a3",16],["r",16],["r",8],
    ["r",8],["r",8],["r",8],
    ["a2",16],["e3",16],["a3",16],["r",16],["r",8],
    ["e2",16],["e3",16],["g+3",16],["r",16],["r",8],
]

UPPER_sono1_after_REPEAT2 = [ ["a4",8],["r",16],["b4",16],["c5",16],["d5",16] ]
LOWER_sono1_after_REPEAT2 = [ ["a2",16],["e3",16],["a3",16],["r",16],["r",8] ]

UPPER_sono2_after_REPEAT2 = [ ["a4",8],["r",16],["b4",16],["c5",16],["d5",16] ]
LOWER_sono2_after_REPEAT2 = [ ["a2",16],["e3",16],["a3",16],["r",16],["r",8] ]


#UPPER_PART = UPPER_REPEAT1
UPPER_PART = UPPER_REPEAT1 + UPPER_sono1_after_REPEAT1 + UPPER_REPEAT1 + UPPER_sono2_after_REPEAT1 + UPPER_REPEAT2 + UPPER_sono1_after_REPEAT2
music1 = score.score_to_sequence(UPPER_PART, tempo=60)
#print("music1=", music1)

#LOWER_PART = LOWER_REPEAT1
LOWER_PART = LOWER_REPEAT1 + LOWER_sono1_after_REPEAT1 + LOWER_REPEAT1 + LOWER_sono2_after_REPEAT1 + LOWER_REPEAT2 + LOWER_sono1_after_REPEAT2
music2 = score.score_to_sequence(LOWER_PART, tempo=60)

sequencer = score.sequencer()
sequencer.add_track(0, music1, form=wave_form.square_wave())  # トラック0：上パート、矩形波を使用
sequencer.add_track(1, music2, form=wave_form.square_wave())  # トラック1：下パート、矩形波を使用

score.render("For_Elise.wav", sequencer)
