Skip to content

Commit

Permalink
Merge pull request #1 from tj10200/update-packaging
Browse files Browse the repository at this point in the history
Update packaging and readme
  • Loading branch information
tj10200 authored Jan 20, 2021
2 parents 68cf43f + 90f121f commit cd96597
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Opus & Wave Recorder
# Raw Opus, Ogg and Wave Recorder

A javascript library to encode the output of Web Audio API nodes in Ogg Opus or WAV format using WebAssembly.
A javascript library originally forked from [chris-rudmin/opus-recorder](https://github.com/chris-rudmin/opus-recorder).
This library handles encoding the output of Web Audio API nodes in
- Raw Opus
- Ogg Opus
- WAV format

The underlying implementation uses webassembly transpiled audio libraries integrated into the Javascript API.

#### Libraries Used

- Libopus: v1.3.1 compiled with emscripten 1.39.14
- speexDSP: 1.2.0 compiled with emscripten 1.39.14
- Emscripten 2.0.8
- Libopus: v1.3.1 compiled with emscripten
- speexDSP: 1.2.0 compiled with emscripten

#### Required Files

Expand All @@ -22,7 +28,8 @@ Examples for recording, encoding, and decoding are in `examples` folder.
The `Recorder` object is available in the global namespace and supports CommonJS and AMD imports.

```js
var rec = new Recorder([config]);
import Recorder from 'raw-opus-recorder'
var rec = new Recorder({config-object});
```

Creates a recorder instance.
Expand All @@ -42,15 +49,15 @@ Creates a recorder instance.
- **sourceNode** - (*optional*) An Instance of MediaStreamAudioSourceNode to use. If a sourceNode is provided, then closing the stream and audioContext will need to be managed by the implementation.


#### Config options for OGG OPUS encoder
#### Config options for OPUS encoder

- **encoderApplication** - (*optional*) Supported values are: `2048` - Voice, `2049` - Full Band Audio, `2051` - Restricted Low Delay. Defaults to `2049`.
- **encoderBitRate** - (*optional*) Target bitrate in bits/sec. The encoder selects an application-specific default when this is not specified.
- **encoderBitRate** - (*optional*) Target bitrate in bits/sec. The encoder selects an application-specific default when this is not specified. Example: (1s == 1000ms, frameSize == 20, encoderOutputMaxLength == 4000) -- (1000 / 20) * encoderOutputMaxLength === 200kbps desired. For perspective Spotify outputs between 96-160Kbps
- **encoderComplexity** - (*optional*) Value between 0 and 10 which determines latency and processing for encoding. `0` is fastest with lowest complexity. `10` is slowest with highest complexity. The encoder selects a default when this is not specified.
- **encoderFrameSize** - (*optional*) Specifies the frame size in ms used for encoding. Defaults to `20`.
- **encoderSampleRate** - (*optional*) Specifies the sample rate to encode at. Defaults to `48000`. Supported values are `8000`, `12000`, `16000`, `24000` or `48000`.
- **maxFramesPerPage** - (*optional*) Maximum number of frames to collect before generating an Ogg page. This can be used to lower the streaming latency. The lower the value the more overhead the ogg stream will incur. Defaults to `40`.
- **originalSampleRateOverride** - (*optional*) Override the ogg opus 'input sample rate' field. Google Speech API requires this field to be `16000`.
- **originalSampleRateOverride** - (*optional*) Override the JS AudioContext recorded sample rate in the ogg opus 'input sample rate' field. Google Speech API requires this field to be `16000`.
- **resampleQuality** - (*optional*) Value between 0 and 10 which determines latency and processing for resampling. `0` is fastest with lowest quality. `10` is slowest with highest quality. Defaults to `3`.
- **streamPages** - (*optional*) `dataAvailable` event will fire after each encoded page. Defaults to `false`.
- **rawOpus** - (*optional*) output events will not be encapsulated in an Ogg frame. Defaults to `false`.
Expand Down Expand Up @@ -142,6 +149,7 @@ The version of the library.
rec.ondataavailable( arrayBuffer )
```
A callback which returns an array buffer of audio data. If `streamPages` is `true`, this will be called with each page of encoded audio. If `streamPages` is `false`, this will be called when the recording is finished with the complete data.
If rawOpus is true, this will be called with each encoded opus packet.


```js
Expand Down Expand Up @@ -188,8 +196,8 @@ module.exports = {

Then get the encoderPath using an import
```js
import Recorder from 'opus-recorder';
import encoderPath from 'opus-recorder/dist/encoderWorker.min.js';
import Recorder from 'raw-opus-stream-recorder';
import encoderPath from 'raw-opus-stream-recorder/dist/encoderWorker.min.js';

const rec = new Recorder({ encoderPath });
```
Expand Down Expand Up @@ -261,8 +269,13 @@ Running the unit tests:
npm test
```

Clean the dist folder and git submodules:
Clean the dist folder:
```bash
make clean
make cleanDist
```

Clean the dist folder and the submodules:
```bash
make cleanAll
```

3 changes: 0 additions & 3 deletions dist-unminified/encoderWorker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist-unminified/recorder.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/encoderWorker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/recorder.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "opus-recorder",
"version": "8.0.3",
"name": "raw-opus-stream-recorder",
"version": "1.0.0",
"description": "A library for recording opus encoded audio",
"homepage": "https://github.com/chris-rudmin/opus-recorder",
"author": "Chris Rudmin",
"homepage": "https://github.com/tj10200/raw-opus-stream-recorder",
"author": "TJ Johnson",
"keywords": [
"Ogg",
"Opus",
Expand All @@ -25,11 +25,11 @@
],
"repository": {
"type": "git",
"url": "git://github.com/chris-rudmin/opus-recorder.git"
"url": "git://github.com/tj10200/raw-opus-stream-recorder.git"
},
"bugs": {
"url": "https://github.com/chris-rudmin/opus-recorder/issues",
"email": "chris.rudmin@gmail.com"
"url": "https://github.com/tj10200/raw-opus-stream-recorder/issues",
"email": "tjjohnson10200@gmail.com"
},
"scripts": {
"make": "make",
Expand Down
2 changes: 1 addition & 1 deletion src/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Recorder.isRecordingSupported = function(){
return AudioContext && getUserMediaSupported && global.WebAssembly;
};

Recorder.version = '8.0.3';
Recorder.version = '1.0.0';


// Instance Methods
Expand Down

0 comments on commit cd96597

Please sign in to comment.