{"id":21186834,"url":"https://github.com/patrickroberts/synth-js","last_synced_at":"2025-07-10T01:31:33.545Z","repository":{"id":57376234,"uuid":"90235084","full_name":"patrickroberts/synth-js","owner":"patrickroberts","description":"JavaScript MIDI-to-WAV synthesizer","archived":false,"fork":false,"pushed_at":"2023-04-01T10:36:22.000Z","size":92,"stargazers_count":37,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-06T23:45:30.427Z","etag":null,"topics":["command-line-tool","javascript","midi-parser","node-module","wav-files"],"latest_commit_sha":null,"homepage":null,"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/patrickroberts.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}},"created_at":"2017-05-04T07:39:05.000Z","updated_at":"2024-08-23T15:37:51.000Z","dependencies_parsed_at":"2022-09-05T19:11:49.582Z","dependency_job_id":null,"html_url":"https://github.com/patrickroberts/synth-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fsynth-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fsynth-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fsynth-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fsynth-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickroberts","download_url":"https://codeload.github.com/patrickroberts/synth-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225609044,"owners_count":17496024,"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":["command-line-tool","javascript","midi-parser","node-module","wav-files"],"created_at":"2024-11-20T18:26:27.427Z","updated_at":"2024-11-20T18:26:27.932Z","avatar_url":"https://github.com/patrickroberts.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# synth-js\n\nCommand-line utility and Node module for generating raw audio data from MIDI files.\n\n## Installation\n\n### Command-line utility:\n\n```bash\n$ npm link synth-js\n```\n\n### Node module:\n\n```bash\n$ npm install --save synth-js\n```\n\n### JavaScript:\n\n```html\n\u003cscript src=\"synth.min.js\"\u003e\u003c/script\u003e\n```\n\nAfter including the file from `dst/synth.min.js`, the global variable `synth` will be initialized.\n\n## Usage\n\n### Command-line utility:\n\n```bash\n# assuming song.mid in cwd\n$ synth -i song\n# now song.wav contains raw audio data for song.mid\n```\n\n### Node module:\n\n```js\nconst synth = require('synth-js');\nconst fs = require('fs');\n\nlet midBuffer = fs.readFileSync('song.mid');\n// convert midi buffer to wav buffer\nlet wavBuffer = synth.midiToWav(midiBuffer).toBuffer();\n\nfs.writeFileSync('song.wav', wavBuffer, {encoding: 'binary'});\n```\n\n### JavaScript:\n\n```html\n\u003cstyle\u003e\n  #wav:after {\n    content: \" \" attr(download);\n  }\n\n  #wav:not([href]) {\n    display: none;\n  }\n\u003c/style\u003e\n\u003cinput type=\"file\" id=\"midi\" accept=\"audio/midi\"\u003e\n\u003ca id=\"wav\"\u003eDownload\u003c/a\u003e\n\u003cscript\u003e\n  var audio;\n  var input = document.getElementById('midi');\n  var anchor = document.getElementById('wav');\n\n  input.addEventListener('change', function change() {\n    // clean up previous song, if any\n    if (anchor.hasAttribute('href')) {\n      URL.revokeObjectURL(anchor.href);\n      anchor.removeAttribute('href');\n\n      if (audio \u0026\u0026 !audio.paused) {\n        audio.pause();\n      }\n    }\n\n    // check if file exists\n    if (input.files.length \u003e 0) {\n      var reader = new FileReader();\n      var midName = input.files[0].name;\n      // replace file extension with .wav\n      var wavName = midName.replace(/\\..+?$/, '.wav');\n\n      // set callback for array buffer\n      reader.addEventListener('load', function load(event) {\n        // convert midi arraybuffer to wav blob\n        var wav = synth.midiToWav(event.target.result).toBlob();\n        // create a temporary URL to the wav file\n        var src = URL.createObjectURL(wav);\n\n        audio = new Audio(src);\n        audio.play();\n\n        anchor.setAttribute('href', src);\n      });\n\n      // read the file as an array buffer\n      reader.readAsArrayBuffer(input.files[0]);\n\n      // set the name of the wav file\n      anchor.setAttribute('download', wavName);\n    }\n  });\n\u003c/script\u003e\n```\n\nSee the demo [here][browser-demo].\n\n## FAQ\n\n### Where can I find documentation?\n\nCurrently, documentation only exists for the command-line utility.\nTo access it, use `man`:\n\n```bash\n$ man synth\n```\n\nFor Node or JavaScript, refer to the `src/` directory for accessible APIs:\n\n* `synth.WAV()`\n* `synth.MIDIStream()`\n* `synth.midiToWav()`\n\n## License\n\nAvailable under the MIT License\n\n[browser-demo]: https://jsfiddle.net/patrob10114/o5r1adyz/show/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickroberts%2Fsynth-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickroberts%2Fsynth-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickroberts%2Fsynth-js/lists"}