-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdemo.py
70 lines (60 loc) · 1.57 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from rcaudio import *
import time
import logging
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
def demo1():
CR = CoreRecorder(
time = 10,
sr = 1000,
batch_num = 100,
frames_per_buffer = 100,
)
CR.start()
while True:
if not CR.buffer.empty():
x = CR.buffer.get()
print('*'*int(abs(x)))
def demo2():
SR = SimpleRecorder()
VA = VolumeAnalyzer(rec_time = 1)
SR.register(VA)
SR.start()
while True:
print("VOLUME : ",VA.get_volume())
time.sleep(1)
def demo3():
SR = SimpleRecorder(sr = 20000)
BA = BeatAnalyzer(rec_time = 15, initial_bpm = 120, smooth_ratio = .8)
SR.register(BA)
SR.start()
while True:
print(BA.block_until_next_beat())
def demo4():
SR = SimpleRecorder(sr = 20000)
BA = BeatAnalyzer(rec_time = 15, initial_bpm = 120, smooth_ratio = .8)
VA = VolumeAnalyzer(rec_time = 1)
SR.register(BA)
SR.register(VA)
SR.start()
low_volume_count = 0
while True:
v = VA.get_volume()
if v < 50:
low_volume_count += 1
if low_volume_count > 4:
break
SR.stop()
SR.join()
def demo5():
SR = SimpleRecorder(sr = 1000)
FA = FeatureAnalyzer(refresh_time = 1)
SR.register(FA)
SR.start()
cpos = 0
while True:
if len(FA.result) > cpos:
print("Zero Crossing Rate : ",FA.result[cpos])
cpos += 1
time.sleep(.01)
demo2()