diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 443fa518224679a0220cb97f46ddafe7238c2056..295a198a025ec62ab6978fa24a063b13d0b76402 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -26,8 +26,9 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p) startTimerHz(60); setResizable(true, true); setResizeLimits(400, 300, 1024, 1024); - setSize(400, 300); + if (processor.m_flogger) + processor.m_flogger->logMessage("Editor initialized"); } Test2AudioProcessorEditor::~Test2AudioProcessorEditor() @@ -43,7 +44,7 @@ void Test2AudioProcessorEditor::paint(juce::Graphics &g) g.setColour(juce::Colours::white); g.setFont(15.0f); - g.drawFittedText("3) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1); + g.drawFittedText("9) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1); // if (processor.m_flogger) // processor.m_flogger->logMessage("paint called"); } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 0dabedddebde8f8aaf9f8ea81e3f48698789fd55..5c3cf4e4ec0b2a921a45b197fc85bf34eeff2718 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -11,20 +11,14 @@ //============================================================================== Test2AudioProcessor::Test2AudioProcessor() -#ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor(BusesProperties() -#if !JucePlugin_IsMidiEffect -#if !JucePlugin_IsSynth .withInput("Input", juce::AudioChannelSet::stereo(), true) -#endif - .withOutput("Output", juce::AudioChannelSet::stereo(), true) -#endif - ) -#endif + .withOutput("Output", juce::AudioChannelSet::stereo(), true)) { m_flogger = std::unique_ptr<juce::FileLogger>(juce::FileLogger::createDateStampedLogger("foo", "mylog", ".txt", "Welcome to plugin")); position = 0; + lastPosInfo.resetToDefault(); addParameter(gain = new juce::AudioParameterFloat("no_gain", // parameter ID "NoGain", // parameter name @@ -53,11 +47,8 @@ bool Test2AudioProcessor::acceptsMidi() const bool Test2AudioProcessor::producesMidi() const { -#if JucePlugin_ProducesMidiOutput + // Should that be true for automation parameters? return true; -#else - return false; -#endif } bool Test2AudioProcessor::isMidiEffect() const @@ -111,28 +102,26 @@ void Test2AudioProcessor::releaseResources() // spare memory, etc. } -#ifndef JucePlugin_PreferredChannelConfigurations bool Test2AudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const { -#if JucePlugin_IsMidiEffect - juce::ignoreUnused(layouts); - return true; -#else - // This is the place where you check if the layout is supported. - // In this template code we only support mono or stereo. - if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo()) + // Only mono/stereo and input/output must have same layout + const auto &mainOutput = layouts.getMainOutputChannelSet(); + const auto &mainInput = layouts.getMainInputChannelSet(); + + // input and output layout must either be the same or the input must be disabled altogether + if (!mainInput.isDisabled() && mainInput != mainOutput) return false; - // This checks if the input layout matches the output layout -#if !JucePlugin_IsSynth - if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) + // do not allow disabling the main buses + if (mainOutput.isDisabled()) + return false; + + // only allow stereo and mono + if (mainOutput.size() > 2) return false; -#endif return true; -#endif } -#endif void Test2AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::MidiBuffer &midiMessages) { @@ -162,6 +151,7 @@ void Test2AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::M // ..do something to the data... } + // aggregate the position for (const auto metadata : midiMessages) { auto msg = metadata.getMessage(); @@ -191,6 +181,9 @@ void Test2AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::M }; }; }; + + // update time info + updateCurrentTimeInfoFromHost(); } //============================================================================== diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 6c52255e22c5df79a528b6ff079287781457b1ee..7d552c04c31d0a85a9054a890af41c99eeb9249b 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -59,6 +59,10 @@ public: // callback - the UI component will read this and display it. juce::AudioPlayHead::CurrentPositionInfo lastPosInfo; +private: + //============================================================================== + juce::AudioParameterFloat *gain; + //============================================================================== void updateCurrentTimeInfoFromHost() { if (auto *ph = getPlayHead()) @@ -68,6 +72,8 @@ public: if (ph->getCurrentPosition(newTime)) { lastPosInfo = newTime; // Successfully got the current time from the host.. + if (m_flogger) + m_flogger->logMessage("Got Pos from host"); return; } } @@ -76,9 +82,5 @@ public: lastPosInfo.resetToDefault(); } -private: - //============================================================================== - juce::AudioParameterFloat *gain; - //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Test2AudioProcessor) };