Coder Social home page Coder Social logo

jmahatpure01 / react-native-sound-level Goto Github PK

View Code? Open in Web Editor NEW

This project forked from punarinta/react-native-sound-level

0.0 1.0 0.0 19 KB

A package to dynamically measure sound input level in React Native applications. Can be used to help user to adjust microphone sensitivity.

License: MIT License

JavaScript 6.16% Ruby 2.98% C++ 45.41% Objective-C 18.22% Java 24.36% CMake 2.87%

react-native-sound-level's Introduction

A package to dynamically measure sound input level in React Native applications. Can be used to help user to adjust microphone sensitivity.

Installation

Install the npm package and link it to your project:

npm install react-native-sound-level --save
react-native link react-native-sound-level

On iOS you need to add a usage description to Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>This sample uses the microphone to analyze sound level.</string>

On Android you need to add a permission to AndroidManifest.xml:

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

Manual installation on iOS

In XCode, in the project navigator:

* Right click _Libraries_
* Add Files to _[your project's name]_
* Go to `node_modules/react-native-sound-level`
* Add the `.xcodeproj` file

In XCode, in the project navigator, select your project.

* Add the `libRNSoundLevel.a` from the _soundlevel_ project to your project's _Build Phases โžœ Link Binary With Libraries_

Installation on Ubuntu

  1. Add to package.json: "desktopExternalModules": [ "node_modules/react-native-sound-level/desktop" ]
  2. You may need to make QT's multimedia library accessible for linker sudo ln -s $YOUR_QT_DIR/5.9.1/gcc_64/lib/libQt5Multimedia.so /usr/local/lib/libQt5Multimedia.so

React Native 0.60+

To make it run correctly on iOS you may need the following:

  1. Add pod 'react-native-sound-level', :podspec => '../node_modules/react-native-sound-level/RNSoundLevel.podspec' to your ios/Podfile file.
  2. Unlink the library if linked before (react-native unlink react-native-sound-level).
  3. Run pod install from within your project ios directory

Usage

import RNSoundLevel from 'react-native-sound-level'

componentDidMount() {
  RNSoundLevel.start()
  RNSoundLevel.onNewFrame = (data) => {
    // see "Returned data" section below
    console.log('Sound level info', data)
  }
}

// don't forget to stop it
componentWillUnmount() {
  RNSoundLevel.stop()
}

Returned data

{
  "id",             // frame number
  "value",          // sound level in decibels, -160 is a silence level
  "rawValue"        // raw level value, OS-dependent
}

react-native-sound-level's People

Contributors

punarinta avatar jmahatpure01 avatar kammeh avatar yasithdev 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.