cannam@1: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@1: cannam@1: /* cannam@1: Vamp cannam@1: cannam@1: An API for audio analysis and feature extraction plugins. cannam@1: cannam@1: Centre for Digital Music, Queen Mary, University of London. cannam@1: Copyright 2006 Chris Cannam. cannam@1: cannam@1: Permission is hereby granted, free of charge, to any person cannam@1: obtaining a copy of this software and associated documentation cannam@1: files (the "Software"), to deal in the Software without cannam@1: restriction, including without limitation the rights to use, copy, cannam@1: modify, merge, publish, distribute, sublicense, and/or sell copies cannam@1: of the Software, and to permit persons to whom the Software is cannam@1: furnished to do so, subject to the following conditions: cannam@1: cannam@1: The above copyright notice and this permission notice shall be cannam@1: included in all copies or substantial portions of the Software. cannam@1: cannam@1: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@1: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@1: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@6: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@1: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@1: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@1: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@1: cannam@1: Except as contained in this notice, the names of the Centre for cannam@1: Digital Music; Queen Mary, University of London; and Chris Cannam cannam@1: shall not be used in advertising or otherwise to promote the sale, cannam@1: use or other dealings in this Software without prior written cannam@1: authorization. cannam@1: */ cannam@1: cannam@1: #include cannam@1: cannam@1: #include "vamp.h" cannam@1: cannam@1: #include "PluginHostAdapter.h" cannam@1: cannam@1: #include "system.h" cannam@1: cannam@1: /* cannam@1: A very simple Vamp plugin host. So far all this does is load the cannam@1: plugin library given on the command line and dump out the names of cannam@1: the plugins found in it. cannam@1: */ cannam@1: cannam@1: int main(int argc, char **argv) cannam@1: { cannam@1: if (argc != 2) { cannam@1: std::cerr << "Usage: " << argv[0] << " pluginlibrary.so" << std::endl; cannam@1: return 2; cannam@1: } cannam@1: cannam@1: std::cerr << std::endl << argv[0] << ": Running..." << std::endl; cannam@1: cannam@1: std::string soname = argv[1]; cannam@1: cannam@1: void *libraryHandle = DLOPEN(soname, RTLD_LAZY); cannam@1: cannam@1: if (!libraryHandle) { cannam@1: std::cerr << argv[0] << ": Failed to open plugin library " cannam@10: << soname << ": " << DLERROR() << std::endl; cannam@1: return 1; cannam@1: } cannam@1: cannam@1: std::cout << argv[0] << ": Opened plugin library " << soname << std::endl; cannam@1: cannam@1: VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) cannam@1: DLSYM(libraryHandle, "vampGetPluginDescriptor"); cannam@1: cannam@1: if (!fn) { cannam@1: std::cerr << argv[0] << ": No Vamp descriptor function in library " cannam@1: << soname << std::endl; cannam@1: DLCLOSE(libraryHandle); cannam@1: return 1; cannam@1: } cannam@1: cannam@1: std::cout << argv[0] << ": Found plugin descriptor function" << std::endl; cannam@1: cannam@1: int index = 0; cannam@1: const VampPluginDescriptor *descriptor = 0; cannam@1: cannam@1: while ((descriptor = fn(index))) { cannam@1: cannam@1: Vamp::PluginHostAdapter adapter(descriptor, 48000); cannam@1: std::cout << argv[0] << ": Plugin " << (index+1) cannam@1: << " is \"" << adapter.getName() << "\"" << std::endl; cannam@1: cannam@1: ++index; cannam@1: } cannam@1: cannam@1: std::cout << argv[0] << ": Done\n" << std::endl; cannam@1: cannam@1: DLCLOSE(libraryHandle); cannam@1: return 0; cannam@1: } cannam@1: