当前位置: 首页>>代码示例>>C++>>正文


C++ MidiDevice::name方法代码示例

本文整理汇总了C++中MidiDevice::name方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiDevice::name方法的具体用法?C++ MidiDevice::name怎么用?C++ MidiDevice::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MidiDevice的用法示例。


在下文中一共展示了MidiDevice::name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeSeqConfiguration

static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)/*{{{*/
{
    xml.tag(level++, "sequencer");

    if (writePortInfo)
    {
        //
        // write information about all midi ports, their assigned
        // instruments and all managed midi controllers
        //
        for (int i = 0; i < MIDI_PORTS; ++i)
        {
            bool used = false;
            MidiPort* mport = &midiPorts[i];

            // Route check by Tim. Port can now be used for routing even if no device.
            // Also, check for other non-defaults and save port, to preserve settings even if no device.
            // Dont write the config for the global inputs list they will be auto created with each startup
            if (mport->defaultInChannels() || mport->defaultOutChannels() ||
                    (mport->instrument() && !mport->instrument()->iname().isEmpty() && mport->instrument()->iname() != "GM") /*|| !mport->syncInfo().isDefault()*/ )
            {
                used = true;
            }
            else
            {//Put the ID of this track into a list
                MidiTrackList* tl = song->midis();
                for (iMidiTrack it = tl->begin(); it != tl->end(); ++it)
                {
                    MidiTrack* t = *it;
                    if (t->outPort() == i)
                    {
                        used = true;
                        break;
                    }
                }
            }

            MidiDevice* dev = mport->device();
            if (!used && !dev)
                continue;
            bool isGlobal = gInputListPorts.contains(mport->portno());
            xml.tag(level++, "midiport portId=\"%lld\" isGlobalInput=\"%d\"", mport->id(), isGlobal);

            if (mport->defaultInChannels())
                xml.intTag(level, "defaultInChans", mport->defaultInChannels());
            if (mport->defaultOutChannels())
                xml.intTag(level, "defaultOutChans", mport->defaultOutChannels());

            if (mport->instrument() && !mport->instrument()->iname().isEmpty() &&
                    (mport->instrument()->iname() != "GM")) // FIXME: TODO: Make this user configurable.
            {
                xml.strTag(level, "instrument", mport->instrument()->iname());
            }

            if (dev)
            {
                xml.strTag(level, "name", dev->name());
                xml.intTag(level, "cacheNRPN", (int)dev->cacheNRPN());

                if (dev->deviceType() != MidiDevice::ALSA_MIDI)
                    xml.intTag(level, "type", dev->deviceType());

                xml.intTag(level, "openFlags", dev->openFlags());
            }
            // write out registered controller for all channels
            MidiCtrlValListList* vll = mport->controller();
            for (int k = 0; k < MIDI_CHANNELS; ++k)
            {
                int min = k << 24;
                int max = min + 0x100000;
                xml.tag(level++, "channel idx=\"%d\"", k);
                iMidiCtrlValList s = vll->lower_bound(min);
                iMidiCtrlValList e = vll->lower_bound(max);
                if (s != e)
                {
                    for (iMidiCtrlValList i = s; i != e; ++i)
                    {
                        if(i->second->num() != 262145)
                        {
                            xml.tag(level++, "controller id=\"%d\"", i->second->num());
                            if (i->second->hwVal() != CTRL_VAL_UNKNOWN)
                                xml.intTag(level, "val", i->second->hwVal());
                            xml.etag(--level, "controller");
                        }
                    }
                }
                xml.etag(--level, "channel");
            }
            QList<PatchSequence*> *patchSequences = mport->patchSequences();
            if (patchSequences && !patchSequences->isEmpty())
            {
                for (int p = 0; p < patchSequences->size(); ++p)
                {
                    PatchSequence* ps = patchSequences->at(p);
                    QString pm = ps->name.replace('\n', " ");
                    xml.put(level, "<patchSequence id=\"%d\" name=\"%s\" checked=\"%d\" />", ps->id, pm.toLatin1().constData(), ps->selected);
                }
            }
            if(!mport->presets()->isEmpty())
            {
//.........这里部分代码省略.........
开发者ID:Adamiko,项目名称:los,代码行数:101,代码来源:conf.cpp

示例2: read

void Route::read(Xml& xml)/*{{{*/
{
	QString s;
	int dtype = MidiDevice::ALSA_MIDI;
	int port = -1;
	unsigned char rtype = Route::TRACK_ROUTE;

	for (;;)
	{
		const QString& tag = xml.s1();
		Xml::Token token = xml.parse();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::Attribut:
#ifdef ROUTE_DEBUG
				printf("Route::read(): attribute:%s\n", tag.toLatin1().constData());
#endif
				if (tag == "type")
					rtype = xml.s2().toInt();
				else if (tag == "devtype")
				{
					dtype = xml.s2().toInt();
					rtype = Route::MIDI_DEVICE_ROUTE;
				}
				else if (tag == "name")
					s = xml.s2();
				else if(tag == "trackId")
				{
					trackId = xml.s2().toLongLong();
					rtype = Route::TRACK_ROUTE;
				}
				else if (tag == "mport") // p3.3.49
				{
					port = xml.s2().toInt();
					rtype = Route::MIDI_PORT_ROUTE;
				}
				else if(tag == "mportId")
				{
					midiPortId  = xml.s2().toLongLong();
					rtype = Route::MIDI_PORT_ROUTE;
				}
				else
					printf("Route::read(): unknown attribute:%s\n", tag.toLatin1().constData());
				break;
			case Xml::TagEnd:
#ifdef ROUTE_DEBUG
				printf("Route::read(): tag end type:%d channel:%d name:%s\n", rtype, channel, s.toLatin1().constData());
#endif
				if (rtype == MIDI_PORT_ROUTE)
				{
					if(midiPortId > 0)
					{
						//qDebug("Route::read(): MIDI_PORT_ROUTE Finding midiport from id");
						type = rtype;
						MidiPort *mp = oomMidiPorts.value(midiPortId);
						if(mp)
						{
							midiPort = mp->portno();
							//qDebug("Route::read(): Found midiport from id: %d", midiPort);
						}
					}
					else if (port >= 0 && port < MIDI_PORTS)
					{
						type = rtype;
						midiPort = port;
						MidiPort *mp = &midiPorts[midiPort];
						midiPortId = mp->id();
					}
					else
						printf("Route::read(): midi port <%d> out of range\n", port);
				}
				else if (!s.isEmpty())
				{
					if (rtype == TRACK_ROUTE)
					{
						if(trackId > 0)
						{
							track = song->findTrackById(trackId);
							type = rtype;
						}
						else
						{
							TrackList* tl = song->tracks();
							iTrack i = tl->begin();
							for (; i != tl->end(); ++i)
							{
								Track* t = *i;
								if (t->name() == s)
								{
									track = t;
									type = rtype;
									trackId = t->id();
									break;
								}
							}
							if (i == tl->end())
								printf("Route::read(): track <%s> not found\n", s.toLatin1().constData());
//.........这里部分代码省略.........
开发者ID:87maxi,项目名称:oom,代码行数:101,代码来源:route.cpp

示例3: rbClicked


//.........这里部分代码省略.........
_redisplay:
            pup->clear();
            gid = 0;

            // Jack input ports if device is writable, and jack output ports if device is readable.
            sl = (col == DEVCOL_OUTROUTES) ? audioDevice->inputPorts(true, _showAliases) : audioDevice->outputPorts(true, _showAliases);

            QAction* act;

            act = pup->addAction(tr("Show first aliases"));
            act->setData(gid);
            act->setCheckable(true);
            act->setChecked(_showAliases == 0);
            ++gid;

            act = pup->addAction(tr("Show second aliases"));
            act->setData(gid);
            act->setCheckable(true);
            act->setChecked(_showAliases == 1);
            ++gid;

            pup->addSeparator();
            for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
            {
                act = pup->addAction(*ip);
                act->setData(gid);
                act->setCheckable(true);

                Route rt(*ip, (col == DEVCOL_OUTROUTES), -1, Route::JACK_ROUTE);
                for (iRoute ir = rl->begin(); ir != rl->end(); ++ir)
                {
                    if (*ir == rt)
                    {
                        currentRoute = (*ir).name();
                        act->setChecked(true);
                        routeSelected = true;
                        break;
                    }
                }
                ++gid;
            }

            act = pup->exec(ppt);
            if (act)
            {
                n = act->data().toInt();
                if (n == 0) // Show first aliases
                {
                    if (_showAliases == 0)
                        _showAliases = -1;
                    else
                        _showAliases = 0;
                    goto _redisplay; // Go back
                }
                else if (n == 1) // Show second aliases
                {
                    if (_showAliases == 1)
                        _showAliases = -1;
                    else
                        _showAliases = 1;
                    goto _redisplay; // Go back
                }

                QString s(act->text());

                if (col == DEVCOL_OUTROUTES) // Writable
开发者ID:peter1000,项目名称:los,代码行数:67,代码来源:confmport.cpp

示例4: songChanged

void MPConfig::songChanged(int flags)
{
    // Is it simply a midi controller value adjustment? Forget it.
    if (flags == SC_MIDI_CONTROLLER)
        return;

    // Get currently selected index...
    int no = -1;
    QTableWidgetItem* sitem = mdevView->currentItem();
    if (sitem)
    {
        QString id = sitem->tableWidget()->item(sitem->row(), DEVCOL_NO)->text();
        no = atoi(id.toLatin1().constData()) - 1;
        if (no < 0 || no >= kMaxMidiPorts)
            no = -1;
    }

    sitem = 0;
    for (int i = kMaxMidiPorts - 1; i >= 0; --i)
    {
        mdevView->blockSignals(true); // otherwise itemChanged() is triggered and bad things happen.
        MidiPort* port = &midiPorts[i];
        MidiDevice* dev = port->device();
        QString s;
        s.setNum(i + 1);
        QTableWidgetItem* itemno = mdevView->item(i, DEVCOL_NO);
        QTableWidgetItem* itemstate = mdevView->item(i, DEVCOL_STATE);
        itemstate->setText(port->state());
        QTableWidgetItem* iteminstr = mdevView->item(i, DEVCOL_INSTR);
        QString instrumentName = port->instrument() ? port->instrument()->iname() : tr("<unknown>");
        iteminstr->setText(instrumentName);
        iteminstr->setToolTip(instrumentName);
        QTableWidgetItem* itemname = mdevView->item(i, DEVCOL_NAME);
        QTableWidgetItem* itemgui = mdevView->item(i, DEVCOL_GUI);
        QTableWidgetItem* itemfb = mdevView->item(i, DEVCOL_CACHE_NRPN);
        QTableWidgetItem* itemrec = mdevView->item(i, DEVCOL_REC);
        QTableWidgetItem* itemplay = mdevView->item(i, DEVCOL_PLAY);
        QTableWidgetItem* itemout = mdevView->item(i, DEVCOL_OUTROUTES);
        QTableWidgetItem* itemin = mdevView->item(i, DEVCOL_INROUTES);
        QTableWidgetItem* itemdefin = mdevView->item(i, DEVCOL_DEF_IN_CHANS);
        itemdefin->setText(bitmap2String(port->defaultInChannels()));
        QTableWidgetItem* itemdefout = mdevView->item(i, DEVCOL_DEF_OUT_CHANS);
        itemdefout->setText(bitmap2String(port->defaultOutChannels()));
        mdevView->blockSignals(false);


        if (dev)
        {
            itemname->setText(dev->name());
            itemname->setToolTip(dev->name());

            // Is it a Jack midi device? Allow renaming.
            //if(dynamic_cast<MidiJackDevice*>(dev))
            if (dev->deviceType() == MidiDevice::JACK_MIDI)
                itemname->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);

            if (dev->rwFlags() & 0x2)
            {
                itemrec->setIcon(dev->openFlags() & 2 ? QIcon(*dotIcon) : QIcon(*dothIcon));
            }
            else
            {
                itemrec->setIcon(QIcon(QPixmap()));
            }

            if (dev->rwFlags() & 0x1)
            {
                itemplay->setIcon(dev->openFlags() & 1 ? QIcon(*dotIcon) : QIcon(*dothIcon));
            }
            else
                itemplay->setIcon(QIcon(QPixmap()));
            itemfb->setIcon(dev->cacheNRPN() ? QIcon(*dotIcon) : QIcon(*dothIcon));
        }
        else
        {
            itemname->setText(tr("<none>"));
            itemname->setToolTip("");
            itemgui->setIcon(QIcon(*dothIcon));
            itemrec->setIcon(QIcon(QPixmap()));
            itemplay->setIcon(QIcon(QPixmap()));
            itemfb->setIcon(QIcon(QPixmap()));
        }
        // falkTX, we don't want this in the connections manager
        //if (port->hasGui())
        //{
        //	itemgui->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
        //}
        //else
        //{
            itemgui->setIcon(QIcon(QPixmap()));
        //}
        iteminstr->setIcon(QIcon(*buttondownIcon));
        itemname->setIcon(QIcon(*buttondownIcon));

        //if(dev && dynamic_cast<MidiJackDevice*>(dev))
        if (dev && dev->deviceType() == MidiDevice::JACK_MIDI)
        {
            //item->setPixmap(DEVCOL_ROUTES, *buttondownIcon);
            //item->setText(DEVCOL_ROUTES, tr("routes"));

//.........这里部分代码省略.........
开发者ID:peter1000,项目名称:los,代码行数:101,代码来源:confmport.cpp

示例5: mdevViewItemRenamed

void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
{
    int col = item->column();
    QString s = item->text();
    //printf("MPConfig::mdevViewItemRenamed col:%d txt:%s\n", col, s.toLatin1().constData());
    if (item == 0)
        return;
    switch (col)
    {
        case DEVCOL_DEF_IN_CHANS:
        {
            QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
            int no = atoi(id.toLatin1().constData()) - 1;
            if (no < 0 || no >= kMaxMidiPorts)
                return;
            midiPorts[no].setDefaultInChannels(((1 << kMaxMidiChannels) - 1) & string2bitmap(s));
            song->update();
        }
            break;
        case DEVCOL_DEF_OUT_CHANS:
        {
            QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
            int no = atoi(id.toLatin1().constData()) - 1;
            if (no < 0 || no >= kMaxMidiPorts)
                return;
            midiPorts[no].setDefaultOutChannels(((1 << kMaxMidiChannels) - 1) & string2bitmap(s));
            song->update();
        }
            break;
        case DEVCOL_NAME:
        {
            QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
            int no = atoi(id.toLatin1().constData()) - 1;
            if (no < 0 || no >= kMaxMidiPorts)
                return;

            MidiPort* port = &midiPorts[no];
            MidiDevice* dev = port->device();
            // Only Jack midi devices.
            if (!dev || dev->deviceType() != MidiDevice::JACK_MIDI)
                return;
            if (dev->name() == s)
                return;

            if (midiDevices.find(s))
            {
                QMessageBox::critical(this,
                        tr("LOS: bad device name"),
                        tr("please choose a unique device name"),
                        QMessageBox::Ok,
                        Qt::NoButton,
                        Qt::NoButton);
                songChanged(-1);
                return;
            }
            dev->setName(s);
            song->update();
        }
            break;
        default:
            //printf("MPConfig::mdevViewItemRenamed unknown column clicked col:%d txt:%s\n", col, s.toLatin1().constData());
            break;
    }
}
开发者ID:peter1000,项目名称:los,代码行数:64,代码来源:confmport.cpp


注:本文中的MidiDevice::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。