March 2019
Intermediate to advanced
642 pages
22h 54m
English
Let's take a look at how to synthesize some music:
import json import numpy as np from scipy.io.wavfile import write
# Synthesize tone def synthesizer(freq, duration, amp=1.0, sampling_freq=44100):
# Build the time axis
t = np.linspace(0, duration, round(duration * sampling_freq))
# Construct the audio signal
audio = amp * np.sin(2 * np.pi * freq * t)
return audio.astype(np.int16)
Read now
Unlock full access