Desirable goals » History » Version 1
Chris Cannam, 2015-01-12 12:14 PM
1 | 1 | Chris Cannam | h1. Desirable goals |
---|---|---|---|
2 | 1 | Chris Cannam | |
3 | 1 | Chris Cannam | Dan writes: |
4 | 1 | Chris Cannam | |
5 | 1 | Chris Cannam | _Well just from my point of view, and not having thought through all the flexible types of output that vamp provides, I'd be hoping to type things like:_ |
6 | 1 | Chris Cannam | |
7 | 1 | Chris Cannam | <pre> |
8 | 1 | Chris Cannam | # all in-memory: |
9 | 1 | Chris Cannam | |
10 | 1 | Chris Cannam | plug = vh.loadPlugin('vamp-example-plugins:mfcc', 44100) |
11 | 1 | Chris Cannam | mfccs = np.array([features[0] for features in plug.processall([-0.1, 0, 0.1, 0, -0.1, 0, 0.1, 0])]) # this gives a 2D numpy array of shape [nframes, nmfccs] |
12 | 1 | Chris Cannam | |
13 | 1 | Chris Cannam | plug = vh.loadPlugin('vamp-example-plugins:onsetdetector', 44100) |
14 | 1 | Chris Cannam | onsets = np.array([features[0] for features in plug.processall([-0.1, 0, 0.1, 0, -0.1, 0, 0.1, 0])]) # this gives a 1D numpy array, a list of onset times I guess |
15 | 1 | Chris Cannam | |
16 | 1 | Chris Cannam | |
17 | 1 | Chris Cannam | # from disk, to memory: |
18 | 1 | Chris Cannam | |
19 | 1 | Chris Cannam | plug = vh.loadPlugin('vamp-example-plugins:mfcc', 44100) |
20 | 1 | Chris Cannam | with open(filepath) as f: |
21 | 1 | Chris Cannam | mfccs = np.array([features[0] for features in plug.processall(f)]) |
22 | 1 | Chris Cannam | plt.matshow(mfccs, interpolate='nearest') # a simple pyplot |
23 | 1 | Chris Cannam | |
24 | 1 | Chris Cannam | |
25 | 1 | Chris Cannam | # fully streaming: |
26 | 1 | Chris Cannam | |
27 | 1 | Chris Cannam | plug = vh.loadPlugin('vamp-example-plugins:mfcc', 44100) |
28 | 1 | Chris Cannam | with open(filepath) as f: |
29 | 1 | Chris Cannam | with open(outpath, 'wb') as outf: |
30 | 1 | Chris Cannam | for features in plug.processall(f): |
31 | 1 | Chris Cannam | outpath.write("%g\n" % features[0][0] ** 2) |
32 | 1 | Chris Cannam | </pre> |
33 | 1 | Chris Cannam | |
34 | 1 | Chris Cannam | _BTW I noticed I made a couple of mistakes in there_ |