Skip to content

Instantly share code, notes, and snippets.

@nileshtrivedi
Created February 12, 2011 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nileshtrivedi/824120 to your computer and use it in GitHub Desktop.
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
#!/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"
@nileshtrivedi
Copy link
Author

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

@nileshtrivedi
Copy link
Author

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