# audio-sample

> A wrapper to turn webcam audio samples into buffers.

Latest version **7.0.0** (published 2026-07-10) · 0 weekly downloads

## Install

```sh
npm install audio-sample
pnpm add audio-sample
yarn add audio-sample
bun add audio-sample
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2026-07-10 |
| First published | 2015-08-20 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=24.18.0 |
| Dependencies | 1 |
| Unpacked size | 133.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Michael Heuberger |
| Maintainers | michael.heuberger |
| Keywords | audio, webcam, float32array, buffer |

## Links

- npm: https://www.npmjs.com/package/audio-sample
- Repository: https://github.com/binarykitchen/audio-sample
- Issues: https://github.com/binarykitchen/audio-sample/issues
- npm.io page: https://npm.io/package/audio-sample

## Dependencies (1)

- [typedarray-to-buffer](https://npm.io/package/typedarray-to-buffer.md) 4.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 7.0.0 (latest) — 2026-07-10
- 6.0.0 — 2025-11-06
- 5.0.0 — 2025-07-26
- 4.1.0 — 2024-09-10
- 4.0.1 — 2024-08-05
- 4.0.0 — 2024-08-05
- 3.0.1 — 2023-03-05
- 3.0.0 — 2022-12-30
- 2.0.0 — 2022-01-04
- 1.1.1 — 2020-10-20
- 1.1.0 — 2019-08-14
- 1.0.5 — 2018-03-24
- 1.0.4 — 2018-03-06
- 1.0.3 — 2017-03-29
- 1.0.2 — 2016-03-03
- … 2 more at https://npm.io/package/audio-sample/versions

## README

# audio-sample

That's an audio sample class, accepting a Float32Array in the constructor with one public function. It turns that Float32 into a buffer with the most fastest algorithm.

This within ~20 code lines only by reusing other useful node modules. It cannot get faster and shorter. If I am wrong, let me know and I'll fix that asap.

This component is very useful for turning raw WebAudio samples, which are in Float32, into a buffer with 16 bit signed integers while respecting endianness.

For inspiration refer to:
<http://blog.groupbuddies.com/posts/39-tutorial-html-audio-capture-streaming-to-node-js-no-browser-extensions>

## Install

```bash
npm i -S audio-sample
```

## How to use

```js
// just an example, this array can come from the first audio channel of a webcam (getUserMedia)
var arrayOfFloats = e.inputBuffer.getChannelData(0);

// create a single audio sample instance
var audioSample = new AudioSample(new Float32Array(arrayOfFloats));

// and now, convert it into a buffer super-fast
var buffer = audioSample.toBuffer();

// then you can send this buffer easily over to the server and do some processing there
```

---
_Source: https://npm.io/package/audio-sample · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
