Skip to content

Instantly share code, notes, and snippets.

@ekim1394
Forked from ayota/audio_fun.py
Last active September 21, 2016 00:49
Show Gist options
  • Save ekim1394/8bc83c18842b9177f5112b4baa6412c6 to your computer and use it in GitHub Desktop.
Save ekim1394/8bc83c18842b9177f5112b4baa6412c6 to your computer and use it in GitHub Desktop.
import numpy as np
import scikits.audiolab
import scipy
#random number generator in n x 3 matrix to generate "Computer Sheet Music"
num = np.random.rand(1,3) #initialize
sheet_music = np.vstack(num)
for i in range (0,8): #number of notes in sheet_music
notes = np.random.rand(1,3)
i += 1
sheet_music = np.append(sheet_music, notes, axis=0)
f = 440
fs = 11025 #22050
T = 0.1
x = scipy.cos((2*scipy.pi*f/fs)*scipy.arange(fs*T))
for y in range(0,1000):
scikits.audiolab.play(x*y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment