orca/mobile/packages/expo-two-way-audio
Neil 46646d7ff1
chore(lint): upgrade oxlint to 1.71 + enable 7 new rules (autofixed backlog) (#6841)
* chore(lint): upgrade oxlint to 1.71 and enable 7 new rules

Upgrade oxlint 1.67.0 -> 1.71.0 (1.72 was blocked by the repo's 3-day
minimum-release-age supply-chain guard; nothing here needs it). The
bump is a no-op on the existing config.

Enable 3 error rules (backlog autofixed to zero in this commit) and
4 warn rules (surface signal without gating CI):

error (autofixed, behavior-preserving):
- unicorn/prefer-node-protocol        (~1531 sites: bare builtin -> node:)
- typescript/no-import-type-side-effects (~36: all-inline-type -> import type)
- unicorn/no-array-reverse            (19: copy-then-reverse -> toReversed)

warn (real signal, current fires are test-only/correct):
- unicorn/no-array-fill-with-reference-type  (aliasing footgun guard)
- typescript/no-unsafe-function-type         (bans bare Function type)
- unicorn/prefer-array-flat-map              (map().flat() -> flatMap())
- unicorn/prefer-regexp-test                 (.match() in bool ctx -> .test())

mobile/.oxlintrc.json extends root, so it inherits all 7; the autofix
ran from root and covered mobile/ too.

Verification (all green): oxlint 0 errors (root+mobile+aux configs),
oxfmt clean, typecheck (node+cli+web), vitest 22795 passed / 0 failed,
builds (electron-vite + web + cli) succeed. node: rewrites confirmed to
skip embedded SSH/CLI string payloads (AST-only); all toReversed sites
verified to operate on fresh copies or write-once locals.

* chore(lint): bump mobile oxlint to 1.71 so inherited rules parse

mobile/ is a standalone pnpm project pinning its own oxlint@1.67, which
lacks unicorn/no-array-fill-with-reference-type (needs >=1.70). Since
mobile/.oxlintrc.json extends the root config, mobile CI's 'cd mobile &&
oxlint' failed to parse the new rule. Bump mobile to match root (1.71).

Verified in mobile/: oxlint 0 errors, oxfmt --check clean, tsc --noEmit
pass, vitest 978 passed / 0 failed.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-06-29 22:38:29 -07:00
..
android perf: trim android audio hot path work (#4062) 2026-05-31 03:08:21 -07:00
ios Fix mobile mic permission requester build (#2228) 2026-05-17 23:33:28 -07:00
src chore(lint): upgrade oxlint to 1.71 + enable 7 new rules (autofixed backlog) (#6841) 2026-06-29 22:38:29 -07:00
LICENSE Add desktop-backed mobile voice dictation (#1869) 2026-05-14 14:36:44 -07:00
README.md Add desktop-backed mobile voice dictation (#1869) 2026-05-14 14:36:44 -07:00
expo-module.config.json Add desktop-backed mobile voice dictation (#1869) 2026-05-14 14:36:44 -07:00
package.json Add desktop-backed mobile voice dictation (#1869) 2026-05-14 14:36:44 -07:00
tsconfig.json Add desktop-backed mobile voice dictation (#1869) 2026-05-14 14:36:44 -07:00

README.md

Orca Two Way Audio

Vendored Expo module for capturing and playing PCM audio data in the Orca mobile app (iOS and Android).

The aim of the module is to facilitate creating real-time conversational apps. The following features are provided:

  • Request audio recording permissions
  • Get clean (applying Acoustic Echo Cancelling) microphone samples in PCM format (1 channel 16 bit at 16kHz)
  • Play audio samples in PCM format (1 channel 16 bit at 16kHz). Playback happens through main speaker unless external audio sources are connected.
  • Provide volume level both for the input and output samples. Float between 0 and 1.
  • [iOS only] Get microphone mode and prompt user to select a microphone mode.

Installation

npm i @orca/expo-two-way-audio

Usage

  1. Request permissions for recording audio

    import {useMicrophonePermissions} from "@orca/expo-two-way-audio";
    
    const [micPermission, requestMicPermission] = useMicrophonePermissions();
    console.log(micPermission);
    
  2. Initialize the module before calling any audio functionality.

    useEffect(() => {
        const initializeAudio = async () => {
            await initialize();
        };
        initializeAudio();
    }, []);
    
    
  3. Play audio

    [!NOTE] The sample below uses the buffer module: npm install buffer

     import { Buffer } from "buffer";
    
     // As an example, play pcm data hardcoded in a variable.
     const audioChunk = "SOME PCM DATA BASE64 ENCODED HERE"
     const buffer = Buffer.from(audioChunk, "base64");
     const pcmData = new Uint8Array(buffer);
     playPCMData(pcmData);
    
  4. Get microphone samples

    // Set up a function to deal with microphone sample events.
    // In this case just print the data in the console.
    useExpoTwoWayAudioEventListener(
        "onMicrophoneData",
        useCallback<MicrophoneDataCallback>((event) => {
            console.log(`MIC DATA: ${event.data}`);
        }, []),
    );
    
    // Unmute the microphone to get microphone data events
    toggleRecording(true);
    

Notes

Some audio features of expo-two-way-audio like Acoustic Echo Cancelling, noise reduction or microphone modes (iOS) don't work on simulator. Run the Orca mobile app on a real device to test these features.

# iOS
npx expo run:ios --device --configuration Release

# Android
npx expo run:android --device --variant release

For Android, the following permissions are needed: RECORD_AUDIO, MODIFY_AUDIO_SETTINGS. In Expo apps they can bee added in your app.json file:

expo.android.permissions: ["RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"]