Skip to content

Commit 22fac3f

Browse files
exzosexzos
authored andcommitted
docs: update README.md and package.json to enhance library documentation and metadata
1 parent f7d49fe commit 22fac3f

File tree

3 files changed

+229
-20
lines changed

3 files changed

+229
-20
lines changed

README.md

Lines changed: 188 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,210 @@
1-
# react-native-audio-analyzer
1+
# react-native-audio-analyzer 🎵
22

3-
Audio analyzer
3+
A powerful library designed for React Native to visualize audio tracks, extract amplitude data, and create stunning audio waveforms.
44

5-
## Installation
5+
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.
66

7+
## Create Stunning Audio Waveforms 🌊
78

8-
```sh
9+
With this library, unleash creativity by generating captivating audio waveforms from your audio tracks, providing an engaging visual representation of sound.
10+
11+
![Audio Waveform Example](https://github.com/exzos28/react-native-audio-analyzer/raw/main/images/image.png)
12+
13+
## Features ✨
14+
15+
- **Audio Analysis**: Easily analyze audio tracks to obtain amplitude data for visualization or analysis purposes
16+
- **Flexible Visualization**: Visualize amplitude data in a customizable manner, allowing developers to create diverse representations based on audio characteristics, including stunning audio waveforms
17+
- **Sample and Scale Data**: Utilize functions to sample and scale amplitude data, providing more granular control over visualization output
18+
- **Platform Compatibility**: Compatible with both Android and iOS platforms, ensuring a consistent experience across devices
19+
- **High Performance**: Built with C++ and miniaudio library for optimal performance
20+
- **TypeScript Support**: Full TypeScript support with comprehensive type definitions
21+
22+
## Installation 🚀
23+
24+
```bash
925
npm install react-native-audio-analyzer react-native-nitro-modules
26+
# or
27+
yarn add react-native-audio-analyzer react-native-nitro-modules
28+
```
29+
30+
> **Note**: `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
1031
11-
> `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
32+
### iOS Setup
33+
34+
```bash
35+
cd ios && pod install
1236
```
1337

38+
## Usage 🎶
1439

15-
## Usage
40+
### Basic Usage
1641

42+
```typescript
43+
import { computeAmplitude } from 'react-native-audio-analyzer';
1744

18-
```js
19-
import { multiply } from 'react-native-audio-analyzer';
45+
// Analyze audio file and get amplitude data
46+
const amplitudeData = computeAmplitude('/path/to/audio.mp3', 1000);
47+
console.log('Amplitude data:', amplitudeData);
48+
```
2049

21-
// ...
50+
### Creating Audio Waveforms
51+
52+
```typescript
53+
import React, { useCallback, useEffect, useState } from 'react';
54+
import { View, StyleSheet, ScrollView } from 'react-native';
55+
import { computeAmplitude } from 'react-native-audio-analyzer';
56+
57+
export default function AudioWaveform() {
58+
const [amplitudeData, setAmplitudeData] = useState<number[]>([]);
59+
60+
const analyzeAudio = useCallback(async () => {
61+
try {
62+
const result = computeAmplitude(
63+
'/path/to/your/audio.mp3',
64+
1000 // Number of amplitude samples to generate
65+
);
66+
setAmplitudeData(result);
67+
} catch (error) {
68+
console.error('Error analyzing audio:', error);
69+
}
70+
}, []);
71+
72+
useEffect(() => {
73+
analyzeAudio();
74+
}, [analyzeAudio]);
75+
76+
return (
77+
<ScrollView horizontal contentContainerStyle={styles.container}>
78+
<View style={styles.waveform}>
79+
{amplitudeData.map((amplitude, index) => (
80+
<View
81+
key={index}
82+
style={[
83+
styles.bar,
84+
{ height: 500 * amplitude } // Scale the height based on amplitude
85+
]}
86+
/>
87+
))}
88+
</View>
89+
</ScrollView>
90+
);
91+
}
92+
93+
const styles = StyleSheet.create({
94+
container: {
95+
flexGrow: 1,
96+
},
97+
waveform: {
98+
flex: 1,
99+
flexDirection: 'row',
100+
alignItems: 'center',
101+
columnGap: 1,
102+
},
103+
bar: {
104+
width: 3,
105+
backgroundColor: '#007AFF',
106+
borderRadius: 1,
107+
},
108+
});
109+
```
22110

23-
const result = multiply(3, 7);
111+
### Advanced Usage
112+
113+
```typescript
114+
import { computeAmplitude } from 'react-native-audio-analyzer';
115+
116+
// Customize the number of amplitude samples
117+
const highResolution = computeAmplitude('/audio.mp3', 2000); // More detailed
118+
const lowResolution = computeAmplitude('/audio.mp3', 100); // Less detailed
119+
120+
// Process the amplitude data for different visualizations
121+
const normalizedData = highResolution.map(amplitude =>
122+
Math.min(amplitude * 100, 1.0) // Normalize to 0-1 range
123+
);
124+
125+
// Create different visualization styles
126+
const createWaveform = (data: number[], style: 'bars' | 'line' | 'area') => {
127+
switch (style) {
128+
case 'bars':
129+
return data.map((amp, i) => ({ x: i, y: amp }));
130+
case 'line':
131+
return data.map((amp, i) => ({ x: i, y: amp }));
132+
case 'area':
133+
return data.map((amp, i) => ({ x: i, y: amp, height: amp }));
134+
}
135+
};
24136
```
25137

