annotate pyspark/timeside_vamp.py @ 0:e34cf1b6fe09 tip

commit
author Daniel Wolff
date Sat, 20 Feb 2016 18:14:24 +0100
parents
children
rev   line source
Daniel@0 1 # Part of DML (Digital Music Laboratory)
Daniel@0 2 #
Daniel@0 3 # This program is free software; you can redistribute it and/or
Daniel@0 4 # modify it under the terms of the GNU General Public License
Daniel@0 5 # as published by the Free Software Foundation; either version 2
Daniel@0 6 # of the License, or (at your option) any later version.
Daniel@0 7 #
Daniel@0 8 # This program is distributed in the hope that it will be useful,
Daniel@0 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Daniel@0 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Daniel@0 11 # GNU General Public License for more details.
Daniel@0 12 #
Daniel@0 13 # You should have received a copy of the GNU General Public
Daniel@0 14 # License along with this library; if not, write to the Free Software
Daniel@0 15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Daniel@0 16
Daniel@0 17 #!/usr/bin/python
Daniel@0 18 # -*- coding: utf-8 -*-
Daniel@0 19 """
Daniel@0 20 Created on Fri Oct 11 13:22:37 2013
Daniel@0 21
Daniel@0 22 @author: thomas
Daniel@0 23 """
Daniel@0 24
Daniel@0 25 from __future__ import division
Daniel@0 26
Daniel@0 27 import matplotlib.pyplot as plt
Daniel@0 28 import numpy as np
Daniel@0 29 import sys
Daniel@0 30 import os
Daniel@0 31
Daniel@0 32 # NOTE: this is only for debugging purposes, we can
Daniel@0 33 # now use a regular timeside and sonic annotator installation,
Daniel@0 34 #sudo ln -s ../../sonic_annotator/sonic-annotator-0.7-linux-amd64/sonic-annotator /usr/sbin/
Daniel@0 35 #sys.path.append(os.getcwd() + '../../sonic_annotator/sonic-annotator-0.7-linux-amd64/')
Daniel@0 36
Daniel@0 37 import timeside
Daniel@0 38 from timeside.analyzer.core import AnalyzerResult, AnalyzerResultContainer
Daniel@0 39 from timeside import __version__
Daniel@0 40 from vamp_plugin_dml import *
Daniel@0 41
Daniel@0 42 def transform(wav_file = 'sweep.wav'):
Daniel@0 43
Daniel@0 44
Daniel@0 45 # normal
Daniel@0 46 d = timeside.decoder.file.FileDecoder(wav_file)
Daniel@0 47
Daniel@0 48 # Get available Vamp plugins list
Daniel@0 49 from timeside.analyzer.vamp_plugin import VampSimpleHost
Daniel@0 50 plugins_list = VampSimpleHostDML.get_plugins_list()
Daniel@0 51
Daniel@0 52 # Display avalaible plugins
Daniel@0 53 print 'index \t soname \t \t identifier \t output '
Daniel@0 54 print '------ \t \t ---------- \t ------ '
Daniel@0 55 for index, line in zip(xrange(len(plugins_list)),plugins_list):
Daniel@0 56 print '%d : %s \t %s \t %s' % (index,line[0],line[1],line[2])
Daniel@0 57
Daniel@0 58 # Let's choose #7
Daniel@0 59 my_plugin = plugins_list[0]#11
Daniel@0 60 print my_plugin
Daniel@0 61
Daniel@0 62 #
Daniel@0 63 # Vamp plugin Analyzer
Daniel@0 64 #vamp = timeside.analyzer.vamp_plugin.VampSimpleHostDML([my_plugin])
Daniel@0 65 vamp = VampSimpleHostDML([my_plugin])
Daniel@0 66 #vamp = timeside.analyzer.VampSimpleHostDML()
Daniel@0 67
Daniel@0 68 myPipe = (d | vamp ).run()
Daniel@0 69
Daniel@0 70 # Get the vamp plugin result and plot it
Daniel@0 71 for key in vamp.results.keys():
Daniel@0 72 print vamp.results[key].data
Daniel@0 73 res_vamp = vamp.results[key]
Daniel@0 74
Daniel@0 75
Daniel@0 76 # test storage as HDF5
Daniel@0 77 #vamp.results.to_hdf5(wav_file + '.h5')
Daniel@0 78 #res_hdf5 = vamp.results.from_hdf5(wav_file + '.h5')
Daniel@0 79 #print '%15s' % 'from hdf5:',
Daniel@0 80 #print res_hdf5
Daniel@0 81
Daniel@0 82 return res_vamp
Daniel@0 83
Daniel@0 84 # res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction']
Daniel@0 85
Daniel@0 86 if __name__ == "__main__":
Daniel@0 87 if len(sys.argv) >= 2:
Daniel@0 88 transform(sys.argv[1])
Daniel@0 89 else:
Daniel@0 90 transform()
Daniel@0 91