This notebook takes a txt file where each line is of the form ("%s,%s" % (G5,1.25)) and plays it to stdout.
IMPORTANT:
This is an independent client that doesn't create output to be piped into the other programs. It just relies on 2. N-Gram. Also, this takes only notes in the input file and not chords.
NOTE: You need to write a function to convert a music21 length to a mingus length, given the time signature.
Dependencies:
--2. N-Gram
import sys, time, re
import music21
import mingus.core.notes as notes
import mingus.core.value as value
sys.path.append('/usr/local/lib/python2.7/dist-packages/fluidsynth/')
from mingus.midi import fluidsynth
from mingus.containers.Note import Note
from mingus.containers.Bar import Bar
fluidsynth.init('/usr/share/sounds/sf2/FluidR3_GM.sf2',"alsa")
True
print len(allnotes)
print sum(alldurations)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-9eb777398a1a> in <module>() 1 ----> 2 print len(allnotes) 3 print sum(alldurations) NameError: name 'allnotes' is not defined
# Put notes into one huge bar.
b = Bar()
b.set_meter((len(allnotes) * 4, 4))
for note in allnotes:
b.place_notes(note, value.eighth)
print len(b)
fluidsynth.play_Bar(b, 1, 375)
490
{'bpm': 375}
# You really should keep rhythm within clusters consistent (either straight eighths or alternating between
# long/short to get that 'swung' feel).