当前位置: 首页>>代码示例>>C++>>正文


C++ NodeRef::set_input方法代码示例

本文整理汇总了C++中NodeRef::set_input方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRef::set_input方法的具体用法?C++ NodeRef::set_input怎么用?C++ NodeRef::set_input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeRef的用法示例。


在下文中一共展示了NodeRef::set_input方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	AudioGraphRef graph = new AudioGraph();

	/*------------------------------------------------------------------------
	 * Create a simple envelope-modulated triangle wave.
	 *-----------------------------------------------------------------------*/
	NodeRef triangle = new Triangle(1000);
	NodeRef envelope = new ASR(0.01, 0.0, 0.1);
	NodeRef output = triangle * envelope;

	/*------------------------------------------------------------------------
	 * Pan the output across the stereo field.
	 *-----------------------------------------------------------------------*/
	NodeRef panned = new Pan(2, output);

	graph->add_output(panned);
	graph->start();

	while (true)
	{
		/*------------------------------------------------------------------------
		 * Periodically, retrigger the envelope, panned to a random location.
		 *-----------------------------------------------------------------------*/
		usleep(random_integer(1e4, 1e6));
		panned->set_input("pan", random_uniform(-1, 1));
		envelope->trigger();
	}
}
开发者ID:cequencer,项目名称:signal,代码行数:29,代码来源:trigger-example.cpp

示例2: instantiate

NodeRef Synth::instantiate(NodeDefinition *nodedef)
{
	/*------------------------------------------------------------------------
	 * Recursively instantiate the subgraph specified in NodeDefinition.
	 * Does not currently support graphs that route one node to multiple
	 * inputs.
	 *-----------------------------------------------------------------------*/
	NodeRegistry *registry = NodeRegistry::global();

	Node *node = registry->create(nodedef->name);
	NodeRef noderef = NodeRef(node);

	/*------------------------------------------------------------------------
	 * Update the synth's internal collection of node refs.
	 *-----------------------------------------------------------------------*/
	this->nodes.insert(noderef);

	for (auto param : nodedef->params)
	{
		std::string param_name = param.first;
		NodeRef param_node = this->instantiate(param.second);
		noderef->set_input(param_name, param_node);
	}

	if (nodedef->is_constant)
	{
		Constant *constant = (Constant *) node;
		constant->value = nodedef->value;
	}

	if (!nodedef->input_name.empty())
	{
		this->inputs[nodedef->input_name] = noderef;
	}

	return noderef;
}
开发者ID:cequencer,项目名称:signal,代码行数:37,代码来源:synth.cpp


注:本文中的NodeRef::set_input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。