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

18 lines
268 B
Python

"""
Niveau 2
Jouer une mélodie
"""
import synthlib, math
music = [
(1, 0),
(1, 2),
(2, 4)
]
sound_encoder = synthlib.SoundEncoder()
for note in music:
for t in range(note[0]*4000):
sound_encoder.write_sample(math.sin(t/16000*440*2**(note[1]/12)*2*math.pi))