{"id":13626332,"url":"https://github.com/feross/timidity","last_synced_at":"2025-04-04T21:06:56.404Z","repository":{"id":42520320,"uuid":"138107388","full_name":"feross/timidity","owner":"feross","description":"Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity","archived":false,"fork":false,"pushed_at":"2023-12-16T01:20:22.000Z","size":637,"stargazers_count":377,"open_issues_count":15,"forks_count":39,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T20:06:25.729Z","etag":null,"topics":["browser","javascript","midi","midi-files","player","web-audio","webassembly"],"latest_commit_sha":null,"homepage":"https://bitmidi.com","language":"Shell","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/feross.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-06-21T02:06:38.000Z","updated_at":"2025-03-19T17:09:29.000Z","dependencies_parsed_at":"2024-01-08T08:09:50.198Z","dependency_job_id":null,"html_url":"https://github.com/feross/timidity","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":"0.010000000000000009","last_synced_commit":"22b8f911fa322165a1e883bf1d7e4c69bd5e3b04"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Ftimidity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Ftimidity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Ftimidity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Ftimidity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feross","download_url":"https://codeload.github.com/feross/timidity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249524,"owners_count":20908212,"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":["browser","javascript","midi","midi-files","player","web-audio","webassembly"],"created_at":"2024-08-01T21:02:15.508Z","updated_at":"2025-04-04T21:06:56.385Z","avatar_url":"https://github.com/feross.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# timidity\n\n[![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[travis-image]: https://img.shields.io/travis/feross/timidity/master.svg\n[travis-url]: https://travis-ci.org/feross/timidity\n[npm-image]: https://img.shields.io/npm/v/timidity.svg\n[npm-url]: https://npmjs.org/package/timidity\n[downloads-image]: https://img.shields.io/npm/dm/timidity.svg\n[downloads-url]: https://npmjs.org/package/timidity\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n### Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity\n\nPlay MIDI files in a browser with a simple API.\n\n## Demo\n\nThis package is used on [BitMidi.com](https://bitmidi.com), the wayback machine for old-school MIDI files! Check out some examples here:\n\n- [Backstreet Boys - I Want It That Way MIDI](https://bitmidi.com/backstreet-boys-i-want-it-that-way-mid)\n- [Beethoven Moonlight Sonata MIDI](https://bitmidi.com/beethoven-moonlight-sonata-mid)\n- [Kingdom Hearts - Dearly Beloved MIDI](https://bitmidi.com/kingdom-hearts-dearly-beloved-mid)\n- [Camptown Races MIDI](https://bitmidi.com/camptown-mid)\n- [Michael Jackson - Billie Jean MIDI](https://bitmidi.com/michael-jackson-billie-jean-mid)\n- [Michael Jackson - Don't Stop Till You Get Enough MIDI](https://bitmidi.com/michael-jackson-dont-stop-till-you-get-enough-mid)\n- [Passenger - Let Her Go MIDI](https://bitmidi.com/passenger-let_her_go-mid)\n- [Red Hot Chili Peppers - Otherside MIDI](https://bitmidi.com/red-hot-chili-peppers-otherside-mid)\n- [Red Hot Chili Peppers - Californication MIDI](https://bitmidi.com/red-hot-chili-peppers-californication-mid)\n- [Golden Sun - Overworld MIDI](https://bitmidi.com/golden-sun-overworld-mid)\n- [Pokemon - Pokemon Center Theme MIDI](https://bitmidi.com/pokemon-pokemon-center-theme-mid)\n- [Pokemon Red Blue Yellow - Opening MIDI](https://bitmidi.com/pokemon-redblueyellow-opening-yellow-mid)\n- [Pokemon Red Blue Yellow - Wild Pokemon Battle MIDI](https://bitmidi.com/pokemon-redblueyellow-wild-pokemon-battle-mid)\n- [Legend of Zelda - Overworld MIDI](https://bitmidi.com/legend-of-zelda-overworld-mid)\n\n## Install\n\n```\nnpm install timidity\n```\n\n## Features\n\n- Lightweight – Just 23 KB of JavaScript and 22 KB of lazy-loaded WebAssembly\n- Simple – No bells and whistles. Just what is needed to play MIDI files.\n- Works with the [FreePats General MIDI soundset](https://www.npmjs.com/package/freepats).\n\n## Usage\n\n```js\nconst Timidity = require('timidity')\n\nconst player = new Timidity()\nplayer.load('/my-file.mid')\nplayer.play()\n\nplayer.on('playing', () =\u003e {\n  console.log(player.duration) // =\u003e 351.521\n})\n```\n\n## Easier Usage\n\nIf you just want to play MIDI files in the browser and don't need a JavaScript\nAPI interface, consider using the\n[`bg-sound`](https://www.npmjs.com/package/bg-sound) package, which supports\nthis much simpler usage:\n\n```html\n\u003cscript src=\"bg-sound.min.js\"\u003e\u003c/script\u003e\n\u003cbg-sound src=\"sound.mid\"\u003e\u003c/bg-sound\u003e\n```\n\n## API\n\n### `player = new Timidity([baseUrl])`\n\nCreate a new MIDI player.\n\nOptionally, provide a `baseUrl` to customize where the player will look for the\nlazy-loaded WebAssembly file `libtimidity.wasm` and the\n[FreePats General MIDI soundset](https://www.npmjs.com/package/freepats) files.\nThe default `baseUrl` is `/`.\n\nFor example, here is how to mount the necessary files at `/` with the `express`\nserver:\n\n```js\nconst timidityPath = path.dirname(require.resolve('timidity'))\napp.use(express.static(timidityPath))\n\nconst freepatsPath = path.dirname(require.resolve('freepats'))\napp.use(express.static(freepatsPath))\n```\n\n### `player.load(urlOrBuf)`\n\nThis function loads the specified MIDI file `urlOrBuf`, which is a `string` path\nto the MIDI file or a `Uint8Array` which contains the MIDI file data.\n\nThis should be the first function called on a new `Timidity` instance.\n\n### `player.play()`\n\nPlays the currently loaded MIDI file.\n\n### `player.pause()`\n\nPauses the currently loaded MIDI file.\n\n### `player.seek(seconds)`\n\nSeeks to a specified time in the MIDI file.\n\nIf the player is paused when the function is called, it will remain paused. If\nthe function is called from another state (playing, etc.), the player will\ncontinue playing.\n\n### `player.duration`\n\nReturns the duration in seconds (`number`) of the currently playing MIDI file.\nNote that `duration` will return `0` until the file is loaded, which normally\nhappens just before the `playing` event.\n\n### `player.currentTime`\n\nReturns the elapsed time in seconds since the MIDI file started playing.\n\n### `player.destroy()`\n\nDestroys the entire player instance, stops the current MIDI file from playing,\ncleans up all resources.\n\nNote: It's best to reuse the same player instance for as long as possible. It is\nnot recommended to call `player.destroy()` to stop or change MIDI files. Rather,\njust call `player.pause()` to pause or `player.load()` to load a new MIDI file.\n\n### `player.destroyed`\n\nReturns `true` if `destroy()` has been called on the player. Returns `false`\notherwise.\n\n### `player.on('error', (err) =\u003e {})`\n\nThis event fires if a fatal error occurs in the player, including if a MIDI file\nis unable to be played.\n\n### `player.on('timeupdate', (seconds) =\u003e {})`\n\nThis event fires when the time indicated by the `currentTime` property has been\nupdated.\n\n### `player.on('unstarted', () =\u003e {})`\n\nThis event fires when a new MIDI file is being loaded.\n\n### `player.on('ended', () =\u003e {})`\n\nThis event fires when a MIDI file has played until the end.\n\n### `player.on('playing', () =\u003e {})`\n\nThis event fires when a MIDI file starts playing.\n\n### `player.on('paused', () =\u003e {})`\n\nThis event fires when a MIDI file is paused.\n\n### `player.on('buffering', () =\u003e {})`\n\nThis event fires when a MIDI file is loading.\n\n## License\n\nCopyright (c) [Feross Aboukhadijeh](https://feross.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Ftimidity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeross%2Ftimidity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Ftimidity/lists"}