Skip to content

Commit 0c6ba16

Browse files
docs: added docs for audio recorder (#502)
Co-authored-by: Maciej Makowski <120780663+maciejmakowski2003@users.noreply.github.com>
1 parent 2cb0662 commit 0c6ba16

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Inputs",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
6+
import { Optional, ReadOnly } from '@site/src/components/Badges';
7+
8+
# AudioRecorder
9+
10+
## Constructor
11+
12+
[`AudioRecorder(options)`](/inputs/audio-recorder#audiorecorderoptions)
13+
14+
## Example
15+
16+
```tsx
17+
import { AudioRecorder } from 'react-native-audio-api';
18+
19+
function App() {
20+
const recorder = new AudioRecorder({
21+
sampleRate: 16000,
22+
bufferLengthInSamples: 16000,
23+
});
24+
25+
recorder.onAudioReady((event) => {
26+
const { buffer, numFrames, when } = event;
27+
28+
console.log(
29+
'Audio recorder buffer ready:',
30+
buffer.duration,
31+
numFrames,
32+
when
33+
);
34+
});
35+
36+
recorder.start();
37+
}
38+
```
39+
40+
## Methods
41+
42+
### `start`
43+
44+
The above starts recording.
45+
46+
#### Returns `undefined`.
47+
48+
### `stop`
49+
50+
The above stops recording.
51+
52+
#### Returns `undefined`.
53+
54+
55+
### `onAudioReady`
56+
57+
The above allows user to set a callback after every portion of data deliverance.
58+
59+
| Parameters | Type | Description |
60+
| :---: | :---: | :---- |
61+
| `callback` | [(OnAudioReadyEventType => void)](/inputs/audio-recorder#onaudioreadyeventtype) | callback that will be invoked |
62+
63+
#### Returns `undefined`.
64+
65+
## Remarks
66+
67+
### `AudioRecorderOptions`
68+
69+
<details>
70+
<summary>Type definitions</summary>
71+
```typescript
72+
interface AudioRecorderOptions {
73+
sampleRate: number;
74+
bufferLengthInSamples: number; //how many samples to be put in the buffer
75+
}
76+
```
77+
</details>
78+
79+
### `OnAudioReadyEventType`
80+
81+
<details>
82+
<summary>Type definitions</summary>
83+
```typescript
84+
interface OnAudioReadyEventType {
85+
buffer: AudioBuffer;
86+
numFrames: number; //number of frames in a buffer
87+
when: number; //timestamp
88+
}
89+
```
90+
</details>

packages/audiodocs/docs/sources/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Sources",
3-
"position": 4,
3+
"position": 3,
44
"link": {
55
"type": "generated-index"
66
}

packages/audiodocs/src/css/colors.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
--swm-background-quote-blue: var(--swm-blue-light-40);
177177
--swm-background-quote-green: var(--swm-green-light-40);
178178
--swm-background-quote-red: var(--swm-red-light-40);
179-
--swm-background-quote-yellow: var(--swm-yellow-light-40);
179+
--swm-background-quote-yellow: var(--swm-blue-light-40);
180180
--swm-background-quote-purple: var(--swm-purple-light-40);
181181

182182
/* Code snippets */
@@ -365,7 +365,7 @@
365365
--swm-background-quote-blue: var(--swm-blue-dark-140);
366366
--swm-background-quote-green: var(--swm-green-light-40);
367367
--swm-background-quote-red: var(--swm-red-light-40);
368-
--swm-background-quote-yellow: var(--swm-yellow-dark-140);
368+
--swm-background-quote-yellow: var(--swm-navy-light-60);
369369
--swm-background-quote-purple: var(--swm-purple-light-80);
370370

371371
/* Code snippets */

0 commit comments

Comments
 (0)