3

I'm wondering if there are any libraries to read live MIDI input from a USB device and translate that data to a web-friendly format like JSON. I've come across a few that can read MIDI files, but this needs to be directly from a USB device. No sound needs to be generated, just the data from the MIDI device. Eventually the goal is to transfer live MIDI data via WebSockets. I've come across Pygame, but I'm not sure if that'll do the trick. Any suggestions?

Shannon Matthews
  • 9,649
  • 7
  • 44
  • 75
Jason Barry
  • 738
  • 5
  • 17
  • What are you trying to read MIDI with? You can't read MIDI input from the browser without some sort of plugin. Encoding MIDI to JSON is definitely possible, and very easy, but I might suggest just sending the raw data for efficiency. – Brad Sep 18 '11 at 16:48
  • 1
    @Brad, that's what I was envisioning, a browser plugin that would encode MIDI to JSON. I want to read it with C/C++ or Python, but am open for other alternatives. – Jason Barry Sep 20 '11 at 21:09
  • MIDI is a simple protocol. If it were me, I'd just send it plain. Why do you want to encode it in JSON? – Brad Sep 20 '11 at 21:30
  • I was thinking of sending data to a server, and want to have the clients offload as much work as possible. If I send it as JSON a node.js server can easily interpret it. – Jason Barry Sep 23 '11 at 06:06
  • what work? Have you *seen* MIDI? There is nothing to it. You still haven't described what you plan to do with it on the server. – Brad Sep 23 '11 at 13:26

3 Answers3

2

OSC is similar to JSON and was devised for this purpose.

There are quite a few libraries that deal with OSC. For whatever it's worth, I use micro-osc with micromidi (libraries I wrote) to do what you're asking

Ari Russo
  • 273
  • 2
  • 10
  • +1 ... OSC is like midi on steroids, and that's a good thing since the midi standard was codified in 1983. – JKirchartz Mar 28 '12 at 18:12
  • 1
    OSC is like MIDI System Exclusive messages on steroids. There is no OSC spec that defines things like note values and pitch bend, it varies from implementation to implementation. Not saying that this is a bad thing, it's just very different and can require more configuration – Ari Russo Apr 04 '12 at 18:34
2

I made a NPAPI browser plugin that sends MIDI messages to Javascript.

Currently the MIDI messages are sent as string with comma separated values (notenumber,velocity), but you can easily convert that to JSON.

See: http://abumarkub.net/abublog/?p=754

abudaan
  • 291
  • 3
  • 4
1

The new Web MIDI API allows for MIDI input in JavaScript.

ChaseMoskal
  • 7,151
  • 5
  • 37
  • 50