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

@mgcrea/react-native-tone-generator

v0.4.1

Published

React Native plugin exposing the Android ToneGenerator and AudioManager stream volume

Readme

@mgcrea/react-native-tone-generator

React Native plugin exposing Android's ToneGenerator (DTMF, call supervisory and proprietary tones) and AudioManager stream volume.

  • Android only. Both are Android platform APIs; autolinking skips iOS automatically, so you do not need to exclude this package by hand.
  • Requires React Native >= 0.86 (New Architecture / TurboModule).

Installation

npm install @mgcrea/react-native-tone-generator

Then rebuild the Android app. No pod install step is needed — the package declares no iOS platform.

Usage

import {
  startTone,
  startToneAndWait,
  stopTone,
  getStreamMaxVolume,
  setStreamVolume,
  TONE_PROP_BEEP,
  STREAM_MUSIC,
} from '@mgcrea/react-native-tone-generator';

// Play a beep for 400ms.
await startTone(TONE_PROP_BEEP, 400);

// Play it and wait for it to finish.
await startToneAndWait(TONE_PROP_BEEP, 400);

// Volume.
const max = await getStreamMaxVolume(STREAM_MUSIC);
await setStreamVolume(Math.floor(max / 2), STREAM_MUSIC);

Tones

| Function | Description | | --- | --- | | startTone(toneType, durationMs = -1) | Starts a tone. -1 plays until stopTone(). | | startToneAndWait(toneType, durationMs = -1) | Starts a tone and waits out durationMs. | | stopTone() | Stops the current tone. | | configureTone(streamType, volume = 100) | Rebuilds the generator on a stream at a volume (0–100). |

Volume

| Function | Description | | --- | --- | | getStreamVolume(streamType = STREAM_MUSIC) | Current volume for the stream. | | setStreamVolume(index, streamType = STREAM_MUSIC, flags = 0) | Sets the stream volume. | | getStreamMaxVolume(streamType = STREAM_MUSIC) | Maximum volume for the stream. | | getStreamMinVolume(streamType = STREAM_MUSIC) | Minimum volume, or null below Android 9 (API 28). |

Note setStreamVolume takes the index first and the stream second.

Constants

All constants are plain JavaScript, so they are safe to use at module scope:

  • Tones: TONE_DTMF_0TONE_DTMF_D, TONE_SUP_*, TONE_PROP_*, TONE_CDMA_*.
  • Streams: STREAM_VOICE_CALL, STREAM_SYSTEM, STREAM_RING, STREAM_MUSIC, STREAM_ALARM, STREAM_NOTIFICATION, STREAM_BLUETOOTH_SCO, STREAM_SYSTEM_ENFORCED, STREAM_DTMF, STREAM_TTS, STREAM_ACCESSIBILITY.
  • Volume bounds for configureTone: MIN_VOLUME (0), MAX_VOLUME (100).

Compatibility

| Package | React Native | | --- | --- | | >= 0.4.0 | >= 0.86 | | <= 0.3.1 | 0.70 (Old Architecture) |

Development

pnpm install          # install the library's dependencies
pnpm run build        # compile src/ -> dist/
pnpm test             # lint + typecheck + unit tests

cd example
pnpm install
pnpm run android      # build and run the example on a device

The example app links the library via "@mgcrea/react-native-tone-generator": "link:..", so autolinking picks it up from node_modules and Metro resolves it through @mgcrea/metro-plugin-linked-packages.

License

MIT