Réduit attaque onde carrée, paramétrise generate

This commit is contained in:
Mattéo Delabre 2020-12-18 00:45:13 +01:00
parent de9d35b08b
commit 9e8e8db032
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
5 changed files with 14 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,4 +1,13 @@
import soundbox import soundbox
import sys
if len(sys.argv) != 2:
print(f"""Utilisation: {sys.argv[0]} [output]
Génère un morceau au synthétiseur dans le fichier [output].""")
sys.exit(1)
output_file = sys.argv[1]
def sine(dur, freq, value=1): def sine(dur, freq, value=1):
@ -9,7 +18,7 @@ def sine(dur, freq, value=1):
def square(dur, freq, value=1): def square(dur, freq, value=1):
return soundbox.envelope( return soundbox.envelope(
attack=.01, decay=.2, release=.2, attack=.2, decay=.2, release=.2,
signal=soundbox.square(dur, freq, value)) signal=soundbox.square(dur, freq, value))
@ -37,9 +46,9 @@ for shift in (.5, 4.5):
for i in range(len(chords_l)): for i in range(len(chords_l)):
soundbox.add_signal(signal, start=i / 2 + shift, soundbox.add_signal(signal, start=i / 2 + shift,
source=soundbox.chord( source=soundbox.chord(
instr=square, dur=.6, instr=square, dur=.4,
freqs=soundbox.note_freqs(chords_l[i]), freqs=soundbox.note_freqs(chords_l[i]),
value=.05 value=.04
)) ))
for i in range(len(chords_r)): for i in range(len(chords_r)):
@ -47,7 +56,7 @@ for shift in (.5, 4.5):
source=soundbox.chord( source=soundbox.chord(
instr=sine, dur=1.1, instr=sine, dur=1.1,
freqs=soundbox.note_freqs(chords_r[i]), freqs=soundbox.note_freqs(chords_r[i]),
value=.6 value=.5
)) ))
soundbox.save_signal('out.wav', signal) soundbox.save_signal(output_file, signal)

BIN
sounds/piano.wav Normal file

Binary file not shown.

Binary file not shown.