A powerful library designed for React Native to visualize audio tracks, extract amplitude data, and create stunning audio waveforms.
This package offers robust tools that enable developers to process audio files efficiently, obtaining amplitude arrays for in-depth analysis or creating visually appealing audio waveforms within React Native applications.
With this library, unleash creativity by generating captivating audio waveforms from your audio tracks, providing an engaging visual representation of sound.
- Audio Analysis: Easily analyze audio tracks to obtain amplitude data for visualization or analysis purposes
- Flexible Visualization: Visualize amplitude data in a customizable manner, allowing developers to create diverse representations based on audio characteristics, including stunning audio waveforms
- Sample and Scale Data: Utilize functions to sample and scale amplitude data, providing more granular control over visualization output
- Platform Compatibility: Compatible with both Android and iOS platforms, ensuring a consistent experience across devices
- High Performance: Built with C++ and miniaudio library for optimal performance
- TypeScript Support: Full TypeScript support with comprehensive type definitions
npm install react-native-audio-analyzer react-native-nitro-modules
# or
yarn add react-native-audio-analyzer react-native-nitro-modulesNote:
react-native-nitro-modulesis required as this library relies on Nitro Modules.
cd ios && pod install
# or
bundle exec pod installimport { computeAmplitude } from 'react-native-audio-analyzer';
// Analyze audio file and get amplitude data
const amplitudeData = computeAmplitude('/path/to/audio.mp3', 1000);
console.log('Amplitude data:', amplitudeData);π¦ Full usage example can be found in the example directory.
Load and cache audio file.
url(string): Url to the audio file to be cached
Promise<string>: Promise with absolute file system path to cached file.
const path = load('https://file-examples.com/storage/fe180a8b03688f5559b9baf/2017/11/file_example_MP3_1MG.mp3', 500);
// Returns: /data/user/0/audioanalyzer.example/cache/9349e0a758090499d982e320a10273ab.audioAnalyzes an audio file and returns an array of amplitude values.
filePath(string): Path to the audio file to analyzeoutputSampleCount(number): Number of amplitude samples to generate
number[]: Array of amplitude values between 0 and 1
const amplitudes = computeAmplitude(path, 500);
// Returns: [0.1, 0.3, 0.5, 0.2, ...] (500 values)This library supports various audio formats through the miniaudio library:
- Lossy: MP3, AAC, OGG Vorbis, Opus
- Lossless: FLAC, WAV, AIFF
- Other: WMA, M4A, and more
- The library uses native C++ code for optimal performance
- Audio processing is done efficiently with minimal memory usage
- Large audio files are processed in chunks to maintain responsiveness
- Consider using appropriate
outputSampleCountvalues based on your visualization needs
We welcome contributions! Please see our contributing guide to learn how to contribute to this repository and the development workflow.
# Clone the repository
git clone https://github.com/exzos28/react-native-audio-analyzer.git
cd react-native-audio-analyzer
# Install dependencies
yarn install
# Run the example app
yarn exampleThis project is licensed under the MIT License - see the LICENSE file for details.
- react-native-nitro-modules - The underlying native module system
- miniaudio - The audio processing library
Made with β€οΈ by the React Native community
