Skip to content

Commit c8a9c58

Browse files
authored
Merge pull request #449 from software-mansion/main
Docs update
2 parents 3c1c1ef + c6db33b commit c8a9c58

File tree

107 files changed

+5880
-3464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5880
-3464
lines changed

apps/common-app/src/examples/AudioFile/AudioFile.tsx

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ const AudioFile: FC = () => {
7575
});
7676
bufferSourceRef.current.buffer = audioBuffer;
7777
bufferSourceRef.current.loop = true;
78-
bufferSourceRef.current.onended = (stopTime?: number) => {
79-
setOffset((_prev) => stopTime || 0);
78+
bufferSourceRef.current.onended = (event) => {
79+
setOffset((_prev) => event.value || 0);
8080
};
8181
bufferSourceRef.current.loopStart = LOOP_START;
8282
bufferSourceRef.current.loopEnd = LOOP_END;
@@ -123,18 +123,44 @@ const AudioFile: FC = () => {
123123
duration: 10,
124124
});
125125

126-
AudioManager.enableRemoteCommand('play');
127-
AudioManager.enableRemoteCommand('pause');
128-
AudioManager.enableRemoteCommand('stop');
126+
const remotePlaySubscription = AudioManager.enableSystemEvent(
127+
'remotePlay',
128+
(event) => {
129+
console.log('remotePlay event:', event);
130+
}
131+
);
132+
133+
const remotePauseSubscription = AudioManager.enableSystemEvent(
134+
'remotePause',
135+
(event) => {
136+
console.log('remotePause event:', event);
137+
}
138+
);
139+
140+
const remoteChangePlaybackPositionSubscription =
141+
AudioManager.enableSystemEvent(
142+
'remoteChangePlaybackPosition',
143+
(event) => {
144+
console.log('remoteChangePlaybackPosition event:', event);
145+
}
146+
);
147+
148+
const interruptionSubscription = AudioManager.enableSystemEvent(
149+
'interruption',
150+
(event) => {
151+
console.log('Interruption event:', event);
152+
}
153+
);
129154

130-
AudioManager.enableRemoteEvent('interruption', (event) => {
131-
console.log('Interruption event:', event);
132-
});
133155
AudioManager.observeAudioInterruptions(true);
134156

135157
fetchAudioBuffer();
136158

137159
return () => {
160+
remotePlaySubscription?.remove();
161+
remotePauseSubscription?.remove();
162+
remoteChangePlaybackPositionSubscription?.remove();
163+
interruptionSubscription?.remove();
138164
audioContextRef.current?.close();
139165
};
140166
}, [fetchAudioBuffer]);

apps/common-app/src/examples/Record/Record.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ const Record: FC = () => {
7171
return;
7272
}
7373

