Skip to content

Commit 9e6edb8

Browse files
committed
docs: update README.md
1 parent 6f333a3 commit 9e6edb8

File tree

1 file changed

+2
-128
lines changed

1 file changed

+2
-128
lines changed

README.md

Lines changed: 2 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cd ios && pod install
1616
With this library, unleash creativity by generating captivating audio waveforms from your audio tracks, providing an engaging visual representation of sound.
1717

1818
<p float="left">
19-
<img src="images/image.png" width="400" alt="android"/>
19+
<img src="images/image.png" width="300" alt="example"/>
2020
</p>
2121

2222
## Features ✨
@@ -32,133 +32,7 @@ With this library, unleash creativity by generating captivating audio waveforms
3232

3333
## Usage 🎶
3434

35-
```js
36-
import React, { useCallback, useState } from 'react';
37-
38-
import {
39-
ActivityIndicator,
40-
Alert,
41-
Button,
42-
ScrollView,
43-
StyleSheet,
44-
Text,
45-
View,
46-
} from 'react-native';
47-
import {
48-
analyzeAudio,
49-
scale,
50-
sample,
51-
robustScale,
52-
trimmedScale,
53-
} from 'react-native-audio-analyzer';
54-
import type { AmplitudeData } from 'react-native-audio-analyzer';
55-
import ReactNativeBlobUtil from 'react-native-blob-util';
56-
57-
export default function App() {
58-
const [result, setResult] = useState<AmplitudeData[]>([]);
59-
const [isLoading, setIsLoading] = useState(false);
60-
61-
const start = useCallback(async () => {
62-
try {
63-
setIsLoading(true);
64-
const response = await ReactNativeBlobUtil.config({
65-
fileCache: true,
66-
}).fetch(
67-
'GET',
68-
'https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp3',
69-
{}
70-
);
71-
const path = response.path();
72-
const data = await analyzeAudio(path, 2);
73-
setResult(data);
74-
} catch (error) {
75-
Alert.alert('Error', String(error));
76-
} finally {
77-
setIsLoading(false);
78-
}
79-
}, []);
80-
81-
const amplitudes = result.map((_) => _.amplitude);
82-
83-
const results = [
84-
{
85-
title: 'Trimmed scale:',
86-
data: trimmedScale(amplitudes).map((value, index) => (
87-
<View key={index} style={[styles.item, { height: value * 100 }]} />
88-
)),
89-
},
90-
{
91-
title: 'Robust scale:',
92-
data: robustScale(amplitudes).map((value, index) => (
93-
<View key={index} style={[styles.item, { height: value * 100 }]} />
94-
)),
95-
},
96-
{
97-
title: 'Scale + sample:',
98-
data: scale(sample(amplitudes, 35)).map((value, index) => (
99-
<View key={index} style={[styles.item, { height: value * 100 }]} />
100-
)),
101-
},
102-
{
103-
title: 'Scale:',
104-
data: scale(amplitudes).map((value, index) => (
105-
<View key={index} style={[styles.item, { height: value * 100 }]} />
106-
)),
107-
},
108-
];
109-
110-
return (
111-
<View style={styles.container}>
112-
<Button title="Start" onPress={start} />
113-
{isLoading ? (
114-
<ActivityIndicator style={styles.loader} size="large" />
115-
) : (
116-
<View>
117-
{results.map((_, index) => (
118-
<View style={styles.example} key={index}>
119-
<Text style={styles.title}>{_.title}</Text>
120-
<ScrollView horizontal style={styles.scroll}>
121-
<View style={styles.row}>{_.data}</View>
122-
</ScrollView>
123-
</View>
124-
))}
125-
</View>
126-
)}
127-
</View>
128-
);
129-
}
130-
131-
const styles = StyleSheet.create({
132-
container: {
133-
flex: 1,
134-
justifyContent: 'center',
135-
backgroundColor: '#ffffff',
136-
},
137-
loader: {
138-
padding: 30,
139-
},
140-
row: {
141-
flexDirection: 'row',
142-
alignItems: 'center',
143-
},
144-
title: {
145-
marginBottom: 5,
146-
},
147-
example: {
148-
padding: 10,
149-
},
150-
scroll: {
151-
maxHeight: 200,
152-
},
153-
item: {
154-
width: 3,
155-
backgroundColor: 'blue',
156-
marginHorizontal: 2,
157-
},
158-
});
159-
160-
161-
```
35+
Usage example you can [find here](example/src/App.tsx)
16236

16337
## Contributing 🤝
16438
We welcome [contributions](CONTRIBUTING.md)! Learn more about how to contribute to this repository by checking out our contributing guide and development workflow.

0 commit comments

Comments
 (0)