{"_id":"@david18284/tonejs-midi-es","_rev":"2-46876e640985b12923a294c0efce6e39","name":"@david18284/tonejs-midi-es","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@david18284/tonejs-midi-es","version":"2.0.0","description":"Convert binary midi into JSON","main":"build/Midi.js","module":"dist/Midi.js","jsnext:main":"dist/Midi.js","types":"dist/Midi.d.ts","scripts":{"build":"tsc && webpack -p --mode=production","codecov":"nyc report --reporter=text-lcov > coverage.lcov && codecov","docs":"typedoc","increment":"node scripts/increment_version.js","lint":"eslint --ext ts ./src","lint:fix":"npm run lint -- --fix","watch":"webpack -w --mode=development","test":"nyc mocha --timeout=10000 --require ts-node/register ./test/*.ts"},"repository":{"type":"git","url":"git+https://github.com/Tonejs/Midi.git"},"author":{"name":"Yotam Mann"},"license":"MIT","bugs":{"url":"https://github.com/Tonejs/Midi/issues"},"homepage":"https://tonejs.github.com/Midi/","devDependencies":{"@babel/core":"^7.11.1","@babel/polyfill":"^7.10.4","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@types/chai":"^4.2.12","@types/mocha":"^8.0.2","@types/node":"^11.15.20","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","chai":"^4.2.0","codecov":"^3.7.2","eslint":"^6.8.0","glob":"^7.1.6","http-server":"^0.12.3","mocha":"^8.1.1","node-fetch":"^2.6.0","nyc":"^14.1.1","semver":"^5.7.1","source-map-support":"^0.5.19","ts-loader":"^5.4.5","ts-node":"^8.10.2","typedoc":"^0.15.8","typescript":"^3.9.7","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"dependencies":{"array-flatten":"^2.1.2","midi-file":"^1.1.2"},"nyc":{"include":["src/**/*.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["lcov","html"],"sourceMap":true,"instrument":true},"prettier":{"trailingComma":"es5","tabWidth":4,"semi":true,"useTabs":true,"singleQuote":false},"gitHead":"9a9f80fec1ba04000e00d8f3fb0024c2fb6857b0","_id":"@david18284/tonejs-midi-es@2.0.0","_nodeVersion":"12.6.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-1ybpj6lmLdcmMSu8wrXVhOagO61P1LqpfuV7IWz5fEuOBhTRSjE7QUka3wlEAX7WSB7KTNkuABZoauXMrZtgIw==","shasum":"9bdc4d724773b5fbab7b84846bfac31471117148","tarball":"https://registry.npmjs.org/@david18284/tonejs-midi-es/-/tonejs-midi-es-2.0.0.tgz","fileCount":50,"unpackedSize":269339,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOYEECRA9TVsSAnZWagAA94YP/0iIWzVwdmfAci9eyM5p\nDa0rkhWq8TEKYtRBOjy3a0ikkvQLSl41LPbAc8CyvKOp/ldtp/qkQGi0F66u\n9L4S+z5oBPolkNQzDevIA+v7iDP6qcohzCjQEPxfG7psf1uxE5uxHuOR0CxS\nmgcUR7ZVgyx7U/rpZLmRzHO+Z3mrjByQg2edsc+lV2r0csMYH370R6LGtw0x\nnObxc3WA36R/Ej302ZmIPxFVDDbpzlzlTTwGKJJEMubJukKo9xj1ee8oTh6w\njH/h46g+0R4eZXmNlKcWqBPmyd+bh+c2T3oLOFNrTdg3zqCp9hUe7mr9DHM+\niNUKC3Xdr4zbm+kykglsIgKbpB5na8Ey8hn9GJITQnaHKDVf09AiRwrb1U9c\nyGq7zQnwY4eS7vgz2GCwgMyuu9rNsP/SCPRlplECW33NfNBVV0IErWdjQgek\n//nXjnWOYV49PS6eM/hdvagaIEMJXu0eBuhf1MIueQhuZkeg5FvsoyRDB63H\nFVBLNWTJ2tYjHOm1nTBp2p2QD8ZBhMjL8g+Valz8dMGSpQNtsI3JHd0bAWdm\nO2q4Bn/HDn8I4uQbp8VCQf4I9HnTXdxqyh7eIi5HFrHchBt6Ps35m/WwFARf\nKr72gJpBshJeHEglc9qWiUNf/0G51NQ61Ek+Pz3fmVThRXUcpMrZE1QTFlpv\nmDJF\r\n=hLyn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFXkAg3KTx+8jg9UGmeYAfLb9/LRD1oi2C/RKfxeJL9vAiByazbwmBKia3XNJtm46SKTrlXpBMXuZiGQ51cXy3r4fg=="}]},"maintainers":[{"name":"david18284","email":"david@davidl.me"}],"_npmUser":{"name":"david18284","email":"david@davidl.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tonejs-midi-es_2.0.0_1597604099748_0.7736103887119883"},"_hasShrinkwrap":false},"2.0.1":{"name":"@david18284/tonejs-midi-es","version":"2.0.1","description":"Convert binary midi into JSON","main":"build/Midi.js","module":"dist/Midi.js","jsnext:main":"dist/Midi.js","types":"dist/Midi.d.ts","scripts":{"build":"tsc && webpack -p --mode=production","codecov":"nyc report --reporter=text-lcov > coverage.lcov && codecov","docs":"typedoc","increment":"node scripts/increment_version.js","lint":"eslint --ext ts ./src","lint:fix":"npm run lint -- --fix","watch":"webpack -w --mode=development","test":"nyc mocha --timeout=10000 --require ts-node/register ./test/*.ts"},"repository":{"type":"git","url":"git+https://github.com/Tonejs/Midi.git"},"author":{"name":"Yotam Mann"},"license":"MIT","bugs":{"url":"https://github.com/Tonejs/Midi/issues"},"homepage":"https://tonejs.github.com/Midi/","devDependencies":{"@babel/core":"^7.11.1","@babel/polyfill":"^7.10.4","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@types/chai":"^4.2.12","@types/mocha":"^8.0.2","@types/node":"^11.15.20","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","chai":"^4.2.0","codecov":"^3.7.2","eslint":"^6.8.0","glob":"^7.1.6","http-server":"^0.12.3","mocha":"^8.1.1","node-fetch":"^2.6.0","nyc":"^14.1.1","semver":"^5.7.1","source-map-support":"^0.5.19","ts-loader":"^5.4.5","ts-node":"^8.10.2","typedoc":"^0.15.8","typescript":"^3.9.7","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"dependencies":{"array-flatten":"^2.1.2","midi-file":"^1.1.2"},"nyc":{"include":["src/**/*.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["lcov","html"],"sourceMap":true,"instrument":true},"prettier":{"trailingComma":"es5","tabWidth":4,"semi":true,"useTabs":true,"singleQuote":false},"gitHead":"9a9f80fec1ba04000e00d8f3fb0024c2fb6857b0","_id":"@david18284/tonejs-midi-es@2.0.1","_nodeVersion":"12.6.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-ArU1CidlG6/aMzK1Mlfha/KdpQyxZlngWVAbHUoYsVHtRuzF1RCf3BKdmI3FMwNK5DX/LTounk64Qb01/RDwjg==","shasum":"ea359170cd82d0a1fbd84a425d7b890be43a1146","tarball":"https://registry.npmjs.org/@david18284/tonejs-midi-es/-/tonejs-midi-es-2.0.1.tgz","fileCount":50,"unpackedSize":269453,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOYG4CRA9TVsSAnZWagAAuxYP/2fVWEQK/yFNEzpwCqYl\nEUlsSz+YNY3ji878n8cZ6HfC8t3XTZZtBdhHye9wQsSdt2pL81i0FlJoiBtb\nMcmQf67dFJTZrQZZf1zehTgIEH3BBCMKD89UqUcY1ZuQOV2kUVJqERg2HMYJ\n4WznVdPO/kH8z13ZIEBjQtAieDnG3M0JAbYaZ/I84YNAY5fvBNFf2CzbaRaj\neNwVPUasvxvIr17vT+jjiqGY+Abe/P3l4h8ZTt5QEMBUtfkOeR6h4dryskZ+\nVvgxvOdvy5+LePJ89Sp+5kn2I8i8OpsHgR9YrX8pA1pb2RMizxaj5ytaU1p7\nzesUVqYfHPjfA3HA+siHFB8/YqtYXMVL9xXcnOGGEoKptXUa8+ohx9JjPaMe\nOz4AxZbgt3szsKSl7dloCcdnGx39vmQcZTcqd4CckPhVBnc6SE9xyPtdoTk6\nurBYOgZgbHZl6IxFbpin6DDHr6fQlC2rZw4r1DKWJ0yNhW89oYVGJApMnTaR\nHSnK8+try+/+IUMDfu50Iez6NP2FNflTstgqkYbT1rCdV+ctRlJjfxRm9aRF\nr5SbA6rQkVLQSIMXj6mxdRiIK4/ELTqJUqkoLU27MlQ8NIMPNSZHTQRFig33\nf7WjSjPVjFda5yjCSb8nwzPM9CgYbmwC/ffQ+KLdf1ochoMDuxJcOkGxhnZ6\n0WPg\r\n=BhvJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICPxlsDGYH7VqkPcrd4cCLsCf/kCFH8J9Ihd8LalxubvAiEAv3tIhkzPVp4rdDLmsO99AjFco+ytYmnqbvsYvYuCBlM="}]},"maintainers":[{"name":"david18284","email":"david@davidl.me"}],"_npmUser":{"name":"david18284","email":"david@davidl.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tonejs-midi-es_2.0.1_1597604279906_0.6984309396949404"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-16T18:54:59.700Z","2.0.0":"2020-08-16T18:54:59.879Z","modified":"2022-04-05T03:05:30.941Z","2.0.1":"2020-08-16T18:58:00.029Z"},"maintainers":[{"name":"david18284","email":"david@davidl.me"}],"description":"Convert binary midi into JSON","homepage":"https://tonejs.github.com/Midi/","repository":{"type":"git","url":"git+https://github.com/Tonejs/Midi.git"},"author":{"name":"Yotam Mann"},"bugs":{"url":"https://github.com/Tonejs/Midi/issues"},"license":"MIT","readme":"[![Build Status](https://travis-ci.org/Tonejs/Midi.svg?branch=master)](https://travis-ci.org/Tonejs/Midi)\n[![codecov](https://codecov.io/gh/Tonejs/Midi/branch/master/graph/badge.svg)](https://codecov.io/gh/Tonejs/Midi)\n\nThis is a modified version of [`@tonejs/midi`](https://github.com/Tonejs/Midi) which uses ES modules.\n\n## Installation\n\n`npm install @david18284/tonejs-midi-es`\n\n## [DEMO](https://tonejs.github.io/Midi/)\n\nMidi makes it straightforward to read and write MIDI files with Javascript. It uses [midi-file](https://github.com/carter-thaxton/midi-file) for parsing and writing.\n\n## Import\n\nNode.js:\n\n```javascript\nconst { Midi } = require('@tonejs/midi')\n```\n\nTypescript / ES6\n\n```javascript\nimport { Midi } from '@tonejs/midi'\n```\n\nBrowser\n\n```html\n<script src=\"https://unpkg.com/@tonejs/midi\"></script>\n```\n```javascript\nconst midi = new Midi()\n```\n\n## Basic Example\n\n\n```javascript\n// load a midi file in the browser\nconst midi = await Midi.fromUrl(\"path/to/midi.mid\")\n//the file name decoded from the first track\nconst name = midi.name\n//get the tracks\nmidi.tracks.forEach(track => {\n  //tracks have notes and controlChanges\n\n  //notes are an array\n  const notes = track.notes\n  notes.forEach(note => {\n    //note.midi, note.time, note.duration, note.name\n  })\n\n  //the control changes are an object\n  //the keys are the CC number\n  track.controlChanges[64]\n  //they are also aliased to the CC number's common name (if it has one)\n  track.controlChanges.sustain.forEach(cc => {\n    // cc.ticks, cc.value, cc.time\n  })\n\n  //the track also has a channel and instrument\n  //track.instrument.name\n})\n```\n\n### Format\n\nThe data parsed from the midi file looks like this:\n\n```javascript\n{\n  // the transport and timing data\n  header: {\n    name: String,                     // the name of the first empty track,\n                                      // which is usually the song name\n    tempos: TempoEvent[],             // the tempo, e.g. 120\n    timeSignatures: TimeSignatureEvent[],  // the time signature, e.g. [4, 4],\n\n    PPQ: Number                       // the Pulses Per Quarter of the midi file\n                                      // this is read only\n  },\n\n  duration: Number,                   // the time until the last note finishes\n\n  // an array of midi tracks\n  tracks: [\n    {\n      name: String,                   // the track name if one was given\n\n      channel: Number,                // channel\n                                      // the ID for this channel; 9 and 10 are\n                                      // reserved for percussion\n      notes: [\n        {\n          midi: Number,               // midi number, e.g. 60\n          time: Number,               // time in seconds\n          ticks: Number,              // time in ticks\n          name: String,               // note name, e.g. \"C4\",\n          pitch: String,              // the pitch class, e.g. \"C\",\n          octave : Number,            // the octave, e.g. 4\n          velocity: Number,           // normalized 0-1 velocity\n          duration: Number,           // duration in seconds between noteOn and noteOff\n        }\n      ],\n\n      // midi control changes\n      controlChanges: {\n        // if there are control changes in the midi file\n        '91': [\n          {\n            number: Number,           // the cc number\n            ticks: Number,            // time in ticks\n            time: Number,             // time in seconds\n            value: Number,            // normalized 0-1\n          }\n        ],\n      },\n\n      instrument: {                   // and object representing the program change events\n        number : Number,              // the instrument number 0-127\n        family: String,               // the family of instruments, read only.\n        name : String,                // the name of the instrument\n        percussion: Boolean,          // if the instrument is a percussion instrument\n      },          \n    }\n  ]\n}\n```\n\n### Raw Midi Parsing\n\nIf you are using Node.js or have the raw binary string from the midi file, just use the `parse` method:\n\n```javascript\nconst midiData = fs.readFileSync(\"test.mid\")\nconst midi = new Midi(midiData)\n```\n\n### Encoding Midi\n\nYou can also create midi files from scratch or by modifying an existing file.\n\n```javascript\n// create a new midi file\nvar midi = new Midi()\n// add a track\nconst track = midi.addTrack()\ntrack.addNote({\n  midi : 60,\n  time : 0,\n  duration: 0.2\n})\n.addNote({\n  name : 'C5',\n  time : 0.3,\n  duration: 0.1\n})\n.addCC({\n  number : 64,\n  value : 127,\n  time : 0.2\n})\n\n// write the output\nfs.writeFileSync(\"output.mid\", new Buffer(midi.toArray()))\n```\n\n### Acknowledgment\n\nThank you [midi-file](https://github.com/carter-thaxton/midi-file)!\n","readmeFilename":"README.md"}