{"_id":"@audio/decode-tta","name":"@audio/decode-tta","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@audio/decode-tta","version":"1.0.0","description":"Decode TTA (True Audio) lossless audio to PCM samples","type":"module","main":"decode-tta.js","types":"decode-tta.d.ts","exports":{".":"./decode-tta.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"devDependencies":{"tst":"^9.4.0"},"scripts":{"test":"node test.js"},"keywords":["tta","true-audio","lossless","audio","decode","decoder","pcm","rice-coding"],"license":"MIT","author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-tta","repository":{"type":"git","url":"git+https://github.com/audiojs/decode.git","directory":"packages/decode-tta"},"bugs":{"url":"https://github.com/audiojs/decode/issues"},"engines":{"node":">=18"},"audio":"./audio.js","sideEffects":false,"publishConfig":{"access":"public"},"funding":"https://github.com/sponsors/audiojs","gitHead":"c227363046dc3a0308c95ee112f22795c0ac04ca","_id":"@audio/decode-tta@1.0.0","_nodeVersion":"25.9.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-aTEoPkZmh1BUJ7ewqKhPT3Sk3OSKzoaUxDFp4AJSQLQDE+Bapc3MRTldoxp8VHu2YZSuiJgcfDutz96uGQV41w==","shasum":"39cc08ee6f6c52ca40279160f3ee09675c114555","tarball":"https://registry.npmjs.org/@audio/decode-tta/-/decode-tta-1.0.0.tgz","fileCount":8,"unpackedSize":21478,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFblb8BYsSChxDdyczUfQLJ4T74hGiS6GWnKc+6h7y8cAiBoT2kQFiMc7Wm24iIXo5HDVXoXXoi7BnnXhXdOarZ1jQ=="}]},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"directories":{},"maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/decode-tta_1.0.0_1787966911760_0.46557537914760294"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-29T01:28:31.568Z","1.0.0":"2026-08-29T01:28:31.907Z","modified":"2026-08-29T01:28:32.102Z"},"maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"description":"Decode TTA (True Audio) lossless audio to PCM samples","homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-tta","keywords":["tta","true-audio","lossless","audio","decode","decoder","pcm","rice-coding"],"repository":{"type":"git","url":"git+https://github.com/audiojs/decode.git","directory":"packages/decode-tta"},"author":{"name":"Dmitry Iv.","email":"dfcreative@gmail.com"},"bugs":{"url":"https://github.com/audiojs/decode/issues"},"license":"MIT","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","_rev":"1-f537ed57fbaa357fe5edb04f269bac7b"}