1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-14 00:14:18 +00:00

Revised multibus API and added support for multibus hosting

This commit is contained in:
hogliux 2016-09-16 17:06:19 +01:00
parent ebf19aa61a
commit 4fa0516f40
140 changed files with 6836 additions and 4478 deletions

View file

@ -29,10 +29,15 @@
/**
*/
class SurroundProcessor : public AudioProcessor,
public ChannelClickListener
public ChannelClickListener,
private AsyncUpdater
{
public:
SurroundProcessor() {}
SurroundProcessor()
: AudioProcessor(BusesProperties().withInput ("Input", AudioChannelSet::stereo())
.withOutput ("Output", AudioChannelSet::stereo()))
{}
~SurroundProcessor() {}
//==============================================================================
@ -41,11 +46,13 @@ public:
channelClicked = 0;
sampleOffset = static_cast<int> (std::ceil (sampleRate));
const int numChannels = busArrangement.inputBuses.getReference(0).channels.size();
const int numChannels = getChannelCountOfBus (true, 0);
channelActive.resize (numChannels);
alphaCoeffs.resize (numChannels);
reset();
triggerAsyncUpdate();
ignoreUnused (samplesPerBlock);
}
@ -73,11 +80,14 @@ public:
const int fillSamples = jmin (static_cast<int> (std::ceil (getSampleRate())) - sampleOffset,
buffer.getNumSamples());
float* const channelBuffer = buffer.getWritePointer (channelClicked);
const float freq = (float) (440.0 / getSampleRate());
if (isPositiveAndBelow (channelClicked, buffer.getNumChannels()))
{
float* const channelBuffer = buffer.getWritePointer (channelClicked);
const float freq = (float) (440.0 / getSampleRate());
for (int i = 0; i < fillSamples; ++i)
channelBuffer[i] += std::sin (2.0f * float_Pi * freq * static_cast<float> (sampleOffset++));
for (int i = 0; i < fillSamples; ++i)
channelBuffer[i] += std::sin (2.0f * float_Pi * freq * static_cast<float> (sampleOffset++));
}
}
//==============================================================================
@ -85,18 +95,12 @@ public:
bool hasEditor() const override { return true; }
//==============================================================================
bool setPreferredBusArrangement (bool isInputBus, int busIndex,
const AudioChannelSet& preferred) override
bool isBusesLayoutSupported (const BusesLayout& layouts) const override
{
if (! preferred.isDiscreteLayout())
{
if (! AudioProcessor::setPreferredBusArrangement (! isInputBus, busIndex, preferred))
return false;
return AudioProcessor::setPreferredBusArrangement (isInputBus, busIndex, preferred);
}
return false;
return ((! layouts.getMainInputChannelSet() .isDiscreteLayout())
&& (! layouts.getMainOutputChannelSet().isDiscreteLayout())
&& (layouts.getMainInputChannelSet() == layouts.getMainOutputChannelSet())
&& (! layouts.getMainInputChannelSet().isDisabled()));
}
void reset() override
@ -133,6 +137,13 @@ public:
return channelActive [channelIndex] > 0;
}
void handleAsyncUpdate() override
{
if (AudioProcessorEditor* editor = getActiveEditor())
if (SurroundEditor* surroundEditor = dynamic_cast<SurroundEditor*> (editor))
surroundEditor->updateGUI();
}
private:
Array<int> channelActive;
Array<float> alphaCoeffs;