コード例 #1
0
ファイル: AudioManager.cpp プロジェクト: bagumondigi/xLights
// Load plugins
void xLightsVamp::LoadPlugins(AudioManager* paudio)
{
	// dont need to load it twice
	if (_loadedPlugins.size() > 0)
	{
		return;
	}

	Vamp::HostExt::PluginLoader::PluginKeyList pluginList = _loader->listPlugins();

	for (int x = 0; x < pluginList.size(); x++)
	{
		Vamp::Plugin *p = _loader->loadPlugin(pluginList[x], paudio->GetRate());
		if (p == nullptr)
		{
			// skip any that dont load
			continue;
		}
		_loadedPlugins.push_back(p);
	}
}
コード例 #2
0
int main(int argc, char **argv)
{
    char *scooter = argv[0];
    char *name = 0;
    while (scooter && *scooter) {
        if (*scooter == '/' || *scooter == '\\') name = ++scooter;
        else ++scooter;
    }
    if (!name || !*name) name = argv[0];

    bool nondeterministic = false;
    bool verbose = false;
    bool all = false;
    bool list = false;
    string plugin;
    string single;

    // Would be better to use getopt, but let's avoid the dependency for now
    for (int i = 1; i < argc; ++i) {
        if (!argv[i]) break;
        if (argv[i][0] == '-') {
            if (!strcmp(argv[i], "-vn") ||
                !strcmp(argv[i], "-nv")) {
                verbose = true;
                nondeterministic = true;
                continue;
            }
            if (!strcmp(argv[i], "-v") ||
                !strcmp(argv[i], "--verbose")) {
                verbose = true;
                continue;
            }
            if (!strcmp(argv[i], "-n") ||
                !strcmp(argv[i], "--nondeterministic")) {
                nondeterministic = true;
                continue;
            }
            if (!strcmp(argv[i], "-a") ||
                !strcmp(argv[i], "--all")) {
                all = true;
                continue;
            }
            if (!strcmp(argv[i], "-l") ||
                !strcmp(argv[i], "--list-tests")) {
                list = true;
                continue;
            }
            if (!strcmp(argv[i], "-t") ||
                !strcmp(argv[i], "--test")) {
                if (i + 1 < argc) {
                    single = argv[i+1];
                    ++i;
                } else {
                    usage(name);
                }
                continue;
            }
            if (!strcmp(argv[i], "--version")) {
                cout << "v" << VERSION << endl;
                return 0;
            }
            usage(name);
        } else {
            if (plugin != "") usage(name);
            else plugin = argv[i];
        }
    }

    if (list) {
        if (all || nondeterministic || (single != "") || (plugin != "")) {
            usage(name);
        }
        Tester::listTests();
        return 0;
    }
    
    if (plugin == "" && !all) usage(name);
    if (plugin != "" &&  all) usage(name);

    cerr << name << ": Running..." << endl;

    Test::Options opts = Test::NoOption;
    if (nondeterministic) opts |= Test::NonDeterministic;
    if (verbose) opts |= Test::Verbose;
    if (single != "") opts |= Test::SingleTest;

    if (all) {
        bool good = true;
        Vamp::HostExt::PluginLoader::PluginKeyList keys =
            Vamp::HostExt::PluginLoader::getInstance()->listPlugins();
        if (keys.size() == 0) {
            cout << name << ": NOTE: No plugins found!" << endl;
            cout << name << ": (No libraries in search path, or no descriptors in library)" << endl;
            return 2;
        }
        int notes = 0, warnings = 0, errors = 0;
        for (int i = 0; i < (int)keys.size(); ++i) {
            cout << "Testing plugin: " << keys[i] << endl;
            Tester tester(keys[i], opts, single);
            if (tester.test(notes, warnings, errors)) {
                cout << name << ": All tests succeeded for this plugin" << endl;
            } else {
                cout << name << ": Some tests failed for this plugin" << endl;
                good = false;
            }
            cout << endl;
        }
        if (good) {
            cout << name << ": All tests succeeded";
            if (warnings > 0) {
                cout << ", with " << warnings << " warning(s)";
                if (notes > 0) {
                    cout << " and " << notes << " other note(s)";
                }
            } else if (notes > 0) {
                cout << ", with " << notes << " note(s)";
            }
            cout << endl;
            return 0;
        } else {
            cout << name << ": Some tests failed" << endl;
            return 1;
        }   
    } else {
        Tester tester(plugin, opts, single);
        int notes = 0, warnings = 0, errors = 0;
        if (tester.test(notes, warnings, errors)) {
            cout << name << ": All tests succeeded";
            if (warnings > 0) {
                cout << ", with " << warnings << " warning(s)";
                if (notes > 0) {
                    cout << " and " << notes << " other note(s)";
                }
            } else if (notes > 0) {
                cout << ", with " << notes << " note(s)";
            }
            cout << endl;
            return 0;
        } else {
            cout << name << ": Some tests failed" << endl;
            return 1;
        }
    }
}