Created
September 3, 2022 02:29
-
-
Save victormurcia/d8c43d3738fb6658856c8af522ad319b to your computer and use it in GitHub Desktop.
Make a song from numpy array generated from image in HSV space
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
song = np.array([]) | |
octaves = np.array([0.5,1,2]) | |
sr = 22050 # sample rate | |
T = 0.1 # 0.1 second duration | |
t = np.linspace(0, T, int(T*sr), endpoint=False) # time variable | |
#Make a song with numpy array :] | |
#nPixels = int(len(frequencies))#All pixels in image | |
nPixels = 60 | |
for i in range(nPixels): | |
octave = random.choice(octaves) | |
val = octave * frequencies[i] | |
note = 0.5*np.sin(2*np.pi*val*t) | |
song = np.concatenate([song, note]) | |
ipd.Audio(song, rate=sr) # load a NumPy array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment