History

python/demos/demo_pysoundcard_*: update to pysoundcard 0.5.2 (closes #42)

Paul Brossier committed 10 years ago

Commit 6d8db801 parent 0e39e882 files · +14 −9Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/demos/demo_pysoundcard_play.py +1 −1
  2. python/demos/demo_pysoundcard_record.py +13 −8
python/demos/demo_pysoundcard_play.py+1−1
@@ -10,7 +10,7 @@ def play_source(source_path): · 9 unmodified lines
10 f = source(source_path, hop_size = hop_size)10 f = source(source_path, hop_size = hop_size)
11 samplerate = f.samplerate11 samplerate = f.samplerate
12 12
13 s = Stream(sample_rate = samplerate, block_length = hop_size)13 s = Stream(samplerate = samplerate, blocksize = hop_size)
14 s.start()14 s.start()
15 read = 015 read = 0
16 while 1:16 while 1:
python/demos/demo_pysoundcard_record.py+13−8
@@ -8,17 +8,22 @@ def record_sink(sink_path): · 7 unmodified lines
8 8
9 hop_size = 2569 hop_size = 256
10 duration = 5 # in seconds10 duration = 5 # in seconds
11 s = Stream(block_length = hop_size)11 s = Stream(blocksize = hop_size, channels = 1)
12 g = sink(sink_path, samplerate = s.sample_rate)12 g = sink(sink_path, samplerate = int(s.samplerate))
13 print s.channels
13 14
14 s.start()15 s.start()
15 total_frames = 016 total_frames = 0
16 while total_frames < duration * s.sample_rate:17 try:
17 vec = s.read(hop_size)18 while total_frames < duration * s.samplerate:
18 # mix down to mono19 vec = s.read(hop_size)
19 mono_vec = vec.sum(-1) / float(s.input_channels)20 # mix down to mono
20 g(mono_vec, hop_size)21 mono_vec = vec.sum(-1) / float(s.channels[0])
21 total_frames += hop_size22 g(mono_vec, hop_size)
23 total_frames += hop_size
24 except KeyboardInterrupt, e:
25 print "stopped after", "%.2f seconds" % (total_frames / s.samplerate)
26 pass
22 s.stop()27 s.stop()
23 28
24if __name__ == '__main__':29if __name__ == '__main__':

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