Utilise uniquement des sinusoïdes dans synth.wav
This commit is contained in:
parent
4104126c6e
commit
7c3679ccaf
14
generate.py
14
generate.py
|
@ -16,13 +16,7 @@ def sine(dur, freq, value=1):
|
||||||
signal=soundbox.sine(dur, freq, value))
|
signal=soundbox.sine(dur, freq, value))
|
||||||
|
|
||||||
|
|
||||||
def square(dur, freq, value=1):
|
signal = soundbox.silence(10)
|
||||||
return soundbox.envelope(
|
|
||||||
attack=.2, decay=.2, release=.2,
|
|
||||||
signal=soundbox.square(dur, freq, value))
|
|
||||||
|
|
||||||
|
|
||||||
signal = soundbox.silence(9)
|
|
||||||
|
|
||||||
chords_l = (
|
chords_l = (
|
||||||
(('do', 2),),
|
(('do', 2),),
|
||||||
|
@ -46,9 +40,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=.4,
|
instr=sine, dur=.8 if shift == 4.5 and i == 7 else .4,
|
||||||
freqs=soundbox.note_freqs(chords_l[i]),
|
freqs=soundbox.note_freqs(chords_l[i]),
|
||||||
value=.04
|
value=.4
|
||||||
))
|
))
|
||||||
|
|
||||||
for i in range(len(chords_r)):
|
for i in range(len(chords_r)):
|
||||||
|
@ -56,7 +50,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=.5
|
value=.4
|
||||||
))
|
))
|
||||||
|
|
||||||
soundbox.save_signal(output_file, signal)
|
soundbox.save_signal(output_file, signal)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import wave
|
import wave
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy.signal as sig
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
# Nombre d’octets par échantillon
|
# Nombre d’octets par échantillon
|
||||||
|
@ -26,11 +25,6 @@ def sine(dur, freq, value=1):
|
||||||
return value * max_val * np.sin(2 * np.pi * freq * x / samp_rate)
|
return value * max_val * np.sin(2 * np.pi * freq * x / samp_rate)
|
||||||
|
|
||||||
|
|
||||||
def square(dur, freq, value=1):
|
|
||||||
x = np.arange(int(samp_rate * dur))
|
|
||||||
return value * max_val * sig.square(2 * np.pi * freq * x / samp_rate)
|
|
||||||
|
|
||||||
|
|
||||||
def envelope(attack, decay, release, signal):
|
def envelope(attack, decay, release, signal):
|
||||||
total = len(signal)
|
total = len(signal)
|
||||||
attack = int(attack * total)
|
attack = int(attack * total)
|
||||||
|
|
BIN
sounds/synth.wav
BIN
sounds/synth.wav
Binary file not shown.
Loading…
Reference in New Issue