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

@techoptio/react-native-live-pitch-detection

v1.2.1

Published

Live pitch detection (frequency, note and octave) from device microphone for React Native.

Downloads

512

Readme

@techoptio/react-native-live-pitch-detection

Live pitch detection (frequency, note and octave) from device microphone for React Native.

This package was heavily inspired by, but not a direct fork of, https://github.com/rnheroes/react-native-pitchy.

This package uses Turbo Modules and is only compatible with the new architecture.

Installation

npm install @techoptio/react-native-live-pitch-detection

iOS

For iOS, you'll need to add microphone permission to your Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access to detect pitch.</string>

Android

For Android, you'll need to add microphone permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

Usage

Important: This library assumes microphone permissions have already been requested and granted before calling startListening(). Make sure to request permissions using a library like react-native-permissions before using this library.

import PitchDetection from '@techoptio/react-native-live-pitch-detection';
import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
import { Platform } from 'react-native';

// Request microphone permission first
const permission = Platform.OS === 'ios'
  ? PERMISSIONS.IOS.MICROPHONE
  : PERMISSIONS.ANDROID.RECORD_AUDIO;

const result = await request(permission);

if (result === RESULTS.GRANTED) {
  // Configure options (optional) - should be called while not listening
  PitchDetection.setOptions({
    bufferSize: 4096,        // Audio buffer size (default: 4096)
    minVolume: -20.0,        // Minimum volume threshold in dB (default: -20.0)
    updateIntervalMs: 100,   // Update interval in milliseconds (default: 100)
    a4Frequency: 440,        // A4 note frequency in Hz (default: 440)
  });

  // Start listening
  await PitchDetection.startListening();

  // Add listener for pitch events
  const subscription = PitchDetection.addListener((event) => {
    console.log('Frequency:', event.frequency);
    console.log('Note:', event.note); // e.g., "C4", "A#3", etc.
  });

  // Stop listening when done
  await PitchDetection.stopListening();
  subscription.remove();
}

API

Methods

setOptions(options: Options)

Configure the pitch detection settings. This method is optional, as all parameters have defaults. However, if you want to customize the settings, call this method while not listening (i.e., before startListening() or after stopListening()), otherwise all parameters may not be applied until the next listening session.

Parameters:

  • options.bufferSize?: number - Audio buffer size (default: 4096)
  • options.minVolume?: number - Minimum volume threshold in dB (default: -20.0)
  • options.updateIntervalMs?: number - Update interval in milliseconds (default: 100)
  • options.a4Frequency?: number - A4 note frequency in Hz (default: 440)

startListening(): Promise<void>

Starts listening to the microphone for pitch detection.

Note: Ensure microphone permissions have been requested and granted before calling this method.

stopListening(): Promise<void>

Stops listening to the microphone.

addListener(callback: (event: PitchEvent) => void): EventSubscription

Adds a listener for pitch detection events. Returns an EventSubscription that should be removed when no longer needed.

Event:

type PitchEvent = {
  frequency: number;  // Detected frequency in Hz
  note: string;       // Musical note (e.g., "C4", "A#3", "-" if no note detected)
};

isListening(): boolean

Returns true if currently listening, false otherwise.

Types

type Options = {
  bufferSize?: number;
  minVolume?: number;
  updateIntervalMs?: number;
  a4Frequency?: number;
};

type PitchEvent = {
  frequency: number;
  note: string;
};

Example

Check out the example app for a complete working implementation.

Example App Preview

Contributing

License

MIT


Made with create-react-native-library