示例#1
0
void ConfigureMIDIOut::slotEditClicked()
{
	QTreeWidgetItem* item;
	MIDIDevice* device;

	item = m_list->currentItem();
	if (item == NULL)
		return;

	device = m_plugin->device(item->text(KColumnNumber).toInt() - 1);
	if (device == NULL)
		return;

	ConfigureMIDIDevice cmd(this, device);
	if (cmd.exec() == QDialog::Accepted)
	{
		/* Update the tree item */
		item->setText(KColumnMIDIChannel,
			      QString("%1").arg(device->midiChannel() + 1));
		item->setText(KColumnMode,
			      MIDIDevice::modeToString(device->mode()));

		/* Save as global settings */
		device->saveSettings();
	}
}
示例#2
0
QString MIDIOut::infoText(quint32 output)
{
    QString str;

    str += QString("<HTML>");
    str += QString("<HEAD>");
    str += QString("<TITLE>%1</TITLE>").arg(name());
    str += QString("</HEAD>");
    str += QString("<BODY>");

    if (output == QLCOutPlugin::invalidOutput())
    {
        str += QString("<H3>%1</H3>").arg(name());
        str += QString("<P>");
        str += tr("This plugin provides DMX output support for various MIDI devices.");
        str += QString("</P>");
    }
    else
    {
        MIDIDevice* dev = device(output);
        if (dev != NULL)
            str += dev->infoText();
    }

    str += QString("</BODY>");
    str += QString("</HTML>");

    return str;
}
示例#3
0
void MIDIOut::close(quint32 output)
{
    MIDIDevice* dev = device(output);
    if (dev != NULL)
        dev->open();
    else
        qWarning() << name() << "has no output number:" << output;
}
示例#4
0
void MIDIOut::writeRange(t_output output, t_channel address, t_value* values,
		t_channel num)
{
	Q_UNUSED(address);

	MIDIDevice* dev = device(output);
	if (dev != NULL)
		dev->writeRange(values, num);
}
示例#5
0
void MIDIInput::feedBack(t_input input, t_input_channel channel,
			 t_input_value value)
{
	MIDIDevice* dev;

	dev = device(input);
	if (dev == NULL)
		return;
	else
		dev->feedBack(channel, value);
}
示例#6
0
void MIDIInput::open(quint32 input)
{
	MIDIDevice* dev = device(input);
	if (dev != NULL)
	{
		connect(dev, SIGNAL(valueChanged(MIDIDevice*,quint32,uchar)),
			this, SLOT(slotDeviceValueChanged(MIDIDevice*,
							  quint32,
							  uchar)));

		dev->open();
	}
示例#7
0
void MIDIInput::open(t_input input)
{
	MIDIDevice* dev = device(input);
	if (dev != NULL)
	{
		connect(dev, SIGNAL(valueChanged(MIDIDevice*,
						 t_input_channel,
						 t_input_value)),
			this, SLOT(slotDeviceValueChanged(MIDIDevice*,
							  t_input_channel,
							  t_input_value)));

		dev->open();
	}
示例#8
0
MIDIDevice* MIDIOut::device(const snd_seq_addr_t* address)
{
	QListIterator <MIDIDevice*> it(m_devices);

	while (it.hasNext() == true)
	{
		MIDIDevice* dev = it.next();

		Q_ASSERT(dev != NULL);
		Q_ASSERT(dev->address() != NULL);
		
		if (dev->address()->client == address->client &&
		    dev->address()->port == address->port)
		{
			return dev;
		}
	}

	return NULL;
}
示例#9
0
文件: midiout.cpp 项目: speakman/qlc
QString MIDIOut::infoText(t_output output)
{
	QString str;

	str += QString("<HTML>");
	str += QString("<HEAD>");
	str += QString("<TITLE>%1</TITLE>").arg(name());
	str += QString("</HEAD>");
	str += QString("<BODY>");

	if (output == KOutputInvalid)
	{
		str += QString("<H3>%1</H3>").arg(name());
		str += QString("<P>");
		str += QString("This plugin provides DMX output support thru ");
		str += QString("various MIDI devices.");
		str += QString("</P>");
	}
	else
	{
		MIDIDevice* dev = device(output);
		if (dev != NULL)
		{
			str += dev->infoText();
		}
		else
		{
			str += QString("<P><I>");
			str += QString("Unable to find device. Please go to ");
			str += QString("the configuration dialog and click ");
			str += QString("the refresh button.");
			str += QString("</I></P>");
		}
	}

        str += QString("</BODY>");
        str += QString("</HTML>");

        return str;
}
示例#10
0
void ConfigureMIDIOut::refreshList()
{
	QTreeWidgetItem* item;
	MIDIDevice* dev;
	int i = 1;

	m_list->clear();

	QListIterator <MIDIDevice*> it(m_plugin->m_devices);
	while (it.hasNext() == true)
	{
		dev = it.next();

		item = new QTreeWidgetItem(m_list);
		item->setText(KColumnNumber, QString("%1").arg(i++));
		item->setText(KColumnName, dev->name());
		item->setText(KColumnMIDIChannel,
			      QString("%1").arg(dev->midiChannel() + 1));
		item->setText(KColumnMode,
			      MIDIDevice::modeToString(dev->mode()));
	}
}
示例#11
0
void MIDIOut::rescanDevices()
{
	snd_seq_client_info_t* clientInfo = NULL;
	snd_seq_port_info_t* portInfo = NULL;

	/* Don't do anything if the ALSA sequencer interface is not open */
	if (m_alsa == NULL)
		return;

	/* Copy all device pointers to a destroy list */
	QList <MIDIDevice*> destroyList(m_devices);

	/* Allocate these from stack */
	snd_seq_client_info_alloca(&clientInfo);
	snd_seq_port_info_alloca(&portInfo);

	/* Find out what kinds of clients and ports there are */
	snd_seq_client_info_set_client(clientInfo, 0); // TODO: -1 ?????
	while (snd_seq_query_next_client(m_alsa, clientInfo) == 0)
	{
		int client;

		/* Get the client ID */
		client = snd_seq_client_info_get_client(clientInfo);

		/* Ignore our own client */
		if (m_address->client == client)
			continue;

		/* Go thru all available ports in the client */
		snd_seq_port_info_set_client(portInfo, client);
		snd_seq_port_info_set_port(portInfo, -1);
		while (snd_seq_query_next_port(m_alsa, portInfo) == 0)
		{
			const snd_seq_addr_t* address;
			MIDIDevice* dev;

			address = snd_seq_port_info_get_addr(portInfo);
			if (address == NULL)
				continue;

			dev = device(address);
			if (dev == NULL)
			{
				/* New address. Create a new device for it. */
				dev = new MIDIDevice(this, address);
				Q_ASSERT(dev != NULL);

				/* Don't show QLC's internal ALSA ports */
				if (dev->name().contains("__QLC__") == false)
					addDevice(dev);
				else
					delete dev;
			}
			else
			{
				/* This device is still alive. Do not destroy
				   it at the end of this function. */
				destroyList.removeAll(dev);
			}
		}
	}

	/* All devices that were not found during rescan are clearly no longer
	   in our presence and must be destroyed. */
	while (destroyList.isEmpty() == false)
		removeDevice(destroyList.takeFirst());
}
示例#12
0
void MIDIOut::outputDMX(quint32 output, const QByteArray& universe)
{
    MIDIDevice* dev = device(output);
    if (dev != NULL)
        dev->outputDMX(universe);
}