static gboolean plugin_create_control (Control * p_poCtrl)
	/* Plugin API */
	/* Create the plugin */
{
    struct plugin_t *poPlugin;

    TRACE ("plugin_create_control()\n");
    poPlugin = NewPlugin ();
    gtk_container_add (GTK_CONTAINER (p_poCtrl->base),
		       poPlugin->oMonitor.wEventBox);
    p_poCtrl->data = (gpointer) poPlugin;
    p_poCtrl->with_popup = FALSE;
    gtk_widget_set_size_request (p_poCtrl->base, -1, -1);
    return (TRUE);
}				/* plugin_create_control() */
Exemple #2
0
bool VSTPlugin::Instance(const char *name,const char *subname)
{
    bool ok = false;
    FLEXT_ASSERT(effect == NULL);
    
    try {

/*
    if(!ok && dllname != name) {
        FreePlugin();
        // freshly load plugin
        ok = NewPlugin(name) && InstPlugin();
    }
*/
    ok = NewPlugin(name) && InstPlugin();

    if(ok && subname && *subname && Dispatch(effGetPlugCategory) == kPlugCategShell) {
        // sub plugin-name given -> scan plugs

        long plugid;
	    char tmp[64];

        // Waves5 continues with the next plug after the last loaded
        // that's not what we want - workaround: swallow all remaining
        while((plugid = Dispatch(effShellGetNextPlugin,0,0,tmp))) {}

        // restart from the beginning
	    while((plugid = Dispatch(effShellGetNextPlugin,0,0,tmp))) { 
		    // subplug needs a name
            FLEXT_LOG1("subplug %s",tmp);
            if(!strcmp(subname,tmp)) 
                // found
                break;
	    }

        // re-init with plugid set
        if(plugid) ok = InstPlugin(plugid);
    }

    if(ok) {
	    //init plugin 
	    effect->user = this;
	    ok = Dispatch(effOpen) == 0;
    }

    if(ok) {
	    ok = Dispatch(effIdentify) == 'NvEf';
    }

    if(ok) {
        *productname = 0;
	    long ret = Dispatch(effGetProductString,0,0,productname);

        if(!*productname) {
		    // no product name given by plugin -> extract it from the filename

		    std::string str1(dllname);
		    std::string::size_type slpos = str1.rfind('\\');
		    if(slpos == std::string::npos) {
			    slpos = str1.rfind('/');
			    if(slpos == std::string::npos)
				    slpos = 0;
			    else
				    ++slpos;
		    }
		    else
			    ++slpos;
		    std::string str2 = str1.substr(slpos);
		    int snip = str2.find('.');
            if( snip != std::string::npos )
			    str1 = str2.substr(0,snip);
		    else
			    str1 = str2;
		    strcpy(productname,str1.c_str());
	    }
    	
        if(*productname) {
            char tmp[512];
            sprintf(tmp,"vst~ - %s",productname);
            title = tmp;
        }
        else
            title = "vst~";

	    *vendorname = 0;
	    Dispatch(effGetVendorString,0,0,vendorname);
    }

    }
    catch(std::exception &e) {
        flext::post("vst~ - caught exception while loading plugin: %s",e.what());
        ok = false;
    }
    catch(...) {
        flext::post("vst~ - Caught exception while loading plugin");
        ok = false;
    }

    if(!ok) Free();
	return ok;
}