feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 3a67894 was
5d5d6b9,
checked in by Paul Brossier <piem@piem.org>, 12 years ago
|
python/demos: add demo_pitch.py and demo_waveform_plot.py
|
-
Property mode set to
100755
|
File size:
743 bytes
|
Line | |
---|
1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | import sys |
---|
4 | from aubio import source, pitch |
---|
5 | |
---|
6 | win_s = 1024 # fft size |
---|
7 | hop_s = win_s # hop size |
---|
8 | |
---|
9 | if len(sys.argv) < 2: |
---|
10 | print "Usage: %s <filename> [samplerate]" % sys.argv[0] |
---|
11 | sys.exit(1) |
---|
12 | |
---|
13 | filename = sys.argv[1] |
---|
14 | |
---|
15 | samplerate = 0 |
---|
16 | if len( sys.argv ) > 2: samplerate = int(sys.argv[2]) |
---|
17 | |
---|
18 | s = source(filename, samplerate, hop_s) |
---|
19 | samplerate = s.samplerate |
---|
20 | |
---|
21 | pitch_o = pitch("default", win_s, hop_s, samplerate) |
---|
22 | pitch_o.set_unit("midi") |
---|
23 | |
---|
24 | pitches = [] |
---|
25 | |
---|
26 | |
---|
27 | # total number of frames read |
---|
28 | total_frames = 0 |
---|
29 | while True: |
---|
30 | samples, read = s() |
---|
31 | pitch = pitch_o(samples)[0] |
---|
32 | print "%f %f" % (total_frames / float(samplerate), pitch) |
---|
33 | #pitches += [pitches] |
---|
34 | total_frames += read |
---|
35 | if read < hop_s: break |
---|
36 | |
---|
37 | #print pitches |
---|
Note: See
TracBrowser
for help on using the repository browser.