Giter VIP home page Giter VIP logo

react-native-loudness's Introduction

react-native-loudness

Read microphone loudness in React Native

Getting started

$ npm install react-native-loudness --save

$ react-native link react-native-loudness

For RN>0.60, no need to link but please run pod install in the project ios directory.

Required Additional Steps

iOS

  1. In Info.plist, add Privacy - Micronphone Usage Description using XCode.

Android

  1. In AndroidManifest.xml, add <uses-permission android:name="android.permission.RECORD_AUDIO" />.

Permission

The app needs to ask permission for microphone usage. If the loudness reading is not a number or is always a fixed number, check the app permission first. For Android 6.0 (API level 23) or later, the permission needs to be asked when running the app. Learn more here. For iOS devices, the permission will be automatically asked when needed. It can also be manually asked. Check out react-native-permissions.

Usage

Loudness is in dbFS from -160 to 0, where -160 represents near absolute silence and 0 represents the maximum loudness the microphone can sense.

import Loudness from 'react-native-loudness';

Loudness.start();

Loudness.getLoudness((loudness) => {
  console.log(loudness);
});

Loudness.stop();

While reading the loudness, this module can save the microphone reading into a WAV audio file at the same time. The file is 16 bit, 44.1kHz, and mono channel both for iOS and Android. The file is located in the document directory of the app. Please use another library such as rn-fetch-blob to move, delete, or copy the file.

Loudness.start('test'); // Supply a file name string to save the file

Example

Check out this example app LoudnessMeter for more details.

react-native-loudness's People

Contributors

fchenchen avatar flyskywhy avatar bandoulyes avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.