Giter Site home page Giter Site logo

midi-message's Introduction

MIDI Message

midi

Ruby MIDI message objects

Features

Install

gem install midi-message

Or if you're using Bundler, add this to your Gemfile

gem "midi-message"

Usage

require "midi-message"

Basic Messages

There are a few ways to create a new MIDI message. Here are some examples

MIDIMessage::NoteOn.new(0, 64, 64)

MIDIMessage::NoteOn["E4"].new(0, 100)

MIDIMessage.with(:channel => 0, :velocity => 100) { note_on("E4") }

Those expressions all evaluate to the same object

#<MIDIMessage::NoteOn:0x9c1c240
   @channel=0,
   @data=[64, 64],
   @name="E4",
   @note=64,
   @status=[9, 0],
   @velocity=64,
   @verbose_name="Note On: E4">

SysEx Messages

As with any kind of message, you can begin with raw data

MIDIMessage::SystemExclusive.new(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)

Or in a more object oriented way

synth = SystemExclusive::Node.new(0x41, :model_id => 0x42, :device_id => 0x10)

SystemExclusive::Command.new([0x40, 0x7F, 0x00], 0x00, :node => synth)

A Node represents a device that you're sending a message to (eg. your Yamaha DX7 is a Node). Sysex messages can either be a Command or Request

You can use the Node to instantiate a message

synth.command([0x40, 0x7F, 0x00], 0x00)

One way or another, you will wind up with a pair of objects like this

#<MIDIMessage::SystemExclusive::Command:0x9c1e57c
   @address=[64, 0, 127],
   @checksum=[65],
   @data=[0],
   @node=
    #<MIDIMessage::SystemExclusive::Node:0x9c1e5a4
     @device_id=16,
     @manufacturer_id=65,
     @model_id=66>>

Parsing

The parse method will take any valid message data and return the object representation

MIDIMessage.parse(0x90, 0x40, 0x40)

  #<MIDIMessage::NoteOn:0x9c1c240 ..>

MIDIMessage.parse(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)

  #<MIDIMessage::SystemExclusive::Command:0x9c1e57c ..>

Check out nibbler for more advanced parsing

Documentation

Author

License

Apache 2.0, See the file LICENSE

Copyright (c) 2011-2015 Ari Russo

midi-message's People

Contributors

aberant avatar arirusso avatar gilesbowkett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.