History

python/demos/demo_pyaudio.py: add some comments, avoid overwriting aubio.pitch

Paul Brossier committed 9 years ago

Commit 62336bb1 parent e7da8ba1 file · +12 −3Browse files

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

Unified · Split

python/demos/demo_pyaudio.py+12−3
@@ -1,9 +1,18 @@
11 #! /usr/bin/env python
22
3+# Use pyaudio to open the microphone and run aubio.pitch on the stream of
4+# incoming samples. If a filename is given as the first argument, it will
5+# record 5 seconds of audio to this location. Otherwise, the script will
6+# run until Ctrl+C is pressed.
7+
8+# Examples:
9+# $ ./python/demos/demo_pyaudio.py
10+# $ ./python/demos/demo_pyaudio.py /tmp/recording.wav
11+
312 import pyaudio
413 import sys
514 import numpy as np
6−from aubio import pitch, sink
15+import aubio
716
817 # initialise pyaudio
918 p = pyaudio.PyAudio()
@@ -23,7 +32,7 @@ if len(sys.argv) > 1: · 13 unmodified lines
2332 # record 5 seconds
2433 output_filename = sys.argv[1]
2534 record_duration = 5 # exit 1
26− outputsink = sink(sys.argv[1], samplerate)
35+ outputsink = aubio.sink(sys.argv[1], samplerate)
2736 total_frames = 0
2837 else:
2938 # run forever
@@ -34,7 +43,7 @@ else: · 4 unmodified lines
3443 tolerance = 0.8
3544 win_s = 4096 # fft size
3645 hop_s = buffer_size # hop size
37−pitch_o = pitch("default", win_s, hop_s, samplerate)
46+pitch_o = aubio.pitch("default", win_s, hop_s, samplerate)
3847 pitch_o.set_unit("midi")
3948 pitch_o.set_tolerance(tolerance)
4049

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