You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
-
# rcaudio : A Realtime Audio Recording & Analyze Script
2
-
1
+
# rcaudio : A Realtime Audio Recording & Analyzing Library
3
2
4
3
## Introduction
5
4
@@ -11,7 +10,12 @@ It supports real-time analysis of :
11
10
* Volume
12
11
* Beat Information
13
12
14
-
For chinese documentation : [中文文档](http://mhy12345.xyz/technology/python-beat-detection/)
13
+
For chinese documentation : [中文文档](http://mhy12345.xyz/technology/rcaudio-documentation/)
14
+
## Installation
15
+
16
+
```bash
17
+
pip install rcaudio
18
+
```
15
19
16
20
## Usage
17
21
@@ -46,6 +50,9 @@ All class extended from `BaseAnalyzer` can be registered into `SimpleRecorder`.
46
50
47
51
48
52
```python
53
+
import time
54
+
from rcaudio import SimpleRecorder,VolumeAnalyzer
55
+
49
56
SR= SimpleRecorder()
50
57
VA= VolumeAnalyzer(rec_time=1)
51
58
SR.register(VA)
@@ -66,3 +73,21 @@ while True:
66
73
print(BA.block_until_next_beat())
67
74
```
68
75
76
+
A FeatureAnalyzer can use to generate all user defined acoustic features. Just override the `data_process` function. (Current function are the calculation of the *Zero Crossing Rate*.
77
+
78
+
```python
79
+
SR= SimpleRecorder(sr=1000)
80
+
FA= FeatureAnalyzer(refresh_time=1)
81
+
SR.register(FA)
82
+
SR.start()
83
+
cpos =0
84
+
whileTrue:
85
+
iflen(FA.result) > cpos:
86
+
print(FA.result[cpos])
87
+
cpos +=1
88
+
time.sleep(.01)
89
+
```
90
+
91
+
## Some note
92
+
93
+
Most function has the time delay about 1-2 seconds. I did lot effort to let the BeatAnalyzer looked as it is real-time. However, for the `FeatureAnalyzer`, if the feature extraction function are too slow compare to the microphone recording, the dalay may become huge. Decrease the sample rates would be a solution, but better solution would be DIY a analyzer yourself.
rcaudiois a realtime audio recording script, it provide easy way to record via microphone and then analyze.
14
+
**rcaudio** Rcaudio is a real-time audio analysis library that allows you to simply record audio through a microphone and analyze.
14
15
15
-
rcaudio provide APIs to get:
16
+
It supports real-time analysis of :
16
17
17
18
* The raw audio data
18
19
* Volume
19
20
* Beat Information
20
21
22
+
For chinese documentation : [中文文档](http://mhy12345.xyz/technology/python-beat-detection/)
23
+
24
+
## Usage
25
+
26
+
### CoreRecorder
27
+
28
+
`CoreRecorder` is used to fetch raw data. When started, the audio data will be stored in the `CoreRecorder.buffer`.
29
+
30
+
```python
31
+
from rcaudio import CoreRecorder
32
+
CR = CoreRecorder(
33
+
time = 10, #How much time to record
34
+
sr = 1000 #sample rate
35
+
)
36
+
CR.start()
37
+
while True:
38
+
if not CR.buffer.empty():
39
+
x = CR.buffer.get()
40
+
print('*'*int(abs(x)))
41
+
```
42
+
43
+
### SimpleRecorder
44
+
45
+
In most cases, we use `SimpleRecorder`. For efficiency consideration, the `SimpleRecorder` should only be instantiated once.
46
+
47
+
This class can register several `Analyzer`.
48
+
49
+
When the function `start()` called, It will begin to record through microphone, and refresh the status of all the `Analyzer`
50
+
51
+
### Analyzers
52
+
53
+
All class extended from `BaseAnalyzer` can be registered into `SimpleRecorder`. For example `VolumeAnalyzer` can get the current volume of the microphone.
54
+
55
+
56
+
```python
57
+
SR = SimpleRecorder()
58
+
VA = VolumeAnalyzer(rec_time = 1)
59
+
SR.register(VA)
60
+
SR.start()
61
+
while True:
62
+
print("VOLUME : ",VA.get_volume())
63
+
time.sleep(1)
64
+
```
65
+
66
+
And beat analyzer can predict the beats from the music. (However, there will be some delay.)
0 commit comments