Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nfroidure/midiplayer
Play MIDI file right in your browser with the WebMIDIAPI
https://github.com/nfroidure/midiplayer
hacktoberfest midi midiplayer
Last synced: 3 months ago
JSON representation
Play MIDI file right in your browser with the WebMIDIAPI
- Host: GitHub
- URL: https://github.com/nfroidure/midiplayer
- Owner: nfroidure
- License: mit
- Created: 2013-09-26T08:12:58.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T16:14:17.000Z (about 5 years ago)
- Last Synced: 2024-11-07T15:06:13.697Z (3 months ago)
- Topics: hacktoberfest, midi, midiplayer
- Language: JavaScript
- Homepage: https://karaoke.insertafter.com/
- Size: 32.2 KB
- Stars: 57
- Watchers: 11
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MIDIPlayer
> MIDIPlayer allows you to play MIDI files in your browser with the help of the
WebMIDIAPI.[![NPM version](https://badge.fury.io/js/midiplayer.svg)](https://npmjs.org/package/midiplayer)
[![Dependency Status](https://david-dm.org/nfroidure/midiplayer.svg)](https://david-dm.org/nfroidure/midiplayer)
[![devDependency Status](https://david-dm.org/nfroidure/midiplayer/dev-status.svg)](https://david-dm.org/nfroidure/midifile#info=devDependencies)MIDIPlayer can be used either in modern browsers
([pick the last bundle](https://github.com/nfroidure/MIDIPlayer/blob/master/dist/MIDIPlayer.js))
or with NodeJS by installing the following
[NPM module](https://npmjs.org/package/midiplayer) :
```bash
npm install midiplayer
```This player is used for this [MIDI Karaoke Player](https://karaoke.insertafter.com/)
## Usage
```js
//Require MIDIPlayer and MIDIFile modules
var MIDIPlayer = require('midiplayer');
var MIDIFile = require('midifile');navigator.requestMIDIAccess().then(function(midiAccess) {
// Creating player
var midiPlayer = new MIDIPlayer({
'output': midiAccess.outputs()[0]
});// creating the MidiFile instance from a buffer (view MIDIFile README)
var midiFile = new MIDIFile(buffer);// Loading the midiFile instance in the player
midiPlayer.load(midiFile);// Playing
midiPlayer.play(function() {
console.log('Play ended');
});// Volume
midiPlayer.volume = 80; // in percent// Pausing
midiPlayer.pause();// Resuming
midiPlayer.resume();// Stopping
midiPlayer.stop();// Playing again and loop
midiPlayer.play(function playCallback() {
midiPlayer.play(playCallback);
});}, function() {
console.log('No midi output');
});
```## License
Copyright Nicolas Froidure 2013. MIT licence.