`.
42 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/destinations/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Destinations",
3 | "position": 8,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/effects/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Effects",
3 | "position": 5,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/effects/stereo-panner-node.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
6 | import { ReadOnly } from '@site/src/components/Badges';
7 |
8 | # StereoPannerNode
9 |
10 | The `StereoPannerNode` interface represents the change in ratio between two outputing channels (f. e. left and right speaker).
11 |
12 | #### [`AudioNode`](/core/audio-node#read-only-properties) properties
13 |
14 |
15 |
16 | ## Constructor
17 |
18 | [`BaseAudioContext.createStereoPanner()`](/core/base-audio-context#createstereopanner)
19 |
20 | ## Properties
21 |
22 | | Name | Type | Default value | Description |
23 | | :----: | :----: | :-------- | :------ |
24 | | `pan` | [`AudioParam`](/core/audio-param) | 0 | [`a-rate`](/core/audio-param#a-rate-vs-k-rate) `AudioParam` representing value of pan to apply. |
25 |
26 | ## Remarks
27 |
28 | #### `pan`
29 | - Nominal range is -1 (only left channel) to 1 (only right channel).
30 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/fundamentals/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Fundamentals",
3 | "position": 1,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/guides/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Guides",
3 | "position": 2,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/other/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Other",
3 | "position": 10,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/other/audio-api-plugin.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | id: audio-api-plugin
3 | sidebar_label: Audio API Expo plugin
4 | sidebar_position: 3
5 | ---
6 |
7 | # 🚧 Audio API Expo plugin 🚧
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/other/compatibility.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | id: compatibility
3 | sidebar_label: RN Compatibility
4 | sidebar_position: 1
5 | ---
6 |
7 | import { Yes, No, Version, Spacer } from '@site/src/components/Compatibility';
8 |
9 | # React Native compatibility table
10 |
11 | ### Supported React Native versions on [the New Architecture](https://reactnative.dev/docs/the-new-architecture/landing-page) (Fabric)
12 |
13 |
14 |
15 | | | 0.74 | 0.75 | 0.76 | 0.77 | 0.78 |
16 | | ----------------------------------- | ----- | ----- | ----- | ----- | ----- |
17 | | | | | | | |
18 | | | | | | | |
19 | | | | | | | |
20 | | | | | | | |
21 |
22 |
23 |
24 | ### Supported React Native versions on the Old Architecture (Paper)
25 |
26 |
27 |
28 | | | 0.74 | 0.75 | 0.76 | 0.77 |
29 | | ----------------------------------- | ----- | ----- | ----- | ----- |
30 | | | | | | |
31 | | | | | | |
32 | | | | | | |
33 | | | | | | |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/sources/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Sources",
3 | "position": 4,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/spatialization/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Spatialization",
3 | "position": 6,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/system/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "System",
3 | "position": 6,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Types",
3 | "position": 9,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/audio-buffer-source-node-options.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # AudioBufferSourceNodeOptions
6 |
7 | `AudioBufferSourceNodeOptions` is a dictionary object specifies if pitch correction algorithm has to be available.
8 |
9 | ```jsx
10 | interface AudioBufferSourceNodeOptions {
11 | pitchCorrection: boolean
12 | }
13 | ```
14 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/audio-context-options.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # AudioContextOptions
6 |
7 | `AudioContextOptions` is a dictionary object specifies sample rate for the new context.
8 |
9 | ```jsx
10 | interface AudioContextOptions {
11 | sampleRate: number;
12 | }
13 | ```
14 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/channel-count-mode.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # ChannelCountMode
6 |
7 | `ChannelCountMode` type determines how the number of input channels affects the number of output channels in an audio node.
8 |
9 | **Acceptable values:**
10 | - `max`
11 |
12 | The number of channels is equal to the maximum number of channels of all connections. In this case, `channelCount` is ignored and only up-mixing happens.
13 |
14 | - `clamped-max`
15 |
16 | The number of channels is equal to the maximum number of channels of all connections, clamped to the value of `channelCount`(serves as the maximum permissible value).
17 |
18 | - `explicit`
19 |
20 | The number of channels is defined by the value of `channelCount`.
21 |
22 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/context-state.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # ContextState
6 |
7 | `ContextState` type represents state of the [`BaseAudioContext`](/core/base-audio-context).
8 |
9 | **Acceptable values:**
10 | - `suspended`
11 |
12 | The audio context has been suspended (with one of [`suspend`](/core/audio-context#suspend) or `OfflineAudioContext.suspend`).
13 |
14 | - `running`
15 |
16 | The audio context is running normally.
17 |
18 | - `closed`
19 |
20 | The audio context has been closed (with [`close`](/core/audio-context#close) method).
21 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/oscillator-type.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 6
3 | ---
4 |
5 | # OscillatorType
6 |
7 | `OscillatorType` is a string that specifies shape of an oscillator wave
8 |
9 | ```jsx
10 | type OscillatorType =
11 | | 'sine'
12 | | 'square'
13 | | 'sawtooth'
14 | | 'triangle'
15 | | 'custom';
16 | ```
17 |
18 | Below you can see possible names with shapes corresponding to them.
19 | 
20 |
21 | ## `custom`
22 |
23 | This value can't be set explicitly, but it allows user to set any shape. See [`setPeriodicWave`](/sources/oscillator-node#setperiodicwave) for reference.
24 |
25 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/periodic-wave-constraints.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 7
3 | ---
4 |
5 | # PeriodicWaveConstraints
6 |
7 | `PeriodicWaveConstraints` is a dictionary object specifies whether normalization should be disabled during creating periodic wave. If not specified normalization is enabled.
8 | If normalized, periodic wave will have maximum peak value of 1 and minimum peak value of -1.
9 |
10 | ```jsx
11 | interface PeriodicWaveConstraints {
12 | disableNormalization: boolean;
13 | }
14 | ```
15 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/types/window-type.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 8
3 | ---
4 |
5 | # WindowType
6 |
7 | `WindowType` type specifies which [window function](https://en.wikipedia.org/wiki/Window_function) is applied when extracting frequency data.
8 |
9 | **Acceptable values:**
10 | - `blackman`
11 |
12 | Set [Blackman window](https://www.sciencedirect.com/topics/engineering/blackman-window) as window function.
13 |
14 | - `hann`
15 |
16 | Set [Hanning window](https://www.sciencedirect.com/topics/engineering/hanning-window) as window function.
17 |
18 | :::caution
19 |
20 | On `Web`, the value of `window` is permanently `'blackman'`, and it cannot be set like on the `Android` or `iOS`.
21 |
22 | :::
23 |
--------------------------------------------------------------------------------
/packages/audiodocs/docs/worklets/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Worklets",
3 | "position": 8,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/audiodocs/prettier.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('prettier').Config} */
2 | module.exports = {
3 | plugins: ['prettier-plugin-jsdoc'],
4 | bracketSameLine: true,
5 | printWidth: 80,
6 | singleQuote: true,
7 | trailingComma: 'es5',
8 | tabWidth: 2,
9 | arrowParens: 'always',
10 | };
11 |
--------------------------------------------------------------------------------
/packages/audiodocs/sidebars.js:
--------------------------------------------------------------------------------
1 | // This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
2 |
3 | /**
4 | * Creating a sidebar enables you to:
5 | - create an ordered group of docs
6 | - render a sidebar for each doc of that group
7 | - provide next/previous navigation
8 |
9 | The sidebars can be generated from the filesystem, or explicitly defined here.
10 |
11 | Create as many sidebars as you want.
12 | */
13 | const sidebars = {
14 | // By default, Docusaurus generates a sidebar from the docs folder structure
15 | tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
16 |
17 | // But you can create a sidebar manually
18 | /*
19 | tutorialSidebar: [
20 | 'intro',
21 | 'hello',
22 | {
23 | type: 'category',
24 | label: 'Tutorial',
25 | items: ['tutorial-basics/create-a-document'],
26 | },
27 | ],
28 | */
29 | };
30 |
31 | module.exports = sidebars;
32 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/AnimableIcon/index.tsx:
--------------------------------------------------------------------------------
1 | import clsx from 'clsx';
2 | import React, { useEffect, JSX } from 'react';
3 | import { useColorMode } from '@docusaurus/theme-common';
4 |
5 | import styles from './styles.module.css';
6 |
7 | export const Animation = {
8 | FADE_IN_OUT: styles.iconClicked,
9 | };
10 |
11 | interface Props {
12 | icon: JSX.Element;
13 | iconDark?: JSX.Element;
14 | animation: string;
15 | onClick: (
16 | actionPerformed: boolean,
17 | setActionPerformed: (ap: boolean) => void
18 | ) => void;
19 | }
20 |
21 | const AnimableIcon = ({
22 | icon,
23 | iconDark,
24 | animation = Animation.FADE_IN_OUT,
25 | onClick,
26 | }: Props): JSX.Element => {
27 | const { colorMode } = useColorMode();
28 | const [actionPerformed, setActionPerformed] = React.useState(false);
29 |
30 | useEffect(() => {
31 | const timeout = setTimeout(() => setActionPerformed(() => false), 1000);
32 | return () => clearTimeout(timeout);
33 | }, [actionPerformed]);
34 |
35 | return (
36 | onClick(actionPerformed, setActionPerformed)}
38 | className={clsx(styles.actionIcon, actionPerformed && animation)}
39 | >
40 | {colorMode === 'light' ? icon : iconDark || icon}
41 |
42 | );
43 | };
44 |
45 | export default AnimableIcon;
46 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/AnimableIcon/styles.module.css:
--------------------------------------------------------------------------------
1 | .actionIcon {
2 | display: flex;
3 | align-items: center;
4 | justify-content: center;
5 |
6 | padding: 0.25em;
7 | cursor: pointer;
8 |
9 | /* Border applied to omit enlarging icon during the animation. */
10 | border: 1px solid transparent;
11 | border-radius: 3px;
12 | }
13 |
14 | .iconClicked {
15 | animation: 1s iconClick;
16 | }
17 |
18 | @keyframes iconClick {
19 | 0% {
20 | border: 1px solid var(--swm-interactive-copy-button-off);
21 | }
22 | 50% {
23 | border: 1px solid var(--swm-interactive-copy-button-on);
24 | }
25 | 100% {
26 | border: 1px solid var(--swm-interactive-copy-button-off);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/AudioNodePropsTable/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | type ChannelCountMode = 'max' | 'clamped-max' | 'explicit';
4 | type ChannelInterpretation = 'speakers' | 'discrete';
5 |
6 | interface AudioNodePropsTableProps {
7 | numberOfInputs: number;
8 | numberOfOutputs: number;
9 | channelCount: number | string;
10 | channelCountMode: ChannelCountMode;
11 | channelInterpretation: ChannelInterpretation;
12 | }
13 |
14 | const AudioNodePropsTable = ({
15 | numberOfInputs,
16 | numberOfOutputs,
17 | channelCount,
18 | channelCountMode,
19 | channelInterpretation,
20 | }: AudioNodePropsTableProps) => {
21 | const props = [
22 | { label: "Number of inputs", value: numberOfInputs },
23 | { label: "Number of outputs", value: numberOfOutputs },
24 | { label: "Channel count", value: channelCount },
25 | { label: "Channel count mode", value: channelCountMode },
26 | { label: "Channel interpretation", value: channelInterpretation },
27 | ];
28 |
29 | return (
30 |
37 |
38 | {props.map((prop, index) => (
39 |
40 |
45 | {prop.label}
46 | |
47 |
52 | {prop.value}
53 | |
54 |
55 | ))}
56 |
57 |
58 | );
59 | };
60 |
61 | export default AudioNodePropsTable;
62 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/Badges/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './styles.module.css';
3 |
4 | export function Optional({ footnote }) {
5 | return Optional{footnote ? '*' : ''}
;
6 | }
7 |
8 | export function ReadOnly({ footnote }) {
9 | return Read only{footnote ? '*' : ''}
;
10 | }
11 |
12 | export function Overridden({ footnote }) {
13 | return Overridden{footnote ? '*' : ''}
;
14 | }
15 |
16 | export function OnlyiOS({ footnote }) {
17 | return iOS only{footnote ? '*' : ''}
;
18 | }
19 |
20 | export function Experimental({ footnote }) {
21 | return Experimental{footnote ? '*' : ''}
;
22 | }
23 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/Badges/styles.module.css:
--------------------------------------------------------------------------------
1 | .badge {
2 | display: inline-block;
3 | border: 1px solid #ccc;
4 | color: var(--ifm-font-color-base);
5 | border-radius: 4rem;
6 | font-size: 12px;
7 | font-weight: 400;
8 | padding: 0.125rem 0.375rem;
9 | white-space: nowrap;
10 | margin: 0 0.25rem;
11 | }
12 |
13 | .experimental {
14 | color: var(--swm-sidebar-label-text-experimental);
15 | background-color: var(--swm-sidebar-label-background-experimental);
16 | }
17 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/Compatibility/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './styles.module.css';
3 |
4 | export function Yes() {
5 | return yes
;
6 | }
7 |
8 | export function No() {
9 | return no
;
10 | }
11 |
12 | interface VersionProps {
13 | version: string;
14 | }
15 |
16 | export function Version({ version }: VersionProps) {
17 | return {version}
;
18 | }
19 |
20 | export function Spacer() {
21 | return ;
22 | }
23 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/components/Compatibility/styles.module.css:
--------------------------------------------------------------------------------
1 | .supported {
2 | color: var(--swm-compatibility-text-color);
3 | background-color: var(--swm-compatibility-supported-background);
4 | text-align: center;
5 | text-transform: capitalize;
6 | padding: 12px;
7 | }
8 |
9 | .notSupported {
10 | color: var(--swm-compatibility-text-color);
11 | background-color: var(--swm-compatibility-not-supported-background);
12 | text-align: center;
13 | text-transform: capitalize;
14 | padding: 12px;
15 | }
16 |
17 | .version {
18 | font-weight: bold;
19 | text-align: center;
20 | padding: 12px;
21 | }
22 |
23 | .spacer {
24 | padding-top: 10px;
25 | }
26 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/css/custom.css:
--------------------------------------------------------------------------------
1 | @import 'colors.css';
2 | @import 'typography.css';
3 | @import 'overrides.css';
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/examples/LetsMakeSomeNoise/Component.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Button, View } from 'react-native';
3 | import { AudioContext } from 'react-native-audio-api';
4 |
5 | export default function App() {
6 | const handlePlay = async () => {
7 | const audioContext = new AudioContext();
8 |
9 | const audioBuffer = await fetch('/react-native-audio-api/audio/music/example-music-01.mp3')
10 | .then((response) => response.arrayBuffer())
11 | .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer));
12 |
13 | const playerNode = await audioContext.createBufferSource();
14 | playerNode.buffer = audioBuffer;
15 |
16 | playerNode.connect(audioContext.destination);
17 | playerNode.start(audioContext.currentTime);
18 | playerNode.stop(audioContext.currentTime + 10);
19 | };
20 |
21 | return (
22 |
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/examples/LetsMakeSomeNoise/Source.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { View, Button } from 'react-native';
3 | import { AudioContext } from 'react-native-audio-api';
4 |
5 | export default function App() {
6 | const handlePlay = async () => {
7 | const audioContext = new AudioContext();
8 |
9 | const audioBuffer = await fetch('https://software-mansion.github.io/react-native-audio-api/audio/music/example-music-01.mp3')
10 | .then((response) => response.arrayBuffer())
11 | .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer));
12 |
13 | const playerNode = audioContext.createBufferSource();
14 | playerNode.buffer = audioBuffer;
15 |
16 | playerNode.connect(audioContext.destination);
17 | playerNode.start(audioContext.currentTime);
18 | };
19 |
20 | return (
21 |
22 |
23 |
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/examples/SeeYourSound/CanvasSizerComponent.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useRef, useState } from 'react';
2 |
3 | const CanvasSizer = ({ canvasHeight, children }) => {
4 | const containerRef = useRef(null);
5 | const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
6 |
7 | useEffect(() => {
8 | const container = containerRef.current;
9 |
10 | if (!window.ResizeObserver) {
11 | console.error('ResizeObserver is not supported in your browser.');
12 | return;
13 | }
14 |
15 | const resizeObserver = new ResizeObserver((entries) => {
16 | for (let entry of entries) {
17 | setDimensions({
18 | width: entry.contentRect.width,
19 | height: entry.contentRect.height,
20 | });
21 | }
22 | });
23 |
24 | if (container) {
25 | resizeObserver.observe(container);
26 | }
27 |
28 | return () => {
29 | resizeObserver.disconnect();
30 | };
31 | }, []);
32 |
33 | return (
34 |
35 | {children(dimensions)}
36 |
37 | );
38 | };
39 |
40 | export default CanvasSizer;
--------------------------------------------------------------------------------
/packages/audiodocs/src/hooks/usePageType.tsx:
--------------------------------------------------------------------------------
1 | import { useLocation } from '@docusaurus/router';
2 | import useBaseUrl from '@docusaurus/useBaseUrl';
3 |
4 | const usePageType = () => {
5 | const location = useLocation();
6 | const baseUrl = useBaseUrl('/');
7 |
8 | return {
9 | isDocumentation: location.pathname.startsWith(`${baseUrl}docs`),
10 | isLanding: location.pathname === baseUrl,
11 | };
12 | };
13 |
14 | export default usePageType;
15 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/hooks/useScreenSize.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from 'react';
2 |
3 | /*
4 | * Caution - read before use!
5 | * As this hook uses innerWidth prop, which belongs to the window object,
6 | * it requires to use the viewport. Thus, building the production build of the
7 | * application may fail, as the Docusaurus is using SSR to serve it.
8 | * Remember to verify if user can use the viewport by using
9 | * `ExecutionEnvironment.canUseViewport` method, `` component or
10 | * `useIsBrowser` hook.
11 | */
12 | const useScreenSize = () => {
13 | const [windowWidth, setWindowWidth] = useState(window.innerWidth);
14 |
15 | useEffect(() => {
16 | const handleWindowResize = () => {
17 | setWindowWidth(window.innerWidth);
18 | };
19 |
20 | window.addEventListener('resize', handleWindowResize);
21 |
22 | return () => {
23 | window.removeEventListener('resize', handleWindowResize);
24 | };
25 | }, []);
26 |
27 | return {
28 | windowWidth,
29 | };
30 | };
31 |
32 | export default useScreenSize;
33 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Admonition/index.jsx:
--------------------------------------------------------------------------------
1 | import { Admonition } from '@swmansion/t-rex-ui';
2 |
3 | export default Admonition;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/CodeBlock/highlighting-dark.js:
--------------------------------------------------------------------------------
1 | const darkTheme = require('prism-react-renderer').themes.github;
2 |
3 | module.exports = {
4 | ...darkTheme,
5 | plain: {
6 | color: 'var(--swm-navy-light-40)',
7 | },
8 | styles: [
9 | ...darkTheme.styles,
10 | {
11 | types: ['comment', 'prolog', 'doctype', 'cdata'],
12 | style: {
13 | color: 'var(--swm-navy-light-60)',
14 | fontStyle: 'italic',
15 | },
16 | },
17 | {
18 | types: ['namespace'],
19 | style: {
20 | opacity: 0.7,
21 | },
22 | },
23 | {
24 | types: ['string', 'property', 'atrule', 'selector', 'tag'],
25 | style: {
26 | color: 'var(--swm-navy-light-40)',
27 | },
28 | },
29 | {
30 | types: ['punctuation'],
31 | style: {
32 | color: 'var(--swm-green-light-80)',
33 | },
34 | },
35 | {
36 | types: [
37 | 'entity',
38 | 'url',
39 | 'symbol',
40 | 'number',
41 | 'boolean',
42 | 'variable',
43 | 'constant',
44 | 'regex',
45 | 'inserted',
46 | 'operator',
47 | 'attr-value',
48 | ],
49 | style: {
50 | color: 'var(--swm-red-light-80)',
51 | },
52 | },
53 | {
54 | types: ['function', 'function-variable', 'deleted'],
55 | style: {
56 | color: 'var(--swm-purple-light-80)',
57 | },
58 | },
59 | {
60 | types: ['property', 'module', 'attr-name', 'keyword'],
61 | style: {
62 | color: 'var(--swm-blue-light-80)',
63 | },
64 | },
65 | ],
66 | };
67 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/CodeBlock/highlighting-light.js:
--------------------------------------------------------------------------------
1 | const lightTheme = require('prism-react-renderer').themes.github;
2 |
3 | module.exports = {
4 | ...lightTheme,
5 | plain: {
6 | color: 'var(--swm-navy-light-80)',
7 | },
8 | styles: [
9 | ...lightTheme.styles,
10 | {
11 | types: ['comment', 'prolog', 'doctype', 'cdata'],
12 | style: {
13 | color: 'var(--swm-navy-light-40)',
14 | fontStyle: 'italic',
15 | },
16 | },
17 | {
18 | types: ['namespace'],
19 | style: {
20 | opacity: 0.7,
21 | },
22 | },
23 | {
24 | types: ['string', 'property', 'atrule', 'selector', 'tag'],
25 | style: {
26 | color: 'var(--swm-navy-light-80)',
27 | },
28 | },
29 | {
30 | types: ['punctuation'],
31 | style: {
32 | color: 'var(--swm-green-light-100)',
33 | },
34 | },
35 | {
36 | types: [
37 | 'entity',
38 | 'url',
39 | 'symbol',
40 | 'number',
41 | 'boolean',
42 | 'variable',
43 | 'constant',
44 | 'regex',
45 | 'inserted',
46 | 'operator',
47 | 'attr-value',
48 | ],
49 | style: {
50 | color: 'var(--swm-red-light-100)',
51 | },
52 | },
53 | {
54 | types: ['function', 'function-variable', 'deleted'],
55 | style: {
56 | color: 'var(--swm-purple-light-100)',
57 | },
58 | },
59 | {
60 | types: ['property', 'module', 'attr-name', 'keyword'],
61 | style: {
62 | color: 'var(--swm-blue-light-100)',
63 | },
64 | },
65 | ],
66 | };
67 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/DocCard/index.jsx:
--------------------------------------------------------------------------------
1 | import { DocCard } from '@swmansion/t-rex-ui';
2 |
3 | export default DocCard;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/DocItem/Metadata/index.jsx:
--------------------------------------------------------------------------------
1 | import { DocItemMetadata } from '@swmansion/t-rex-ui';
2 |
3 | export default DocItemMetadata;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/DocItem/TOC/Mobile/index.jsx:
--------------------------------------------------------------------------------
1 | import { DocItemTOCMobile } from '@swmansion/t-rex-ui';
2 |
3 | export default DocItemTOCMobile;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/DocSidebar/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import useBaseUrl from '@docusaurus/useBaseUrl';
3 | import { DocSidebar } from '@swmansion/t-rex-ui';
4 |
5 | export default function DocSidebarWrapper(props) {
6 | const titleImages = {
7 | light: useBaseUrl('/img/title.svg?v=12'),
8 | dark: useBaseUrl('/img/title-dark.svg?v=12'),
9 | };
10 |
11 | const heroImages = {
12 | logo: useBaseUrl('/img/logo-hero.svg'),
13 | };
14 |
15 | const newItems = ['animations/withClamp'];
16 | const experimentalItems = ['shared-element-transitions/overview'];
17 |
18 | return (
19 |
26 | );
27 | }
28 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Footer/index.jsx:
--------------------------------------------------------------------------------
1 | import { Footer } from '@swmansion/t-rex-ui';
2 |
3 | export default Footer;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Navbar/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import useBaseUrl from '@docusaurus/useBaseUrl';
3 | import { Navbar } from '@swmansion/t-rex-ui';
4 |
5 | export default function NavbarWrapper(props) {
6 | const titleImages = {
7 | light: useBaseUrl('/img/title.svg?v=12'),
8 | dark: useBaseUrl('/img/title-dark.svg?v=12'),
9 | };
10 |
11 | const heroImages = {
12 | logo: useBaseUrl('/img/logo-hero.svg'),
13 | };
14 |
15 | return (
16 |
22 | );
23 | }
24 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/NotFound/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import NotFound from '@theme-original/NotFound';
3 |
4 | export default function NotFoundWrapper(props) {
5 | return ;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/PaginatorNavLink/index.jsx:
--------------------------------------------------------------------------------
1 | import { PaginatorNavLink } from '@swmansion/t-rex-ui';
2 |
3 | export default PaginatorNavLink;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Root.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { getInitColorSchemeScript } from '@mui/material/styles';
3 | import { Experimental_CssVarsProvider as CssVarsProvider } from '@mui/material/styles';
4 | import theme from '@site/src/theme/muiTheme';
5 |
6 | export default function Root({ children }) {
7 | return (
8 | <>
9 | {getInitColorSchemeScript()}
10 | {children}
11 | >
12 | );
13 | }
14 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/SkipToContent/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { SkipToContentLink } from '@docusaurus/theme-common';
3 | import styles from './styles.module.css';
4 | import clsx from 'clsx';
5 | import usePageType from '@site/src/hooks/usePageType';
6 | export default function SkipToContent() {
7 | const { isDocumentation } = usePageType();
8 | return (
9 |
12 | );
13 | }
14 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/SkipToContent/styles.module.css:
--------------------------------------------------------------------------------
1 | .skipToContent {
2 | position: fixed;
3 | top: 1rem;
4 | left: 100%;
5 | z-index: calc(var(--ifm-z-index-fixed) + 1);
6 | padding: calc(var(--ifm-global-spacing) / 2) var(--ifm-global-spacing);
7 | color: var(--ifm-color-emphasis-900);
8 | background-color: var(--ifm-background-surface-color);
9 | }
10 |
11 | .skipToContent:focus {
12 | left: 1rem;
13 | box-shadow: var(--ifm-global-shadow-md);
14 | }
15 |
16 | .hidden {
17 | display: none;
18 | }
19 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/TOCCollapsible/index.jsx:
--------------------------------------------------------------------------------
1 | import { TOCCollapsible } from '@swmansion/t-rex-ui';
2 |
3 | export default TOCCollapsible;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/TOCItems/Tree.jsx:
--------------------------------------------------------------------------------
1 | import { TOCItemTree } from '@swmansion/t-rex-ui';
2 |
3 | export default TOCItemTree;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/TOCItems/index.jsx:
--------------------------------------------------------------------------------
1 | import { TOCItems } from '@swmansion/t-rex-ui';
2 |
3 | export default TOCItems;
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Tabs/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Tabs from '@theme-original/Tabs';
3 | import styles from './styles.module.css';
4 | import clsx from 'clsx';
5 |
6 | export default function TabsWrapper(props) {
7 | return (
8 | <>
9 |
10 |
11 |
12 | >
13 | );
14 | }
15 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/Tabs/styles.module.css:
--------------------------------------------------------------------------------
1 | .tabs__wrapper {
2 | }
3 |
4 | [class*='tabs__item']:hover {
5 | background-color: inherit;
6 | }
7 |
8 | ul[role='tablist'] li {
9 | padding: 4px 16px;
10 |
11 | color: var(--swm-tab);
12 | transition: color 0.15s, border-bottom-color 0.15s;
13 |
14 | border-bottom: 4px solid var(--swm-tab);
15 | border-radius: 0;
16 | }
17 |
18 | ul[role='tablist'] li:hover {
19 | color: var(--swm-tab-hover);
20 | border-bottom-color: var(--swm-tab-hover);
21 | }
22 |
23 | ul[role='tablist'] li[class*='active'] {
24 | color: var(--swm-tab-active);
25 | border-bottom-color: var(--swm-tab-active);
26 | }
27 |
--------------------------------------------------------------------------------
/packages/audiodocs/src/theme/muiTheme.jsx:
--------------------------------------------------------------------------------
1 | import { experimental_extendTheme as extendTheme } from '@mui/material/styles';
2 |
3 | import Aeonik from '../../static/fonts/Aeonik-Regular.otf';
4 |
5 | // General MUI theme
6 | const extTheme = extendTheme({
7 | typography: {
8 | fontFamily: 'Aeonik, Arial',
9 | },
10 | colorSchemes: {
11 | light: {
12 | palette: {
13 | text: {
14 | secondary: '#6676aa',
15 | },
16 | primary: {
17 | main: '#001a72', //--swm-navy-light-100
18 | },
19 | secondary: {
20 | main: '#782aeb', //--swm-purple-light-100
21 | },
22 | background: {
23 | default: '#fcfcff',
24 | paper: '#f8f9ff',
25 | },
26 | },
27 | },
28 | dark: {
29 | palette: {
30 | text: {
31 | secondary: '#919fcf',
32 | },
33 | primary: {
34 | main: '#eef0ff', //--swm-navy-light-10
35 | },
36 | secondary: {
37 | main: '#b58df1', //--swm-purple-light-80
38 | },
39 | background: {
40 | default: '#232736',
41 | paper: '#272b3c',
42 | },
43 | },
44 | },
45 | },
46 | components: {
47 | MuiCssBaseline: {
48 | styleOverrides: `
49 | @font-face {
50 | font-family: 'Aeonik';
51 | font-style: normal;
52 | font-display: swap;
53 | font-weight: 400;
54 | src: local('Aeonik'), local('Aeonik-Regular'), url(${Aeonik}) format('otf');
55 | `,
56 | },
57 | },
58 | });
59 |
60 | export default extTheme;
61 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/.nojekyll
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/music/example-music-01.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/music/example-music-01.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/music/example-music-02.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/music/example-music-02.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/music/example-music-03.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/music/example-music-03.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/music/example-music-04.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/music/example-music-04.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/sounds/C4.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/sounds/C4.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/sounds/Ds4.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/sounds/Ds4.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/sounds/Fs4.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/sounds/Fs4.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/audio/voice/example-voice-01.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/audio/voice/example-voice-01.mp3
--------------------------------------------------------------------------------
/packages/audiodocs/static/fonts/Aeonik-Bold.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/fonts/Aeonik-Bold.otf
--------------------------------------------------------------------------------
/packages/audiodocs/static/fonts/Aeonik-Medium.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/fonts/Aeonik-Medium.otf
--------------------------------------------------------------------------------
/packages/audiodocs/static/fonts/Aeonik-Regular.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/fonts/Aeonik-Regular.otf
--------------------------------------------------------------------------------
/packages/audiodocs/static/fonts/DMMono-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/fonts/DMMono-Regular.ttf
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/audio-graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/audio-graph.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/audioBuffer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/audioBuffer.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/copy-dark.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/copy.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/exponentialRampToValueAtTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/exponentialRampToValueAtTime.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/favicon.ico
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/frequencies-on-piano.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/frequencies-on-piano.jpg
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/gain-node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/gain-node.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/github.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/linearRampToValueAtTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/linearRampToValueAtTime.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/oscillator-waves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/oscillator-waves.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/reset-dark.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/reset.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/setTargetAtTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/setTargetAtTime.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/setValueAtTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/setValueAtTime.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/setValueCurveAtTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/setValueCurveAtTime.png
--------------------------------------------------------------------------------
/packages/audiodocs/static/img/time_domain_vs_frequency_domain.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/software-mansion/react-native-audio-api/cddba015d56caf285ae8bbcbbee4f0a6daddf451/packages/audiodocs/static/img/time_domain_vs_frequency_domain.jpg
--------------------------------------------------------------------------------
/packages/audiodocs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | // This file is not used in compilation. It is here just for a nice editor experience.
3 | "extends": "@docusaurus/tsconfig",
4 | "compilerOptions": {
5 | "baseUrl": "."
6 | },
7 | "exclude": [".docusaurus", "build"]
8 | }
9 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /** @type {import('eslint').ESLint.ConfigData} */
2 | module.exports = {
3 | extends: ['../../.eslintrc.js'],
4 | overrides: [
5 | {
6 | files: ['./src/**/*.{ts,tsx}'],
7 | },
8 | ],
9 | ignorePatterns: ['lib', 'src/web-core/custom/signalsmithStretch' ],
10 | };
11 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/.prettierignore:
--------------------------------------------------------------------------------
1 | lib
2 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.12.0)
2 | project(react-native-audio-api)
3 |
4 | set(CMAKE_VERBOSE_MAKEFILE ON)
5 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6 | set(CMAKE_CXX_STANDARD 20)
7 |
8 | # Detect the processor and SIMD support
9 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
10 | set(HAVE_ARM_NEON_INTRINSICS TRUE)
11 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
12 | set(HAVE_X86_SSE2 TRUE)
13 | endif()
14 |
15 | include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
16 | add_compile_options(${folly_FLAGS})
17 |
18 | # frtti - enable Run-Time Type Information (dynamic_cast, typeid)
19 | # -std=c++20 - use C++20 standard
20 | # -Wall - enable all compiler's warning messages
21 | string(APPEND CMAKE_CXX_FLAGS
22 | " -frtti -std=c++${CMAKE_CXX_STANDARD} -Wall")
23 |
24 | if(${IS_NEW_ARCHITECTURE_ENABLED})
25 | string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
26 | endif()
27 |
28 | set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
29 | set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../common/cpp")
30 |
31 | add_subdirectory("${ANDROID_CPP_DIR}/audioapi")
32 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/gradle.properties:
--------------------------------------------------------------------------------
1 | AudioAPI_kotlinVersion=1.7.0
2 | AudioAPI_minSdkVersion=21
3 | AudioAPI_targetSdkVersion=31
4 | AudioAPI_compileSdkVersion=31
5 | AudioAPI_ndkversion=21.4.7075529
6 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/AndroidManifestNew.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/cpp/audioapi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.12.0)
2 |
3 | file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp")
4 | file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c")
5 |
6 | add_library(react-native-audio-api SHARED ${ANDROID_CPP_SOURCES} ${COMMON_CPP_SOURCES})
7 |
8 | find_package(ReactAndroid REQUIRED CONFIG)
9 | find_package(fbjni REQUIRED CONFIG)
10 | find_package(oboe REQUIRED CONFIG)
11 |
12 | target_include_directories(
13 | react-native-audio-api
14 | PRIVATE
15 | "${COMMON_CPP_DIR}"
16 | "${ANDROID_CPP_DIR}"
17 | "${REACT_NATIVE_DIR}/ReactCommon"
18 | "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
19 | "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
20 | )
21 |
22 | set(LINK_LIBRARIES
23 | ReactAndroid::jsi
24 | fbjni::fbjni
25 | android
26 | log
27 | oboe::oboe
28 | )
29 |
30 | if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
31 | set(RN_VERSION_LINK_LIBRARIES
32 | ReactAndroid::reactnative
33 | )
34 | else()
35 | set(RN_VERSION_LINK_LIBRARIES
36 | ReactAndroid::folly_runtime
37 | ReactAndroid::react_nativemodule_core
38 | ReactAndroid::glog
39 | ReactAndroid::reactnativejni
40 | )
41 | endif()
42 |
43 | target_link_libraries(react-native-audio-api ${LINK_LIBRARIES} ${RN_VERSION_LINK_LIBRARIES})
44 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/cpp/audioapi/android/AudioAPIModule.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | namespace audioapi {
15 |
16 | using namespace facebook;
17 | using namespace react;
18 |
19 | class AudioAPIModule : public jni::HybridClass {
20 | public:
21 | static auto constexpr kJavaDescriptor =
22 | "Lcom/swmansion/audioapi/AudioAPIModule;";
23 |
24 | static jni::local_ref initHybrid(
25 | jni::alias_ref jThis,
26 | jlong jsContext,
27 | jni::alias_ref
28 | jsCallInvokerHolder);
29 |
30 | static void registerNatives();
31 |
32 | void injectJSIBindings();
33 | void invokeHandlerWithEventNameAndEventBody(jni::alias_ref eventName, jni::alias_ref> eventBody);
34 |
35 | private:
36 | friend HybridBase;
37 |
38 | jni::global_ref javaPart_;
39 | jsi::Runtime *jsiRuntime_;
40 | std::shared_ptr jsCallInvoker_;
41 | std::shared_ptr audioEventHandlerRegistry_;
42 |
43 | explicit AudioAPIModule(
44 | jni::alias_ref &jThis,
45 | jsi::Runtime *jsiRuntime,
46 | const std::shared_ptr &jsCallInvoker);
47 | };
48 |
49 | } // namespace audioapi
50 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/cpp/audioapi/android/OnLoad.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 |
5 | using namespace audioapi;
6 |
7 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
8 | return facebook::jni::initialize(
9 | vm, [] { AudioAPIModule::registerNatives(); });
10 | }
11 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | namespace audioapi {
10 |
11 | using namespace oboe;
12 |
13 | class AudioBus;
14 |
15 | class AndroidAudioRecorder : public AudioStreamDataCallback, public AudioRecorder {
16 | public:
17 | AndroidAudioRecorder(float sampleRate,
18 | int bufferLength,
19 | const std::shared_ptr &audioEventHandlerRegistry);
20 |
21 | ~AndroidAudioRecorder() override;
22 |
23 | void start() override;
24 | void stop() override;
25 |
26 | DataCallbackResult onAudioReady(
27 | AudioStream *oboeStream,
28 | void *audioData,
29 | int32_t numFrames) override;
30 |
31 | private:
32 | std::shared_ptr mStream_;
33 | };
34 |
35 | } // namespace audioapi
36 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AudioPlayer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | namespace audioapi {
9 |
10 | using namespace oboe;
11 |
12 | class AudioContext;
13 | class AudioBus;
14 |
15 | class AudioPlayer : public AudioStreamDataCallback {
16 | public:
17 | AudioPlayer(
18 | const std::function, int)> &renderAudio,
19 | float sampleRate);
20 |
21 | void start();
22 | void stop();
23 | void resume();
24 | void suspend();
25 | void cleanup();
26 |
27 | DataCallbackResult onAudioReady(
28 | AudioStream *oboeStream,
29 | void *audioData,
30 | int32_t numFrames) override;
31 |
32 | private:
33 | std::function, int)> renderAudio_;
34 | std::shared_ptr mStream_;
35 | std::shared_ptr mBus_;
36 | bool isInitialized_ = false;
37 | float sampleRate_;
38 | int channelCount_;
39 | };
40 |
41 | } // namespace audioapi
42 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt:
--------------------------------------------------------------------------------
1 | package com.swmansion.audioapi
2 |
3 | import com.facebook.react.BaseReactPackage
4 | import com.facebook.react.bridge.NativeModule
5 | import com.facebook.react.bridge.ReactApplicationContext
6 | import com.facebook.react.module.annotations.ReactModuleList
7 | import com.facebook.react.module.model.ReactModuleInfo
8 | import com.facebook.react.module.model.ReactModuleInfoProvider
9 |
10 | @ReactModuleList(
11 | nativeModules = [
12 | AudioAPIModule::class,
13 | ],
14 | )
15 | class AudioAPIPackage : BaseReactPackage() {
16 | override fun getModule(
17 | name: String,
18 | reactContext: ReactApplicationContext,
19 | ): NativeModule? {
20 | when (name) {
21 | AudioAPIModule.NAME -> return AudioAPIModule(reactContext)
22 | }
23 | return null
24 | }
25 |
26 | override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
27 | ReactModuleInfoProvider {
28 | val moduleInfos: MutableMap = HashMap()
29 | val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
30 | moduleInfos[AudioAPIModule.NAME] =
31 | ReactModuleInfo(
32 | AudioAPIModule.NAME,
33 | AudioAPIModule.NAME,
34 | canOverrideExistingModule = true,
35 | needsEagerInit = false,
36 | hasConstants = true,
37 | isCxxModule = false,
38 | isTurboModule = isTurboModule,
39 | )
40 |
41 | moduleInfos
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/java/com/swmansion/audioapi/system/PermissionRequestListener.kt:
--------------------------------------------------------------------------------
1 | package com.swmansion.audioapi.system
2 |
3 | import android.content.pm.PackageManager
4 | import com.facebook.react.bridge.Promise
5 | import com.facebook.react.modules.core.PermissionListener
6 |
7 | class PermissionRequestListener(
8 | private val promise: Promise,
9 | ) : PermissionListener {
10 | companion object {
11 | const val RECORDING_REQUEST_CODE = 1234
12 | }
13 |
14 | override fun onRequestPermissionsResult(
15 | requestCode: Int,
16 | permissions: Array,
17 | grantResults: IntArray,
18 | ): Boolean {
19 | if (requestCode == RECORDING_REQUEST_CODE) {
20 | if (grantResults.isEmpty()) {
21 | this.promise.resolve("Undetermined")
22 | } else {
23 | val granted = grantResults[0] == PackageManager.PERMISSION_GRANTED
24 | if (granted) {
25 | this.promise.resolve("Granted")
26 | } else {
27 | this.promise.resolve("Denied")
28 | }
29 | }
30 | }
31 | return true
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/java/com/swmansion/audioapi/system/VolumeChangeListener.kt:
--------------------------------------------------------------------------------
1 | package com.swmansion.audioapi.system
2 |
3 | import android.content.BroadcastReceiver
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.content.IntentFilter
7 | import android.media.AudioManager
8 | import com.swmansion.audioapi.AudioAPIModule
9 | import java.lang.ref.WeakReference
10 | import java.util.HashMap
11 |
12 | class VolumeChangeListener(
13 | private val audioManager: WeakReference,
14 | private val audioAPIModule: WeakReference,
15 | ) : BroadcastReceiver() {
16 | override fun onReceive(
17 | context: Context?,
18 | intent: Intent?,
19 | ) {
20 | val currentVolume = audioManager.get()?.getStreamVolume(AudioManager.STREAM_MUSIC)?.toDouble()!!
21 | val maxVolume = audioManager.get()?.getStreamMaxVolume(AudioManager.STREAM_MUSIC)?.toDouble()!!
22 |
23 | val body = HashMap().apply { put("value", currentVolume / maxVolume) }
24 | audioAPIModule.get()?.invokeHandlerWithEventNameAndEventBody("volumeChange", body)
25 | }
26 |
27 | fun getIntentFilter(): IntentFilter {
28 | val intentFilter = IntentFilter()
29 | intentFilter.addAction("android.media.VOLUME_CHANGED_ACTION")
30 | return intentFilter
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/next.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/pause.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/play.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/previous.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/skip_backward_10.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/skip_forward_10.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/android/src/main/res/drawable/stop.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/app.plugin.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/commonjs/plugin/withAudioAPI');
2 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:@react-native/babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/HostObjects/AudioDestinationNodeHostObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | namespace audioapi {
10 | using namespace facebook;
11 |
12 | class AudioDestinationNodeHostObject : public AudioNodeHostObject {
13 | public:
14 | explicit AudioDestinationNodeHostObject(
15 | const std::shared_ptr &node)
16 | : AudioNodeHostObject(node) {}
17 | };
18 | } // namespace audioapi
19 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/HostObjects/AudioScheduledSourceNodeHostObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | namespace audioapi {
10 | using namespace facebook;
11 |
12 | class AudioScheduledSourceNodeHostObject : public AudioNodeHostObject {
13 | public:
14 | explicit AudioScheduledSourceNodeHostObject(
15 | const std::shared_ptr &node)
16 | : AudioNodeHostObject(node) {
17 | addSetters(
18 | JSI_EXPORT_PROPERTY_SETTER(AudioScheduledSourceNodeHostObject, onended));
19 | addFunctions(
20 | JSI_EXPORT_FUNCTION(AudioScheduledSourceNodeHostObject, start),
21 | JSI_EXPORT_FUNCTION(AudioScheduledSourceNodeHostObject, stop));
22 | }
23 |
24 | JSI_PROPERTY_SETTER(onended) {
25 | auto audioScheduleSourceNode =
26 | std::static_pointer_cast(node_);
27 |
28 | audioScheduleSourceNode->setOnEndedCallbackId(std::stoull(value.getString(runtime).utf8(runtime)));
29 | }
30 |
31 | JSI_HOST_FUNCTION(start) {
32 | auto when = args[0].getNumber();
33 | auto audioScheduleSourceNode =
34 | std::static_pointer_cast(node_);
35 | audioScheduleSourceNode->start(when);
36 | return jsi::Value::undefined();
37 | }
38 |
39 | JSI_HOST_FUNCTION(stop) {
40 | auto time = args[0].getNumber();
41 | auto audioScheduleSourceNode =
42 | std::static_pointer_cast(node_);
43 | audioScheduleSourceNode->stop(time);
44 | return jsi::Value::undefined();
45 | }
46 | };
47 | } // namespace audioapi
48 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/HostObjects/GainNodeHostObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 |
10 | namespace audioapi {
11 | using namespace facebook;
12 |
13 | class GainNodeHostObject : public AudioNodeHostObject {
14 | public:
15 | explicit GainNodeHostObject(const std::shared_ptr &node)
16 | : AudioNodeHostObject(node) {
17 | addGetters(JSI_EXPORT_PROPERTY_GETTER(GainNodeHostObject, gain));
18 | }
19 |
20 | JSI_PROPERTY_GETTER(gain) {
21 | auto gainNode = std::static_pointer_cast(node_);
22 | auto gainParam =
23 | std::make_shared(gainNode->getGainParam());
24 | return jsi::Object::createFromHostObject(runtime, gainParam);
25 | }
26 | };
27 | } // namespace audioapi
28 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/HostObjects/PeriodicWaveHostObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | namespace audioapi {
10 | using namespace facebook;
11 |
12 | class PeriodicWaveHostObject : public jsi::HostObject {
13 | public:
14 | std::shared_ptr periodicWave_;
15 |
16 | explicit PeriodicWaveHostObject(
17 | const std::shared_ptr &periodicWave)
18 | : periodicWave_(periodicWave) {}
19 | };
20 | } // namespace audioapi
21 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/HostObjects/StereoPannerNodeHostObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | namespace audioapi {
12 | using namespace facebook;
13 |
14 | class StereoPannerNodeHostObject : public AudioNodeHostObject {
15 | public:
16 | explicit StereoPannerNodeHostObject(
17 | const std::shared_ptr &node)
18 | : AudioNodeHostObject(node) {
19 | addGetters(JSI_EXPORT_PROPERTY_GETTER(StereoPannerNodeHostObject, pan));
20 | }
21 |
22 | JSI_PROPERTY_GETTER(pan) {
23 | auto stereoPannerNode = std::static_pointer_cast(node_);
24 | auto panParam_ =
25 | std::make_shared(stereoPannerNode->getPanParam());
26 | return jsi::Object::createFromHostObject(runtime, panParam_);
27 | }
28 | };
29 | } // namespace audioapi
30 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/core/AudioContext.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include
6 | #include
7 |
8 | namespace audioapi {
9 | #ifdef ANDROID
10 | class AudioPlayer;
11 | #else
12 | class IOSAudioPlayer;
13 | #endif
14 |
15 | class AudioContext : public BaseAudioContext {
16 | public:
17 | explicit AudioContext(float sampleRate, bool initSuspended, const std::shared_ptr &audioEventHandlerRegistry);
18 | ~AudioContext() override;
19 |
20 | void close();
21 | bool resume();
22 | bool suspend();
23 |
24 | private:
25 | #ifdef ANDROID
26 | std::shared_ptr audioPlayer_;
27 | #else
28 | std::shared_ptr audioPlayer_;
29 | #endif
30 | bool playerHasBeenStarted_;
31 |
32 | std::function, int)> renderAudio();
33 | };
34 |
35 | } // namespace audioapi
36 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/core/Constants.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | // https://webaudio.github.io/web-audio-api/
7 |
8 | namespace audioapi {
9 | // audio
10 | static constexpr int RENDER_QUANTUM_SIZE = 128;
11 | static constexpr size_t MAX_FFT_SIZE = 32768;
12 |
13 | // general
14 | static constexpr float MOST_POSITIVE_SINGLE_FLOAT = static_cast(std::numeric_limits::max());
15 | static constexpr float MOST_NEGATIVE_SINGLE_FLOAT = static_cast(std::numeric_limits::lowest());
16 | static float LOG2_MOST_POSITIVE_SINGLE_FLOAT = std::log2(MOST_POSITIVE_SINGLE_FLOAT);
17 | static float LOG10_MOST_POSITIVE_SINGLE_FLOAT = std::log10(MOST_POSITIVE_SINGLE_FLOAT);
18 | static constexpr float PI = static_cast(M_PI);
19 | } // namespace audioapi
20 |
--------------------------------------------------------------------------------
/packages/react-native-audio-api/common/cpp/audioapi/core/OfflineAudioContext.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "BaseAudioContext.h"
4 |
5 | #include
6 | #include