Beispiel #1
0
void Pipeline::setActive(int idx, bool flag)
{
	int s = size();
	if(idx >= s)
		return;
    BasePlugin* p = (*this)[idx];
    if (p)
    {
        p->setActive(flag);

        if (p->gui())
            p->gui()->setActive(flag);
    }
}
Beispiel #2
0
void EffectRack::choosePlugin(QListWidgetItem* it, bool replace)/*{{{*/
{
    PluginI* plugi = PluginDialog::getPlugin(track->type(), this);
    if (plugi)
    {
        BasePlugin* nplug = 0;

        if (plugi->type() == PLUGIN_LADSPA)
            nplug = new LadspaPlugin();
        else if (plugi->type() == PLUGIN_LV2)
            nplug = new Lv2Plugin();
        else if (plugi->type() == PLUGIN_VST)
            nplug = new VstPlugin();

        if (nplug)
        {
            if (nplug->init(plugi->filename(), plugi->label()))
            {
                // just in case is needed later
                //if (!audioDevice || audioDevice->deviceType() != AudioDevice::JACK_AUDIO)
                //    nplug->aboutToRemove();

                int idx = row(it);
                if (replace)
                {
                    audio->msgAddPlugin(track, idx, 0);
                    //Do this part from the GUI context so user interfaces can be properly deleted
                    // track->efxPipe()->insert(0, idx); was set on lv2 only
                }
                audio->msgAddPlugin(track, idx, nplug);
                nplug->setChannels(track->channels());
                nplug->setActive(true);
                song->dirty = true;
            }
            else
            {
                QMessageBox::warning(this, tr("Failed to load plugin"), tr("Plugin '%1'' failed to initialize properly, error was:\n%2").arg(plugi->name()).arg(get_last_error()));
                nplug->deleteMe();
                return;
            }
        }

        updateContents();
    }
}/*}}}*/
Beispiel #3
0
void EffectRack::menuRequested(QListWidgetItem* it)/*{{{*/
{
    if (it == 0 || track == 0)
        return;
    RackSlot* curitem = (RackSlot*) it;

    Pipeline* epipe = track->efxPipe();

    int idx = row(curitem);
    QString name;
    bool mute = false;
    bool nativeGui = false;
    Pipeline* pipe = track->efxPipe();
    if (pipe)
    {
        name = pipe->name(idx);
        mute = (pipe->isActive(idx) == false);
        nativeGui = pipe->hasNativeGui(idx);
    }

    //enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SAVE };

    enum
    {
        NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SHOW_NATIVE, SAVE
    };
    QMenu* menu = new QMenu;
    QAction* newAction = menu->addAction(tr("new"));
    QAction* changeAction = menu->addAction(tr("change"));
    QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); //,   UP, UP);
    QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); //, DOWN, DOWN);
    QAction* removeAction = menu->addAction(tr("remove")); //,    REMOVE, REMOVE);
    QAction* bypassAction = menu->addAction(tr("bypass")); //,    BYPASS, BYPASS);
    QAction* showGuiAction = menu->addAction(tr("show gui")); //,  SHOW, SHOW);
    QAction* showNativeGuiAction = menu->addAction(tr("show native gui")); //,  SHOW_NATIVE, SHOW_NATIVE);
    QAction* saveAction = menu->addAction(tr("save preset"));

    newAction->setData(NEW);
    changeAction->setData(CHANGE);
    upAction->setData(UP);
    downAction->setData(DOWN);
    removeAction->setData(REMOVE);
    bypassAction->setData(BYPASS);
    showGuiAction->setData(SHOW);
    showNativeGuiAction->setData(SHOW_NATIVE);
    saveAction->setData(SAVE);

    bypassAction->setCheckable(true);
    showGuiAction->setCheckable(true);
    showNativeGuiAction->setCheckable(true);

    bypassAction->setChecked(mute);
    showGuiAction->setChecked(pipe->guiVisible(idx));
    showNativeGuiAction->setEnabled(nativeGui);
    if (nativeGui)
        showNativeGuiAction->setChecked(pipe->nativeGuiVisible(idx));

    if (pipe->empty(idx))
    {
        menu->removeAction(changeAction);
        menu->removeAction(saveAction);
        upAction->setEnabled(false);
        downAction->setEnabled(false);
        removeAction->setEnabled(false);
        bypassAction->setEnabled(false);
        showGuiAction->setEnabled(false);
        showNativeGuiAction->setEnabled(false);
    }
    else
    {
        menu->removeAction(newAction);
        if (idx == 0)
            upAction->setEnabled(true);
        if (idx == ((int)epipe->size() - 1))
            downAction->setEnabled(false);
    }

    QPoint pt = QCursor::pos();
    QAction* act = menu->exec(pt, 0);

    //delete menu;
    if (!act)
    {
        delete menu;
        return;
    }

    int sel = act->data().toInt();
    delete menu;

    int pdepth = epipe->size();
    switch (sel)
    {
    case NEW:
    {
        choosePlugin(it);
        break;
    }
    case CHANGE:
    {
        choosePlugin(it, true);
        break;
    }
    case REMOVE:
    {
        BasePlugin* oldPlugin = (*epipe)[idx];
        oldPlugin->setActive(false);
        oldPlugin->aboutToRemove();

        if(debugMsg)
            qCritical("Plugin to remove now and here");

        audio->msgAddPlugin(track, idx, 0);
        song->dirty = true;
        break;
    }
    case BYPASS:
    {
        bool flag = !pipe->isActive(idx);
        pipe->setActive(idx, flag);
        break;
    }
    case SHOW:
    {
        bool flag = !pipe->guiVisible(idx);
        pipe->showGui(idx, flag);
        break;
    }
    case SHOW_NATIVE:
    {
        printf("Show native GUI called\n");
        bool flag = !pipe->nativeGuiVisible(idx);
        pipe->showNativeGui(idx, flag);
        break;
    }
    case UP:
        if (idx > 0)
        {
            setCurrentItem(item(idx - 1));
            pipe->move(idx, true);
        }
        break;
    case DOWN:
        if (idx < pdepth)
        {
            setCurrentItem(item(idx + 1));
            pipe->move(idx, false);
        }
        break;
    case SAVE:
        savePreset(idx);
        break;
    }
    //Already done on songChanged
    //updateContents();
    song->update(SC_RACK);
}/*}}}*/