74-
recorderRef.current.onAudioReady((buffer, numFrames, when) => {
74+
recorderRef.current.onAudioReady((event) => {
75+
const { buffer, numFrames, when } = event;
76+
7577
console.log(
7678
'Audio recorder buffer ready:',
7779
buffer.duration,
@@ -81,14 +83,6 @@ const Record: FC = () => {
8183
audioBuffersRef.current.push(buffer);
8284
});
8385

84-
recorderRef.current.onError((error) => {
85-
console.log('Audio recorder error:', error);
86-
});
87-
88-
recorderRef.current.onStatusChange((status, previousStatus) => {
89-
console.log('Audio recorder status changed:', status, previousStatus);
90-
});
91-
9286
recorderRef.current.start();
9387

9488
setTimeout(() => {

apps/fabric-example/ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ PODS:
16091609
- React-logger (= 0.77.1)
16101610
- React-perflogger (= 0.77.1)
16111611
- React-utils (= 0.77.1)
1612-
- RNAudioAPI (0.6.0-rc.5):
1612+
- RNAudioAPI (0.6.0):
16131613
- DoubleConversion
16141614
- glog
16151615
- hermes-engine
@@ -1629,9 +1629,9 @@ PODS:
16291629
- ReactCodegen
16301630
- ReactCommon/turbomodule/bridging
16311631
- ReactCommon/turbomodule/core
1632-
- RNAudioAPI/audioapi (= 0.6.0-rc.5)
1632+
- RNAudioAPI/audioapi (= 0.6.0)
16331633
- Yoga
1634-
- RNAudioAPI/audioapi (0.6.0-rc.5):
1634+
- RNAudioAPI/audioapi (0.6.0):
16351635
- DoubleConversion
16361636
- glog
16371637
- hermes-engine
@@ -1651,9 +1651,9 @@ PODS:
16511651
- ReactCodegen
16521652
- ReactCommon/turbomodule/bridging
16531653
- ReactCommon/turbomodule/core
1654-
- RNAudioAPI/audioapi/ios (= 0.6.0-rc.5)
1654+
- RNAudioAPI/audioapi/ios (= 0.6.0)
16551655
- Yoga
1656-
- RNAudioAPI/audioapi/ios (0.6.0-rc.5):
1656+
- RNAudioAPI/audioapi/ios (0.6.0):
16571657
- DoubleConversion
16581658
- glog
16591659
- hermes-engine
@@ -2161,7 +2161,7 @@ SPEC CHECKSUMS:
21612161
ReactAppDependencyProvider: 41e9fb63606c32cce924653d2d410cb01ec81286
21622162
ReactCodegen: 8cae67dac8144aa8d9d5bee12e55ead0fb73537f
21632163
ReactCommon: 08f4808f02ff115884e870e5cfea689703ff759a
2164-
RNAudioAPI: 872637460cd5f7d8cafe5ab44a51b659b8a868f2
2164+
RNAudioAPI: a360b6e9626f23e8960baf015b3264dacaf28b1b
21652165
RNGestureHandler: 8b1080a6db0be82dbca18550d6212b885bfab6b2
21662166
RNReanimated: afed763d6c0b1916bfef1dbde4271ec0947dd376
21672167
RNScreens: 0d4cb9afe052607ad0aa71f645a88bb7c7f2e64c

packages/audiodocs/docs/guides/lets-make-some-noise.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ import LetsMakeSomeNoiseSrc from '!!raw-loader!@site/src/examples/LetsMakeSomeNo
108108
In this guide, we have learned how to create a simple audio player using [`AudioContext`](/core/audio-context) and [``AudioBufferSourceNode``](/sources/audio-buffer-source-node) as well as how we can load audio data from a remote source. To sum up:
109109

110110
- `AudioContext` is the main object that controls the audio graph.
111-
- the [`decodeAudioData`](/core/base-audio-context#decodeaudiodata) method can be used to load audio data from a remote resource in the form of an [`AudioBuffer`](sources/audio-buffer).
111+
- the [`decodeAudioData`](/core/base-audio-context#decodeaudiodata) method can be used to load audio data from a remote resource in the form of an [`AudioBuffer`](/sources/audio-buffer).
112112
- `AudioBufferSourceNode` can be used with any `AudioBuffer`.
113113
- In order to hear the sounds, we need to connect the source node to the destination node exposed by `AudioContext`.
114114
- We can control the playback of the sound using [`start`](/sources/audio-buffer-source-node#start) and [`stop`](/sources/audio-scheduled-source-node#stop) methods of the `AudioBufferSourceNode` (and other source nodes, which we will show later).

packages/audiodocs/docs/guides/noise-generation.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ The last noise type I would like to describe is brownian noise (also known as Br
8989

9090
Brownian noise, similarly to pink one, decreases in power by $\dfrac{12dB}{octave}$ and sounds similar to waterfall. The implementation is taken from article by Zach Denton, [How to Generate Noise with the Web Audio API](https://noisehack.com/generate-noise-web-audio-api/):
9191

92+
9293
```tsx
9394
const createBrownianNoise = () => {
9495
const aCtx = new AudioContext();

packages/audiodocs/docs/sources/audio-buffer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ specific sample rate which is the quantity of frames that will play in one secon
1313
![](/img/audioBuffer.png)
1414

1515
It can be created from audio file using `decodeAudioData`, `decodeAudioDataSource` or from raw data using `constructor`.
16-
Once you have data in `AudioBuffer`, audio can be played by passing it to [`AudioBufferSourceNode`](/sources/audio-buffer-source-node).
16+
Once you have data in `AudioBuffer`, audio can be played by passing it to [`AudioBufferSourceNode`](audio-buffer-source-node).
1717

1818
## Constructor
1919

packages/audiodocs/docusaurus.config.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
const lightCodeTheme = require('./src/theme/CodeBlock/highlighting-light.js');
55
const darkCodeTheme = require('./src/theme/CodeBlock/highlighting-dark.js');
6-
const math = require('remark-math');
7-
const katex = require('rehype-katex');
6+
import remarkMath from 'remark-math';
7+
import rehypeKatex from 'rehype-katex';
88
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
99

1010
const webpack = require('webpack');
@@ -44,8 +44,8 @@ const config = {
4444
breadcrumbs: false,
4545
sidebarCollapsible: false,
4646
sidebarPath: require.resolve('./sidebars.js'),
47-
remarkPlugins: [math],
48-
rehypePlugins: [katex],
47+
remarkPlugins: [remarkMath],
48+
rehypePlugins: [rehypeKatex],
4949
editUrl:
5050
'https://github.com/software-mansion/react-native-audio-api/edit/main/packages/audiodocs/docs',
5151
},
@@ -109,6 +109,7 @@ const config = {
109109
copyright: `All trademarks and copyrights belong to their respective owners.`,
110110
},
111111
prism: {
112+
additionalLanguages: ['bash'],
112113
theme: lightCodeTheme,
113114
darkTheme: darkCodeTheme,
114115
},
@@ -127,26 +128,26 @@ const config = {
127128

128129
const raf = require('raf');
129130
raf.polyfill();
130-
131+
131132
return {
132133
mergeStrategy: {
133134
'resolve.extensions': 'prepend',
134135
},
135136
plugins: [
136137
new webpack.DefinePlugin({
137-
...processMock,
138-
__DEV__: 'false',
139-
setImmediate: () => {},
138+
...processMock,
139+
__DEV__: 'false',
140140
}),
141141
],
142142
module: {
143143
rules: [
144144
{
145-
test: /\.txt/,
145+
test: /\.txt$/,
146146
type: 'asset/source',
147147
},
148148
{
149149
test: /\.tsx?$/,
150+
use: 'babel-loader',
150151
},
151152
],
152153
},

packages/audiodocs/package.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,48 @@
2121
"@babel/preset-env": "^7.23.2",
2222
"@babel/preset-react": "^7.18.6",
2323
"@babel/preset-typescript": "^7.21.0",
24-
"@docusaurus/core": "^2.4.3",
25-
"@docusaurus/plugin-debug": "^2.4.3",
26-
"@docusaurus/preset-classic": "^2.4.3",
27-
"@docusaurus/theme-mermaid": "^2.4.3",
28-
"@emotion/react": "^11.10.6",
29-
"@emotion/styled": "^11.10.6",
30-
"@mdx-js/react": "^1.6.22",
31-
"@mui/material": "^5.12.0",
32-
"@swmansion/t-rex-ui": "^0.0.13",
24+
"@docusaurus/core": "3.7.0",
25+
"@docusaurus/plugin-debug": "3.7.0",
26+
"@docusaurus/preset-classic": "3.7.0",
27+
"@docusaurus/theme-mermaid": "3.7.0",
28+
"@emotion/react": "^11.14.0",
29+
"@emotion/styled": "^11.14.0",
30+
"@mdx-js/react": "^3.0.0",
31+
"@mui/material": "^7.1.0",
3332
"@shopify/react-native-skia": "1.10.2",
33+
"@swmansion/t-rex-ui": "1.0.0",
3434
"@vercel/og": "^0.6.2",
3535
"babel-polyfill": "^6.26.0",
3636
"babel-preset-expo": "^9.2.2",
37-
"clsx": "^1.2.1",
37+
"clsx": "^2.1.0",
3838
"hast-util-is-element": "1.1.0",
39+
"prism-react-renderer": "^2.1.0",
3940
"raf": "^3.4.1",
4041
"raw-loader": "^4.0.2",
41-
"react": "^17.0.2",
42+
"react": "^18.2.0",
4243
"react-colorful": "^5.6.1",
43-
"react-dom": "^17.0.2",
44+
"react-dom": "^18.2.0",
4445
"react-draggable": "^4.4.5",
4546
"react-native": "^0.71.4",
4647
"react-native-audio-api": "0.5.6",
4748
"react-native-gesture-handler": "^2.16.0",
4849
"react-native-reanimated": "^3.8.1",
4950
"react-native-web": "^0.18.12",
50-
"rehype-katex": "5",
51-
"remark-math": "3",
51+
"rehype-katex": "7",
52+
"remark-math": "6",
5253
"source-map": "^0.7.4",
5354
"source-map-loader": "^4.0.1",
5455
"usehooks-ts": "^2.9.1"
5556
},
5657
"devDependencies": {
57-
"@docusaurus/module-type-aliases": "^2.4.3",
58-
"@tsconfig/docusaurus": "^1.0.7",
58+
"@docusaurus/module-type-aliases": "^3.7.0",
59+
"@docusaurus/tsconfig": "3.7.0",
5960
"copy-webpack-plugin": "^11.0.0",
6061
"esbuild": "^0.20.2",
6162
"esbuild-register": "^3.5.0",
6263
"eslint-plugin-mdx": "^2.2.0",
6364
"prettier": "^2.8.4",
64-
"typescript": "^4.7.4",
65+
"typescript": "~5.2.2",
6566
"typescript-eslint": "^8.18.0",
6667
"webpack-cli": "^5.0.1"
6768
},

packages/audiodocs/src/theme/CodeBlock/CodeBlock/highlighting-dark.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)