{"id":18446354,"url":"https://github.com/misterhat/tinymidipcm","last_synced_at":"2025-07-26T07:05:33.752Z","repository":{"id":74315240,"uuid":"595040785","full_name":"misterhat/tinymidipcm","owner":"misterhat","description":"render MIDIs to PCM with custom soundfonts via tinysoundfont in WASM","archived":false,"fork":false,"pushed_at":"2023-02-02T06:48:56.000Z","size":6058,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-13T01:21:41.538Z","etag":null,"topics":["midi","pcm","sf2","soundfont","wasm"],"latest_commit_sha":null,"homepage":"","language":"C","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/misterhat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T09:16:43.000Z","updated_at":"2025-01-09T07:21:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"61cac827-985b-4d8a-8876-b1263fdc9a74","html_url":"https://github.com/misterhat/tinymidipcm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/misterhat/tinymidipcm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Ftinymidipcm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Ftinymidipcm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Ftinymidipcm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Ftinymidipcm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misterhat","download_url":"https://codeload.github.com/misterhat/tinymidipcm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Ftinymidipcm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267133643,"owners_count":24040782,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["midi","pcm","sf2","soundfont","wasm"],"created_at":"2024-11-06T07:09:05.422Z","updated_at":"2025-07-26T07:05:33.732Z","avatar_url":"https://github.com/misterhat.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tinymidipcm\n\nrender MIDIs to PCM with custom soundfonts via tinysoundfont in WASM.\n\n## example\n```javascript\nimport TinyMidiPCM from 'tinymidipcm';\n\n(async () =\u003e {\n    const midiRes = await fetch('/e1m1.mid');\n    const midiBuffer = new Uint8Array(await midiRes.arrayBuffer());\n\n    const channels = 2;\n    const sampleRate = 44100;\n\n    let renderEndSeconds = 0;\n\n    const tinyMidiPCM = new TinyMidiPCM({\n        channels,\n        sampleRate,\n        renderInterval: 1000,\n        onPCMData: (pcm) =\u003e player.feed(pcm),\n        onRenderEnd: (ms) =\u003e {\n            console.log('midi finished rendering.');\n\n            renderEndSeconds = Math.floor(ms / 1000);\n            console.log(renderEndSeconds, 'seconds');\n        }\n    });\n\n    const pcmPlayerOptions = {\n        inputCodec: 'Float32',\n        channels,\n        sampleRate,\n        onended: async () =\u003e {\n            const timeSeconds = Math.floor(\n                player.audioCtx.currentTime\n            );\n\n            if (\n                renderEndSeconds \u003e 0 \u0026\u0026\n                Math.abs(timeSeconds - renderEndSeconds) \u003c= 2\n            ) {\n                console.log('midi finished playing.');\n                renderEndSeconds = 0;\n            }\n        },\n        flushTime: 1000\n    };\n\n    // https://www.npmjs.com/package/pcm-player\n    const player = new PCMPlayer(pcmPlayerOptions);\n\n    tinyMidiPCM.setBufferDuration(2);\n\n    await tinyMidiPCM.init();\n\n    const soundfontRes = await fetch('/scc1t2.sf2');\n\n    const soundfontBuffer = new Uint8Array(\n        await soundfontRes.arrayBuffer()\n    );\n\n    tinyMidiPCM.setSoundfont(soundfontBuffer);\n\n    window.onclick = async () =\u003e {\n        await player.pause();\n        player.destroy();\n        player.init(pcmPlayerOptions);\n\n        player.volume(1);\n\n        tinyMidiPCM.render(midiBuffer);\n    };\n})();\n```\n\n## api\n\n### tinyMidiPCM = new TinyMidiPCM(options = {})\n\ncreate a new rendering instance. options include:\n\n* `bufferSize` PCM chunk size to render per `renderInterval`. default\nto 1 second worth of data.\n* `renderInterval` how often in ms to generate a new `bufferSize` PCM data\nevent. default `30`.\n* `sampleRate` default `44100`.\n* `channels` stereo or mono. default `2`.\n* `gain` volume gain in decibels (\u003e0 means higher, \u003c0 means lower).\n* `onPCMData` function callback wich emits a `Uint8Array` of PCM data at\n`renderInterval` rate. encoded as 32 bit floats.\n* `onRenderEnd` function callback when the entire MIDI is processed, providing\nmillseconds rendered argument.\n\n### async tinyMidiPCM.init()\n\nfetch and load the wasm. required for following methods.\n\n### tinyMidiPCM.render(midiBuffer)\n\nstart emitting `onPCMData` callbacks. `midiBuffer` is a `Uint8Array` of a MIDI\nfile.\n\n## license\n\n\u003e [TinySoundFont](https://github.com/schellingb/TinySoundFont) is available\n\u003e under the [MIT license](https://choosealicense.com/licenses/mit/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterhat%2Ftinymidipcm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisterhat%2Ftinymidipcm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterhat%2Ftinymidipcm/lists"}