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)
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");
}
......
......@@ -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();
}
//==============================================================================
......
......@@ -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)
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment