diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 295a198a025ec62ab6978fa24a063b13d0b76402..584a0f81e924f116ec7f6f7b880488ad38757d92 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -18,7 +18,14 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p) addAndMakeVisible(positionLabel); // add a label that will display the current timecode and status.. addAndMakeVisible(timecodeDisplayLabel); + + // slider + addAndMakeVisible(posSlider); + posSlider.setRange(50, 5000.0); + posSlider.setValue(500.0); + timecodeDisplayLabel.setFont(juce::Font(juce::Font::getDefaultMonospacedFontName(), 15.0f, juce::Font::plain)); + posSlider.addListener(this); positionLabel.setText("Text input:", juce::dontSendNotification); positionLabel.setColour(juce::Label::textColourId, juce::Colours::orange); @@ -28,7 +35,10 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p) setResizeLimits(400, 300, 1024, 1024); setSize(400, 300); if (processor.m_flogger) + { + processor.m_flogger->logMessage("Editor initialized"); + } } Test2AudioProcessorEditor::~Test2AudioProcessorEditor() @@ -44,7 +54,7 @@ void Test2AudioProcessorEditor::paint(juce::Graphics &g) g.setColour(juce::Colours::white); g.setFont(15.0f); - g.drawFittedText("9) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1); + g.drawFittedText("10) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1); // if (processor.m_flogger) // processor.m_flogger->logMessage("paint called"); } @@ -57,6 +67,11 @@ void Test2AudioProcessorEditor::resized() auto bounds = getLocalBounds(); positionLabel.setBounds(bounds.removeFromBottom(30).withSizeKeepingCentre(50, 24)); timecodeDisplayLabel.setBounds(bounds.removeFromTop(26)); + posSlider.setBounds(100, 30, getWidth() - 120, 20); + if (processor.m_flogger) + { processor.m_flogger->logMessage(bounds.toString()); + processor.m_flogger->logMessage(std::to_string(processor.buf_size)); + } } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index c8ee2268bccefdc8d9475dafc152beac8d218756..a08697d9be668bc6aa227ab5eab45d2695c61607 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -14,7 +14,7 @@ //============================================================================== /** */ -class Test2AudioProcessorEditor : public juce::AudioProcessorEditor, private juce::Timer +class Test2AudioProcessorEditor : public juce::AudioProcessorEditor, public juce::Slider::Listener, private juce::Timer { public: Test2AudioProcessorEditor(Test2AudioProcessor &); @@ -28,6 +28,17 @@ private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Test2AudioProcessor &processor; + juce::Slider posSlider; + + void sliderValueChanged(juce::Slider *slider) override + { + if (slider == &posSlider) + { + if (processor.m_flogger) + processor.m_flogger->logMessage("slider changed"); + } + } + // is this the way juce::Label positionLabel, timecodeDisplayLabel; // = juce::Label("Position", "Position : 0"); // or something like diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 5c3cf4e4ec0b2a921a45b197fc85bf34eeff2718..fe2af35e100bf0ca1debc009e6112e42f3b047d3 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -129,6 +129,8 @@ void Test2AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::M auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); + buf_size = buffer.getNumSamples(); + // In case we have more outputs than inputs, this code clears any output // channels that didn't contain input data, (because these aren't // guaranteed to be empty - they may contain garbage). diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 7d552c04c31d0a85a9054a890af41c99eeb9249b..8734c2c8f158190faf6b6cba21ead722743b429a 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -58,6 +58,7 @@ public: // this keeps a copy of the last set of time info that was acquired during an audio // callback - the UI component will read this and display it. juce::AudioPlayHead::CurrentPositionInfo lastPosInfo; + int buf_size; private: //============================================================================== @@ -72,8 +73,8 @@ private: if (ph->getCurrentPosition(newTime)) { lastPosInfo = newTime; // Successfully got the current time from the host.. - if (m_flogger) - m_flogger->logMessage("Got Pos from host"); + //if (m_flogger) + // m_flogger->logMessage("Got Pos from host"); return; } }