예제 #1
0
파일: OSCData.cpp 프로젝트: scztt/sc-debug
int prArray_OSCBytes(VMGlobals *g, int numArgsPushed)
{
	PyrSlot* a = g->sp;
	PyrObject *array = a->uo;
	PyrSlot* args = array->slots;
	int numargs = array->size;
	if (numargs < 1) return errFailed;
	big_scpacket packet;

	if (IsFloat(args) || IsNil(args) || IsInt(args)) {
		makeSynthBundle(&packet, args, numargs, false);
	} else if (IsSym(args) || isKindOfSlot(args, class_string)) {
		makeSynthMsgWithTags(&packet, args, numargs);
	} else {
		return errWrongType;
	}

	int size = packet.size();
	PyrInt8Array* obj = newPyrInt8Array(g->gc, size, 0, true);
	obj->size = size;
	memcpy(obj->b, packet.data(), size);
	SetObject(a, (PyrObject*)obj);
	//for (int i=0; i<packet.size()/4; i++) post("%d %08X\n", i, packet.buf[i]);

	return errNone;
}
예제 #2
0
파일: OSCData.cpp 프로젝트: scztt/sc-debug
int prNetAddr_BundleSize(VMGlobals *g, int numArgsPushed)
{
	PyrSlot* args = g->sp;
	big_scpacket packet;
	int numargs = args->uo->size;
	if (numargs < 1) return errFailed;
	makeSynthBundle(&packet, args->uo->slots, numargs, true);
	SetInt(args, packet.size());
	return errNone;
}
예제 #3
0
파일: OSCData.cpp 프로젝트: scztt/sc-debug
int prNetAddr_SendBundle(VMGlobals *g, int numArgsPushed)
{
	PyrSlot* netAddrSlot = g->sp - numArgsPushed + 1;
	PyrSlot* args = netAddrSlot + 1;
	big_scpacket packet;

	double time;
	int err = slotDoubleVal(args, &time);
	if (!err) {
		time += g->thread->seconds.uf;
		SetFloat(args, time);
	}
	int numargs = numArgsPushed - 1;
	makeSynthBundle(&packet, args, numargs, true);

	//for (int i=0; i<packet.size()/4; i++) post("%d %08X\n", i, packet.buf[i]);

	return netAddrSend(netAddrSlot->uo, packet.size(), (char*)packet.buf);
}
예제 #4
0
static int addMsgSlot(big_scpacket *packet, PyrSlot *slot)
{
	switch (GetTag(slot)) {
		case tagInt :
			packet->addi(slotRawInt(slot));
			break;
		case tagSym :
			packet->adds(slotRawSymbol(slot)->name);
			break;
		case tagObj :
			if (isKindOf(slotRawObject(slot), class_string)) {
				PyrString *stringObj = slotRawString(slot);
				packet->adds(stringObj->s, stringObj->size);
			} else if (isKindOf(slotRawObject(slot), class_int8array)) {
				PyrInt8Array *arrayObj = slotRawInt8Array(slot);
				packet->addb(arrayObj->b, arrayObj->size);
			} else if (isKindOf(slotRawObject(slot), class_array)) {
				PyrObject *arrayObj = slotRawObject(slot);
				big_scpacket packet2;
				if (arrayObj->size > 1 && isKindOfSlot(arrayObj->slots+1, class_array)) {
					makeSynthBundle(&packet2, arrayObj->slots, arrayObj->size, true);
				} else {
					int error = makeSynthMsgWithTags(&packet2, arrayObj->slots, arrayObj->size);
					if (error != errNone)
						return error;
				}
				packet->addb((uint8*)packet2.data(), packet2.size());
			}
			break;
		case tagNil :
		case tagTrue :
		case tagFalse :
		case tagChar :
		case tagPtr :
			break;
		default :
			if (gUseDoubles) packet->addd(slotRawFloat(slot));
			else packet->addf(slotRawFloat(slot));
			break;
	}
	return errNone;
}
예제 #5
0
파일: OSCData.cpp 프로젝트: scztt/sc-debug
void addMsgSlot(big_scpacket *packet, PyrSlot *slot)
{
	switch (slot->utag) {
		case tagInt :
			packet->addi(slot->ui);
			break;
		case tagSym :
			packet->adds(slot->us->name);
			break;
		case tagObj :
			if (isKindOf(slot->uo, class_string)) {
				PyrString *stringObj = slot->uos;
				packet->adds(stringObj->s, stringObj->size);
			} else if (isKindOf(slot->uo, class_int8array)) {
				PyrInt8Array *arrayObj = slot->uob;
				packet->addb(arrayObj->b, arrayObj->size);
			} else if (isKindOf(slot->uo, class_array)) {
				PyrObject *arrayObj = slot->uo;
				big_scpacket packet2;
				if (arrayObj->size > 1 && isKindOfSlot(arrayObj->slots+1, class_array)) {
					makeSynthBundle(&packet2, arrayObj->slots, arrayObj->size, true);
				} else {
					makeSynthMsgWithTags(&packet2, arrayObj->slots, arrayObj->size);
				}
				packet->addb((uint8*)packet2.data(), packet2.size());
			}
			break;
		case tagNil :
		case tagTrue :
		case tagFalse :
		case tagChar :
		case tagPtr :
			break;
		default :
			if (gUseDoubles) packet->addd(slot->uf);
			else packet->addf(slot->uf);
			break;
	}
}