Thanks to visit codestin.com
Credit goes to www.ruby-toolbox.com

Project

webmidi

0.0
The project is in a healthy, maintained state
Webmidi brings the W3C Web MIDI API design to Ruby with idiomatic DSL, MIDI message parsing, Standard MIDI File I/O, middleware pipeline, music theory DSL, network MIDI (RTP/OSC), and MIDI 2.0 UMP support.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Webmidi

Ruby Gem Version Ruby Version License

Webmidi is a pure-Ruby MIDI library inspired by the W3C Web MIDI API. It provides MIDI messages, ports, Standard MIDI File I/O, middleware, network MIDI, and MIDI 2.0 UMP support with zero runtime dependencies.

Requirements

  • Ruby 3.2 or newer

Installation

gem "webmidi"

Quick Start

require "webmidi"

loopback = Webmidi::Virtual::Loopback.create(name: "Demo")

loopback.input.on_message do |message|
  puts message.to_hex
end

loopback.output.note_on(60, velocity: 100)
loopback.output.note_off(60)

loopback.close

Core APIs

# MIDI messages
message = Webmidi::Message.note_on(:C4, velocity: 100, channel: 0)
message.to_bytes # => [0x90, 60, 100]

parsed = Webmidi::Message.from_bytes(0x90, 60, 100)

# Standard MIDI Files
sequence = Webmidi::SMF::Sequence.read("input.mid")
sequence.write("output.mid")

# MIDI 2.0 UMP
ump = Webmidi::Message.upgrade(message)
midi1 = Webmidi::Message.downgrade(ump)

Included

  • MIDI 1.0 channel and system messages
  • MIDI byte parsing, stream parsing, and running status support
  • Virtual input/output ports and loopback ports
  • Standard MIDI File format 0/1 reader and writer
  • Middleware for filtering, transposition, velocity changes, logging, recording, and routing
  • Music helpers for notes, chords, scales, rhythm, and frequencies
  • RTP-MIDI, AppleMIDI negotiation, and OSC bridging
  • MIDI 2.0 Universal MIDI Packet parsing and MIDI 1.0 conversion

Development

bundle install
bundle exec rake spec
bundle exec rake release:check

License

MIT License. See LICENSE.txt.