Skip to content

Commit

Permalink
generate new music using machine learning
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham3121 committed May 25, 2018
1 parent 86b4448 commit 8fca815
Show file tree
Hide file tree
Showing 8 changed files with 935 additions and 0 deletions.
890 changes: 890 additions & 0 deletions Jazz Music Sampling .ipynb

Large diffs are not rendered by default.

Binary file added Jazz/AndreandSchwandt-aLittleDream.mid
Binary file not shown.
Binary file added Jazz/Berckman-Berckman.mid
Binary file not shown.
Binary file added Jazz/CameronLeeSimpson-.mid
Binary file not shown.
Binary file added data/notes
Binary file not shown.
45 changes: 45 additions & 0 deletions play.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

# coding: utf-8

# In[4]:


import pygame

def play_music(music_file):
"""
stream music with mixer.music module in blocking manner
this will stream the sound from disk while playing
"""
clock = pygame.time.Clock()
try:
pygame.mixer.music.load(music_file)
print ("Music file %s loaded!" % music_file)
except pygame.error:
print ("File %s not found! (%s)" % (music_file, pygame.get_error()))
return
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
# check if playback has finished
clock.tick(30)
# pick a midi music file you have ...
# (if not in working folder use full path)

def play_midi(midi_file):
freq = 44100 # audio CD quality
bitsize = -16 # unsigned 16 bit
channels = 2 # 1 is mono, 2 is stereo
buffer = 1024 # number of samples
pygame.mixer.init(freq, bitsize, channels, buffer)

# optional volume 0 to 1.0
pygame.mixer.music.set_volume(0.8)
try:
play_music(midi_file)
except KeyboardInterrupt:
# if user hits Ctrl/C then exit
# (works only in console mode)
pygame.mixer.music.fadeout(1000)
pygame.mixer.music.stop()
raise SystemExit

Binary file added test_output3.mid
Binary file not shown.
Binary file added weights.best.music3.hdf5
Binary file not shown.

0 comments on commit 8fca815

Please sign in to comment.