Created
September 20, 2019 20:15
-
-
Save Centrinia/be643d1528eb5ba4a0c2e0477f4bf5bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rate = 44100 | |
total_time = 60 | |
iterations = 2**6 | |
f0 = 440 * pow(2, -4 + 1) | |
f1 = 440 * pow(2, -4 + 8) | |
a0, a1 = 2.4, 4.0 | |
import numpy as np | |
rs = np.linspace(a0, a1, rate * total_time, dtype=np.float64) | |
wav = np.zeros(len(rs), dtype=np.float64) | |
xs = np.full(len(rs), 0.5, dtype=np.float64) | |
def lerp(a, b, t): | |
return a * (1 - t) + b * t | |
for i in range(iterations): | |
print(f'{i/(iterations-1):%} complete') | |
xs = rs * xs * (1 - xs) | |
xm = pow(2, lerp(np.log(f0) / np.log(2), np.log(f1) / np.log(2), xs)) | |
wav += np.cos(2 * np.pi * np.cumsum(xm) / rate) | |
wav /= np.max(np.abs(wav)) | |
import scipy.io.wavfile | |
scipy.io.wavfile.write('bif.wav', rate, wav) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment