https://github.com/binarykitchen/audio-sample
A wrapper to turn webcam audio samples into buffers.
https://github.com/binarykitchen/audio-sample
Last synced: 5 months ago
JSON representation
A wrapper to turn webcam audio samples into buffers.
- Host: GitHub
- URL: https://github.com/binarykitchen/audio-sample
- Owner: binarykitchen
- Created: 2015-08-20T05:52:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T22:58:15.000Z (almost 2 years ago)
- Last Synced: 2024-12-31T02:22:49.622Z (over 1 year ago)
- Language: TypeScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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
```
npm i -S audio-sample
```
## How to use
```
// 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
```