diff --git a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp index faf09813ccbf0fa076fcefc220a04698ee190135..8583c15e1e825cb5ac9ab31d5dd71d70af38df09 100644 --- a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp +++ b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp @@ -493,6 +493,11 @@ int LfpDisplayCanvas::getNumChannelsVisible() return lfpDisplay->drawableChannels.size(); } +int LfpDisplayCanvas::getChannelSubprocessorIdx(int channel) +{ + return processor->getDataChannel(channel)->getSubProcessorIdx(); +} + const float LfpDisplayCanvas::getYCoord(int chan, int samp) { return *screenBuffer->getReadPointer(chan, samp); @@ -577,6 +582,11 @@ void LfpDisplayCanvas::setDrawableSampleRate(float samplerate) lfpDisplay->setDisplayedSampleRate(samplerate); } +void LfpDisplayCanvas::setDrawableSubprocessor(int idx) +{ + lfpDisplay->setDisplayedSubprocessor(idx); +} + void LfpDisplayCanvas::redraw() { fullredraw=true; @@ -1956,6 +1966,7 @@ void LfpDisplay::setNumChannels(int numChannels) //lfpInfo->setColour(channelColours[i % channelColours.size()]); lfpInfo->setRange(range[options->getChannelType(i)]); lfpInfo->setChannelHeight(canvas->getChannelHeight()); + lfpInfo->setSubprocessorIdx(canvas->getChannelSubprocessorIdx(i)); addAndMakeVisible(lfpInfo); @@ -2249,6 +2260,16 @@ void LfpDisplay::setDisplayedSampleRate(float samplerate) drawableSampleRate = samplerate; } +int LfpDisplay::getDisplayedSubprocessor() +{ + return drawableSubprocessorIdx; +} + +void LfpDisplay::setDisplayedSubprocessor(int subProcessorIdx) +{ + drawableSubprocessorIdx = subProcessorIdx; +} + bool LfpDisplay::getChannelsReversed() { return channelsReversed; @@ -2502,8 +2523,9 @@ void LfpDisplay::rebuildDrawableChannelsList() // iterate over all channels and select drawable ones for (size_t i = 0; i < channels.size(); i++) { - // if channel[i] is not the right samplerate, hide it and continue - if (canvas->getChannelSampleRate(i) != getDisplayedSampleRate()) +// std::cout << "\tchannel " << i << " has subprocessor index of " << channelInfo[i]->getSubprocessorIdx() << std::endl; + // if channel[i] is not sourced from the correct subprocessor, then hide it and continue + if (channelInfo[i]->getSubprocessorIdx() != getDisplayedSubprocessor()) { channels[i]->setHidden(true); channelInfo[i]->setHidden(true); diff --git a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.h b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.h index 4186580fa9d2b2c25cb8c382f4a89b0ff8152046..07833e3bdb2edda700cfa2228a5bfc3e24202602 100644 --- a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.h +++ b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.h @@ -107,6 +107,13 @@ public: /** Delegates a samplerate for drawing to the LfpDisplay referenced by this canvas */ void setDrawableSampleRate(float samplerate); + + /** Returns the subprocessor index of the given channel */ + int getChannelSubprocessorIdx(int channel); + + /** Delegates a subprocessor index for drawing to the LfpDisplay referenced by this + this canvas */ + void setDrawableSubprocessor(int idx); const float getXCoord(int chan, int samp); const float getYCoord(int chan, int samp); @@ -467,6 +474,10 @@ public: */ void setDisplayedSampleRate(float samplerate); + int getDisplayedSubprocessor(); + + void setDisplayedSubprocessor(int subProcessorIdx); + /** Caches a new channel height without updating the channels */ void cacheNewChannelHeight(int r); @@ -574,6 +585,7 @@ private: int displaySkipAmt; int cachedDisplayChannelHeight; // holds a channel height if reset during single channel focus float drawableSampleRate; + int drawableSubprocessorIdx; int totalHeight; @@ -712,6 +724,7 @@ protected: class LfpChannelDisplayInfo : public LfpChannelDisplay, public Button::Listener { + friend class LfpDisplay; public: LfpChannelDisplayInfo(LfpDisplayCanvas*, LfpDisplay*, LfpDisplayOptions*, int channelNumber); @@ -733,6 +746,10 @@ public: /** Sets the sample rate associated with this channel */ void setChannelSampleRate(int samplerate); + int getSubprocessorIdx() { return subProcessorIdx; } + + void setSubprocessorIdx(int subProcessorIdx_) { subProcessorIdx = subProcessorIdx_; } + /** Updates the parent LfpDisplay that the track vertical zoom should update */ virtual void mouseDrag(const MouseEvent &event) override; @@ -747,6 +764,7 @@ private: float x, y; int samplerate; + int subProcessorIdx; ScopedPointer<UtilityButton> enableButton; diff --git a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.cpp b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.cpp index 73f800555fc18e6855b0102d3bf5d1fbd77e115a..17f395920e3a27b7171df48b3ebcc8641dbba092 100644 --- a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.cpp +++ b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.cpp @@ -35,14 +35,21 @@ LfpDisplayEditor::LfpDisplayEditor(GenericProcessor* parentNode, bool useDefault desiredWidth = 180; - subprocessorSelectionLabel = new Label("Display subprocessor sample rate", "Display Subproc. Sample Rate"); - subprocessorSelectionLabel->setBounds(10, 25, 140, 20); - addAndMakeVisible(subprocessorSelectionLabel); - subprocessorSelection = new ComboBox("Subprocessor sample rate"); - subprocessorSelection->setBounds(subprocessorSelectionLabel->getX()+5, subprocessorSelectionLabel->getBottom(), 60, 22); +// subprocessorSelection->setBounds(subprocessorSelectionLabel->getX()+5, subprocessorSelectionLabel->getBottom(), 60, 22); + subprocessorSelection->setBounds(10, 30, 50, 22); subprocessorSelection->addListener(this); addAndMakeVisible(subprocessorSelection); + + subprocessorSelectionLabel = new Label("Display subprocessor sample rate", "Display Subproc."); + // subprocessorSelectionLabel->setBounds(10, 25, 140, 20); + subprocessorSelectionLabel->setBounds(subprocessorSelection->getRight(), subprocessorSelection->getY(), 100, 20); + addAndMakeVisible(subprocessorSelectionLabel); + + subprocessorSampleRateLabel = new Label("Subprocessor sample rate label", "Sample Rate:"); + subprocessorSampleRateLabel->setFont(Font(Font::getDefaultSerifFontName(), 14, italic)); + subprocessorSampleRateLabel->setBounds(subprocessorSelection->getX(), subprocessorSelection->getBottom() + 10, 200, 40); + addAndMakeVisible(subprocessorSampleRateLabel); } LfpDisplayEditor::~LfpDisplayEditor() @@ -67,7 +74,8 @@ void LfpDisplayEditor::buttonClicked(Button *button) // (else) initialization errors. lots of time-critical cross dependencies here, // should be cleaned up updateSubprocessorSelectorOptions(); - ((LfpDisplayCanvas*)canvas.get())->setDrawableSampleRate(*(inputSampleRates.begin() + (subprocessorSelection->getSelectedId() - 1))); + ((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + (subprocessorSelection->getSelectedId() - 1))); +// ((LfpDisplayCanvas*)canvas.get())->setDrawableSampleRate(*(inputSampleRates.begin() + (subprocessorSelection->getSelectedId() - 1))); canvas->update(); @@ -90,50 +98,57 @@ void LfpDisplayEditor::comboBoxChanged(juce::ComboBox *cb) { if (cb == subprocessorSelection) { - setCanvasDrawableSampleRate(cb->getSelectedId() - 1); +// setCanvasDrawableSampleRate(cb->getSelectedId() - 1); + setCanvasDrawableSubprocessor(cb->getSelectedId() - 1); } } void LfpDisplayEditor::updateSubprocessorSelectorOptions() { // clear out the old data + inputSubprocessorIndices.clear(); inputSampleRates.clear(); subprocessorSelection->clear(dontSendNotification); - // get a list of all the sample rates - for (int i = 0, len = lfpProcessor->getNumInputs(); i < len; ++i) + for (int i = 0, len = lfpProcessor->getTotalDataChannels(); i < len; ++i) { - float samplerate = lfpProcessor->getDataChannel(i)->getSampleRate(); - bool success = inputSampleRates.add(samplerate); + int subProcessorIdx = lfpProcessor->getDataChannel(i)->getSubProcessorIdx(); -// if (success) std::cout << "\t\tadding sample rate " << samplerate << " ... size = " << inputSampleRates.size() << std::endl; + bool success = inputSubprocessorIndices.add(subProcessorIdx); + + if (success) inputSampleRates.set(subProcessorIdx, lfpProcessor->getDataChannel(i)->getSampleRate()); + +// if (success) std::cout << "\t\tadding subprocessor index " << subProcessorIdx << std::endl; } - // if the source changes, default to first samplerate given - int sampleRateToSet = -1; - if (inputSampleRates.size() > 0) + int subprocessorToSet = -1; + if (inputSubprocessorIndices.size() > 0) { - sampleRateToSet = 0; + subprocessorToSet = 0; } - // add the samplerate options to the combobox - for (int i = 0; i < inputSampleRates.size(); ++i) + for (int i = 0; i < inputSubprocessorIndices.size(); ++i) { - subprocessorSelection->addItem(String(*(inputSampleRates.begin()+i)), i+1); + subprocessorSelection->addItem (String (*(inputSubprocessorIndices.begin() + i)), i + 1); } - if (sampleRateToSet >= 0) + if (subprocessorToSet >= 0) { - subprocessorSelection->setSelectedId(sampleRateToSet + 1, dontSendNotification); - setCanvasDrawableSampleRate(sampleRateToSet); + subprocessorSelection->setSelectedId(subprocessorToSet + 1, dontSendNotification); + + String sampleRateLabelText = "Sample Rate: "; + sampleRateLabelText += String(inputSampleRates[*(inputSubprocessorIndices.begin()+subprocessorToSet)]); + + subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification); + setCanvasDrawableSubprocessor(subprocessorToSet); } } -void LfpDisplayEditor::setCanvasDrawableSampleRate(int index) +void LfpDisplayEditor::setCanvasDrawableSubprocessor(int index) { if (canvas) { - ((LfpDisplayCanvas*)canvas.get())->setDrawableSampleRate(*(inputSampleRates.begin() + (index))); + ((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + index)); } } diff --git a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.h b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.h index c1e27e0fd26cb9f35009d628476d131d4a49d2ec..55aff29723ebba024d3a3bd2e87f6df763e2dfb5 100644 --- a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.h +++ b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.h @@ -73,7 +73,8 @@ public: private: - SortedSet<float> inputSampleRates; // hold the possible subprocessor sample rates + HashMap<int, float> inputSampleRates; // hold the possible subprocessor sample rates + SortedSet<int> inputSubprocessorIndices; LfpDisplayNode* lfpProcessor; @@ -81,10 +82,12 @@ private: ScopedPointer<Label> subprocessorSelectionLabel; ScopedPointer<ComboBox> subprocessorSelection; - /** Communicates the drawable sample rate information to the canvas, if - one exists + ScopedPointer<Label> subprocessorSampleRateLabel; + + /** Communicates the drawable subprocessor information to the canvas, if + one exists */ - void setCanvasDrawableSampleRate(int index); + void setCanvasDrawableSubprocessor(int index); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LfpDisplayEditor);