midi-player-js

WebJar for midi-player-js

License

License

MIT
Categories

Categories

JavaScript Languages
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

midi-player-js
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

midi-player-js
WebJar for midi-player-js
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/grimmdude/MidiPlayerJS

Download midi-player-js

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/midi-player-js/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>midi-player-js</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/midi-player-js/
implementation 'org.webjars.npm:midi-player-js:2.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/midi-player-js/
implementation ("org.webjars.npm:midi-player-js:2.0.3")
'org.webjars.npm:midi-player-js:jar:2.0.3'
<dependency org="org.webjars.npm" name="midi-player-js" rev="2.0.3">
  <artifact name="midi-player-js" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='midi-player-js', version='2.0.3')
)
libraryDependencies += "org.webjars.npm" % "midi-player-js" % "2.0.3"
[org.webjars.npm/midi-player-js "2.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

♬ MidiPlayerJS

npm version Build Status

MidiPlayerJS is a JavaScript library which reads standard MIDI files and emits JSON events in real time. This player does not generate any audio, but by attaching a handler to the event emitter you can trigger any code you like which could play audio, control visualizations, feed into a MIDI interface, etc.

Demos

Getting Started

Using MidiWriterJS is pretty simple. Create a new player by instantiating MidiPlayer.Player with an event handler to be called for every MIDI event. Then you can load and play a MIDI file.

var MidiPlayer = require('midi-player-js');

// Initialize player and register event handler
var Player = new MidiPlayer.Player(function(event) {
	console.log(event);
});

// Load a MIDI file
Player.loadFile('./test.mid');
Player.play();

Player Events

There are a handful of events on the Player object which you can subscribe to using the Player.on() method. Some events pass data as the first argument of the callback as described below:

Player.on('fileLoaded', function() {
    // Do something when file is loaded
});

Player.on('playing', function(currentTick) {
    // Do something while player is playing
    // (this is repeatedly triggered within the play loop)
});

Player.on('midiEvent', function(event) {
    // Do something when a MIDI event is fired.
    // (this is the same as passing a function to MidiPlayer.Player() when instantiating.
});

Player.on('endOfFile', function() {
    // Do something when end of the file has been reached.
});

Note that because of a common practice called "running status" many MIDI files may use Note on events with 0 velocity in place of Note off events.

Full API Documentation

http://grimmdude.com/MidiPlayerJS/docs/

Versions

Version
2.0.3