GithubHelp home page GithubHelp logo

okame / midi-parser-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from colxi/midi-parser-js

0.0 2.0 0.0 214 KB

Read .mid binary files or base64 encoded MIDI data, and converts data (Tracks and Events) to Javascript structured Object .

Home Page: http://www.colxi.info

License: GNU General Public License v3.0

JavaScript 100.00%

midi-parser-js's Introduction

Midi Parser Library (AKA JSMIDIPArser)

NoDependencies Browser Node

MIDIParser is a Javascript Binary MIDI files reader, for Browsers and NODEjs. Converts MIDI binary files to Javascript Structured Objects, easier to iterate and interact with.

It can also Parse BASE64 encoded .mid data, or UINT8 array data structures from a raw .mid binary.

Author URI: http://www.colxi.info/

Package distribution networks :

In browser enviroment you can include this library using the jsdelivr CDN ...

<script src='https://cdn.jsdelivr.net/gh/colxi/[email protected]/src/midi-parser.min.js'></script>

If you are in the NodeJs enviroment, can install the package via:

$ npm install midi-parser-js

Usage:

Midi-parser-js can proces MIDI data from a File input Element, or as an alternative you can provide manually the .mid file data, encoded with BASE64 or as a UINT8 Array. These are the usage options:

Autodetected Input Type:

  • MIDIParser.parse( input [,CallbackFunction] ) : Accepts any of the supported Data Sources (FileInput|uint8Array|base64String) , and selects automatically the appropiate Parse method. When a FileInput element is provided, is required a callback to handle the return of the Midi Object.

FileInput DOM Element Listener (Async) :

  • MIDIParser.addListener( FileInputElem , CallbackFunction ) : Sets a listener on a FileInput Element, that gets executed when the user selects a file. The listener automatically Parsess the attached .mid file and calls the provided CallbackFunction with the resulting object as first argument. ( Note: ONLY IN BROWSERS! )

Direct Encoded Data Parsing (Sync) :

  • MIDIParser.Uint8( uint8Array ) : Accepts an uint8 Array as input. Returns the formatted MIDI object.

  • MIDIParser.Base64( base64String ) : Accepts a Base64 String. Returns the formatted MIDI object.

Returned Object Structure :

	Output_Object{
		formatType: 0|1|2, 					// Midi format type
		timeDivision: (int),					// song tempo (bpm)
		tracks: (int), 						// total tracks count
		track: Array[
			[0]: Object{					// TRACK 1!
				event: Array[				// Midi events in track 1
					[0] : Object{			// EVENT 1
						data: (string),
						deltaTime: (int),
						metaType: (int),
						type: (int),
					},
					[1] : Object{...}		// EVENT 2
					[2] : Object{...}		// EVENT 3
					...
				]
			},
			[1] : Object{...}
			[2] : Object{...}
			...
		]
	}

Data from Event 12 of Track 2 could be easilly readed with:

	Output_Object.track[2].event[12].data;

MIDI File Format Specifications :

MIDI Binary Encoding Specifications in https://github.com/colxi/midi-parser-js/wiki/MIDI-File-Format-Specifications

midi-parser-js's People

Contributors

colxi avatar nicolaitanes avatar okame avatar

Watchers

 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.