{"id":18909031,"url":"https://github.com/chdh/wav-file-decoder","last_synced_at":"2025-04-15T05:32:25.553Z","repository":{"id":65001351,"uuid":"579828542","full_name":"chdh/wav-file-decoder","owner":"chdh","description":"A simple decoder for WAV audio files","archived":false,"fork":false,"pushed_at":"2022-12-27T02:31:30.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T16:51:18.012Z","etag":null,"topics":["audio","decoder","wav-file"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/chdh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-19T02:59:55.000Z","updated_at":"2024-06-17T17:15:18.000Z","dependencies_parsed_at":"2023-01-13T15:12:34.230Z","dependency_job_id":null,"html_url":"https://github.com/chdh/wav-file-decoder","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/chdh%2Fwav-file-decoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fwav-file-decoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fwav-file-decoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fwav-file-decoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chdh","download_url":"https://codeload.github.com/chdh/wav-file-decoder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249015622,"owners_count":21198823,"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":["audio","decoder","wav-file"],"created_at":"2024-11-08T09:30:14.940Z","updated_at":"2025-04-15T05:32:25.283Z","avatar_url":"https://github.com/chdh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wav-file-decoder\n\nA simple decoder for [WAV](https://en.wikipedia.org/wiki/WAV) audio files.\n\n**NPM package**: [wav-file-decoder](https://www.npmjs.com/package/wav-file-decoder)\u003cbr\u003e\n**Online demo**: [www.source-code.biz/snippets/typescript/wavFileDecoder](http://www.source-code.biz/snippets/typescript/wavFileDecoder)\u003cbr\u003e\n**Examples of how to use it**: [github.com/chdh/wav-file-decoder/tree/main/test/src](https://github.com/chdh/wav-file-decoder/tree/main/test/src)\u003cbr\u003e\n**Compagnion package**: [wav-file-encoder](https://www.npmjs.com/package/wav-file-encoder)\n\n## API\n\n### Test if a file is a WAV file\n\n```typescript\nfunction isWavFile (fileData: ArrayBufferView | ArrayBuffer) : boolean\n```\n\n* `fileData`: An `ArrayBufferView`\n  (e.g. [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\n  or Node.js [Buffer](https://nodejs.org/api/buffer.html))\n  or an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n  that contains the raw data bytes of a WAV file.\n* Return value: `true` if the file looks like a valid and supported WAV file.\n\n### Decode a WAV file\n\n```typescript\nfunction decodeWavFile (fileData: ArrayBufferView | ArrayBuffer) : AudioData\n```\n\n* `fileData`: An `ArrayBufferView`\n  (e.g. [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\n  or Node.js [Buffer](https://nodejs.org/api/buffer.html))\n  or an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n  that contains the raw data bytes of a WAV file.\n* Return value: A data structure containing the decoded WAV file data.\n\n```typescript\ninterface AudioData {\n  channelData:      Float32Array[]; // arrays containing the audio samples (PCM data), one array per channel\n  sampleRate:       number;         // sample rate (samples per second)\n  numberOfChannels: number;         // number of channels, same as channelData.length\n  audioEncoding:    AudioEncoding;  // audio encoding in the WAV file (int or float)\n  bitsPerSample:    number;         // number of bits per sample in the WAV file\n  wavFileTypeName:  string;         // combination of audioEncoding and bitsPerSample, e.g. \"int16\" or \"float32\"\n}\nenum AudioEncoding {\n  pcmInt,                           // 0 = PCM integer\n  pcmFloat                          // 1 = PCM float\n}\n```\n\nThe audio sample values in the `channelData` arrays are within the range -1 to +1.\u003cbr\u003e\nAn exception is thrown when the passed file is not a WAV file or when the format of the WAV file is not supported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fwav-file-decoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchdh%2Fwav-file-decoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fwav-file-decoder/lists"}