Esempio n. 1
0
static void callback_send_a_buffer_create(void *user, VNodeID node_id, VBufferID buffer_id, const char *name,
        VNABlockType type, real64 frequency)
{
    VSNodeAudio *node;
    unsigned int i, j, count;

    if(frequency < 0.0)
        return;
    node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
    if(node == NULL)
        return;

    for(i = 0; i < node->buffer_count; i++)
    {
        if(buffer_id != i)
        {
            for(j = 0; name[j] == node->buffers[i].name[j] && name[j] != 0; j++);
            if(name[j] == node->buffers[i].name[j])
                return;
        }
    }

    if(buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0 && type != node->buffers[buffer_id].type)
    {
        free(node->buffers[buffer_id].data);
        vs_destroy_subscription_list(node->buffers[buffer_id].subscribers);
        node->buffers[buffer_id].name[0] = 0;
    }

    if(buffer_id >= node->buffer_count || node->buffers[buffer_id].name[0] == 0)
    {
        for(buffer_id = 0; buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0; buffer_id++);
        if(buffer_id == node->buffer_count)
        {
            buffer_id = node->buffer_count;
            node->buffer_count += 16;
            node->buffers = realloc(node->buffers, (sizeof *node->buffers) * node->buffer_count);
            for(i = buffer_id; i < node->buffer_count; i++)
                node->buffers[i].name[0] = 0;
        }
        node->buffers[buffer_id].subscribers = vs_create_subscription_list();
        node->buffers[buffer_id].type = type;
        node->buffers[buffer_id].frequency = frequency;
        node->buffers[buffer_id].length = 64;
        node->buffers[buffer_id].data = malloc(sizeof(*node->buffers[buffer_id].data) * node->buffers[buffer_id].length);
        for(i = 0; i < node->buffers[buffer_id].length; i++)
            node->buffers[buffer_id].data[i] = NULL;
    }
    for(i = 0; name[i] != 0 && i < 15; i++)
        node->buffers[buffer_id].name[i] = name[i];
    node->buffers[buffer_id].name[i] = 0;

    count =	vs_get_subscript_count(node->head.subscribers);
    for(i = 0; i < count; i++)
    {
        vs_set_subscript_session(node->head.subscribers, i);
        verse_send_a_buffer_create(node_id, buffer_id, name, type, frequency);
    }
    vs_reset_subscript_session();
}
Esempio n. 2
0
void vs_init_node_storage(void)
{
	unsigned int i;
	VSNodeStorage.nodes = malloc((sizeof *VSNodeStorage.nodes) * VS_NODE_STORAGE_CHUNK_SIZE);
	VSNodeStorage.nodes[0] = NULL;
	VSNodeStorage.node_length = 0;
	VSNodeStorage.node_allocated = VS_NODE_STORAGE_CHUNK_SIZE;
	for(i = 0; i < V_NT_NUM_TYPES; i++)
		VSNodeStorage.list[i] = vs_create_subscription_list();
}
Esempio n. 3
0
static void callback_send_a_stream_create(void *user, VNodeID node_id, VLayerID stream_id, const char *name)
{
    VSNodeAudio *node;
    unsigned int i, j, count;

    node = (VSNodeAudio *) vs_get_node(node_id, V_NT_AUDIO);
    if(node == NULL)
        return;

    for(i = 0; i < node->stream_count; i++)
    {
        if(stream_id != i)
        {
            for(j = 0; name[j] == node->streams[i].name[j] && name[j] != 0; j++);
            if(name[j] == node->streams[i].name[j])
                return;
        }
    }
    if(stream_id >= node->stream_count || node->streams[stream_id].name[0] == 0)
    {
        for(stream_id = 0; stream_id < node->stream_count && node->streams[stream_id].name[0] != 0; stream_id++);
        if(stream_id == node->stream_count)
        {
            stream_id = node->stream_count;
            node->stream_count += 16;
            node->streams = realloc(node->streams, (sizeof *node->streams) * node->stream_count);
            for(i = stream_id; i < node->stream_count; i++)
                node->streams[i].name[0] = 0;
        }
        node->streams[stream_id].subscribers = vs_create_subscription_list();
    }
    for(i = 0; name[i] != 0 && i < 15; i++)
        node->streams[stream_id].name[i] = name[i];
    node->streams[stream_id].name[i] = 0;
    count =	vs_get_subscript_count(node->head.subscribers);
    for(i = 0; i < count; i++)
    {
        vs_set_subscript_session(node->head.subscribers, i);
        verse_send_a_stream_create(node_id, stream_id, name);
    }
    vs_reset_subscript_session();
}
Esempio n. 4
0
static void callback_send_c_curve_create(void *user, VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions)
{
	VSNodeCurve *node;
	unsigned int i, j, count;
	node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
	if(node == NULL)
		return;

	for(i = 0; i < node->curve_count; i++)
	{
		if(curve_id != i)
		{
			for(j = 0; name[j] == node->curves[i].name[j] && name[j] != 0; j++);
			if(name[j] == node->curves[i].name[j])
				return;
		}
	}
	if(curve_id >= node->curve_count || node->curves[curve_id].name[0] == 0)
	{
		for(curve_id = 0; curve_id < node->curve_count && node->curves[curve_id].name[0] != 0; curve_id++);
		if(curve_id == node->curve_count)
		{
			curve_id = node->curve_count;
			node->curve_count += 16;
			node->curves = realloc(node->curves, (sizeof *node->curves) * node->curve_count);
			for(i = curve_id; i < node->curve_count; i++)
				node->curves[i].name[0] = 0;		
		}
		node->curves[curve_id].subscribers = vs_create_subscription_list();
		node->curves[curve_id].length = 64;
		node->curves[curve_id].keys = malloc((sizeof *node->curves[curve_id].keys) * 64);
		for(i = 0; i < 64; i++)
			node->curves[curve_id].keys[i].pos = V_REAL64_MAX;			

	}else if(node->curves[curve_id].dimensions != dimensions)
	{
		for(i = 0; i < node->curves[curve_id].length; i++)
		{
			if(node->curves[curve_id].keys[i].pos != V_REAL64_MAX)
			{
				for(j = node->curves[curve_id].dimensions; j < dimensions; j++)
				{
					node->curves[curve_id].keys[i].pre_value[j] = node->curves[curve_id].keys[i].pre_value[0];
					node->curves[curve_id].keys[i].pre_pos[j] = node->curves[curve_id].keys[i].pre_pos[0];
					node->curves[curve_id].keys[i].value[j] = node->curves[curve_id].keys[i].value[0];
					node->curves[curve_id].keys[i].post_value[j] = node->curves[curve_id].keys[i].post_value[0];
					node->curves[curve_id].keys[i].post_pos[j] = node->curves[curve_id].keys[i].post_pos[0];
				}
			}
		}
		vs_destroy_subscription_list(node->curves[curve_id].subscribers);
		node->curves[curve_id].subscribers = vs_create_subscription_list();
	}
	for(i = 0; name[i] != 0 && i < 15; i++)
		node->curves[curve_id].name[i] = name[i];
	node->curves[curve_id].name[i] = 0;
	node->curves[curve_id].dimensions = dimensions;
	count =	vs_get_subscript_count(node->head.subscribers);
	for(i = 0; i < count; i++)
	{
		vs_set_subscript_session(node->head.subscribers, i);
		verse_send_c_curve_create(node_id, curve_id, name, dimensions);
	}
	vs_reset_subscript_session();
}