Initial commit
This commit is contained in:
commit
778fe31c38
35 changed files with 1849 additions and 0 deletions
27
stage/level5.py
Normal file
27
stage/level5.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""
|
||||
Niveau 5
|
||||
Jouer une partition
|
||||
"""
|
||||
|
||||
import synth
|
||||
import math
|
||||
|
||||
music = synth.Midi(32000)
|
||||
|
||||
encoder = synth.Encoder()
|
||||
encoder.sampling = 32000
|
||||
|
||||
instruments = [
|
||||
lambda t, f: math.sin(t * f * 2*math.pi),
|
||||
lambda t, f: math.sin(t * f * 2*math.pi) + math.sin(t * f * 4*math.pi)/2,
|
||||
lambda t, f: math.sin(t * f * 2*math.pi) + math.sin(t * f * 4*math.pi)/2,
|
||||
lambda t, f: t * f % 1 - 0.5,
|
||||
]
|
||||
|
||||
t = 0
|
||||
for notes in music:
|
||||
total = 0
|
||||
for note in notes:
|
||||
total = total + instruments[note[0]](t/32000, 440 * 2**(note[1]/12)) * note[2]
|
||||
encoder.write(total * 0.3)
|
||||
t = t + 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue