### Create and Start StreamerNode Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/sources/streamer-node.mdx This example demonstrates how to create a new AudioContext, instantiate a StreamerNode, initialize it with an HLS stream path, connect it to the audio destination, and start playback. ```tsx import React, { useRef } from 'react'; import { AudioContext, StreamerNode, } from 'react-native-audio-api'; function App() { const audioContextRef = useRef(null); if (!audioContextRef.current) { audioContextRef.current = new AudioContext(); } const streamer = audioContextRef.current.createStreamer(); streamer.initialize('link/to/your/hls/source'); streamer.connect(audioContextRef.current.destination); streamer.start(audioContextRef.current.currentTime); } ``` -------------------------------- ### start Method Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/sources/audio-scheduled-source-node.mdx Schedules the node to start audio playback at a specified time. If no time is given, it starts immediately. This method can only be invoked once per node. ```APIDOC ## start ### Description Schedules the node to start audio playback at specified time. If no time is given, it starts immediately. You can invoke this method only once in node's life. ### Parameters #### Path Parameters - **when** (number) - The time, in seconds, at which the node will start to play. #### Errors - `RangeError`: `when` is negative number. - `InvalidStateError`: If node has already been started once. ### Returns `undefined` ``` -------------------------------- ### Register New Example in Index Source: https://github.com/software-mansion/react-native-audio-api/blob/main/apps/CLAUDE.md Adds a new example screen to the main examples index, providing key details for navigation and display. ```typescript // apps/common-app/src/examples/index.ts import MyExample from './MyExample'; import { icons } from 'lucide-react-native'; // pick any icon export const Examples = [ // ... existing { key: 'MyExample', title: 'My Example', Icon: icons.Zap, screen: MyExample, }, ]; ``` -------------------------------- ### Create and Start Oscillator Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/sources/oscillator-node.mdx Demonstrates how to create an AudioContext, instantiate an OscillatorNode, connect it to the destination, and start it. ```tsx import React, { useRef } from 'react'; import { AudioContext, OscillatorNode, } from 'react-native-audio-api'; function App() { const audioContextRef = useRef(null); if (!audioContextRef.current) { audioContextRef.current = new AudioContext(); } const oscillator = audioContextRef.current.createOscillator(); oscillator.connect(audioContextRef.current.destination); oscillator.start(audioContextRef.current.currentTime); } ``` -------------------------------- ### Run Fabric Example iOS Tests Source: https://github.com/software-mansion/react-native-audio-api/blob/main/apps/fabric-example/README.md Execute native XCTest targets for the Fabric example. Ensure Pods are installed first. ```sh bundle exec pod install xcodebuild test \ -workspace ios/FabricExample.xcworkspace \ -scheme FabricExample \ -destination 'platform=iOS Simulator,name=iPhone 17 pro,OS=26.4' \ -parallelizeTargets ``` -------------------------------- ### start Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/inputs/audio-recorder.mdx Starts the stream from system audio input device. You can pass an optional object with `fileNameOverride` string, to provide your own file name generation. ```APIDOC ## start ### Description Starts the stream from system audio input device. You can pass optional object with `fileNameOverride` string, to provide your own fileName generation. ### Parameters #### Request Body - **fileNameOverride** (string) - Optional - Allows to provide your own file name generation. ### Usage ```tsx const result = audioRecorder.start({ fileNameOverride: `my_audio_${mySessionId}` }); console.log(result.status); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation ('success' or 'error'). ``` -------------------------------- ### start Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/sources/audio-buffer-source-node.mdx Schedules the AudioBufferSourceNode to start playback of audio data contained in the associated AudioBuffer, or starts to play immediately. It inherits methods from AudioBufferBaseSourceNode. ```APIDOC ## start ### Description Schedules the `AudioBufferSourceNode` to start playback of audio data contained in the associated [`AudioBuffer`](/docs/sources/audio-buffer), or starts to play immediately. ### Method Signature `start(when?: number, offset?: number, duration?: number): undefined` ### Parameters #### Optional Parameters - **when** (`number`) - The time, in seconds, at which playback is scheduled to start. If `when` is less than [`AudioContext.currentTime`](/docs/core/base-audio-context#properties) or set to 0, the node starts playing immediately. Default: `0`. - **offset** (`number`) - The position, in seconds, within the audio buffer where playback begins. The default value is `0`, which starts playback from the beginning of the buffer. If the offset exceeds the buffer’s [`duration`](/docs/sources/audio-buffer#properties) (or the defined [`loopEnd`](/docs/sources/audio-buffer-source-node#properties) value), it’s automatically clamped to the valid range. Offsets are calculated using the buffer’s natural sample rate rather than the current playback rate. - **duration** (`number`) - The playback duration, in seconds. If not provided, playback continues until the sound ends naturally or is manually stopped with [`stop() method`](/docs/sources/audio-scheduled-source-node#stop). Equivalent to calling `start(when, offset)` followed by `stop(when + duration)`. ### Errors - `RangeError`: `when` is a negative number. - `RangeError`: `offset` is a negative number. - `RangeError`: `duration` is a negative number. - `InvalidStateError`: If the node has already been started once. ### Returns `undefined` ``` -------------------------------- ### Create Example Screen Index Source: https://github.com/software-mansion/react-native-audio-api/blob/main/apps/CLAUDE.md Defines the index file for an example screen, re-exporting the default component. ```typescript // index.ts export { default } from './MyExample'; ``` -------------------------------- ### GainNode Documentation Example Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/CLAUDE.md Example of how to document a GainNode, including its constructor, options, properties, and methods, following the MDX format. ```APIDOC ## GainNode Brief one-line description. `GainNode` extends [`AudioNode`](/docs/core/audio-node). #### [`AudioNode`](/docs/core/audio-node#properties) properties ## Constructor ```tsx constructor(context: BaseAudioContext, options?: GainOptions) ``` ### `GainOptions` Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions). | Parameter | Type | Default | | | :---: | :---: | :----: | :---- | | `gain` | `number` | `1` | Initial gain value. | Or by using [`BaseAudioContext.createGain()`](/docs/core/base-audio-context#creategain). ## Example ```tsx import { AudioContext } from 'react-native-audio-api'; const ctx = new AudioContext(); const gain = ctx.createGain(); gain.gain.value = 0.5; gain.connect(ctx.destination); ``` ## Properties It inherits all properties from [`AudioNode`](/docs/core/audio-node#properties). | Name | Type | Default | Description | | :----: | :----: | :-------- | :------- | | `gain` | `AudioParam` | `1` | Gain applied to the signal. Range: [0, 1] typical. | ## Methods It inherits all methods from [`AudioNode`](/docs/core/audio-node#methods). ## Remarks #### `gain` - Nominal range is [0, 1] for attenuation but accepts any finite value. - Values > 1 amplify; negative values invert phase. ``` -------------------------------- ### GainNode Usage Examples Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/effects/gain-node.mdx Examples demonstrating how to use GainNode for master volume control and smooth volume transitions. ```APIDOC ## Usage A common use case is controlling the master volume of an audio graph: ```tsx const audioContext = new AudioContext(); const gainNode = audioContext.createGain(); // Set volume to 50% gainNode.gain.setValueAtTime(0.5, audioContext.currentTime); // Connect source → gain → output source.connect(gainNode); gainNode.connect(audioContext.destination); ``` To fade in a sound over 2 seconds: ```tsx gainNode.gain.setValueAtTime(0, audioContext.currentTime); gainNode.gain.linearRampToValueAtTime(1, audioContext.currentTime + 2); ``` ``` -------------------------------- ### Example App Structure Source: https://github.com/software-mansion/react-native-audio-api/blob/main/apps/CLAUDE.md Illustrates the directory structure for the React Native Audio API example applications, separating native app shells from shared common code. ```tree apps/ ├── fabric-example/ # RN app shell (native + metro config) │ ├── App.tsx # Re-exports App from common-app │ ├── metro.config.js # Monorepo-aware Metro (watches workspaces) │ └── android/ ios/ # Native projects └── common-app/ # Actual app code — edit this └── src/ ├── App.tsx # Navigation root (Stack + Bottom Tabs) ├── examples/ # "Tests" tab — focused feature examples │ └── index.ts # Exports Examples array — register new screens here ├── demos/ # "Demo Apps" tab — full mini-apps │ └── index.ts # Exports demos array — register new screens here ├── components/ # Shared UI: Container, Button, Slider, Spacer, Switch, Select ├── utils/ │ ├── soundEngines/ # Reusable synth classes (MetronomeSound, Kick, HiHat, Clap) │ └── usePlayer.tsx # Hook for pattern-based scheduled playback ├── singletons/ # Global audioContext and audioRecorder instances └── styles.ts # Shared colors and layout constants ``` -------------------------------- ### startRendering Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/core/offline-audio-context.mdx Starts rendering the audio, taking into account the current connections and scheduled changes. ```APIDOC ## startRendering Starts rendering the audio, taking into account the current connections and the current scheduled changes. ### Method `startRendering(): Promise` ``` -------------------------------- ### Manual Mock Setup for Testing Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/other/testing.mdx Set up the mock implementation manually in your test setup file for use in tests. This approach allows you to import from the main library path. ```typescript // In your test setup file jest.mock('react-native-audio-api', () => require('react-native-audio-api/mock') ); // Then in your tests import { AudioContext, AudioRecorder } from 'react-native-audio-api'; ``` -------------------------------- ### Create Example Screen Component Source: https://github.com/software-mansion/react-native-audio-api/blob/main/apps/CLAUDE.md A basic React Native component for a new example screen, demonstrating the initialization of AudioContext and cleanup. ```tsx // MyExample.tsx import React, { useEffect, useRef, FC } from 'react'; import { AudioContext, GainNode } from 'react-native-audio-api'; import { Container, Button, Slider } from '../../components'; const MyExample: FC = () => { const audioContextRef = useRef(null); const gainRef = useRef(null); useEffect(() => { audioContextRef.current = new AudioContext(); return () => { audioContextRef.current?.close(); }; }, []); return ( {/* UI here */} ); }; export default MyExample; ``` -------------------------------- ### LaTeX Math Examples Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/CLAUDE.md Illustrates how to render inline and block-level mathematical formulas using LaTeX syntax. ```tex Inline: `$f = -\frac{\text{sampleRate}}{2}$` Block: `$$formula$$` ``` -------------------------------- ### Development Server and Build Commands Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/CLAUDE.md Commands to start the development server with hot reloading, build the production site, and serve the built site. ```bash yarn start # dev server with hot reload yarn build # production build yarn serve # serve the built site ``` -------------------------------- ### OscillatorNode Example Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/sources/oscillator-node.mdx A basic example demonstrating how to create and use an OscillatorNode. ```APIDOC ## Example ```tsx import React, { useRef } from 'react'; import { AudioContext, OscillatorNode, } from 'react-native-audio-api'; function App() { const audioContextRef = useRef(null); if (!audioContextRef.current) { audioContextRef.current = new AudioContext(); } const oscillator = audioContextRef.current.createOscillator(); oscillator.connect(audioContextRef.current.destination); oscillator.start(audioContextRef.current.currentTime); } ``` ``` -------------------------------- ### Play Audio with AudioBufferSourceNode Source: https://github.com/software-mansion/react-native-audio-api/blob/main/packages/audiodocs/docs/guides/lets-make-some-noise.mdx Create an AudioBufferSourceNode, set its buffer, connect it to the audio context's destination, and start playback. Playback can be controlled with start and stop methods. ```jsx import React from 'react'; import { View, Button } from 'react-native'; import { AudioContext } from 'react-native-audio-api'; export default function App() { const handlePlay = async () => { const audioContext = new AudioContext(); const audioBuffer = await audioContext.decodeAudioData(arrayBuffer); const playerNode = audioContext.createBufferSource(); playerNode.buffer = audioBuffer; playerNode.connect(audioContext.destination); playerNode.start(audioContext.currentTime); playerNode.stop(audioContext.currentTime + 10); }; return (