本文整理汇总了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();
}
}
示例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;
}