Beispiel #1
0
SCErr meth_s_newargs(World *inWorld, int inSize, char *inData, ReplyAddress* /*inReply*/)
{
	SCErr err;
	sc_msg_iter msg(inSize, inData);
	int32 *defname = msg.gets4();
	if (!defname) return kSCErr_WrongArgType;

	int32 nodeID = msg.geti();
	int32 addAction = msg.geti();

	GraphDef *def = World_GetGraphDef(inWorld, defname);
	if (!def) {
		scprintf("*** ERROR: SynthDef %s not found\n", (char*)defname);
		return kSCErr_SynthDefNotFound;
	}

	Graph *graph = 0;
	switch (addAction) {
		case 0 : {
			Group *group = Msg_GetGroup(inWorld, msg);
			if (!group) return kSCErr_GroupNotFound;
			err = Graph_New(inWorld, def, nodeID, &msg, &graph,false);//false for setn type args
			if (err) return err;
			if (!graph) return kSCErr_Failed;
			Group_AddHead(group, &graph->mNode);
		} break;
		case 1 : {
			Group *group = Msg_GetGroup(inWorld, msg);
			if (!group) return kSCErr_GroupNotFound;
			err = Graph_New(inWorld, def, nodeID, &msg, &graph,false);
			if (err) return err;
			Group_AddTail(group, &graph->mNode);
		} break;
		case 2 : {
			Node *beforeThisNode = Msg_GetNode(inWorld, msg);
			if (!beforeThisNode) return kSCErr_NodeNotFound;
			err = Graph_New(inWorld, def, nodeID, &msg, &graph,false);
			if (err) return err;
			Node_AddBefore(&graph->mNode, beforeThisNode);
		} break;
		case 3 : {
			Node *afterThisNode = Msg_GetNode(inWorld, msg);
			if (!afterThisNode) return kSCErr_NodeNotFound;
			err = Graph_New(inWorld, def, nodeID, &msg, &graph,false);
			if (err) return err;
			Node_AddAfter(&graph->mNode, afterThisNode);
		} break;
		case 4 : {
			Node *replaceThisNode = Msg_GetNode(inWorld, msg);
			if (!replaceThisNode) return kSCErr_NodeNotFound;
			err = Graph_New(inWorld, def, nodeID, &msg, &graph,false);
			if (err) return err;
			Node_Replace(&graph->mNode, replaceThisNode);
		} break;
		default: return kSCErr_Failed;
	}
	Node_StateMsg(&graph->mNode, kNode_Go);
	return kSCErr_None;
}
Beispiel #2
0
void GraphDef_Remove(World *inWorld, int32 *inName)
{
	GraphDef* graphDef = World_GetGraphDef(inWorld, inName);
	if (graphDef) {
		World_RemoveGraphDef(inWorld, graphDef);
		if (--graphDef->mRefCount == 0) {
			GraphDef_DeleteMsg(inWorld, graphDef);
		}
	}
}
Beispiel #3
0
SCErr GraphDef_Remove(World *inWorld, int32 *inName)
{
	GraphDef* graphDef = World_GetGraphDef(inWorld, inName);
	if (graphDef) {
		World_RemoveGraphDef(inWorld, graphDef);
		if (--graphDef->mRefCount == 0) {
			return GraphDef_DeleteMsg(inWorld, graphDef);
		}
	}
	return kSCErr_None;
}
Beispiel #4
0
void GraphDef_Define(World *inWorld, GraphDef *inList)
{
	GraphDef *graphDef = inList;
	while (graphDef) {
		GraphDef *next = graphDef->mNext;

		GraphDef* previousDef = World_GetGraphDef(inWorld, graphDef->mNodeDef.mName);
		if (previousDef) {
			World_RemoveGraphDef(inWorld, previousDef);
			if (--previousDef->mRefCount == 0) {
				GraphDef_DeleteMsg(inWorld, previousDef);
			}
		}
		World_AddGraphDef(inWorld, graphDef);
		graphDef->mNext = 0;
		graphDef = next;
	}
}