Exemplo n.º 1
0
status_t GlMidiEvent::ReadFrom(const BMessage& msg, bool portName)
{
	status_t				err;
	if (portName) {
		BString16			name;
		if ((err = msg.FindString(P_STR, &name)) != B_OK) return err;
		int32				id = 0;
		BMidiProducer*		prod;
		bool				found = false;
		while ((prod = BMidiRoster::NextProducer(&id)) != NULL) {
			if (prod->IsValid() && prod->Name() && name == prod->Name()) {
				portId = prod->ID();
				found = true;
				break;
			}
		}
		if (!found) return B_ERROR;
	} else {
		if ((err = msg.FindInt32(P_STR, &portId)) != B_OK) return err;
	}
	if ((err = msg.FindInt32(T_STR, &type)) != B_OK) return err;
	if ((err = msg.FindInt32(C_STR, &channel)) != B_OK) return err;
	if ((err = msg.FindInt32(V1_STR, &value1)) != B_OK) return err;
	if ((err = msg.FindInt32(V2_STR, &value2)) != B_OK) return err;
	return B_OK;
}
Exemplo n.º 2
0
/********************************************************
 * _ENDPOINT-LIST
 ********************************************************/
_EndpointList::_EndpointList(BRect frame)
		: inherited(frame, ENDPOINT_LIST_STR, B_FOLLOW_ALL,
					B_WILL_DRAW, B_NO_BORDER),
		  mLabelTarget(NULL), mDeviceTarget(NULL)
{
	SetSelectionMode(B_SINGLE_SELECTION_LIST);
	SetSortingEnabled(false);

	AddColumn( new SeqColoredColumn(MIDI_PORT_STR, 150, 20, 350, B_TRUNCATE_MIDDLE), 0);
	AddColumn( new SeqColoredColumn(TYPE_STR, 50, 20, 350, B_TRUNCATE_MIDDLE), 1);
	AddColumn( new SeqColoredColumn(DEVICE_STR, 150, 20, 350, B_TRUNCATE_MIDDLE), 2);
	AddColumn( new SeqColoredColumn(LABEL_STR, 50, 20, 350, B_TRUNCATE_MIDDLE), 3);

	int32 id = 0;
	BMidiProducer* prod;
	while ((prod=BMidiRoster::NextProducer(&id)) != NULL) {
		if (prod->IsValid() ) AddEndpoint(prod);
	}
	id = 0;
	BMidiConsumer* cons;
	while ((cons=BMidiRoster::NextConsumer(&id)) != NULL) {
		if (cons->IsValid() ) AddEndpoint(cons);
	}

	am_studio_endpoint		endpt;
	BString					l, m, n;
	for (uint32 k = 0; AmGlobals().GetStudioInfoAt(k, endpt, &l, &m, &n) == B_OK; k++) {
		AddChildRow(endpt, &l, &m, &n);
	}
}