Skip to content
Snippets Groups Projects
Commit 3a44af73 authored by Per Lindgren's avatar Per Lindgren
Browse files

update works

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