feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change
on this file since 65628c4 was
c470ad0,
checked in by Paul Brossier <piem@piem.org>, 8 years ago
|
python/demos/demo_notes.py: add simple notes demos
|
-
Property mode set to
100755
|
File size:
877 bytes
|
Line | |
---|
1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | import sys |
---|
4 | from aubio import source, notes |
---|
5 | |
---|
6 | if len(sys.argv) < 2: |
---|
7 | print("Usage: %s <filename> [samplerate]" % sys.argv[0]) |
---|
8 | sys.exit(1) |
---|
9 | |
---|
10 | filename = sys.argv[1] |
---|
11 | |
---|
12 | downsample = 1 |
---|
13 | samplerate = 44100 // downsample |
---|
14 | if len( sys.argv ) > 2: samplerate = int(sys.argv[2]) |
---|
15 | |
---|
16 | win_s = 512 // downsample # fft size |
---|
17 | hop_s = 256 // downsample # hop size |
---|
18 | |
---|
19 | s = source(filename, samplerate, hop_s) |
---|
20 | samplerate = s.samplerate |
---|
21 | |
---|
22 | tolerance = 0.8 |
---|
23 | |
---|
24 | notes_o = notes("default", win_s, hop_s, samplerate) |
---|
25 | |
---|
26 | print("%8s" % "time","[ start","vel","last ]") |
---|
27 | |
---|
28 | # total number of frames read |
---|
29 | total_frames = 0 |
---|
30 | while True: |
---|
31 | samples, read = s() |
---|
32 | new_note = notes_o(samples) |
---|
33 | if (new_note[0] != 0): |
---|
34 | note_str = ' '.join(["%.2f" % i for i in new_note]) |
---|
35 | print("%.6f" % (total_frames/float(samplerate)), new_note) |
---|
36 | total_frames += read |
---|
37 | if read < hop_s: break |
---|
Note: See
TracBrowser
for help on using the repository browser.