Browse Source

Added some speaker arrangement methods to AudioProcessor, with support for retrieving host speaker arrangements in a VST plugin.

tags/2021-05-28
jules 13 years ago
parent
commit
2e0640b8ba
3 changed files with 88 additions and 24 deletions
  1. +49
    -7
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  2. +6
    -0
      modules/juce_audio_processors/processors/juce_AudioProcessor.cpp
  3. +33
    -17
      modules/juce_audio_processors/processors/juce_AudioProcessor.h

+ 49
- 7
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -825,11 +825,10 @@ public:
public:
static int compareElements (const short* const first, const short* const second) noexcept
{
if (first[0] < second[0]) return -1;
else if (first[0] > second[0]) return 1;
else if (first[1] < second[1]) return -1;
else if (first[1] > second[1]) return 1;
if (first[0] < second[0]) return -1;
if (first[0] > second[0]) return 1;
if (first[1] < second[1]) return -1;
if (first[1] > second[1]) return 1;
return 0;
}
};
@@ -853,21 +852,64 @@ public:
if (inCountMatches && outCountMatches)
{
speakerIn = (VstSpeakerArrangementType) pluginInput->type;
speakerIn = (VstSpeakerArrangementType) pluginInput->type;
speakerOut = (VstSpeakerArrangementType) pluginOutput->type;
numInChans = pluginInput->numChannels;
numInChans = pluginInput->numChannels;
numOutChans = pluginOutput->numChannels;
filter->setPlayConfigDetails (numInChans, numOutChans,
filter->getSampleRate(),
filter->getBlockSize());
filter->setSpeakerArrangement (getSpeakerArrangementString (speakerIn),
getSpeakerArrangementString (speakerOut));
return true;
}
}
filter->setSpeakerArrangement (String::empty, String::empty);
return false;
}
static const char* getSpeakerArrangementString (VstSpeakerArrangementType type) noexcept
{
switch (type)
{
case kSpeakerArrMono: return "M";
case kSpeakerArrStereo: return "L R";
case kSpeakerArrStereoSurround: return "Ls Rs";
case kSpeakerArrStereoCenter: return "Lc Rc";
case kSpeakerArrStereoSide: return "Sl Sr";
case kSpeakerArrStereoCLfe: return "C Lfe";
case kSpeakerArr30Cine: return "L R C";
case kSpeakerArr30Music: return "L R S";
case kSpeakerArr31Cine: return "L R C Lfe";
case kSpeakerArr31Music: return "L R Lfe S";
case kSpeakerArr40Cine: return "L R C S";
case kSpeakerArr40Music: return "L R Ls Rs";
case kSpeakerArr41Cine: return "L R C Lfe S";
case kSpeakerArr41Music: return "L R Lfe Ls Rs";
case kSpeakerArr50: return "L R C Ls Rs" ;
case kSpeakerArr51: return "L R C Lfe Ls Rs";
case kSpeakerArr60Cine: return "L R C Ls Rs Cs";
case kSpeakerArr60Music: return "L R Ls Rs Sl Sr ";
case kSpeakerArr61Cine: return "L R C Lfe Ls Rs Cs";
case kSpeakerArr61Music: return "L R Lfe Ls Rs Sl Sr";
case kSpeakerArr70Cine: return "L R C Ls Rs Lc Rc ";
case kSpeakerArr70Music: return "L R C Ls Rs Sl Sr";
case kSpeakerArr71Cine: return "L R C Lfe Ls Rs Lc Rc";
case kSpeakerArr71Music: return "L R C Lfe Ls Rs Sl Sr";
case kSpeakerArr80Cine: return "L R C Ls Rs Lc Rc Cs";
case kSpeakerArr80Music: return "L R C Ls Rs Cs Sl Sr";
case kSpeakerArr81Cine: return "L R C Lfe Ls Rs Lc Rc Cs";
case kSpeakerArr81Music: return "L R C Lfe Ls Rs Cs Sl Sr" ;
case kSpeakerArr102: return "L R C Lfe Ls Rs Tfl Tfc Tfr Trl Trr Lfe2";
default: break;
}
return nullptr;
}
//==============================================================================
VstInt32 getChunk (void** data, bool onlyStoreCurrentProgramData)
{


+ 6
- 0
modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -76,6 +76,12 @@ void AudioProcessor::setPlayConfigDetails (const int numIns,
blockSize = blockSize_;
}
void AudioProcessor::setSpeakerArrangement (const String& inputs, const String& outputs)
{
inputSpeakerArrangement = inputs;
outputSpeakerArrangement = outputs;
}
void AudioProcessor::setNonRealtime (const bool nonRealtime_) noexcept
{
nonRealtime = nonRealtime_;


+ 33
- 17
modules/juce_audio_processors/processors/juce_AudioProcessor.h View File

@@ -145,7 +145,7 @@ public:
If the host hasn't supplied a playhead object, this will return 0.
*/
AudioPlayHead* getPlayHead() const noexcept { return playHead; }
AudioPlayHead* getPlayHead() const noexcept { return playHead; }
//==============================================================================
@@ -154,7 +154,7 @@ public:
This can be called from your processBlock() method - it's not guaranteed
to be valid at any other time, and may return 0 if it's unknown.
*/
double getSampleRate() const noexcept { return sampleRate; }
double getSampleRate() const noexcept { return sampleRate; }
/** Returns the current typical block size that is being used.
@@ -165,7 +165,7 @@ public:
processBlock, it's just the normal one. The actual block sizes used may be
larger or smaller than this, and will vary between successive calls.
*/
int getBlockSize() const noexcept { return blockSize; }
int getBlockSize() const noexcept { return blockSize; }
//==============================================================================
/** Returns the number of input channels that the host will be sending the filter.
@@ -177,7 +177,7 @@ public:
Note that this method is only valid during or after the prepareToPlay()
method call. Until that point, the number of channels will be unknown.
*/
int getNumInputChannels() const noexcept { return numInputChannels; }
int getNumInputChannels() const noexcept { return numInputChannels; }
/** Returns the number of output channels that the host will be sending the filter.
@@ -188,18 +188,33 @@ public:
Note that this method is only valid during or after the prepareToPlay()
method call. Until that point, the number of channels will be unknown.
*/
int getNumOutputChannels() const noexcept { return numOutputChannels; }
int getNumOutputChannels() const noexcept { return numOutputChannels; }
/** Returns the name of one of the input channels, as returned by the host.
/** Returns a string containing a whitespace-separated list of speaker types
corresponding to each input channel.
For example in a 5.1 arrangement, the string may be "L R C Lfe Ls Rs"
If the speaker arrangement is unknown, the returned string will be empty.
*/
const String& getInputSpeakerArrangement() const noexcept { return inputSpeakerArrangement; }
/** Returns a string containing a whitespace-separated list of speaker types
corresponding to each output channel.
For example in a 5.1 arrangement, the string may be "L R C Lfe Ls Rs"
If the speaker arrangement is unknown, the returned string will be empty.
*/
const String& getOutputSpeakerArrangement() const noexcept { return outputSpeakerArrangement; }
The host might not supply very useful names for channels, and this might be
//==============================================================================
/** Returns the name of one of the processor's input channels.
The processor might not supply very useful names for channels, and this might be
something like "1", "2", "left", "right", etc.
*/
virtual const String getInputChannelName (int channelIndex) const = 0;
/** Returns the name of one of the output channels, as returned by the host.
/** Returns the name of one of the processor's output channels.
The host might not supply very useful names for channels, and this might be
The processor might not supply very useful names for channels, and this might be
something like "1", "2", "left", "right", etc.
*/
virtual const String getOutputChannelName (int channelIndex) const = 0;
@@ -216,7 +231,7 @@ public:
The host will call this to find the latency - the filter itself should set this value
by calling setLatencySamples() as soon as it can during its initialisation.
*/
int getLatencySamples() const noexcept { return latencySamples; }
int getLatencySamples() const noexcept { return latencySamples; }
/** The filter should call this to set the number of samples delay that it introduces.
@@ -243,7 +258,7 @@ public:
@see suspendProcessing
*/
const CriticalSection& getCallbackLock() const noexcept { return callbackLock; }
const CriticalSection& getCallbackLock() const noexcept { return callbackLock; }
/** Enables and disables the processing callback.
@@ -345,8 +360,7 @@ public:
//==============================================================================
/** Returns the active editor, if there is one.
Bear in mind this can return 0, even if an editor has previously been
opened.
Bear in mind this can return nullptr, even if an editor has previously been opened.
*/
AudioProcessorEditor* getActiveEditor() const noexcept { return activeEditor; }
@@ -541,12 +555,13 @@ public:
//==============================================================================
/** Not for public use - this is called before deleting an editor component. */
void editorBeingDeleted (AudioProcessorEditor* editor) noexcept;
void editorBeingDeleted (AudioProcessorEditor*) noexcept;
/** Not for public use - this is called to initialise the processor before playing. */
void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize) noexcept;
/** Not for public use - this is called to initialise the processor before playing. */
void setPlayConfigDetails (int numIns, int numOuts,
double sampleRate,
int blockSize) noexcept;
void setSpeakerArrangement (const String& inputs, const String& outputs);
protected:
//==============================================================================
@@ -581,6 +596,7 @@ private:
int blockSize, numInputChannels, numOutputChannels, latencySamples;
bool suspended, nonRealtime;
CriticalSection callbackLock, listenerLock;
String inputSpeakerArrangement, outputSpeakerArrangement;
#if JUCE_DEBUG
BigInteger changingParams;


Loading…
Cancel
Save