History

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

Paul Brossier committed 12 years ago

Commit 40133821 parent c1f0c1d1 file · +24 −0Browse files

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

Unified · Split

python/demos/demo_pysoundcard_play.py+24−0
@@ -0,0 +1,24 @@
1+#! /usr/bin/env python
2+
3+def play_source(source_path):
4+ """Play an audio file using pysoundcard."""
5+
6+ from aubio import source
7+ from pysoundcard import Stream
8+
9+ hop_size = 256
10+ f = source(source_path, hop_size = hop_size)
11+ samplerate = f.samplerate
12+
13+ s = Stream(sample_rate = samplerate, block_length = hop_size)
14+ s.start()
15+ read = 0
16+ while 1:
17+ vec, read = f()
18+ s.write(vec)
19+ if read < hop_size: break
20+ s.stop()
21+
22+if __name__ == '__main__':
23+ import sys
24+ play_source(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