本文整理汇总了C++中AudioBuffer::connect_in方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::connect_in方法的具体用法?C++ AudioBuffer::connect_in怎么用?C++ AudioBuffer::connect_in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::connect_in方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_connection
void AudioGraphProcess::add_connection(const AudioConnection& p_connection) {
//printf("connecting %lls %i to %lls %i\n",process_nodes[p_connection.from_node]->node->get_caption().c_str(),p_connection.from_port,process_nodes[p_connection.to_node]->node->get_caption().c_str(),p_connection.to_port);
ERR_FAIL_INDEX(p_connection.from_node,(int)process_nodes.size());
ERR_FAIL_INDEX(p_connection.to_node,(int)process_nodes.size());
ERR_FAIL_INDEX(p_connection.from_port,process_nodes[p_connection.from_node]->node->get_out_audio_port_count());
ERR_FAIL_INDEX(p_connection.to_port,(int)process_nodes[p_connection.to_node]->input_audio_buffers.size());
/* FIRST: Check if source node (an output) has a writing-to buffer, if not, create it */
ProcessNode *from_node=process_nodes[p_connection.from_node];
ProcessNode *to_node=process_nodes[p_connection.to_node];
switch(p_connection.type) {
case AudioNode::PORT_AUDIO: {
int chans = from_node->node->get_out_audio_port_channel_count( p_connection.from_port );
ERR_FAIL_COND( chans !=
to_node->node->get_in_audio_port_channel_count( p_connection.to_port ) );
if (!from_node->output_audio_buffers[p_connection.from_port]) {
from_node->output_audio_buffers[p_connection.from_port] = new AudioBuffer(chans);
from_node->output_audio_buffers[p_connection.from_port]->connect_out( from_node->node, p_connection.from_port );
}
/* SECOND - Check if destination node (INPUT port) is either empty/reads from buffer(1 connection) or reads from many */
if (process_nodes[p_connection.to_node]->input_audio_sources[p_connection.to_port].empty()) {
/** No one connected to this node
* Since so far after this it will have only ONE connection,
* we can set it to read directly.
*/
AudioBuffer *buff = from_node->output_audio_buffers[p_connection.from_port];
buff->connect_in( to_node->node, p_connection.to_port );
process_nodes[p_connection.to_node]->input_audio_sources[p_connection.to_port].push_back( buff );
} else {
/**
* IF it only has one connection, it means it's reading directly.
* Since now it's going to have more than one, we need a buffer to
* mix the data from the source connections.
*/
if (process_nodes[p_connection.to_node]->input_audio_sources[p_connection.to_port].size()==1) {
ERR_FAIL_COND( process_nodes[p_connection.to_node]->input_audio_buffers[p_connection.to_port]!=NULL);
AudioBuffer * buff=new AudioBuffer(chans);
process_nodes[p_connection.to_node]->input_audio_buffers[p_connection.to_port]=buff;
buff->connect_in( to_node->node, p_connection.to_port );
}
/**
* Add the Source Buffer to the listof Source Buffers
*/
AudioBuffer *src_buff=from_node->output_audio_buffers[p_connection.from_port];
process_nodes[p_connection.to_node]->input_audio_sources[p_connection.to_port].push_back(src_buff);
}
} break;
case AudioNode::PORT_EVENT: {
if (!from_node->output_event_buffers[p_connection.from_port]) {
EventBuffer *ev = new EventBuffer;
ev->resize(EVENT_BUFFER_SIZE);
from_node->output_event_buffers[p_connection.from_port] = ev;
from_node->node->connect_out_event_port_buffer(p_connection.from_port,&(*ev)[0]);
}
/* SECOND - Check if destination node (INPUT port) is either empty/reads from buffer(1 connection) or reads from many */
if (process_nodes[p_connection.to_node]->input_event_sources[p_connection.to_port].empty()) {
/** No one connected to this node
* Since so far after this it will have only ONE connection,
* we can set it to read directly.
*/
EventBuffer *buff = from_node->output_event_buffers[p_connection.from_port];
to_node->node->connect_in_event_port_buffer( p_connection.to_port, &(*buff)[0] );
//.........这里部分代码省略.........