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

22 lines
405 B
Python

"""
Niveau 3
Jouer des accords
Ne pas introduire le facteur d'amplitude avant d'avoir entendu le résultat sans lui
"""
import synthlib, math
music = [
(1, [-9]),
(1, [-5]),
(1, [-2]),
(3, [-9, -5, -2])
]
sound_encoder = synthlib.SoundEncoder()
for note in music:
for t in range(note[0]*6000):
sound_encoder.write_sample(sum([0.3*math.sin(t/16000*440*2**(i/12)*2*math.pi) for i in note[1]]))