# HG changeset patch # User Chris Cannam # Date 1486640064 0 # Node ID 5d4727387c9363102139a3872809ccb92e1d98f1 # Parent e2f8dc4a76221785499c2fb0d2025c1c3341529c Some test scripts and doc files diff -r e2f8dc4a7622 -r 5d4727387c93 COPYING --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/COPYING Thu Feb 09 11:34:24 2017 +0000 @@ -0,0 +1,29 @@ + + Piper + Copyright (c) 2015-2017 Queen Mary, University of London + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. + diff -r e2f8dc4a7622 -r 5d4727387c93 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Thu Feb 09 11:34:24 2017 +0000 @@ -0,0 +1,26 @@ + +# Piper Vamp Javascript and JSON Adapter + +Compile your C++ Vamp plugin code into a Javascript module that +exports the Piper JSON protocol, for use with Javascript code that +uses Piper audio feature extractors. + +## What this repository contains + + * Adapter code to make a Vamp plugin library into a module that + exports request-handling functions for the Piper protocol's JSON + serialisation. This code is in C++ and can be compiled to a native + shared library or to Javascript with Emscripten. + + * Examples of usage with Vamp plugin code, found in the + examples/vamp-example-plugins and examples/vamp-test-plugin + directories. + +## Authors and licensing + +Written by Chris Cannam and Lucas Thompson at the Centre for Digital +Music, Queen Mary, University of London. + +Copyright (c) 2015-2017 Queen Mary, University of London, provided +under a BSD-style licence. See the file COPYING for details. + diff -r e2f8dc4a7622 -r 5d4727387c93 test/expected.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/expected.txt Thu Feb 09 11:34:24 2017 +0000 @@ -0,0 +1,6 @@ +{"jsonrpc": "2.0", "method": "list", "result": {"available": [{"basic": {"description": "Track the amplitude of the audio signal", "identifier": "amplitudefollower", "name": "Amplitude Follower"}, "basicOutputInfo": [{"description": "The peak tracked amplitude for the current processing block", "identifier": "amplitude", "name": "Amplitude"}], "category": [], "copyright": "Code copyright 2006 Dan Stowell; method from SuperCollider. Freely redistributable (BSD license)", "inputDomain": "TimeDomain", "key": "vamp-example-plugins:amplitudefollower", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [{"basic": {"description": "The 60dB convergence time for an increase in amplitude", "identifier": "attack", "name": "Attack time"}, "defaultValue": 0.0099999997764825821, "extents": {"max": 1, "min": 0}, "unit": "s", "valueNames": []}, {"basic": {"description": "The 60dB convergence time for a decrease in amplitude", "identifier": "release", "name": "Release time"}, "defaultValue": 0.0099999997764825821, "extents": {"max": 1, "min": 0}, "unit": "s", "valueNames": []}], "programs": [], "version": 1}, {"basic": {"description": "Study a short section of audio and estimate its tempo, assuming the tempo is constant", "identifier": "fixedtempo", "name": "Simple Fixed Tempo Estimator"}, "basicOutputInfo": [{"description": "Estimated tempo", "identifier": "tempo", "name": "Tempo"}, {"description": "Possible tempo estimates, one per bin with the most likely in the first bin", "identifier": "candidates", "name": "Tempo candidates"}, {"description": "Onset detection function", "identifier": "detectionfunction", "name": "Detection Function"}, {"description": "Autocorrelation of onset detection function", "identifier": "acf", "name": "Autocorrelation Function"}, {"description": "Filtered autocorrelation of onset detection function", "identifier": "filtered_acf", "name": "Filtered Autocorrelation"}], "category": [], "copyright": "Code copyright 2008 Queen Mary, University of London. Freely redistributable (BSD license)", "inputDomain": "FrequencyDomain", "key": "vamp-example-plugins:fixedtempo", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [{"basic": {"description": "Minimum beat-per-minute value which the tempo estimator is able to return", "identifier": "minbpm", "name": "Minimum estimated tempo"}, "defaultValue": 50, "extents": {"max": 360, "min": 10}, "unit": "bpm", "valueNames": []}, {"basic": {"description": "Maximum beat-per-minute value which the tempo estimator is able to return", "identifier": "maxbpm", "name": "Maximum estimated tempo"}, "defaultValue": 190, "extents": {"max": 360, "min": 10}, "unit": "bpm", "valueNames": []}, {"basic": {"description": "Length of audio input, in seconds, which should be taken into account when estimating tempo. There is no need to supply the plugin with any further input once this time has elapsed since the start of the audio. The tempo estimator may use only the first part of this, up to eight times the slowest beat duration: increasing this value further than that is unlikely to improve results.", "identifier": "maxdflen", "name": "Input duration to study"}, "defaultValue": 10, "extents": {"max": 40, "min": 2}, "unit": "s", "valueNames": []}], "programs": [], "version": 1}, {"basic": {"description": "Detect percussive note onsets by identifying broadband energy rises", "identifier": "percussiononsets", "name": "Simple Percussion Onset Detector"}, "basicOutputInfo": [{"description": "Percussive note onset locations", "identifier": "onsets", "name": "Onsets"}, {"description": "Broadband energy rise detection function", "identifier": "detectionfunction", "name": "Detection Function"}], "category": [], "copyright": "Code copyright 2006 Queen Mary, University of London, after Dan Barry et al 2005. Freely redistributable (BSD license)", "inputDomain": "FrequencyDomain", "key": "vamp-example-plugins:percussiononsets", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [{"basic": {"description": "Energy rise within a frequency bin necessary to count toward broadband total", "identifier": "threshold", "name": "Energy rise threshold"}, "defaultValue": 3, "extents": {"max": 20, "min": 0}, "unit": "dB", "valueNames": []}, {"basic": {"description": "Sensitivity of peak detector applied to broadband detection function", "identifier": "sensitivity", "name": "Sensitivity"}, "defaultValue": 40, "extents": {"max": 100, "min": 0}, "unit": "%", "valueNames": []}], "programs": [], "version": 2}, {"basic": {"description": "Return the power spectrum of a signal", "identifier": "powerspectrum", "name": "Simple Power Spectrum"}, "basicOutputInfo": [{"description": "Power values of the frequency spectrum bins calculated from the input signal", "identifier": "powerspectrum", "name": "Power Spectrum"}], "category": [], "copyright": "Freely redistributable (BSD license)", "inputDomain": "FrequencyDomain", "key": "vamp-example-plugins:powerspectrum", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [], "programs": [], "version": 1}, {"basic": {"description": "Calculate the centroid frequency of the spectrum of the input signal", "identifier": "spectralcentroid", "name": "Spectral Centroid"}, "basicOutputInfo": [{"description": "Centroid of the log weighted frequency spectrum", "identifier": "logcentroid", "name": "Log Frequency Centroid"}, {"description": "Centroid of the linear frequency spectrum", "identifier": "linearcentroid", "name": "Linear Frequency Centroid"}], "category": [], "copyright": "Freely redistributable (BSD license)", "inputDomain": "FrequencyDomain", "key": "vamp-example-plugins:spectralcentroid", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [], "programs": [], "version": 2}, {"basic": {"description": "Detect and count zero crossing points", "identifier": "zerocrossing", "name": "Zero Crossings"}, "basicOutputInfo": [{"description": "The number of zero crossing points per processing block", "identifier": "counts", "name": "Zero Crossing Counts"}, {"description": "The locations of zero crossing points", "identifier": "zerocrossings", "name": "Zero Crossings"}], "category": [], "copyright": "Freely redistributable (BSD license)", "inputDomain": "TimeDomain", "key": "vamp-example-plugins:zerocrossing", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [], "programs": [], "version": 2}]}} +{"jsonrpc": "2.0", "method": "load", "result": {"defaultConfiguration": {"channelCount": 1, "framing": {"blockSize": 1024, "stepSize": 512}, "parameterValues": {}}, "handle": 1, "staticData": {"basic": {"description": "Return the power spectrum of a signal", "identifier": "powerspectrum", "name": "Simple Power Spectrum"}, "basicOutputInfo": [{"description": "Power values of the frequency spectrum bins calculated from the input signal", "identifier": "powerspectrum", "name": "Power Spectrum"}], "category": [], "copyright": "Freely redistributable (BSD license)", "inputDomain": "TimeDomain", "key": "vamp-example-plugins:powerspectrum", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [], "programs": [], "version": 1}}} +{"jsonrpc": "2.0", "method": "configure", "result": {"framing": {"blockSize": 8, "stepSize": 8}, "handle": 1, "outputList": [{"basic": {"description": "Power values of the frequency spectrum bins calculated from the input signal", "identifier": "powerspectrum", "name": "Power Spectrum"}, "configured": {"binCount": 5, "binNames": [], "hasDuration": false, "sampleRate": 0, "sampleType": "OneSamplePerStep", "unit": ""}}]}} +{"id": 6, "jsonrpc": "2.0", "method": "process", "result": {"features": {"powerspectrum": [{"featureValues": [0, 1, 4, 1, 0]}]}, "handle": 1}} +{"jsonrpc": "2.0", "method": "process", "result": {"features": {"powerspectrum": [{"featureValues": "AAAAAAAAgD8AAIBAAACAPwAAAAA"}]}, "handle": 1}} +{"jsonrpc": "2.0", "method": "finish", "result": {"features": {}, "handle": 1}} diff -r e2f8dc4a7622 -r 5d4727387c93 test/quick-test.cpp --- a/test/quick-test.cpp Thu Feb 09 11:07:30 2017 +0000 +++ b/test/quick-test.cpp Thu Feb 09 11:34:24 2017 +0000 @@ -6,7 +6,7 @@ int main(int, char **) { - string example = "../examples/VampExamplePlugins.so"; + string example = "../examples/vamp-example-plugins/VampExamplePlugins.so"; void *lib = dlopen(example.c_str(), RTLD_LAZY | RTLD_LOCAL); if (!lib) { @@ -40,7 +40,7 @@ cout << loadResponse << endl; freeFn(loadResponse); - string configRequest = "{\"method\":\"configure\",\"params\":{\"handle\":1,\"configuration\":{\"blockSize\":8,\"channelCount\":1,\"stepSize\":8}}}"; + string configRequest = "{\"method\":\"configure\",\"params\":{\"handle\":1,\"configuration\":{\"framing\":{\"blockSize\":8,\"stepSize\": 8},\"channelCount\":1}}}"; const char *configResponse = reqFn(configRequest.c_str()); cout << configResponse << endl; freeFn(configResponse); @@ -59,5 +59,7 @@ const char *finishResponse = reqFn(finishRequest.c_str()); cout << finishResponse << endl; freeFn(finishResponse); + + return 0; } diff -r e2f8dc4a7622 -r 5d4727387c93 test/test.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test.sh Thu Feb 09 11:34:24 2017 +0000 @@ -0,0 +1,35 @@ +#!/bin/bash + +set -eu + +mydir="$(dirname $0)" + +cd "$mydir" + +echo +echo "Running C++ test..." +echo + +( cd ../examples/vamp-example-plugins && make clean linux ) + +make quick-test + +./quick-test > /tmp/$$ + +if ! cmp /tmp/$$ ./expected.txt ; then + echo + echo "FAILED: output not as expected: diff follows:" + diff -u /tmp/$$ ./expected.txt + exit 1 +fi + +echo +echo "Running Emscripten tests..." +echo + +( cd ../examples/vamp-example-plugins && make clean test ) +( cd ../examples/vamp-test-plugin && make clean test ) + +echo +echo "Done" +echo