Logo Search packages:      
Sourcecode: rosegarden version File versions  Download package

void RosegardenGUIApp::slotPluginSelected ( Rosegarden::InstrumentId  instrument,
int  index,
int  plugin 
) [slot]

!! seems iffy -- why can't we just unassign it?

!! much code duplicated here from RosegardenGUIDoc::initialiseStudio

Definition at line 6755 of file rosegardengui.cpp.

References RosegardenGUIDoc::getAudioFileManager(), RosegardenGUIDoc::getStudio(), m_doc, pluginSelected(), and RosegardenGUIDoc::slotDocumentModified().

Referenced by RosegardenGUIApp(), slotManageSynths(), slotOpenAudioMixer(), and slotShowPluginDialog().

{
    const QObject *s = sender();

    bool fromSynthMgr = (s == m_synthManager);

    // It's assumed that ports etc will already have been set up on
    // the AudioPluginInstance before this is invoked.

    Rosegarden::PluginContainer *container = 0;

    container = m_doc->getStudio().getInstrumentById(instrumentId);
    if (!container) container = m_doc->getStudio().getBussById(instrumentId);
    if (!container) {
      RG_DEBUG << "RosegardenGUIApp::slotPluginSelected - "
             << "no instrument or buss of id " << instrumentId << endl;
      return;
    }    
    
    Rosegarden::AudioPluginInstance *inst = 
      container->getPlugin(index);

    if (!inst) {
        RG_DEBUG << "RosegardenGUIApp::slotPluginSelected - "
                 << "got index of unknown plugin!" << endl;
      return;
    }

    if (plugin == -1)
    {
      // Destroy plugin instance
      //!!! seems iffy -- why can't we just unassign it?

      if (Rosegarden::StudioControl::
          destroyStudioObject(inst->getMappedId()))
      {
          RG_DEBUG << "RosegardenGUIApp::slotPluginSelected - "
                 << "cannot destroy Studio object "
                 << inst->getMappedId() << endl;
      }
      
      inst->setAssigned(false);
    }
    else
    {
      // If unassigned then create a sequencer instance of this
      // AudioPluginInstance.
      //
      if (inst->isAssigned())
      {
          RG_DEBUG << "RosegardenGUIApp::slotPluginSelected - "
                 << " setting identifier for mapper id " << inst->getMappedId()
                 << " to " << inst->getIdentifier() << endl;

          Rosegarden::StudioControl::setStudioObjectProperty
            (inst->getMappedId(),
             Rosegarden::MappedPluginSlot::Identifier,
             strtoqstr(inst->getIdentifier()));
      }
      else
      {
          // create a studio object at the sequencer
          Rosegarden::MappedObjectId newId =
            Rosegarden::StudioControl::createStudioObject
            (Rosegarden::MappedObject::PluginSlot);
          
          RG_DEBUG << "RosegardenGUIApp::slotPluginSelected - "
                 << " new MappedObjectId = " << newId << endl;
          
          // set the new Mapped ID and that this instance
          // is assigned
          inst->setMappedId(newId);
          inst->setAssigned(true);
          
          // set the instrument id
          Rosegarden::StudioControl::setStudioObjectProperty
            (newId,
             Rosegarden::MappedObject::Instrument,
             Rosegarden::MappedObjectValue(instrumentId));
          
          // set the position
          Rosegarden::StudioControl::setStudioObjectProperty
            (newId,
             Rosegarden::MappedObject::Position,
             Rosegarden::MappedObjectValue(index));
          
          // set the plugin id
          Rosegarden::StudioControl::setStudioObjectProperty
            (newId,
             Rosegarden::MappedPluginSlot::Identifier,
             strtoqstr(inst->getIdentifier()));
      }
    }

    int pluginMappedId = inst->getMappedId();

    //!!! much code duplicated here from RosegardenGUIDoc::initialiseStudio
    
    inst->setConfigurationValue
      (qstrtostr(Rosegarden::PluginIdentifier::RESERVED_PROJECT_DIRECTORY_KEY),
       m_doc->getAudioFileManager().getAudioPath());

    // Set opaque string configuration data (e.g. for DSSI plugin)
    //
    Rosegarden::MappedObjectPropertyList config;
    for (Rosegarden::AudioPluginInstance::ConfigMap::const_iterator
           i = inst->getConfiguration().begin();
       i != inst->getConfiguration().end(); ++i) {
      config.push_back(strtoqstr(i->first));
      config.push_back(strtoqstr(i->second));
    }
    Rosegarden::StudioControl::setStudioObjectPropertyList
      (pluginMappedId,
       Rosegarden::MappedPluginSlot::Configuration,
       config);
    
    // Set the bypass
    //
    Rosegarden::StudioControl::setStudioObjectProperty
      (pluginMappedId,
       Rosegarden::MappedPluginSlot::Bypassed,
       Rosegarden::MappedObjectValue(inst->isBypassed()));
    
    // Set the program
    //
    if (inst->getProgram() != "") {
      Rosegarden::StudioControl::setStudioObjectProperty
          (pluginMappedId,
           Rosegarden::MappedPluginSlot::Program,
           strtoqstr(inst->getProgram()));
    }
    
    // Set all the port values
    // 
    Rosegarden::PortInstanceIterator portIt;
    
    for (portIt = inst->begin();
       portIt != inst->end(); ++portIt)
    {
      Rosegarden::StudioControl::setStudioPluginPort
          (pluginMappedId,
           (*portIt)->number,
           (*portIt)->value);
    }
    
    if (fromSynthMgr) {
      int key = (index << 16) + instrumentId;
      if (m_pluginDialogs[key]) {
          m_pluginDialogs[key]->updatePlugin(plugin);
      }
    } else if (m_synthManager) {
      m_synthManager->updatePlugin(instrumentId, plugin);
    }

    emit pluginSelected(instrumentId, index, plugin);

    // Set modified
    m_doc->slotDocumentModified();
}


Generated by  Doxygen 1.6.0   Back to index