History

python/demos/demo_pysoundcard_record.py: added simple example using pysoundcard

Paul Brossier committed 12 years ago

Commit 97d77da1 parent 40133821 file · +26 −0Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_pysoundcard_record.py+26−0
@@ -0,0 +1,26 @@
1+#! /usr/bin/env python
2+
3+def record_sink(sink_path):
4+ """Record an audio file using pysoundcard."""
5+
6+ from aubio import sink
7+ from pysoundcard import Stream
8+
9+ hop_size = 256
10+ duration = 5 # in seconds
11+ s = Stream(block_length = hop_size)
12+ g = sink(sink_path, samplerate = s.sample_rate)
13+
14+ s.start()
15+ total_frames = 0
16+ while total_frames < duration * s.sample_rate:
17+ vec = s.read(hop_size)
18+ # mix down to mono
19+ mono_vec = vec.sum(-1)
20+ g(mono_vec, hop_size)
21+ total_frames += hop_size
22+ s.stop()
23+
24+if __name__ == '__main__':
25+ import sys
26+ record_sink(sys.argv[1])

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t