comparison quick-test.js @ 110:2f621b00747e

Merge from branch jsonrpc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 06 Oct 2016 14:33:12 +0100
parents 9d20eb251fbc
children 90bf9d9f9c95
comparison
equal deleted inserted replaced
107:f272e46f5615 110:2f621b00747e
47 } 47 }
48 48
49 function test() { 49 function test() {
50 50
51 comment("Querying plugin list..."); 51 comment("Querying plugin list...");
52 var result = request('{"type": "list"}'); 52 var result = request('{"method": "list"}');
53 53
54 comment("Loading zero crossings plugin..."); 54 comment("Loading zero crossings plugin...");
55 result = request('{"type":"load","content": {"pluginKey":"vamp-example-plugins:powerspectrum","inputSampleRate":16,"adapterFlags":["AdaptAllSafe"]}}'); 55 result = request('{"method":"load","params": {"key":"vamp-example-plugins:powerspectrum","inputSampleRate":16,"adapterFlags":["AdaptAllSafe"]}}');
56 56
57 comment("I'm now assuming that the load succeeded and the returned pluginHandle was 1. I haven't bothered to parse the JSON. If those assumptions are wrong, this obviously isn't going to work. Configuring the plugin..."); 57 comment("I'm now assuming that the load succeeded and the returned handle was 1. I haven't bothered to parse the JSON. If those assumptions are wrong, this obviously isn't going to work. Configuring the plugin...");
58 result = request('{"type":"configure","content":{"pluginHandle":1,"configuration":{"blockSize": 8, "channelCount": 1, "stepSize": 8}}}'); 58 result = request('{"method":"configure","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "stepSize": 8}}}');
59 59
60 comment("If I try to configure it again, it should fail because it's already configured... but this doesn't change anything, and subsequent processing should work fine. Just an example of a failure call. NB this only works if Emscripten has exception catching enabled -- it's off by default in opt builds, which would just end the script here. Wonder what the performance penalty is like."); 60 comment("If I try to configure it again, it should fail because it's already configured... but this doesn't change anything, and subsequent processing should work fine. Just an example of a failure call. NB this only works if Emscripten has exception catching enabled -- it's off by default in opt builds, which would just end the script here. Wonder what the performance penalty is like.");
61 result = request('{"type":"configure","content":{"pluginHandle":1,"configuration":{"blockSize": 8, "channelCount": 1, "stepSize": 8}}}'); 61 result = request('{"method":"configure","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "stepSize": 8}}}');
62 62
63 comment("Now processing a couple of blocks of data, on the same assumptions..."); 63 comment("Now processing a couple of blocks of data, on the same assumptions...");
64 result = request('{"type":"process","content":{"pluginHandle":1,"processInput":{"timestamp":{"s":0,"n":0},"inputBuffers":[{"values":[0,1,-1,0,1,-1,0,1]}]}}}'); 64 result = request('{"method":"process","params":{"handle":1,"processInput":{"timestamp":{"s":0,"n":0},"inputBuffers":[[0,1,-1,0,1,-1,0,1]]}}}');
65 result = request('{"type":"process","content":{"pluginHandle":1,"processInput":{"timestamp":{"s":0,"n":500000000},"inputBuffers":[{"values":[0,1,-1,0,1,-1,0,1]}]}}}'); 65 result = request('{"method":"process","params":{"handle":1,"processInput":{"timestamp":{"s":0,"n":500000000},"inputBuffers":[[0,1,-1,0,1,-1,0,1]]}}}');
66 66
67 comment("Cleaning up the plugin and getting any remaining features..."); 67 comment("Cleaning up the plugin and getting any remaining features...");
68 result = request('{"type":"finish","content":{"pluginHandle":1}}'); 68 result = request('{"method":"finish","params":{"handle":1}}');
69 69
70 comment("A process call should now fail, as the plugin has been cleaned up."); 70 comment("A process call should now fail, as the plugin has been cleaned up.");
71 result = request('{"type":"process","content":{"pluginHandle":1,"processInput":{"timestamp":{"s":0,"n":1000000000},"inputBuffers":[{"values":[0,1,-1,0,1,-1,0,1]}]}}}'); 71 result = request('{"method":"process","params":{"handle":1,"processInput":{"timestamp":{"s":0,"n":1000000000},"inputBuffers":[{"values":[0,1,-1,0,1,-1,0,1]}]}}}');
72 } 72 }
73 73
74 window.onload = function() { 74 window.onload = function() {
75 test(); 75 test();
76 } 76 }