Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/domchristie/audio-recorder
https://github.com/domchristie/audio-recorder
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/domchristie/audio-recorder
- Owner: domchristie
- Created: 2020-01-20T04:29:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T01:40:40.000Z (over 2 years ago)
- Last Synced: 2023-04-09T21:37:11.920Z (over 1 year ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Audio Recorder
An alternative to the `MediaRecorder` API for capturing audio. It wraps the well supported (but deprecated) [`ScriptProcessorNode`](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) as well as the newer (but poorly supported) [`AudioWorkletNode`](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletNode)/[`AudioWorkletProcessor`](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor).
## Getting Started
The library consists of 3 files:
- `audio-recorder.js`: the main entry point
- `audio-recorder-worklet.js`: used in the most recent browsers
- `audio-recorder-worker.js`: used browsers that don't support Audio WorkletsThe worklet and worker files need to be referencable via a URI.
### Basic Usage
Import the library, then instantiate an `AudioRecorder`, passing in the [streaming audio source node](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamAudioSourceNode) and the worker URIs:
```js
import AudioRecorder from './path/to/audio-recorder'const audioRecorder = new AudioRecorder({
source: source,
workletUri: 'path/to/audio-recorder-worklet.js',
workerUri: 'path/to/audio-recorder-worker.js'
})
```Start the recording and capture the data when available:
```js
audioRecorder.on('dataavailable', function () {
const blob = new Blob([event.data.buffer], { type: 'audio/wav' })
})audioRecorder.start()
```Stop the recording when done:
```js
audioRecorder.stop()
```Todo: detail methods
---
Copyright © 2020+ Dom Christie