54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
|
import soundbox
|
||
|
|
||
|
|
||
|
def sine(dur, freq, value=1):
|
||
|
return soundbox.envelope(
|
||
|
attack=.01, decay=.2, release=.2,
|
||
|
signal=soundbox.sine(dur, freq, value))
|
||
|
|
||
|
|
||
|
def square(dur, freq, value=1):
|
||
|
return soundbox.envelope(
|
||
|
attack=.01, decay=.2, release=.2,
|
||
|
signal=soundbox.square(dur, freq, value))
|
||
|
|
||
|
|
||
|
signal = soundbox.silence(9)
|
||
|
|
||
|
chords_l = (
|
||
|
(('do', 2),),
|
||
|
(('sol', 2),),
|
||
|
(('la', 2),),
|
||
|
(('sol', 2),),
|
||
|
(('do', 2),),
|
||
|
(('sol', 2),),
|
||
|
(('la', 2),),
|
||
|
(('sol', 2),),
|
||
|
)
|
||
|
|
||
|
chords_r = (
|
||
|
(('do', 3), ('mi', 3), ('sol', 3)),
|
||
|
(('sol', 3), ('si', 3), ('re', 4)),
|
||
|
(('la', 3), ('do', 4), ('mi', 4)),
|
||
|
(('fa', 3), ('la', 3), ('do', 4)),
|
||
|
)
|
||
|
|
||
|
for shift in (.5, 4.5):
|
||
|
for i in range(len(chords_l)):
|
||
|
soundbox.add_signal(signal, start=i / 2 + shift,
|
||
|
source=soundbox.chord(
|
||
|
instr=square, dur=.6,
|
||
|
freqs=soundbox.note_freqs(chords_l[i]),
|
||
|
value=.05
|
||
|
))
|
||
|
|
||
|
for i in range(len(chords_r)):
|
||
|
soundbox.add_signal(signal, start=i + shift,
|
||
|
source=soundbox.chord(
|
||
|
instr=sine, dur=1.1,
|
||
|
freqs=soundbox.note_freqs(chords_r[i]),
|
||
|
value=.6
|
||
|
))
|
||
|
|
||
|
soundbox.save_signal('out.wav', signal)
|