jsb-synth/stage/level3.py
2025-02-27 00:41:31 +01:00

25 lines
306 B
Python

"""
Niveau 3
Jouer une mélodie
"""
import synth
import math
music = [
[1, 4],
[1, 3],
[1, 4],
[1, 3],
[1, 4],
[1, -1],
[1, 2],
[1, 0],
[2, -3]
]
encoder = synth.Encoder()
for note in music:
for t in range(note[0]*3000):
encoder.write(math.sin(t/16000 * 440 * 2**(note[1]/12) * 2*math.pi))