Daniel@0: # Part of DML (Digital Music Laboratory) Daniel@0: # Daniel@0: # This program is free software; you can redistribute it and/or Daniel@0: # modify it under the terms of the GNU General Public License Daniel@0: # as published by the Free Software Foundation; either version 2 Daniel@0: # of the License, or (at your option) any later version. Daniel@0: # Daniel@0: # This program is distributed in the hope that it will be useful, Daniel@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Daniel@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Daniel@0: # GNU General Public License for more details. Daniel@0: # Daniel@0: # You should have received a copy of the GNU General Public Daniel@0: # License along with this library; if not, write to the Free Software Daniel@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Daniel@0: Daniel@0: #!/usr/bin/python Daniel@0: # -*- coding: utf-8 -*- Daniel@0: """ Daniel@0: Created on Fri Oct 11 13:22:37 2013 Daniel@0: Daniel@0: @author: thomas Daniel@0: """ Daniel@0: Daniel@0: from __future__ import division Daniel@0: Daniel@0: import matplotlib.pyplot as plt Daniel@0: import numpy as np Daniel@0: import sys Daniel@0: import os Daniel@0: Daniel@0: # NOTE: this is only for debugging purposes, we can Daniel@0: # now use a regular timeside and sonic annotator installation, Daniel@0: #sudo ln -s ../../sonic_annotator/sonic-annotator-0.7-linux-amd64/sonic-annotator /usr/sbin/ Daniel@0: #sys.path.append(os.getcwd() + '../../sonic_annotator/sonic-annotator-0.7-linux-amd64/') Daniel@0: Daniel@0: import timeside Daniel@0: from timeside.analyzer.core import AnalyzerResult, AnalyzerResultContainer Daniel@0: from timeside import __version__ Daniel@0: from vamp_plugin_dml import * Daniel@0: Daniel@0: def transform(wav_file = 'sweep.wav'): Daniel@0: Daniel@0: Daniel@0: # normal Daniel@0: d = timeside.decoder.file.FileDecoder(wav_file) Daniel@0: Daniel@0: # Get available Vamp plugins list Daniel@0: from timeside.analyzer.vamp_plugin import VampSimpleHost Daniel@0: plugins_list = VampSimpleHostDML.get_plugins_list() Daniel@0: Daniel@0: # Display avalaible plugins Daniel@0: print 'index \t soname \t \t identifier \t output ' Daniel@0: print '------ \t \t ---------- \t ------ ' Daniel@0: for index, line in zip(xrange(len(plugins_list)),plugins_list): Daniel@0: print '%d : %s \t %s \t %s' % (index,line[0],line[1],line[2]) Daniel@0: Daniel@0: # Let's choose #7 Daniel@0: my_plugin = plugins_list[0]#11 Daniel@0: print my_plugin Daniel@0: Daniel@0: # Daniel@0: # Vamp plugin Analyzer Daniel@0: #vamp = timeside.analyzer.vamp_plugin.VampSimpleHostDML([my_plugin]) Daniel@0: vamp = VampSimpleHostDML([my_plugin]) Daniel@0: #vamp = timeside.analyzer.VampSimpleHostDML() Daniel@0: Daniel@0: myPipe = (d | vamp ).run() Daniel@0: Daniel@0: # Get the vamp plugin result and plot it Daniel@0: for key in vamp.results.keys(): Daniel@0: print vamp.results[key].data Daniel@0: res_vamp = vamp.results[key] Daniel@0: Daniel@0: Daniel@0: # test storage as HDF5 Daniel@0: #vamp.results.to_hdf5(wav_file + '.h5') Daniel@0: #res_hdf5 = vamp.results.from_hdf5(wav_file + '.h5') Daniel@0: #print '%15s' % 'from hdf5:', Daniel@0: #print res_hdf5 Daniel@0: Daniel@0: return res_vamp Daniel@0: Daniel@0: # res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction'] Daniel@0: Daniel@0: if __name__ == "__main__": Daniel@0: if len(sys.argv) >= 2: Daniel@0: transform(sys.argv[1]) Daniel@0: else: Daniel@0: transform() Daniel@0: