Exemplo n.º 1
0
SoundPluginType *PR_get_plugin_type_by_name(const char *container_name, const char *type_name, const char *plugin_name){

  // Compatibility with older songs
  if (!strcmp(type_name, "Patchbay") && !strcmp(plugin_name, "Patchbay"))
    plugin_name = "Patchbay 8x8";
  
  for(SoundPluginType *plugin_type : g_plugin_types)
    if(!strcmp(plugin_type->type_name,type_name))
      if(!strcmp(plugin_type->name,plugin_name))
        return plugin_type;

  // check if the container needs to be populated.
  if (container_name != NULL)
    for(auto container : g_plugin_type_containers)
      if (!container->is_populated)
        if(!strcmp(container->type_name,type_name))
          if(!strcmp(container->name,container_name)){
            container->populate(container);
            return PR_get_plugin_type_by_name(container_name, type_name, plugin_name);
          }

  // Older songs didn't store vst container names (because there were no containers). Try to set container_name to plugin_name and try again.
  if(!strcmp(type_name,"VST") && container_name==NULL){
    return PR_get_plugin_type_by_name(plugin_name,type_name,plugin_name);
  }

  if(!strcmp(type_name,"VST") || !strcmp(type_name,"VST3") || !strcmp(type_name,"AudioUnit")){
    while(true){
      vector_t v = {}; // c++ way of zero-initialization without getting missing-field-initializers warning.

      int select_plugin_file = VECTOR_push_back(&v, "Select plugin file");
      int use_different_plugin = VECTOR_push_back(&v, "Use different plugin");
      int replace_with_pipe = VECTOR_push_back(&v, "Replace with pipe");
      (void)replace_with_pipe; // default
      
      int ret = GFX_Message(&v, ("VST Plugin " + QString(plugin_name) + " not found.").toUtf8().constData());

      if (ret==select_plugin_file) {

        QString filename;
        
        {
          R_ASSERT(g_radium_runs_custom_exec==false);

          radium::ScopedExec scopedExec;
          filename = QFileDialog::getOpenFileName(NULL,
                                                  plugin_name,
                                                  QString(),
                                                  QString(),
                                                  0,
                                                  QFileDialog::DontUseCustomDirectoryIcons | (useNativeFileRequesters() ? (QFileDialog::Option)0 : QFileDialog::DontUseNativeDialog)
                                                  );
        }

        QFileInfo info(filename);

        QString basename = info.fileName();
        basename.resize(basename.size()-strlen(VST_SUFFIX)-1);

        //        if(basename==QString(plugin_name) && info.exists()){
        VST_add_path(info.dir().path());
        PR_init_plugin_types();
        return PR_get_plugin_type_by_name(container_name, type_name, plugin_name);
        //}
      } else if (ret==use_different_plugin) {
        SoundPluginType *plugintype = MW_popup_plugin_type_selector();
        if (plugintype==NULL)
          break;
        else
          return plugintype;
      } else
        break;
    }

  }else if(!strcmp(type_name,"Pd") && strcmp(plugin_name, "")){ // type_name doesn't mean anything for already saved files. Without this excpetion, plugins would be replaced by pipes if a pd patch file was renamed.
    return PR_get_plugin_type_by_name("Pd", "");

  }else{

    MyQMessageBox msgBox;
    msgBox.setText("Plugin " + QString(type_name) + " / " + QString(plugin_name) + " not found. Replacing with a Pipe.");
    if(!strcmp(type_name,"Ladspa") && getenv("LADSPA_PATH")==NULL)
      msgBox.setInformativeText("(LADSPA_PATH is not set)");

    EVENTLOG_add_event(strdup(msgBox.text().toUtf8().constData()));
                       
    msgBox.setDefaultButton(QMessageBox::Ok);
    safeExec(msgBox);
  }

  return PR_get_plugin_type_by_name("Pipe","Pipe");
}
Exemplo n.º 2
0
SoundPluginType *PR_get_plugin_type_by_name(const char *container_name, const char *type_name, const char *plugin_name){
  for(SoundPluginType *plugin_type : g_plugin_types)
    if(!strcmp(plugin_type->type_name,type_name))
      if(!strcmp(plugin_type->name,plugin_name))
        return plugin_type;

  // check if the container needs to be populated.
  if (container_name != NULL)
    for(auto container : g_plugin_type_containers)
      if (!container->is_populated)
        if(!strcmp(container->type_name,type_name))
          if(!strcmp(container->name,container_name)){
            container->populate(container);
            return PR_get_plugin_type_by_name(container_name, type_name, plugin_name);
          }

  // Older songs didn't store vst container names (because there were no containers). Try to set container_name to plugin_name and try again.
  if(!strcmp(type_name,"VST") && container_name==NULL){
    return PR_get_plugin_type_by_name(plugin_name,type_name,plugin_name);
  }

  if(!strcmp(type_name,"VST")){
    while(true){
      vector_t v = {0};

      VECTOR_push_back(&v, "Select plugin file");
      VECTOR_push_back(&v, "Use different plugin");
      VECTOR_push_back(&v, "Replace with pipe");

      int ret = GFX_Message(&v, ("VST Plugin " + QString(plugin_name) + " not found.").toUtf8().constData());

      if (ret==0) {
        QString filename = QFileDialog::getOpenFileName(NULL, plugin_name);
        QFileInfo info(filename);

        QString basename = info.fileName();
        basename.resize(basename.size()-strlen(VST_SUFFIX)-1);

        //        if(basename==QString(plugin_name) && info.exists()){
        VST_add_path(info.dir().path());
        PR_init_plugin_types();
        return PR_get_plugin_type_by_name(container_name, type_name, plugin_name);
        //}
      } else if (ret==1) {
        SoundPluginType *plugintype = MW_popup_plugin_selector(NULL, 0, 0, false);
        if (plugintype==NULL)
          break;
        else
          return plugintype;
      } else
        break;
    }

  }else if(!strcmp(type_name,"Pd") && strcmp(plugin_name, "")){ // type_name doesn't mean anything for already saved files. Without this excpetion, plugins would be replaced by pipes if a pd patch file was renamed.
    return PR_get_plugin_type_by_name("Pd", "");

  }else{

    QMessageBox msgBox;
    msgBox.setText("Plugin " + QString(type_name) + " / " + QString(plugin_name) + " not found. Replacing with a Pipe.");
    if(!strcmp(type_name,"Ladspa") && getenv("LADSPA_PATH")==NULL)
      msgBox.setInformativeText("(LADSPA_PATH is not set)");

    msgBox.setDefaultButton(QMessageBox::Ok);
    safeExec(msgBox);
  }

  return PR_get_plugin_type_by_name("Pipe","Pipe");
}