138+
## API Reference 📚
139+
140+
### `computeAmplitude(filePath: string, outputSampleCount: number): number[]`
141+
142+
Analyzes an audio file and returns an array of amplitude values.
143+
144+
#### Parameters
145+
146+
- `filePath` (string): Path to the audio file to analyze
147+
- `outputSampleCount` (number): Number of amplitude samples to generate
148+
149+
#### Returns
150+
151+
- `number[]`: Array of amplitude values between 0 and 1
152+
153+
#### Example
154+
155+
```typescript
156+
const amplitudes = computeAmplitude('/path/to/song.mp3', 500);
157+
// Returns: [0.1, 0.3, 0.5, 0.2, ...] (500 values)
158+
```
159+
160+
## Supported Audio Formats 🎼
161+
162+
This library supports various audio formats through the miniaudio library:
163+
164+
- **Lossy**: MP3, AAC, OGG Vorbis, Opus
165+
- **Lossless**: FLAC, WAV, AIFF
166+
- **Other**: WMA, M4A, and more
167+
168+
## Performance Considerations ⚡
169+
170+
- The library uses native C++ code for optimal performance
171+
- Audio processing is done efficiently with minimal memory usage
172+
- Large audio files are processed in chunks to maintain responsiveness
173+
- Consider using appropriate `outputSampleCount` values based on your visualization needs
174+
175+
## Platform Support 📱
176+
177+
- ✅ iOS 12.0+
178+
- ✅ Android API 21+
179+
- ✅ React Native 0.70+
180+
181+
## Contributing 🤝
182+
183+
We welcome contributions! Please see our [contributing guide](CONTRIBUTING.md) to learn how to contribute to this repository and the development workflow.
184+
185+
### Development Setup
186+
187+
```bash
188+
# Clone the repository
189+
git clone https://github.com/exzos28/react-native-audio-analyzer.git
190+
cd react-native-audio-analyzer
191+
192+
# Install dependencies
193+
yarn install
194+
195+
# Run the example app
196+
yarn example
197+
```
26198
27-
## Contributing
199+
## License 📝
28200
29-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
201+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
30202
31-
## License
203+
## Related Projects 🔗
32204
33-
MIT
205+
- [react-native-nitro-modules](https://github.com/margelo/react-native-nitro-modules) - The underlying native module system
206+
- [miniaudio](https://github.com/mackron/miniaudio) - The audio processing library
34207
35208
---
36209
37-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
210+
Made with ❤️ by the React Native community

images/image.png

83.5 KB
Loading

package.json

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-audio-analyzer",
33
"version": "3.0.0-alpha.1",
4-
"description": "Audio analyzer",
4+
"description": "A powerful React Native library for audio analysis, waveform visualization, and amplitude data extraction. Create stunning audio visualizations with high-performance native C++ implementation.",
55
"main": "./lib/module/index.js",
66
"types": "./lib/typescript/src/index.d.ts",
77
"exports": {
@@ -47,19 +47,38 @@
4747
},
4848
"keywords": [
4949
"react-native",
50+
"audio",
51+
"waveform",
52+
"visualization",
53+
"amplitude",
54+
"audio-analysis",
55+
"audio-visualizer",
56+
"music-player",
57+
"audio-player",
58+
"sound-analysis",
59+
"audio-processing",
60+
"miniaudio",
5061
"ios",
51-
"android"
62+
"android",
63+
"typescript",
64+
"native-module",
65+
"nitro-modules"
5266
],
5367
"repository": {
5468
"type": "git",
5569
"url": "git+https://github.com/exzos28/react-native-audio-analyzer.git"
5670
},
57-
"author": "exzos <[email protected]> (https://github.com/exzos28)",
71+
"author": {
72+
"name": "Oleksandr Kurinnyi",
73+
"email": "[email protected]",
74+
"url": "https://github.com/exzos28"
75+
},
5876
"license": "MIT",
5977
"bugs": {
6078
"url": "https://github.com/exzos28/react-native-audio-analyzer/issues"
6179
},
6280
"homepage": "https://github.com/exzos28/react-native-audio-analyzer#readme",
81+
"readme": "README.md",
6382
"publishConfig": {
6483
"registry": "https://registry.npmjs.org/"
6584
},
@@ -166,5 +185,22 @@
166185
"languages": "kotlin-swift",
167186
"type": "nitro-module",
168187
"version": "0.52.0"
169-
}
170-
}
188+
},
189+
"funding": {
190+
"type": "github",
191+
"url": "https://github.com/sponsors/exzos28"
192+
},
193+
"maintainers": [
194+
{
195+
"name": "exzos",
196+
"email": "[email protected]"
197+
}
198+
],
199+
"contributors": [
200+
{
201+
"name": "exzos",
202+
"email": "[email protected]",
203+
"url": "https://github.com/exzos28"
204+
}
205+
]
206+
}

0 commit comments

Comments
 (0)