{"_id":"@audio/decode-tta","_rev":"2-9d73320df5f5c0e951116c115c89268f","name":"@audio/decode-tta","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@audio/decode-tta","version":"1.0.0","keywords":["tta","true-audio","lossless","audio","decode","decoder","pcm","rice-coding"],"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"license":"MIT","_id":"@audio/decode-tta@1.0.0","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-tta","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"39cc08ee6f6c52ca40279160f3ee09675c114555","tarball":"https://registry.npmjs.org/@audio/decode-tta/-/decode-tta-1.0.0.tgz","fileCount":8,"integrity":"sha512-aTEoPkZmh1BUJ7ewqKhPT3Sk3OSKzoaUxDFp4AJSQLQDE+Bapc3MRTldoxp8VHu2YZSuiJgcfDutz96uGQV41w==","signatures":[{"sig":"MEQCIFblb8BYsSChxDdyczUfQLJ4T74hGiS6GWnKc+6h7y8cAiBoT2kQFiMc7Wm24iIXo5HDVXoXXoi7BnnXhXdOarZ1jQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21478},"main":"decode-tta.js","type":"module","audio":"./audio.js","types":"decode-tta.d.ts","engines":{"node":">=18"},"exports":{".":"./decode-tta.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"c227363046dc3a0308c95ee112f22795c0ac04ca","scripts":{"test":"node test.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-tta"},"_npmVersion":"11.12.1","description":"Decode TTA (True Audio) lossless audio to PCM samples","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.4.0"},"_npmOperationalInternal":{"tmp":"tmp/decode-tta_1.0.0_1787966911760_0.46557537914760294","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"_id":"@audio/decode-tta@2.0.0","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"9d604e5cef8397c90e467d929694569605144e43","tarball":"https://registry.npmjs.org/@audio/decode-tta/-/decode-tta-2.0.0.tgz","fileCount":8,"integrity":"sha512-kJ7h2EUfWAwAidvP0+LbTzY6ivz3x03Qbpo9M+h3b9/F2VOTtEP/SAIV+FQLfDh9r5R5lzppvGB4lxg1Bp2hsQ==","signatures":[{"sig":"MEYCIQDukrCdwRkfr6a4N3ERrvrjlxRx7GyNk5MHQtH83LIuKwIhAKUrFHD8TBt1Mp3DDIKyAavDbef8rBWYtVJhQBhUZZ9t","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC98U2qV0MpnsUqF/XR1dx+HP0KGMv0MNJOaieCmuxCmwIgLmeuDmvK8d6mCMw+jbWwI6Stlhtr/0gNLh80XdtVn6s="}],"unpackedSize":21487},"main":"decode-tta.js","name":"@audio/decode-tta","type":"module","audio":"./audio.js","types":"decode-tta.d.ts","author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"engines":{"node":">=18"},"exports":{".":"./decode-tta.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"1c88e2371bc5ef978c5c25b15c27aacbcea6b04a","license":"MIT","scripts":{"test":"node test.js"},"version":"2.0.0","_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-tta","keywords":["tta","true-audio","lossless","audio","decode","decoder","pcm","rice-coding"],"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-tta"},"_npmVersion":"11.12.1","description":"Decode TTA (True Audio) lossless audio to PCM samples","directories":{},"maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"sideEffects":false,"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.4.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/decode-tta_2.0.0_1790635532778_0.03521163903807034"}}},"time":{"created":"2026-08-29T01:28:31.568Z","modified":"2026-09-28T22:45:33.080Z","1.0.0":"2026-08-29T01:28:31.907Z","2.0.0":"2026-09-28T22:45:32.934Z"},"bugs":{"url":"https://github.com/audiojs/decode/issues"},"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"license":"MIT","homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-tta","keywords":["tta","true-audio","lossless","audio","decode","decoder","pcm","rice-coding"],"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-tta"},"description":"Decode TTA (True Audio) lossless audio to PCM samples","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"readme":"# @audio/decode-tta [![npm](https://img.shields.io/npm/v/@audio/decode-tta)](https://www.npmjs.com/package/@audio/decode-tta) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license)\n\nDecode TTA (True Audio) lossless audio to PCM samples, in pure JavaScript\n\n```\nnpm install @audio/decode-tta\n```\n\n```js\nimport decode, { decoder } from '@audio/decode-tta'\n```\n\nTTA1 is Alexander Djourik's lossless codec: per channel, an adaptive two-state Rice coder feeds an 8-tap sign-sign-LMS \"hybrid\" filter and a fixed first-order predictor; multichannel streams decorrelate the last channel against the rest with a cascading half-sum/difference. Written from the [TTA project](https://sourceforge.net/projects/tta/) and the BSD-licensed reference decoder — Djourik & Zhilin, True Audio Software (2004): `ttadec.c` / `filter.h` / `ttadec.h` / `ttalib.h`, via [Rockbox's libtta port](https://github.com/Rockbox/rockbox/tree/master/lib/rbcodec/codecs/libtta) which retains the original license — see [LICENSE.ttadec](./LICENSE.ttadec). Decodes exactly what `ffmpeg -c:a tta` writes: 8/16/24-bit PCM, mono through 16 channels.\n\n```js\nlet { channelData, sampleRate } = decode(ttaBytes)\n\nlet dec = decoder()\nlet head = dec.decode(chunk1)   // synchronous; header/seek-table/frame boundaries carry over\nlet tail = dec.flush()\ndec.free()\n```\n\n## API\n\n### `decode(src: Uint8Array | ArrayBuffer): AudioData`\n\nDecode a complete stream.\n\n### `decoder(): TTADecoder`\n\nSynchronous streaming decoder. `decode(chunk)` returns the samples of every complete frame in the data so far — frame byte lengths are known from the seek table, so a chunk boundary anywhere (even mid-header) just carries over to the next call. `flush()` drops a trailing incomplete header/seek-table/frame. `free()` releases state and is idempotent. `errors` counts frames dropped for a CRC32 mismatch.\n\n### `AudioData`\n\n```ts\n{ channelData: Float32Array[], sampleRate: number }\n```\n\n## CRC32\n\nTTA1 checksums the header, the seek table, and every frame independently. A header or seek-table mismatch throws — those describe the stream's shape and can't be decoded around. A frame mismatch is not fatal: since each frame resets its filter/predictor/Rice state from scratch, one bad frame can't corrupt its neighbors, so that frame's samples are dropped, `errors` increments, and decoding continues.\n\n## Notes\n\n- Only format 1 (plain PCM) is decoded; format 2 (password-encrypted TTA) throws.\n- Channel order is kept exactly as encoded — TTA does not reorder channels the way AC-3/DTS do, so `channelData[i]` is stream channel `i`.\n- A leading ID3v2 tag (some encoders other than ffmpeg prepend one) is detected and skipped before the `TTA1` signature; a trailing APEv2 tag is ignored.\n- A truncated file loses its final incomplete frame silently, matching `flush()`'s \"drop the partial\" behavior in the other atoms in this umbrella.\n- 60 s of 44.1 kHz stereo decodes in ~225 ms on a current laptop (~265× real-time).\n\n**Use when:** opening `.tta` files, or decoding a TTA track pulled out of a container.\n\n---\n\nPart of [@audio/decode](https://github.com/audiojs/decode) — the decode family umbrella.\n\nMIT © [audiojs](https://github.com/audiojs), algorithm ported from the BSD-licensed TTA reference decoder — see [LICENSE.ttadec](./LICENSE.ttadec)\n","readmeFilename":"README.md"}