npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-simple-audio-input

v0.2.1

Published

A simple audio configuration library to use in tandem with react-native-vision-camera

Readme

react-native-simple-audio-input

iOS mic input picking and live level metering, built for pairing with react-native-vision-camera.

  • Configure and activate the AVAudioSession for recording
  • List and switch between available audio inputs (built-in mic, wired headset, USB/Bluetooth mic, etc.)
  • Meter the currently selected mic's input level in real time, for building a mic level indicator

Powered by Nitro Modules. iOS only — on Android these calls are safe to call but no-op (getAvailableAudioInputs returns [], configureAudio/setPreferredAudioInput do nothing, activate resolves immediately, listeners never fire).

Installation

npm install react-native-simple-audio-input react-native-nitro-modules

react-native-nitro-modules is required as this library relies on Nitro Modules.

Add a microphone usage description to your iOS Info.plist (required for metering, since it taps the mic via AVAudioEngine):

<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access to show the input level meter.</string>

Usage

getAvailableAudioInputs only enumerates inputs once the session is in a record-capable category (e.g. PlayAndRecord) — call configureAudio + activate first, as below.

import {
  configureAudio,
  activate,
  getAvailableAudioInputs,
  setPreferredAudioInput,
  addInputLevelListener,
  addRouteChangeListener,
  type PortDescription,
} from 'react-native-simple-audio-input';

// Configure the session for recording, then activate it.
configureAudio({
  category: 'PlayAndRecord',
  mode: 'VideoRecording',
  categoryOptions: ['AllowBluetoothHFP'],
});
await activate();

// List the mics currently available to the session.
const inputs: PortDescription[] = getAvailableAudioInputs();

// Force the session onto one of them.
setPreferredAudioInput(inputs[0]);

// Get continuous mic level updates, roughly on a 0-100 scale.
const unsubscribeLevel = addInputLevelListener((level) => {
  console.log('mic level', level);
});

// Refresh your input list when the route changes (mic plugged/unplugged, etc).
const unsubscribeRoute = addRouteChangeListener(() => {
  console.log('available inputs', getAvailableAudioInputs());
});

// later, e.g. on unmount
unsubscribeLevel();
unsubscribeRoute();

See example/src/App.tsx for a full input picker + live level meter demo.

API

| Function | Description | | --- | --- | | configureAudio(config: AudioSessionConfiguration): void | Configures the AVAudioSession category/mode/options. Throws on an invalid category, mode, or an incompatible category option; degraded/unsupported preferences log a warning instead. | | activate(): Promise<void> | Activates the session (call after configureAudio). Resolves even if already active (logs a warning in that case). | | getAvailableAudioInputs(): PortDescription[] | Lists the audio inputs currently available to the session. | | setPreferredAudioInput(port: PortDescription): void | Switches the session to the given input. Falls back to the default input and logs a warning if the port can't be found or the switch fails. | | addInputLevelListener(callback: (level: number) => void): () => void | Starts reporting the input level of whatever mic is currently active (survives route changes, interruptions, and foreground/background transitions). Returns an unsubscribe function. | | addRouteChangeListener(callback: () => void): () => void | Notifies on every audio route change (mic plugged/unplugged, Bluetooth connect, etc), with no payload — call getAvailableAudioInputs again from the callback to refresh your list. Returns an unsubscribe function. |

Types

  • PortDescription — { portName, portType, uid, channels?, isDataSourceSupported?, selectedDataSourceId? }
  • PortType — InputPort | InputOutputPort (e.g. 'BuiltInMic', 'HeadsetMic', 'USBAudio', 'BluetoothHFP')
  • AudioSessionConfiguration — { category, mode?, policy?, categoryOptions?, prefersNoInterruptionFromSystemAlerts?, prefersInterruptionOnRouteDisconnect?, allowHapticsAndSystemSoundsDuringRecording?, prefersEchoCancelledInput? }. mode/categoryOptions/prefersEchoCancelledInput are constrained by TypeScript generics to values actually compatible with the given category (see AudioSessionCompatibleModes/AudioSessionCompatibleCategoryOptions/EchoCancelledInputCompatibleCategories).
  • AudioSessionCategory, AudioSessionMode, AudioSessionCategoryOptions, AudioSessionRouteSharingPolicy — string-literal enums mirroring AVAudioSession.Category/.Mode/.CategoryOptions/.RouteSharingPolicy
  • AudioSessionWarning — { name, message }, logged via console.warn for non-fatal issues (e.g. an unsupported preference, or setPreferredAudioInput falling back to the default input)

Contributing

License

MIT


Made with create-react-native-library