Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisguttandin/json-midi-encoder
This module encodes a JSON representation of MIDI data into a binary MIDI file.
https://github.com/chrisguttandin/json-midi-encoder
midi
Last synced: 16 days ago
JSON representation
This module encodes a JSON representation of MIDI data into a binary MIDI file.
- Host: GitHub
- URL: https://github.com/chrisguttandin/json-midi-encoder
- Owner: chrisguttandin
- License: mit
- Created: 2016-05-30T13:56:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-27T18:49:10.000Z (9 months ago)
- Last Synced: 2024-05-01T23:22:17.539Z (9 months ago)
- Topics: midi
- Language: JavaScript
- Size: 19.6 MB
- Stars: 39
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-midi-encoder
**This module encodes a JSON representation of MIDI data into a binary MIDI file.**
[![version](https://img.shields.io/npm/v/json-midi-encoder.svg?style=flat-square)](https://www.npmjs.com/package/json-midi-encoder)
By using this module it is possible to encode a JSON representation of a MIDI file into its binary
counterpart. That JSON representation can either be created from scratch or produced by parsing an
existing file with the [midi-json-parser](https://github.com/chrisguttandin/midi-json-parser).## Usage
This module is distributed as package on [npm](https://www.npmjs.com/package/json-midi-encoder). It
can be installed by running the following command:```shell
npm install json-midi-encoder
```The only exported function is called `encode()`. It expects to receive a JSON representation as its
only parameter. It returns a Promise which hopefully resolves with an ArrayBuffer containing the
binary MIDI file. Here is a little example.```js
import { encode } from 'json-midi-encoder';const json = {
division: 480,
format: 1,
tracks: [
[
{
delta: 0,
trackName: 'example'
},
// ... there are probably more events ...
{
delta: 0,
endOfTrack: true
}
]
// ... maybe there are more tracks ...
]
};encode(json).then((midiFile) => {
// midiFile is an ArrayBuffer containing the binary data.
});
```To see what kind of events this module can handle, you may want to have a look at the
[JSON files](https://github.com/chrisguttandin/json-midi-encoder/tree/master/test/fixtures) used
to test this module. There is also a
[TypeScript interface](https://github.com/chrisguttandin/midi-json-parser-worker/blob/master/src/interfaces/midi-file.ts)
which describes the JSON representation.