• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    JavaScript
  • Created about 14 years ago
  • Updated almost 14 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library for reading/writing midi files in JavaScript

JSMidi

JSMidi is a lightweight JavaScript library that can generate and play Standard MIDI (scm) files on the fly directly from your browser or JavaScript server.

Disclaimer: This is Work In Progress, and it is by no means finished yet.

How does it work?

JSMidi generates a Base64 string that can be saved as a MIDI file or played directly in the browser using HTML5 tag.

Example

This is a very simple example showing how to create a single track with 3 notes. Since timings are not specified the defaults will be taken.

// We pass some notes to |MidiWriter.createNote| to create the MIDI
// events that define the notes that will be in the final MIDI stream. If
// no other parameters are specified to |createNote|, a NoteOff event
// will be inserted automatically, instead of letting the note ring forever.

// Disregard the |push.apply|, it is used here simply to flatten the
// resulting array, since |createNote| returns an array of events.

var noteEvents = [];
["C4", "E4", "G4"].forEach(function(note) {
    Array.prototype.push.apply(noteEvents, MidiEvent.createNote(note));
});

// Create a track that contains the events to play the notes above
var track = new MidiTrack({ events: noteEvents });

// Creates an object that contains the final MIDI track in base64 and some
// useful methods.
var song  = MidiWriter({ tracks: [track] });

// Alert the base64 representation of the MIDI file
alert(song.b64);

// Play the song
song.play();

// Play/save the song (depending of MIDI plugins in the browser). It opens
// a new window and loads the generated MIDI file with the proper MIME type
song.save();

Still to be done

  • MetaEvents won't be processed properly right now (this is important, and will be solved soon).
  • MetaEvents shortcuts
  • Reading MIDI files (it only writes to them now)
  • MIDI Type 0 & 1 differences and validations

Contributors

License

This material is licensed by Sergi Mansilla under the Creative Commons Attribution-ShareAlike 3.0 license. You are free to copy, distribute, transmit, and remix this work, provided you attribute the work to Sergi Mansilla as the original author and reference this repository. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or compatible license. Any of the above conditions can be waived if you get permission from the copyright holder. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the Creative Commons Attribution-Share Alike 3.0.

More Repositories

1

go-diff

Diff, match and patch text in Go
Go
1,827
star
2

jsftp

Light and complete FTP client implementation for Node.js
JavaScript
808
star
3

virtual-list

Scrollable list of DOM elements that can hold an unlimited amount of rows without breaking a sweat
JavaScript
265
star
4

narwhal-mongodb

Wrapper of MongoDB database for CommonJS
JavaScript
94
star
5

tabgrenade

Tab Grenade is a Firefox Browser extension that creates a persistent list of all your open tabs and then closes them all.
JavaScript
62
star
6

abcnode

Node.js parser for the ABC music notation format
JavaScript
27
star
7

Design-By-Canvas

Port of John Maeda's Design By Numbers to Javascript using PEG.js
JavaScript
20
star
8

parse-listing

Small library to parse file listings into JavaScript objects
JavaScript
16
star
9

xslty

Command-line XSLT 2.0 processor
JavaScript
13
star
10

re-alpine

Mirror of the official re-alpine repository at sourceforge.net
C
12
star
11

rxjs-minimal-boilerplate

Minimal boilerplate for a barebones project in modern RxJS
JavaScript
11
star
12

par

par is a paragraph reformatter, vaguely similar to fmt, but better.
C
10
star
13

pipeline2dcd

Converts JSON Spinnaker pipelines to DCD pipelines (https://github.com/spinnaker/dcd-spec)
JavaScript
9
star
14

siphon

Stream commands output to your browser
Go
8
star
15

cascade

A desktop IRC client made using Node and AngularJS
JavaScript
7
star
16

ftp-test-server

Simple wrapper around pyftpdlib to have an easy FTP server to try stuff with
Python
6
star
17

mlkit

Mirror of the official smltojs SVN repository
Standard ML
4
star
18

ftp-response-parser

Streaming parser for FTP responses
JavaScript
3
star
19

Wakame

Wakame is a Gtk application that acts as a frontend to Wesabe and adds some extra functionality such as complex filters, graphs and persistence.
C#
3
star
20

enumjs

Enumeration over abstract collection of elements, in a functional way.
JavaScript
2
star
21

vimfiles

My vim config
Vim Script
2
star
22

jsmacros

Sweet.js macro collection for JavaScript
JavaScript
2
star
23

sergimansilla.com

My personal website
2
star
24

gab

JavaScript
2
star
25

sergi-vim

My vim environment
Vim Script
2
star
26

coconut

An idempotent photo organizer
Go
2
star
27

detect-failed-junit

Returns error if there are any test suites that failed or errored in a JUnit test report
Go
2
star
28

solitaire

Bruce Schneier's Solitaire cryptoalgorithm implemented in a variety of languages
2
star
29

conceal

Conceals a string or part of it.
JavaScript
2
star
30

rxjs-codemod

JavaScript
2
star
31

sergi.github.com

Personal blog
CSS
1
star
32

parcel_testcase

JavaScript
1
star
33

evidence

C#
1
star
34

mime-multipart

Library to help creating Mime Multi Part Archives
JavaScript
1
star
35

Tagger

Tagger is a speed tagging extension for Thunderbird
JavaScript
1
star
36

vim-chicken-doc

Vim plugin that integrates chicken-doc for scheme files
Vim Script
1
star
37

mesos-scheduler

Simple Scheduler from scratch for Apache Mesos
JavaScript
1
star
38

roughdb-clj

Clojure
1
star
39

XPMParser.js

A parser of the XPM graphical format implemented in JavaScript
JavaScript
1
star
40

geekdots

JavaScript
1
star
41

siphon-ui

UI for Siphon
CSS
1
star
42

roughdb

JavaScript
1
star
43

FoxStat

F#
1
star
44

jpl-website

JavaScript
1
star
45

nodejsconfit2012

Code for the talk given at http://nodejsconf.it/ 2012
JavaScript
1
star