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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-pitchy

v1.0.0

Published

A simple pitch detection module for React Native

Downloads

38

Readme

react-native-pitchy

A real-time pitch detection library for React Native.

Installation

  1. Install the library using a package manager of your choice:
npm install react-native-pitchy
  1. Linking (iOS only):
npx pod-install
  1. Rebuild your app after installing the package.

On iOS simulators, pitch detection may not work as expected due to the lack of microphone support. Make sure to test on a real device.

Permissions

Microphone permissions are required for pitch detection to work. Make sure to request the necessary permissions before starting pitch detection. You can use a library like react-native-permissions to request permissions.

iOS

Microphone

Android

RECORD_AUDIO

Usage

  1. Import the library:
import Pitchy, { PitchyConfig, PitchyEventCallback } from 'react-native-pitchy';
  1. (Optional) Configure Pitchy before initialization:
const config: PitchyConfig = {
  bufferSize: 4096, // Adjust buffer size for performance vs accuracy
  minVolume: -60, // Minimum volume threshold for pitch detection (in dB)
};
  1. Initialize Pitchy with the optional configuration:
Pitchy.init(config);
  1. Start pitch detection:
Pitchy.start().then(() => {
  console.log('Pitch detection started!');
});
  1. Listen to pitch events:
const handlePitchDetected: PitchyEventCallback = (data) => {
  console.log('Pitch detected:', data.pitch);
};

const subscription = Pitchy.addListener(handlePitchDetected);

// Remember to unsubscribe later to avoid memory leaks
subscription.remove();
  1. Stop pitch detection:
Pitchy.stop().then(() => {
  console.log('Pitch detection stopped!');
});
  1. Check if pitch detection is running:
Pitchy.isRecording().then((isRecording) => {
  console.log('Pitch detection is recording:', isRecording);
});

API

Types

  • PitchyAlgorithm: String representing the pitch detection algorithm (currently only supports "ACF2+")
  • PitchyConfig: Configuration object for Pitchy.init
    • bufferSize: (optional) Number representing the audio buffer size (default: 4096)
    • minVolume: (optional) Number representing the minimum volume threshold (default: -60)
    • algorithm: (optional) PitchyAlgorithm used for detection (default: "ACF2+")
  • PitchyEventCallback: Function called when pitch is detected. Receives an object with a pitch property (number)

Methods

  • Pitchy.init(config?: PitchyConfig): Initializes Pitchy with an optional configuration.
  • Pitchy.start(): Starts pitch detection and returns a Promise.
  • Pitchy.stop(): Stops pitch detection and returns a Promise.
  • Pitchy.isRecording(): Checks if pitch detection is currently running and returns a Promise resolving to a boolean.
  • Pitchy.addListener(callback: PitchyEventCallback): Adds a listener for the onPitchDetected event.

Roadmap

  • [ ] Fix example app (permissions issue related to builder-bob)
  • [ ] Add FFT for ACF2+ algorithm (currently uses a naive implementation)
  • [ ] Add more pitch detection algorithms

Examples

Check out the example app for a simple implementation of pitch detection using Pitchy.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT