opus-codec 0.0.48 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# opus-codec
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
yarn add opus-codec
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import native from '../native';
|
|
13
|
+
export default async () => {
|
|
14
|
+
const runtime = new Runtime(await native());
|
|
15
|
+
const enc = new opus.Encoder(
|
|
16
|
+
runtime,
|
|
17
|
+
48000,
|
|
18
|
+
1,
|
|
19
|
+
opus.constants.OPUS_APPLICATION_VOIP,
|
|
20
|
+
10000,
|
|
21
|
+
frameSizeInBytes
|
|
22
|
+
);
|
|
23
|
+
const frameSizeInSamples = 2880;
|
|
24
|
+
enc.setBitrate(16000);
|
|
25
|
+
console.log(enc.getBitrate()); // 16000
|
|
26
|
+
onreceivesamples = (samples: Float32Array) => {
|
|
27
|
+
const encodedSamples = enc.encodeFloat(
|
|
28
|
+
samples,
|
|
29
|
+
frameSizeInSamples,
|
|
30
|
+
10000
|
|
31
|
+
);
|
|
32
|
+
console.log(
|
|
33
|
+
'encoded buffer: %o',
|
|
34
|
+
enc.encoded().subarray(0, encodedSamples)
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
```
|