{"name":"audio-type","version":"2.4.2","keywords":["audio","type","detect","format","wav","mp3","aac","flac","ogg","opus","m4a","aiff","midi","webm","amr","wma","caf","qoa"],"author":{"url":"http://h3manth.com","name":"Hemanth.HM","email":"hemanth.hm@gmail.com"},"license":"MIT","_id":"audio-type@2.4.2","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"hemanth","email":"hemanth.hm@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/audio-type#readme","bugs":{"url":"https://github.com/audiojs/audio-type/issues"},"dist":{"shasum":"ac3bc9d75f562c065543c65c32095d5bf13a7c5d","tarball":"http://registry-npm.ywwl.com/audio-type/download/audio-type-2.4.2.tgz","fileCount":4,"integrity":"sha512-E9Bl1FGGDS81H/mKvaoPq0iQ8uT3qTBe6XWjipOo5kYrhLMAbjD7hREAVle0YJFahZOVbztxTdkwi0VBDJutSA==","signatures":[{"sig":"MEQCIBPwhQB2sJaIiIbJqxVp/wIsb/sT6/lir41gWI3uvTsiAiBwbohat2q+uxzqdUGqd1zZMNBVT2TpQRLuTnr8E6SZpA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7040,"size":2775,"noattachment":false,"key":"/audio-type/-/audio-type-2.4.2.tgz"},"main":"audio-type.js","type":"module","engines":{"node":">=14"},"funding":"https://github.com/sponsors/audiojs","gitHead":"1e594587e203e8570d79fbb572e7bedf4db4eed7","scripts":{"test":"node test"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/audio-type.git","type":"git"},"_npmVersion":"11.12.1","description":"Detect the audio type of a Buffer/Uint8Array","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","_hasShrinkwrap":false,"devDependencies":{"tape":"^4.6.3","read-chunk":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/audio-type_2.4.2_1783732095595_0.5416299900317694","host":"s3://npm-registry-packages-npm-production"},"readme":"# audio-type [![test](https://github.com/audiojs/audio-type/actions/workflows/test.js.yml/badge.svg)](https://github.com/audiojs/audio-type/actions/workflows/test.js.yml) [![stable](https://img.shields.io/badge/stability-stable-brightgreen.svg)](http://github.com/badges/stability-badges) [![npm](https://img.shields.io/npm/v/audio-type.svg)](https://www.npmjs.com/package/audio-type) [![license](https://img.shields.io/npm/l/audio.svg)](https://www.npmjs.com/package/audio-type)\n\n> Detect the audio type of a ArrayBuffer/Uint8Array\n\n## Install\n\n```sh\n$ npm i audio-type\n```\n\n## Usage\n\n##### Node.js\n\n```js\nimport readChunk from 'read-chunk'; // npm install read-chunk\nimport audioType from 'audio-type';\nvar buffer = readChunk.sync('meow.wav', 0, 64);\n\naudioType(buffer);\n//=> wav\n```\n\n##### Browser\n\n```js\nimport audioType from './audio-type.js'\n\nvar xhr = new XMLHttpRequest();\nxhr.open('GET', 'meow.flac');\nxhr.responseType = 'arraybuffer';\n\nxhr.onload = function () {\n\taudioType(this.response);\n\t//=> flac\n};\n\nxhr.send();\n```\n\n\n## API\n\n### audioType(buffer)\n\nReturns one of the keys below, or `undefined` if the format isn't recognized.\n\n| Key | Format | Magic | Offset |\n| --- | --- | --- | --- |\n| `wav` | WAVE | `RIFF`…`WAVE` | 0, 8 |\n| `aiff` | AIFF/AIFC | `FORM`…`AIFF`/`AIFC` | 0, 8 |\n| `mp3` | MPEG audio | MPEG sync (`0xFF Ex`) or `TAG` (ID3v1 trailer) | 0 |\n| `aac` | AAC (ADTS) | `0xFFF` sync, layer 00 | 0 |\n| `flac` | FLAC, native or in Ogg | `fLaC`, or `OggS`…`\\x7FFLAC` | 0, or 0 and 28 |\n| `tta` | True Audio | `TTA1` | 0 |\n| `m4a` | MPEG-4 audio | `ftyp` or `M4A ` | 4 or 0 |\n| `opus` | Opus (in Ogg) | `OggS`…`OpusHead` | 0, 28 |\n| `oga` | Ogg | `OggS` | 0 |\n| `qoa` | Quite OK Audio | `qoaf` | 0 |\n| `mid` | MIDI | `MThd` | 0 |\n| `caf` | Core Audio Format | `caff` | 0 |\n| `wma` | ASF/WMA | ASF header GUID | 0 |\n| `amr` | AMR | `#!AMR` | 0 |\n| `wv` | WavPack | `wvpk` | 0 |\n| `mpc` | Musepack | `MP+` (SV7) or `MPCK` (SV8) | 0 |\n| `ape` | Monkey's Audio | `MAC ` | 0 |\n| `dsf` | DSD Stream File | `DSD ` | 0 |\n| `dff` | DSDIFF | `FRM8`…`DSD ` | 0, 12 |\n| `eac3` | E-AC-3 (Dolby Digital Plus) | `0x0B77` sync, bsid 11–16 | 0 |\n| `ac3` | AC-3 (Dolby Digital) | `0x0B77` sync, bsid ≤ 8 | 0 |\n| `dts` | DTS | `0x7FFE8001` (or its bit-reordered variants) | 0 |\n| `it` | Impulse Tracker | `IMPM` | 0 |\n| `s3m` | Scream Tracker 3 | `SCRM` | 44 |\n| `xm` | Extended Module | `Extended Module: ` | 0 |\n| `mod` | ProTracker & friends | `M.K.`, `M!K!`, `xCHN`, `xxCH`, `FLTx`, `TDZx`, `CD81`, `OKTA` | 1080 |\n| `mkv` | Matroska | EBML header, DocType `matroska` | 0 |\n| `webm` | WebM | EBML header, DocType `webm` | 0 |\n| `avi` | AVI | `RIFF`…`AVI ` | 0, 8 |\n\nNote: OpenMPT's `.mptm` format is IT-derived and reuses the `IMPM` magic verbatim — it is indistinguishable from `.it` by magic bytes alone and also detects as `it`.\n\n#### buffer\n\nType: `buffer` *(Node.js)*, `arrayBuffer`, `uint8array`\n\nThe first 64 bytes are enough for every format except `mod`, whose tag sits at offset 1080 (past the sample header table) — pass at least the first 1084 bytes if you need to detect trackers.\n\n#### ID3v2 tags\n\n`mp3`, `flac`, `tta` and `aac` files may carry a leading ID3v2 tag. `audioType()` skips it and inspects what follows: `mp3` is only returned once a real MPEG sync is found after the tag — unless the tag's declared size runs past the end of the buffer you gave it, in which case `mp3` is assumed (the overwhelming majority of ID3v2-tagged audio in the wild is MP3, and a truncated probe buffer — the common case — can't prove otherwise). `dsf`'s optional ID3v2 tag lives at the *end* of the file, not the start, so it never enters into this.\n\n## License\n\nMIT • <a href=\"https://github.com/krishnized/license/\">ॐ</a>\n\n","publish_time":1783732095743,"_cnpm_publish_time":1783732095743,"dist-tags":{"latest":"2.8.0"}}