Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -1,9 +1,18 @@ | ||
| 1 | 1 | #! /usr/bin/env python |
| 2 | 2 | |
| 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 | + | |
| 3 | 12 | import pyaudio |
| 4 | 13 | import sys |
| 5 | 14 | import numpy as np |
| 6 | −from aubio import pitch, sink | |
| 15 | +import aubio | |
| 7 | 16 | |
| 8 | 17 | # initialise pyaudio |
| 9 | 18 | p = pyaudio.PyAudio() |
| @@ -23,7 +32,7 @@ if len(sys.argv) > 1: · 13 unmodified lines | ||
| 23 | 32 | # record 5 seconds |
| 24 | 33 | output_filename = sys.argv[1] |
| 25 | 34 | record_duration = 5 # exit 1 |
| 26 | − outputsink = sink(sys.argv[1], samplerate) | |
| 35 | + outputsink = aubio.sink(sys.argv[1], samplerate) | |
| 27 | 36 | total_frames = 0 |
| 28 | 37 | else: |
| 29 | 38 | # run forever |
| @@ -34,7 +43,7 @@ else: · 4 unmodified lines | ||
| 34 | 43 | tolerance = 0.8 |
| 35 | 44 | win_s = 4096 # fft size |
| 36 | 45 | 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) | |
| 38 | 47 | pitch_o.set_unit("midi") |
| 39 | 48 | pitch_o.set_tolerance(tolerance) |
| 40 | 49 | |