Example #1
0
void Midi::Print(void) {
	const _midi_direction dir = GetDirection();
	const uint32_t nBaudrate = GetBaudrate();
	const uint8_t nChannel = GetChannel();

	printf("MIDI configuration:\n");
	printf(" Direction    : %s\n", dir == MIDI_DIRECTION_INPUT ? "Input" : "Output");
	if (dir == MIDI_DIRECTION_INPUT) {
		printf(" Channel      : %d %d\n", nChannel, nChannel == 0 ? "(OMNI mode)" : "");
	}
	printf(" Active sense : %s\n", GetActiveSense() ? "Enabled" : "Disabled");
	printf(" Baudrate     : %d %s\n", (int) nBaudrate, nBaudrate == MIDI_BAUDRATE_DEFAULT ? "(Default)" : "");
	printf(" Interface    : %s\n", GetInterfaceDescription());
}
Example #2
0
// IXArray<IPortInfoEntry>
BOOL CSNMP::QueryPortInfo(IXArray **pPortInfo, BOOL bUseInterfaceIDAsPortID)
{
	if (!pPortInfo)
	{
		m_strLastError = L"[QueryPortInfo] : Verify the arguments failed. ";
		return FALSE;
	}

	std::map<UINT, CString>	/* interface ID -> description */ mapInterfaceDescription;
	std::vector<std::pair<UINT, UINT>> /* port ID -> interface ID */ vPortToInterfaceList;

	if (!GetInterfaceDescription(&mapInterfaceDescription))
	{
		m_strLastError = L"Get the interface descriptions failed. ( " + m_strLastError + L" )";
		return FALSE;
	}

	if (!bUseInterfaceIDAsPortID)
		if (!GetPortToInterfaceList(&vPortToInterfaceList))
		{
			m_strLastError = L"Get the port-to-interface list failed. ( " + m_strLastError + L" )";
			return FALSE;
		}

	IXArray *pArray = NULL;

	BOOL bRes = FALSE;
	do 
	{
		if (!SMCCreateLocalInterfaceInstance(&pArray))
		{
			m_strLastError = L"[QueryPortInfo] : Create IXArray instance failed. ";
			break;
		}

		if (bUseInterfaceIDAsPortID)
		{
			std::map<UINT, CString>::const_iterator it =
				mapInterfaceDescription.begin();
			for (; it != mapInterfaceDescription.end(); it++)
			{
				IPortInfoEntry *pEntry = NULL;
				if (!SMCCreateLocalInterfaceInstance(&pEntry))
				{
					m_strLastError = L"[QueryPortInfo] : Create IPortInfoEntry instance failed. ";
					break;
				}

				pEntry->SetPortID(it->first);
				pEntry->SetInterfaceID(it->first);
				pEntry->SetPortDescription(it->second);

				pArray->push_back(pEntry);

				pEntry->Release();
			}
			if (it != mapInterfaceDescription.end())
				break;

		}
		else
		{
			std::vector<std::pair<UINT, UINT>>::size_type i = 0;
			for ( ; i < vPortToInterfaceList.size(); i++)
			{
				std::map<UINT, CString>::const_iterator itFind =
					mapInterfaceDescription.find(vPortToInterfaceList[i].second);

				if (itFind == mapInterfaceDescription.end())
				{
					assert(NULL);
					continue;
				}

				IPortInfoEntry *pEntry = NULL;
				if (!SMCCreateLocalInterfaceInstance(&pEntry))
				{
					m_strLastError = L"[QueryPortInfo] : Create IPortInfoEntry instance failed. ";
					break;
				}

				pEntry->SetPortID(vPortToInterfaceList[i].first);
				pEntry->SetInterfaceID(itFind->first);
				pEntry->SetPortDescription(itFind->second);

				pArray->push_back(pEntry);

				pEntry->Release();
			}
			if (i < vPortToInterfaceList.size())
				break;
		}

		pArray->AddRef();
		*pPortInfo = pArray;

		bRes = TRUE;
	} while (FALSE);


	if (pArray)
		pArray->Release();

	return bRes;
}