Exemplo n.º 1
0
void ControlPanel::updateChildComponents()
{

    filenameComponent->addListener(getProcessorGraph()->getRecordNode());
    getProcessorGraph()->getRecordNode()->filenameComponentChanged(filenameComponent);

}
Exemplo n.º 2
0
void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int samplePosition)
{

    //std::cout << "Received event of type " << eventType << std::endl;

    if (eventType == SPIKE)
    {

        const uint8_t* dataptr = event.getRawData();
        int bufferSize = event.getRawDataSize();

        if (bufferSize > 0)
        {

            SpikeObject newSpike;

            bool isValid = unpackSpike(&newSpike, dataptr, bufferSize);

            if (isValid)
            {
                int electrodeNum = newSpike.source;

                Electrode& e = electrodes.getReference(electrodeNum);
                // std::cout << electrodeNum << std::endl;

                bool aboveThreshold = false;

                // update threshold / check threshold
                for (int i = 0; i < e.numChannels; i++)
                {
                    e.detectorThresholds.set(i, float(newSpike.threshold[i])); // / float(newSpike.gain[i]));

                    aboveThreshold = aboveThreshold | checkThreshold(i, e.displayThresholds[i], newSpike);
                }

                if (aboveThreshold)
                {

                    // add to buffer
                    if (e.currentSpikeIndex < displayBufferSize)
                    {
                        //  std::cout << "Adding spike " << e.currentSpikeIndex + 1 << std::endl;
                        e.mostRecentSpikes.set(e.currentSpikeIndex, newSpike);
                        e.currentSpikeIndex++;
                    }

                    // save spike
                    if (isRecording)
                    {
						getProcessorGraph()->getRecordNode()->writeSpike(newSpike,e.recordIndex);
                    }
                }

            }

        }

    }

}
Exemplo n.º 3
0
void SpikeDisplayNode::updateSettings()
{
    //std::cout << "Setting num inputs on SpikeDisplayNode to " << getNumInputs() << std::endl;

    electrodes.clear();

    for (int i = 0; i < eventChannels.size(); i++)
    {
        if ((eventChannels[i]->eventType < 999) && (eventChannels[i]->eventType > SPIKE_BASE_CODE))
        {

            Electrode elec;
            elec.numChannels = eventChannels[i]->eventType - 100;
            elec.name = eventChannels[i]->name;
            elec.currentSpikeIndex = 0;
            elec.mostRecentSpikes.ensureStorageAllocated(displayBufferSize);

            for (int j = 0; j < elec.numChannels; j++)
            {
                elec.displayThresholds.add(0);
                elec.detectorThresholds.add(0);
            }
            
            electrodes.add(elec);
        }
    }

    recordNode = getProcessorGraph()->getRecordNode();
    diskWriteLock = recordNode->getLock();

}
Exemplo n.º 4
0
bool RecordControl::enable()
{
    if (recordNode == 0)
        recordNode = getProcessorGraph()->getRecordNode();

    //recordNode->appendTrialNumber(createNewFilesOnTrigger);

    return true;
}
Exemplo n.º 5
0
bool SpikeDisplayNode::enable()
{
    std::cout << "SpikeDisplayNode::enable()" << std::endl;
    SpikeDisplayEditor* editor = (SpikeDisplayEditor*) getEditor();

	getProcessorGraph()->getRecordNode()->registerSpikeSource(this);
	for (int i = 0; i < electrodes.size(); i ++)
	{
		Electrode& elec = electrodes.getReference(i);
		SpikeRecordInfo *recElec = new SpikeRecordInfo();
		recElec->name = elec.name;
		recElec->numChannels = elec.numChannels;
		recElec->sampleRate = settings.sampleRate;
		elec.recordIndex = getProcessorGraph()->getRecordNode()->addSpikeElectrode(recElec);
	}

    editor->enable();
    return true;

}
Exemplo n.º 6
0
void MergerEditor::mouseDown(const MouseEvent& e)
{



    if (e.mods.isRightButtonDown())
    {

        PopupMenu m;
        m.addItem(1, "Choose input 2:",false);

        Array<GenericProcessor*> availableProcessors = getProcessorGraph()->getListOfProcessors();

        for (int i = 0; i < availableProcessors.size(); i++)
        {
            if (!availableProcessors[i]->isSink() && 
                !availableProcessors[i]->isMerger() &&
                !availableProcessors[i]->isSplitter() &&
                availableProcessors[i]->getDestNode() != getProcessor())
            {

                String name = String(availableProcessors[i]->getNodeId());
                name += " - ";
                name += availableProcessors[i]->getName();

                m.addItem(i+2, name);
                //processorsInList.add(availableProcessors[i]);
            }
        }

        const int result = m.show();

        if (result > 1)
        {
            std::cout << "Selected " << availableProcessors[result-2]->getName() << std::endl;
        
            switchSource(1);

            Merger* processor = (Merger*) getProcessor();
            processor->setMergerSourceNode(availableProcessors[result-2]);
            availableProcessors[result-2]->setDestNode(getProcessor());

            getGraphViewer()->updateNodeLocations();

            getEditorViewport()->makeEditorVisible(this, false, true);
        }
    }

    

}
Exemplo n.º 7
0
void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
{

    if (chan != getProcessorGraph()->midiChannelIndex)
    {

        int channelIndex = getNextChannel(false);

        setPlayConfigDetails(channelIndex+1,0,44100.0,128);

        channelPointers.add(sourceNode->channels[chan]);

        //   std::cout << channelIndex << std::endl;

        updateFileName(channelPointers[channelIndex]);



        //if (channelPointers[channelIndex]->isRecording)
        //	std::cout << "  This channel will be recorded." << std::endl;
        //else
        //	std::cout << "  This channel will NOT be recorded." << std::endl;

        //std::cout << "adding channel " << getNextChannel(false) << std::endl;

        //std::pair<int, Channel> newPair (getNextChannel(false), newChannel);

        //std::cout << "adding channel " << getNextChannel(false) << std::endl;

        //continuouschannelPointers.insert(newPair);


    }
    else
    {

        for (int n = 0; n < sourceNode->eventChannels.size(); n++)
        {

            eventChannelPointers.add(sourceNode->eventChannels[n]);

        }

    }

}
Exemplo n.º 8
0
void SpikeSortingDisplay::updateSettings()
{
    electrodes.clear();

    for (int i = 0; i < eventChannels.size(); i++)
    {
        if ((eventChannels[i]->eventType < 999) && (eventChannels[i]->eventType > SPIKE_BASE_CODE))
        {

            Electrode elec;
            elec.numChannels = eventChannels[i]->eventType - 100;
            elec.name = eventChannels[i]->name;
            elec.currentSpikeIndex = 0;
            elec.mostRecentSortedSpikes.ensureStorageAllocated(displayBufferSize);
            electrodes.add(elec);
        }
    }
    // Set K
    ProcessorGraph* gr = getProcessorGraph();
    Array<GenericProcessor*> p = gr->getListOfProcessors();
    ParameterEstimator* node;
    bool flag = false;
    for (int k=0;k<p.size();k++)
    {
        if (p[k]->getName() == "Parameter Estimator")
        {
            node = (ParameterEstimator*)p[k];
            flag = true;
        }

    }
    if (!flag)
    {
        std::cout << "Could not find a Parameter Estimator." << std::endl;
        svdCols = 3;
    }
    else
    {
        svdCols = node->SVDCols;
        std::cout << "SVDCols is now " << node->SVDCols <<  "  /  ";
    }
    // endof Set K

    getRippleDetectorPointer();
}
Exemplo n.º 9
0
void SpikeSortingDisplay::getRippleDetectorPointer()
{
    ProcessorGraph* gr = getProcessorGraph();
    juce::Array<GenericProcessor*> p = gr->getListOfProcessors();

    bool flag = false;
    for (int k=0;k<p.size();k++)
    {
        if (p[k]->getName() == "Ripple Detector")
        {
            node = (RippleDetector*)p[k];
            flag = true;
            std::cout << "Sorted Spike Viewer did find the Ripple Detector." << std::endl;
        }

    }
    if (!flag)
    {
        std::cout << "Could not find a the Ripple Detector." << std::endl;
    }
}
Exemplo n.º 10
0
int getRecordingNumber()
{
	return getProcessorGraph()->getRecordNode()->getRecordingNumber();
}
Exemplo n.º 11
0
void ProcessorList::mouseDownInCanvas(const MouseEvent& e) 
{

	isDragging = false;

	Point<int> pos = e.getPosition();
	int xcoord = pos.getX();
	int ycoord = pos.getY();

	//std::cout << xcoord << " " << ycoord << std::endl;

	ProcessorListItem* fli = getListItemForYPos(ycoord);

	if (fli != 0) 
	{
		//std::cout << "Selecting: " << fli->getName() << std::endl;
		if (!fli->hasSubItems()){
			clearSelectionState();
			fli->setSelected(true);
		}
			
	} else {
		//std::cout << "No selection." << std::endl;
	}

	if (fli != 0) {
		if (xcoord < getWidth() - getScrollBarWidth())
		{
			if (e.mods.isRightButtonDown() || e.mods.isCtrlDown())
			{

				if (fli->getName().equalsIgnoreCase("Sources"))
				{
					currentColor = SOURCE_COLOR;
				} else if (fli->getName().equalsIgnoreCase("Filters"))
				{
					currentColor = FILTER_COLOR;
				} else if (fli->getName().equalsIgnoreCase("Utilities"))
				{
					currentColor = UTILITY_COLOR;
				} else if (fli->getName().equalsIgnoreCase("Sinks"))
				{
					currentColor = SINK_COLOR;
				} else {
					return;
				}

				int options;
				options += (0 << 0); // showAlpha
				options += (0 << 1); // showColorAtTop
				options += (0 << 2); // showSliders
				options += (1 << 3); // showColourSpace

		        ColourSelector colourSelector(options);
		        colourSelector.setName ("background");
		        colourSelector.setCurrentColour (findColour (currentColor));
		        colourSelector.addChangeListener (this);
		        colourSelector.addChangeListener (getProcessorGraph());
		        colourSelector.setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
		        colourSelector.setSize (300, 275);

		        CallOutBox callOut (colourSelector, *fli, 0);//*this, 0);
		        callOut.setTopLeftPosition (e.getScreenX(), e.getScreenY());
		        callOut.setArrowSize(0.0f);

		        callOut.runModalLoop();

			} else {
				fli->reverseOpenState();
			}
		}

		if (fli == baseItem)
		{
			if (fli->isOpen()) {
				getUIComponent()->childComponentChanged();
			}
			else
			{
				getUIComponent()->childComponentChanged();
				totalHeight = itemHeight + 2*yBuffer;
			}
			
		}
	}

	repaint();
}
Exemplo n.º 12
0
void createNewrecordingDir()
{
    getProcessorGraph()->getRecordNode()->createNewDirectory();
}
Exemplo n.º 13
0
File getRecordingPath()
{
    return getProcessorGraph()->getRecordNode()->getDataDirectory();
}
Exemplo n.º 14
0
int addSpikeElectrode(SpikeRecordInfo* elec)
{
    return getProcessorGraph()->getRecordNode()->addSpikeElectrode(elec);
}
Exemplo n.º 15
0
void registerSpikeSource(GenericProcessor* processor)
{
    getProcessorGraph()->getRecordNode()->registerSpikeSource(processor);
}
Exemplo n.º 16
0
void writeSpike(SpikeObject& spike, int electrodeIndex)
{
    getProcessorGraph()->getRecordNode()->writeSpike(spike, electrodeIndex);
}
Exemplo n.º 17
0
int getExperimentNumber()
{
	return getProcessorGraph()->getRecordNode()->getExperimentNumber();
}