{"id":15570266,"url":"https://github.com/nfroidure/midifile","last_synced_at":"2025-04-06T20:13:56.168Z","repository":{"id":57296875,"uuid":"11185771","full_name":"nfroidure/midifile","owner":"nfroidure","description":"A MIDI file parser/writer using ArrayBuffers","archived":false,"fork":false,"pushed_at":"2018-04-29T10:49:26.000Z","size":342,"stargazers_count":200,"open_issues_count":8,"forks_count":30,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-30T18:09:14.085Z","etag":null,"topics":["hacktoberfest","midi"],"latest_commit_sha":null,"homepage":"http://karaoke.insertafter.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfroidure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-04T20:12:52.000Z","updated_at":"2025-01-24T20:51:23.000Z","dependencies_parsed_at":"2022-09-01T13:01:54.313Z","dependency_job_id":null,"html_url":"https://github.com/nfroidure/midifile","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fmidifile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fmidifile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fmidifile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfroidure%2Fmidifile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfroidure","download_url":"https://codeload.github.com/nfroidure/midifile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543595,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","midi"],"created_at":"2024-10-02T17:41:48.872Z","updated_at":"2025-04-06T20:13:56.149Z","avatar_url":"https://github.com/nfroidure.png","language":"JavaScript","readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# midifile\n\u003e Read/write standard MIDI files.\n\n[![NPM version](https://badge.fury.io/js/midifile.svg)](https://npmjs.org/package/midifile)\n[![Build status](https://secure.travis-ci.org/nfroidure/midifile.svg)](https://travis-ci.org/nfroidure/midifile)\n[![Dependency Status](https://david-dm.org/nfroidure/midifile.svg)](https://david-dm.org/nfroidure/midifile)\n[![devDependency Status](https://david-dm.org/nfroidure/midifile/dev-status.svg)](https://david-dm.org/nfroidure/midifile#info=devDependencies)\n[![Coverage Status](https://coveralls.io/repos/nfroidure/midifile/badge.svg?branch=master)](https://coveralls.io/r/nfroidure/midifile?branch=master)\n[![Code Climate](https://codeclimate.com/github/nfroidure/midifile.svg)](https://codeclimate.com/github/nfroidure/midifile)\n[![Dependency Status](https://dependencyci.com/github/nfroidure/midifile/badge)](https://dependencyci.com/github/nfroidure/midifile)\n\n\n[//]: # (::contents:start)\n\nMIDIFile uses the [MIDIEvents](https://github.com/nfroidure/midievents) project\n and is part of the [MIDIPlayer](https://github.com/nfroidure/midiplayer) one.\n You can also check this [Karaoke Player](http://karaoke.insertafter.com) built\n on top of those libraries.\n\n## What it does\n* Read MIDI files\n* Check MIDI file structure (using strictMode)\n*\tWrite MIDI files (still experimental)\n\n## What it doesn't do\n*\tPlaying MIDI files. It's the role of the\n [MIDIPlayer project](https://github.com/nfroidure/midiplayer).\n\n## Usage\n```js\n// Your variable with your MIDI file as an ArrayBuffer or UInt8Array instance\nvar anyBuffer;\n\n// Creating the MIDIFile instance\nvar midiFile = new MIDIFile(anyBuffer);\n\n// Reading headers\nmidiFile.header.getFormat(); // 0, 1 or 2\nmidiFile.header.getTracksCount(); // n\n// Time division\nif(midiFile.header.getTimeDivision() === MIDIFile.Header.TICKS_PER_BEAT) {\n\tmidiFile.header.getTicksPerBeat();\n} else {\n\tmidiFile.header.getSMPTEFrames();\n\tmidiFile.header.getTicksPerFrame();\n}\n\n// MIDI events retriever\nvar events = midiFile.getMidiEvents();\nevents[0].subtype; // type of [MIDI event](https://github.com/nfroidure/MIDIFile/blob/master/src/MIDIFile.js#L34)\nevents[0].playTime; // time in ms at wich the event must be played\nevents[0].param1; // first parameter\nevents[0].param2; // second one\n\n// Lyrics retriever\nvar lyrics = midiFile.getLyrics();\nif ( lyrics.length ) {\n\tlyrics[0].playTime; // Time at wich the text must be displayed\n\tlyrics[0].text; // The text content to be displayed\n}\n\n// Reading whole track events and filtering them yourself\nvar events = midiFile.getTrackEvents(0);\n\nevents.forEach(console.log.bind(console));\n\n// Or for a single track\nvar trackEventsChunk = midiFile.tracks[0].getTrackContent();\nvar events = MIDIEvents.createParser(trackEventsChunk);\n\nvar event;\nwhile(event = events.next()) {\n\t// Printing meta events containing text only\n\tif(event.type === MIDIEvents.EVENT_META \u0026\u0026 event.text) {\n\t\tconsole.log('Text meta: '+event.text);\n\t}\n}\n```\n\n## Testing\nUnit tests are using mocha and NodeJS. Install them and run the following command:\n\n```bash\nmocha tests/*.mocha.js\n```\n\n## Why ArrayBuffers ?\nArrayBuffer instances are the best way to manage binary data like MIDI files.\n\n## Why not streams ?\nThe Standard MIDI files format isn't streamable by nature. If you want to stream\n MIDI file contents, you should consider transforming your files in another\n format (plain linearized MIDI events should do the job).\n\n## Requirements\n* ArrayBuffer, DataView or their polyfills\n\n## Contributing\n* Feel free to PR\n* If you find a MIDI File the library can't read an if it's under a free, PR\n the file in the sounds folder and add tests for him. I'll work on it asap.\n\n\n[//]: # (::contents:end)\n\n# License\n[MIT](https://github.com/nfroidure/midifile/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfroidure%2Fmidifile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfroidure%2Fmidifile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfroidure%2Fmidifile/lists"}