« first day (2979 days earlier)      last day (599 days later) » 

19:24
import numpy as np
import scipy.io.wavfile as wf


def cosinewave(f):
    return lambda t: np.iinfo(np.int16).max*np.sin(2*np.pi*f*t)


fs = 44100
tn = np.linspace(0, 0.5, int(fs*0.5))


def getTone(n):
    f = 440*(2**((n-49)/12))
    return cosinewave(f)(tn)


notes = [52, 52, 59, 59, 61, 61, 59, 59, 57, 57, 56, 56,
         54, 54, 56, 52, 59, 59, 57, 57, 56, 56, 54, 54]

output = []
for n in notes:
    output.append(getTone(n))

output = np.array(output)


wf.write("song.wav", fs, output.astype(np.int16))
1 message moved from Python

« first day (2979 days earlier)      last day (599 days later) »