Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arirusso/micromidi
A Ruby DSL for MIDI
https://github.com/arirusso/micromidi
Last synced: 13 days ago
JSON representation
A Ruby DSL for MIDI
- Host: GitHub
- URL: https://github.com/arirusso/micromidi
- Owner: arirusso
- License: other
- Created: 2011-08-15T20:39:56.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-02-10T21:33:59.000Z (9 months ago)
- Last Synced: 2024-10-31T13:19:29.209Z (20 days ago)
- Language: Ruby
- Homepage:
- Size: 162 KB
- Stars: 138
- Watchers: 11
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MicroMIDI
A Ruby DSL for MIDI
![micromidi](http://img855.imageshack.us/img855/9804/midi.png)
## Features
* Cross-platform compatible using MRI or JRuby.
* Simplified MIDI and Sysex message output
* MIDI Thru, processing and custom input events
* Optional shorthand for [live coding](http://en.wikipedia.org/wiki/Live_coding)## Installation
`gem install micromidi`
or using Bundler, add this to your Gemfile
`gem "micromidi"`
If you're using Linux, the *libasound* and *libasound-dev* packages may be required
## Usage
Here's a quick example that plays some arpeggios
```ruby
require "midi"# prompt the user to select an input and output
@input = UniMIDI::Input.gets
@output = UniMIDI::Output.getsMIDI.using(@output) do
5.times do |oct|
octave oct
%w{C E G B}.each { |n| play n, 0.5 }
endend
```This next example filters outs notes if their octave is between 1 and 3. All other messages are sent thru.
Output is also printed to the console by passing `$stdout` as though it's a MIDI device
```ruby
MIDI.using(@input, @output, $stdout) dothru_except :note { |msg| only(msg, :octave, (1..3)) }
join
end
```This is the same example redone using shorthand aliases
```ruby
M(@input, @output) dote :n { |m| only(m, :oct, (1..3)) }
j
end
```Finally, here is an example that maps some MIDI Control Change messages to SysEx
```ruby
MIDI.using(@input, @output) do*@the_map =
[0x40, 0x7F, 0x00],
[0x41, 0x7F, 0x00],
[0x42, 0x7F, 0x00]node :roland, :model_id => 0x42, :device_id => 0x10
receive :cc do |message|
command @the_map[message.index - 1], message.value
end
end
```Here are a few posts explaining each of the concepts used here in greater detail:
* [Output](http://tx81z.blogspot.com/2011/08/micromidi-midi-messages-and-output.html)
* [MIDI Thru and Processing](http://tx81z.blogspot.com/2011/08/micromidi-midi-thru-and-midi-processing.html)
* [Binding Custom Input Events](http://tx81z.blogspot.com/2011/08/micromidi-custom-events.html)
* [Shorthand](http://tx81z.blogspot.com/2011/08/micromidi-shorthand.html)
* [Sysex](http://tx81z.blogspot.com/2011/09/generating-sysex-messages-with.html)
* [Etc](http://tx81z.blogspot.com/2011/09/more-micromidi-tricks.html)## Documentation
* [rdoc](http://rubydoc.info/github/arirusso/micromidi)
## Author
* [Ari Russo](http://github.com/arirusso)
## License
Apache 2.0, See the file LICENSE
Copyright (c) 2011-2015 Ari Russo