Created
February 12, 2011 21:03
-
-
Save nileshtrivedi/824120 to your computer and use it in GitHub Desktop.
Quick Ruby script to play a simple accompanying track on command-line using MMA
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
#!/usr/bin/env ruby | |
#Example usage: mmacmd.rb basicrock 120 4 Bm Bm A A G Em Bm Bm | |
#MMA Website is here: http://www.mellowood.ca/mma/index.html | |
groove = ARGV.slice!(0) | |
tempo = ARGV.slice!(0) | |
count = ARGV.slice!(0) | |
puts "Generating MMA file" | |
File.open("/tmp/mmaout.mma","w") { |f| | |
f.puts "Tempo #{tempo}" | |
f.puts "Groove #{groove}" | |
f.puts "Repeat" | |
ARGV.each { |chord| f.puts chord } | |
f.puts "RepeatEnd #{count}" | |
} | |
puts "Running MMA" | |
puts `mma -m5000 /tmp/mmaout.mma` | |
puts "Running Timidity" | |
puts `timidity /tmp/mmaout.mid` | |
puts "Done" |
Ob Ubuntu 11.04, software midi can be enabled by:
timidity -iA -B2,8 -Os1l -s 44100
Or alternatively, timidity-daemon can be installed and started after editing /etc/default/timidity.
Ubuntu ships an outdated version of mma so install the deb from upstream manually.
Finally, a file with name "mmarc" will need to be created in the current directory before the above command (mma -V) will work. The content of mmarc should be:
SetMIDIplayer aplaymidi -p128:0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never mind. Newer versions of MMA support this out of the box as follows:
mma -V lfusion Chords=Bm,Bm,A,A,G,Em,Bm,Bm Tempo=123 Count=200