Exemplo n.º 1
0
void ProcessorGraph::setRecordState(bool isRecording)
{

    // actually start recording
    if (isRecording)
    {
        getRecordNode()->setParameter(1,10.0f);
    }
    else
    {
        getRecordNode()->setParameter(0,10.0f);
    }

    for (int i = 0; i < getNumNodes(); i++)
    {
        Node* node = getNode(i);
        if (node->nodeId != OUTPUT_NODE_ID)
        {
            GenericProcessor* p = (GenericProcessor*) node->getProcessor();

            p->setRecording(isRecording);
        }
    }



}
Exemplo n.º 2
0
void ProcessorGraph::setRecordState(bool isRecording)
{

   // const MessageManagerLock mmLock; // lock the message manager to prevent rendering crashes
    
    // inform other processors that recording will begin

    // actually start recording
    if (isRecording)
    {
        getRecordNode()->setParameter(1,10.0f);
    } else {
        getRecordNode()->setParameter(0,10.0f);
    }
    
    for (int i = 0; i < getNumNodes(); i++)
    {
        Node* node = getNode(i);
        if (node->nodeId != OUTPUT_NODE_ID)
        {
            GenericProcessor* p = (GenericProcessor*) node->getProcessor();
            
            if (isRecording)
                p->startRecording();
            else
                p->stopRecording();
            
        }
    }
    
    
    
}
Exemplo n.º 3
0
void ProcessorGraph::connectProcessorToAudioAndRecordNodes(GenericProcessor* source)
{

    if (source == nullptr)
        return;

    getRecordNode()->registerProcessor(source);

    for (int chan = 0; chan < source->getNumOutputs(); chan++)
    {

        getAudioNode()->addInputChannel(source, chan);

        // THIS IS A HACK TO MAKE SURE AUDIO NODE KNOWS WHAT THE SAMPLE RATE SHOULD BE
        // IT CAN CAUSE PROBLEMS IF THE SAMPLE RATE VARIES ACROSS PROCESSORS

		//TODO: See if this causes problems with the newer architectures
        //getAudioNode()->settings.sampleRate = source->getSampleRate();

        addConnection(source->getNodeId(),                   // sourceNodeID
                      chan,                                  // sourceNodeChannelIndex
                      AUDIO_NODE_ID,                         // destNodeID
                      getAudioNode()->getNextChannel(true)); // destNodeChannelIndex

        getRecordNode()->addInputChannel(source, chan);

        addConnection(source->getNodeId(),                    // sourceNodeID
                      chan,                                   // sourceNodeChannelIndex
                      RECORD_NODE_ID,                         // destNodeID
                      getRecordNode()->getNextChannel(true)); // destNodeChannelIndex

    }

    // connect event channel
    addConnection(source->getNodeId(),    // sourceNodeID
                  midiChannelIndex,       // sourceNodeChannelIndex
                  RECORD_NODE_ID,         // destNodeID
                  midiChannelIndex);      // destNodeChannelIndex

    // connect event channel
    addConnection(source->getNodeId(),    // sourceNodeID
                  midiChannelIndex,       // sourceNodeChannelIndex
                  AUDIO_NODE_ID,          // destNodeID
                  midiChannelIndex);      // destNodeChannelIndex


    getRecordNode()->addInputChannel(source, midiChannelIndex);

}
Exemplo n.º 4
0
void ProcessorGraph::updatePointers()
{
    getAudioNode()->setUIComponent(getUIComponent());
    getAudioNode()->updateBufferSize();
    getRecordNode()->setUIComponent(getUIComponent());
    getMessageCenter()->setUIComponent(getUIComponent());
}
Exemplo n.º 5
0
void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSection> tabs)
{
    clearConnections(); // clear processor graph

    std::cout << "Updating connections:" << std::endl;

    Array<GenericProcessor*> splitters;

    for (int n = 0; n < tabs.size(); n++)
    {
        std::cout << "Signal chain " << n << std::endl;

        GenericEditor* sourceEditor = (GenericEditor*) tabs[n]->getEditor();
        GenericProcessor* source = (GenericProcessor*) sourceEditor->getProcessor();

        while (source != 0)// && destEditor->isEnabled())
        {
            std::cout << "Source node: " << source->getName() << ", ";
            GenericProcessor* dest = (GenericProcessor*) source->getDestNode();

            if (dest != 0)
            {
                std::cout << "Dest node: " << dest->getName() << std::endl;
                if (dest->isMerger()) // move it forward by one
                {
                    dest = dest->getDestNode();
                }
                else if (dest->isSplitter())
                {
                    if (!dest->wasConnected)
                        splitters.add(dest);

                    dest = dest->getDestNode();
                }

            }
            else
            {
                std::cout << "no dest node." << std::endl;
            }

            if (source->enabledState())
            {

                // add the connections to audio and record nodes if necessary
                if (!(source->isSink() ||
                      source->isSplitter() || source->isMerger() || source->isUtility()) && !(source->wasConnected))
                {
                    std::cout << "   Connecting to audio and record nodes." << std::endl;

                    //source->setStartChannel(getAudioNode()->getNextChannel(false));


                    for (int chan = 0; chan < source->getNumOutputs(); chan++)
                    {

                        getAudioNode()->addInputChannel(source, chan);

                        // std::cout << "Connecting to audio channel: " <<
                        // 	      getAudioNode()->getNextChannel(false) << std::endl;

                        //getAudioNode()->enableCurrentChannel(source->audioStatus(chan));

                        addConnection(source->getNodeId(), 		   // sourceNodeID
                                      chan, 						           // sourceNodeChannelIndex
                                      AUDIO_NODE_ID, 					       // destNodeID
                                      getAudioNode()->getNextChannel(true)); // destNodeChannelIndex
                        // add 2 to account for 2 output channels


                        //std::cout << getAudioNode()->getNextChannel(false) << " ";

                        getRecordNode()->addInputChannel(source, chan);

                        // std::cout << "Connecting to record channel: " <<
                        // 	      getRecordNode()->getNextChannel(false) << std::endl;


                        addConnection(source->getNodeId(),          // sourceNodeID
                                      chan,                                   // sourceNodeChannelIndex
                                      RECORD_NODE_ID, 					    // destNodeID
                                      getRecordNode()->getNextChannel(true)); // destNodeChannelIndex

                    }

                    // connect event channel
                    addConnection(source->getNodeId(), 				// sourceNodeID
                                  midiChannelIndex, 							// sourceNodeChannelIndex
                                  RECORD_NODE_ID, 							// destNodeID
                                  midiChannelIndex);							// destNodeChannelIndex

                    // connect event channel
                    addConnection(source->getNodeId(), 				// sourceNodeID
                                  midiChannelIndex, 							// sourceNodeChannelIndex
                                  AUDIO_NODE_ID, 							// destNodeID
                                  midiChannelIndex);							// destNodeChannelIndex


                    getRecordNode()->addInputChannel(source, midiChannelIndex);

                }

                std::cout << std::endl;

                if (dest != 0)
                {

                    if (dest->enabledState())
                        std::cout << "     OK." << std::endl;
                    else
                        std::cout << "     Not OK." << std::endl;

                    if (dest->enabledState())
                    {

                        std::cout << "     Connecting " << source->getName() << " channel ";

                        for (int chan = 0; chan < source->getNumOutputs(); chan++)
                        {
                            std::cout << chan << " ";

                            addConnection(source->getNodeId(), // sourceNodeID
                                          chan, // sourceNodeChannelIndex
                                          dest->getNodeId(), // destNodeID
                                          dest->getNextChannel(true)); // destNodeChannelIndex
                        }

                        std::cout << " to " << dest->getName() << std::endl;

                        std::cout << "     Connecting " << source->getName() <<
                                  " event channel to " <<
                                  dest->getName() << std::endl;

                        // connect event channel
                        addConnection(source->getNodeId(), // sourceNodeID
                                      midiChannelIndex, // sourceNodeChannelIndex
                                      dest->getNodeId(), // destNodeID
                                      midiChannelIndex); // destNodeChannelIndex

                    }

                }
            }

            source->wasConnected = true;
            source = dest; // switch source and dest

            if (source == 0 && splitters.size() > 0)
            {
                dest = splitters.getFirst(); // dest is now the splitter
                splitters.remove(0); // take it out of the
                dest->switchIO(); // switch to the other destination
                dest->wasConnected = true; // don't want to re-add splitter
                source = dest->getSourceNode(); // splitter is now source
            }

        } // end while source != 0
    } // end "tabs" for loop
} // end method
Exemplo n.º 6
0
bool ProcessorGraph::enableProcessors()
{

    updateConnections(AccessClass::getEditorViewport()->requestSignalChain());

    std::cout << "Enabling processors..." << std::endl;

    bool allClear;

    if (getNumNodes() < 5)
    {
        AccessClass::getUIComponent()->disableCallbacks();
        return false;
    }

    for (int i = 0; i < getNumNodes(); i++)
    {

        Node* node = getNode(i);

        if (node->nodeId != OUTPUT_NODE_ID)
        {
            GenericProcessor* p = (GenericProcessor*) node->getProcessor();
            allClear = p->isReady();

            if (!allClear)
            {
                std::cout << p->getName() << " said it's not OK." << std::endl;
                //	sendActionMessage("Could not initialize acquisition.");
                AccessClass::getUIComponent()->disableCallbacks();
                return false;

            }
        }
    }

    for (int i = 0; i < getNumNodes(); i++)
    {

        Node* node = getNode(i);

        if (node->nodeId != OUTPUT_NODE_ID)
        {
            GenericProcessor* p = (GenericProcessor*) node->getProcessor();
            p->enableEditor();
            p->enableProcessor();
        }
    }

    AccessClass::getEditorViewport()->signalChainCanBeEdited(false);

	//Update special channels indexes, at the end
	//To change, as many other things, when the probe system is implemented
	getRecordNode()->updateRecordChannelIndexes();
	getAudioNode()->updateRecordChannelIndexes();

    //	sendActionMessage("Acquisition started.");
	m_startSoftTimestamp = Time::getHighResolutionTicks();
	if (m_timestampWindow)
		m_timestampWindow->setAcquisitionState(true);
    return true;
}
Exemplo n.º 7
0
void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSection> tabs)
{
    clearConnections(); // clear processor graph

    std::cout << "Updating connections:" << std::endl;
    std::cout << std::endl;
    std::cout << std::endl;

    Array<GenericProcessor*> splitters;
    // GenericProcessor* activeSplitter = nullptr;

    for (int n = 0; n < tabs.size(); n++) // cycle through the tabs
    {
        std::cout << "Signal chain: " << n << std::endl;
        std::cout << std::endl;

        GenericEditor* sourceEditor = (GenericEditor*) tabs[n]->getEditor();
        GenericProcessor* source = (GenericProcessor*) sourceEditor->getProcessor();

        while (source != nullptr)// && destEditor->isEnabled())
        {
            std::cout << "Source node: " << source->getName() << "." << std::endl;
            GenericProcessor* dest = (GenericProcessor*) source->getDestNode();

            if (source->isEnabledState())
            {
                // add the connections to audio and record nodes if necessary
                if (!(source->isSink()     ||
                      source->isSplitter() ||
                      source->isMerger()   ||
                      source->isUtility())
                    && !(source->wasConnected))
                {
                    std::cout << "     Connecting to audio and record nodes." << std::endl;
                    connectProcessorToAudioAndRecordNodes(source);
                }
                else
                {
                    std::cout << "     NOT connecting to audio and record nodes." << std::endl;
                }

                if (dest != nullptr)
                {

                    while (dest->isMerger()) // find the next dest that's not a merger
                    {
                        dest = dest->getDestNode();

                        if (dest == nullptr)
                            break;
                    }

                    if (dest != nullptr)
                    {
                        while (dest->isSplitter())
                        {
                            if (!dest->wasConnected)
                            {
                                if (!splitters.contains(dest))
                                {
                                    splitters.add(dest);
                                    dest->switchIO(0); // go down first path
                                }
                                else
                                {
                                    int splitterIndex = splitters.indexOf(dest);
                                    splitters.remove(splitterIndex);
                                    dest->switchIO(1); // go down second path
                                    dest->wasConnected = true; // make sure we don't re-use this splitter
                                }
                            }

                            dest = dest->getDestNode();

                            if (dest == nullptr)
                                break;
                        }

                        if (dest != nullptr)
                        {

                            if (dest->isEnabledState())
                            {
                                connectProcessors(source, dest);
                            }
                        }

                    }
                    else
                    {
                        std::cout << "     No dest node." << std::endl;
                    }

                }
                else
                {
                    std::cout << "     No dest node." << std::endl;
                }
            }

            std::cout << std::endl;

            source->wasConnected = true;
            source = dest; // switch source and dest

            if (source == nullptr && splitters.size() > 0)
            {

                source = splitters.getLast();
                GenericProcessor* newSource;// = source->getSourceNode();

                while (source->isSplitter() || source->isMerger())
                {
                    newSource = source->getSourceNode();
                    newSource->setPathToProcessor(source);
                    source = newSource;
                }

            }

        } // end while source != 0
    } // end "tabs" for loop
	
	//Update RecordNode internal channel mappings
	Array<EventChannel*> extraChannels;
	getMessageCenter()->addSpecialProcessorChannels(extraChannels);
	getRecordNode()->addSpecialProcessorChannels(extraChannels);
} // end method