@@ -35,14 +35,21 @@ LfpDisplayEditor::LfpDisplayEditor(GenericProcessor* parentNode, bool useDefault
3535
3636 desiredWidth = 180 ;
3737
38- subprocessorSelectionLabel = new Label (" Display subprocessor sample rate" , " Display Subproc. Sample Rate" );
39- subprocessorSelectionLabel->setBounds (10 , 25 , 140 , 20 );
40- addAndMakeVisible (subprocessorSelectionLabel);
41-
4238 subprocessorSelection = new ComboBox (" Subprocessor sample rate" );
43- subprocessorSelection->setBounds (subprocessorSelectionLabel->getX ()+5 , subprocessorSelectionLabel->getBottom (), 60 , 22 );
39+ // subprocessorSelection->setBounds(subprocessorSelectionLabel->getX()+5, subprocessorSelectionLabel->getBottom(), 60, 22);
40+ subprocessorSelection->setBounds (10 , 30 , 50 , 22 );
4441 subprocessorSelection->addListener (this );
4542 addAndMakeVisible (subprocessorSelection);
43+
44+ subprocessorSelectionLabel = new Label (" Display subprocessor sample rate" , " Display Subproc." );
45+ // subprocessorSelectionLabel->setBounds(10, 25, 140, 20);
46+ subprocessorSelectionLabel->setBounds (subprocessorSelection->getRight (), subprocessorSelection->getY (), 100 , 20 );
47+ addAndMakeVisible (subprocessorSelectionLabel);
48+
49+ subprocessorSampleRateLabel = new Label (" Subprocessor sample rate label" , " Sample Rate:" );
50+ subprocessorSampleRateLabel->setFont (Font (Font::getDefaultSerifFontName (), 14 , italic));
51+ subprocessorSampleRateLabel->setBounds (subprocessorSelection->getX (), subprocessorSelection->getBottom () + 10 , 200 , 40 );
52+ addAndMakeVisible (subprocessorSampleRateLabel);
4653}
4754
4855LfpDisplayEditor::~LfpDisplayEditor ()
@@ -67,7 +74,8 @@ void LfpDisplayEditor::buttonClicked(Button *button)
6774 // (else) initialization errors. lots of time-critical cross dependencies here,
6875 // should be cleaned up
6976 updateSubprocessorSelectorOptions ();
70- ((LfpDisplayCanvas*)canvas.get ())->setDrawableSampleRate (*(inputSampleRates.begin () + (subprocessorSelection->getSelectedId () - 1 )));
77+ ((LfpDisplayCanvas *)canvas.get ())->setDrawableSubprocessor (*(inputSubprocessorIndices.begin () + (subprocessorSelection->getSelectedId () - 1 )));
78+ // ((LfpDisplayCanvas*)canvas.get())->setDrawableSampleRate(*(inputSampleRates.begin() + (subprocessorSelection->getSelectedId() - 1)));
7179
7280 canvas->update ();
7381
@@ -90,50 +98,57 @@ void LfpDisplayEditor::comboBoxChanged(juce::ComboBox *cb)
9098{
9199 if (cb == subprocessorSelection)
92100 {
93- setCanvasDrawableSampleRate (cb->getSelectedId () - 1 );
101+ // setCanvasDrawableSampleRate(cb->getSelectedId() - 1);
102+ setCanvasDrawableSubprocessor (cb->getSelectedId () - 1 );
94103 }
95104}
96105
97106void LfpDisplayEditor::updateSubprocessorSelectorOptions ()
98107{
99108 // clear out the old data
109+ inputSubprocessorIndices.clear ();
100110 inputSampleRates.clear ();
101111 subprocessorSelection->clear (dontSendNotification);
102112
103- // get a list of all the sample rates
104- for (int i = 0 , len = lfpProcessor->getNumInputs (); i < len; ++i)
113+ for (int i = 0 , len = lfpProcessor->getTotalDataChannels (); i < len; ++i)
105114 {
106- float samplerate = lfpProcessor->getDataChannel (i)->getSampleRate ();
107- bool success = inputSampleRates.add (samplerate);
115+ int subProcessorIdx = lfpProcessor->getDataChannel (i)->getSubProcessorIdx ();
108116
109- // if (success) std::cout << "\t\tadding sample rate " << samplerate << " ... size = " << inputSampleRates.size() << std::endl;
117+ bool success = inputSubprocessorIndices.add (subProcessorIdx);
118+
119+ if (success) inputSampleRates.set (subProcessorIdx, lfpProcessor->getDataChannel (i)->getSampleRate ());
120+
121+ // if (success) std::cout << "\t\tadding subprocessor index " << subProcessorIdx << std::endl;
110122 }
111123
112- // if the source changes, default to first samplerate given
113- int sampleRateToSet = -1 ;
114- if (inputSampleRates.size () > 0 )
124+ int subprocessorToSet = -1 ;
125+ if (inputSubprocessorIndices.size () > 0 )
115126 {
116- sampleRateToSet = 0 ;
127+ subprocessorToSet = 0 ;
117128 }
118129
119- // add the samplerate options to the combobox
120- for (int i = 0 ; i < inputSampleRates.size (); ++i)
130+ for (int i = 0 ; i < inputSubprocessorIndices.size (); ++i)
121131 {
122- subprocessorSelection->addItem (String (*(inputSampleRates .begin ()+ i)), i+ 1 );
132+ subprocessorSelection->addItem (String (*(inputSubprocessorIndices .begin () + i)), i + 1 );
123133 }
124134
125- if (sampleRateToSet >= 0 )
135+ if (subprocessorToSet >= 0 )
126136 {
127- subprocessorSelection->setSelectedId (sampleRateToSet + 1 , dontSendNotification);
128- setCanvasDrawableSampleRate (sampleRateToSet);
137+ subprocessorSelection->setSelectedId (subprocessorToSet + 1 , dontSendNotification);
138+
139+ String sampleRateLabelText = " Sample Rate: " ;
140+ sampleRateLabelText += String (inputSampleRates[*(inputSubprocessorIndices.begin ()+subprocessorToSet)]);
141+
142+ subprocessorSampleRateLabel->setText (sampleRateLabelText, dontSendNotification);
143+ setCanvasDrawableSubprocessor (subprocessorToSet);
129144 }
130145}
131146
132- void LfpDisplayEditor::setCanvasDrawableSampleRate (int index)
147+ void LfpDisplayEditor::setCanvasDrawableSubprocessor (int index)
133148{
134149 if (canvas)
135150 {
136- ((LfpDisplayCanvas*)canvas.get ())->setDrawableSampleRate (*(inputSampleRates .begin () + ( index) ));
151+ ((LfpDisplayCanvas *)canvas.get ())->setDrawableSubprocessor (*(inputSubprocessorIndices .begin () + index));
137152 }
138153}
139154
0 commit comments